Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add joypad camera support #12

Merged
merged 7 commits into from
Mar 25, 2024

Conversation

emersonbottero
Copy link
Contributor

Take a look at InputExtensions and see if it makes sense to be part of your library...
the intention is to keep the logic used in the mouse the same with the one used with joypad..
since is my first interaction with your libs and even Godot it can be completely wrong.. 😆

Copy link
Member

@jolexxa jolexxa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, really good job implementing this! It's really solid.

I added a few whitespace things you can just click to commit right in (for this project I try to keep lines at 80 wide).

We'll also need to add unit tests for your new code. If you're not sure how to do this, I'm happy to help in Discord or give it a shot later.

I ran the coverage.sh script and it shows these areas needing coverage from your new code:

image

For InputExtensions, I would rename it and its file to InputUtilities and make an InputUtiltiesTest.cs file in test/src/utils.

image

Note that in the test, you could use Input.ActionPress to simulate the names of the actions you want to press, similar to how its done in this test:

public void InputsPauseButtonPressed() {
_logic.Setup(
logic => logic.Input(It.IsAny<GameLogic.Input.PauseButtonPressed>())
);
Input.ActionPress("ui_cancel");
_game._Input(default!);
_logic.VerifyAll();
}

For PlayerCamera.cs, these added lines now need coverage:

image

And lastly, you can probably copy/paste the PlayerCameraLogic.State.InputEnabled tests for mouse input and modify them to test your joypad input to get these lines covered:

image

Again, happy to answer questions in Discord :)) Thank you so much for doing this!! It's really good work.

public void OnPhysicsProcess(double delta) {
var xMotion = InputExtensions.GetJoyPadActionPressedMotion("camera_left", "camera_right", JoyAxis.RightX);
if (xMotion is not null) {
CameraLogic.Input(new PlayerCameraLogic.Input.JoyPadInputOccurred(xMotion));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(wrap long lines)

Suggested change
CameraLogic.Input(new PlayerCameraLogic.Input.JoyPadInputOccurred(xMotion));
CameraLogic.Input(
new PlayerCameraLogic.Input.JoyPadInputOccurred(xMotion)
);


var yMotion = InputExtensions.GetJoyPadActionPressedMotion("camera_up", "camera_down", JoyAxis.RightY);
if (yMotion is not null) {
CameraLogic.Input(new PlayerCameraLogic.Input.JoyPadInputOccurred(yMotion));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(wrap long lines)

Suggested change
CameraLogic.Input(new PlayerCameraLogic.Input.JoyPadInputOccurred(yMotion));
CameraLogic.Input(
new PlayerCameraLogic.Input.JoyPadInputOccurred(yMotion)
);

Copy link
Member

@jolexxa jolexxa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good! Looks like you can get rid of some of the stuff that's copy/pasted from the other test for the input utilities since they are only interfacing with the engine.

@jolexxa
Copy link
Member

jolexxa commented Mar 24, 2024

Looks like two whitespace changes still need to be made (see previous comments) and we're not quite back at 100% test coverage yet. Super close!

(InputUtilities.cs)
image

(PlayerCamera.cs)
image

@jolexxa
Copy link
Member

jolexxa commented Mar 25, 2024

This is really awesome work. Thank you for doing the tests and dealing with all the Joypad input simulation to make sure it's good. I'll merge if you're ready!

@jolexxa jolexxa merged commit 9edfcd4 into chickensoft-games:main Mar 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants