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 gamepad support to escoria-ui-simplemouse #518

Merged
merged 1 commit into from
Mar 14, 2022

Conversation

bolinfest
Copy link
Contributor

@bolinfest bolinfest commented Mar 1, 2022

Review stack (3/3) Prev


Updates escoria-ui-simplemouse to demonstrate basic gamepad support.
Addresses godot-escoria/escoria-issues#101.

addons/escoria-ui-keyboard-9verbs/input_map.gd Outdated Show resolved Hide resolved
addons/escoria-ui-keyboard-9verbs/game.gd Outdated Show resolved Hide resolved
addons/escoria-ui-simplemouse/game.gd Outdated Show resolved Hide resolved
@bolinfest bolinfest force-pushed the rfc-gamepad-support branch 2 times, most recently from 0413244 to 0f204fd Compare March 2, 2022 06:29
@bolinfest bolinfest changed the title feat: gamepad support feat: add gamepad support to escoria-ui-simplemouse Mar 2, 2022
@bolinfest bolinfest force-pushed the rfc-gamepad-support branch 2 times, most recently from 5e66361 to 2c16685 Compare March 2, 2022 06:34
@bolinfest
Copy link
Contributor Author

OK, rebased everything on develop. Note that I updated the commit messages, which will hopefully make reviewing each commit a bit easier.

@dploeger
Copy link
Collaborator

dploeger commented Mar 3, 2022

I don't have a gamepad so I'm afraid I can't review this properly. Code looks good so far.

Copy link
Collaborator

@StraToN StraToN left a comment

Choose a reason for hiding this comment

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

Some conversations still to be resolved

@bolinfest
Copy link
Contributor Author

@StraToN I looked through, but I'm unclear on which conversations still need to be resolved?

@bolinfest bolinfest force-pushed the rfc-gamepad-support branch from 2c16685 to 6cd148b Compare March 3, 2022 21:17
@bolinfest
Copy link
Contributor Author

FYI, I just rebased on develop and updated this PR again, for good measure, though there were no merge conflicts.

@bolinfest bolinfest force-pushed the rfc-gamepad-support branch 2 times, most recently from 2a11e4a to 15c999e Compare March 8, 2022 15:51
@StraToN
Copy link
Collaborator

StraToN commented Mar 11, 2022

Tested after rebase onto develop branch (to benefit fix from cb538ed). Keyboard plugin works fine. Gamepad in simple mouse works fine as well. All good to me, thanks a lot!

@bolinfest bolinfest force-pushed the rfc-gamepad-support branch from 15c999e to ce212ac Compare March 12, 2022 17:53
This commit starts by introducing a new action, `ESC_UI_PRIMARY_ACTION`,
that is used to represent a "primary action" from an input device, such
as a left-click on a mouse or the press of the primary button on a
gamepad. Although this action is not added to `InputMap` by default in
`escoria-core`, `_unhandled_input()` in `esc_item.gd` is updated to look
for it.

The other portion of this commit is an update to
`addons/escoria-ui-simplemouse/game.gd` that adds a gamepad mapping to
the `InputMap` for both `ESC_UI_PRIMARY_ACTION` as well as another new
action `ESC_UI_CHANGE_VERB_ACTION`. These actions are mapped to X and Y
on an XBox controller, respectively.

Note that `game.gd` is also updated to implement `_process()` such that
moving `JOY_AXIS_0` and `JOY_AXIS_1` on "gamepad 0" will move the
cursor around on the screen as the mouse would.

Overall, this makes the game fairly playable with a gamepad, though
admittedly a mouse is still currently required to click the "New game"
button on the initial menu because `BaseButton::gui_input()` appears to
be hardcoded to check for mouse events exclusively:

https://github.com/godotengine/godot/blob/a09814e4f86861948615fcd83139de6ed9a34434/scene/gui/base_button.cpp#L55-L81
@bolinfest bolinfest force-pushed the rfc-gamepad-support branch from ce212ac to 54b116c Compare March 12, 2022 17:55
@dploeger dploeger merged commit d636c1d into godot-escoria:develop Mar 14, 2022
dploeger added a commit that referenced this pull request Mar 14, 2022
StraToN pushed a commit that referenced this pull request Mar 14, 2022
This commit starts by introducing a new action, `ESC_UI_PRIMARY_ACTION`,
that is used to represent a "primary action" from an input device, such
as a left-click on a mouse or the press of the primary button on a
gamepad. Although this action is not added to `InputMap` by default in
`escoria-core`, `_unhandled_input()` in `esc_item.gd` is updated to look
for it.

The other portion of this commit is an update to
`addons/escoria-ui-simplemouse/game.gd` that adds a gamepad mapping to
the `InputMap` for both `ESC_UI_PRIMARY_ACTION` as well as another new
action `ESC_UI_CHANGE_VERB_ACTION`. These actions are mapped to X and Y
on an XBox controller, respectively.

Note that `game.gd` is also updated to implement `_process()` such that
moving `JOY_AXIS_0` and `JOY_AXIS_1` on "gamepad 0" will move the
cursor around on the screen as the mouse would.

Overall, this makes the game fairly playable with a gamepad, though
admittedly a mouse is still currently required to click the "New game"
button on the initial menu because `BaseButton::gui_input()` appears to
be hardcoded to check for mouse events exclusively:

godotengine/godot@a09814e/scene/gui/base_button.cpp#L55-L81
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.

4 participants