-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: Add joypad camera support #12
Conversation
There was a problem hiding this 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:
For InputExtensions, I would rename it and its file to InputUtilities
and make an InputUtiltiesTest.cs
file in test/src/utils
.
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:
GameDemo/test/src/game/GameTest.cs
Lines 218 to 227 in 6b593e9
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:
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:
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(wrap long lines)
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(wrap long lines)
CameraLogic.Input(new PlayerCameraLogic.Input.JoyPadInputOccurred(yMotion)); | |
CameraLogic.Input( | |
new PlayerCameraLogic.Input.JoyPadInputOccurred(yMotion) | |
); |
src/player_camera/State/states/PlayerCameraLogic.State.InputEnabled.cs
Outdated
Show resolved
Hide resolved
src/player_camera/State/states/PlayerCameraLogic.State.InputEnabled.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
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! |
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.. 😆