Repository navigation
Move the menu cursor with the directional pad too - #83
Merged
Merged
Conversation
gameControllerEmulateMouse read only the left analog stick, so on a controller without one (many handhelds, such as the TrimUI Brick) the menu cursor could not be moved, though the directional pad already moves Murphy. The pad now moves the cursor at about half the stick's full speed when the stick is not pushed.
There was a problem hiding this comment.
🔵 Needs a closer look
The shared input path also moves the hidden pointer during gameplay, a behavior change that needs maintainer confirmation.
No open issues 🎉
What changed in this PR
Enables menu cursor movement on SDL2 controllers without analog sticks by extending the existing controller-to-mouse emulation.
Changes:
- Adds directional-pad movement at a fixed speed of 5 on the stick’s 1–9 scale.
- Preserves analog-stick priority per axis and existing confirm/cancel button handling.
| File | Description |
|---|---|
src/sdl2/controller.c |
Adds directional-pad fallback to SDL2 mouse emulation. |
Review effort: Max
Owner
|
Thank you for this! 💖 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a controller without an analog stick, the menu cursor can't be moved.
gameControllerEmulateMousereads only the left stick, while in a level the directional pad already works (getGameControllerAxisfalls back to the pad's buttons).I found it on a TrimUI Brick (no analog stick): the game starts, Murphy moves with the pad, but the cursor in the menus stays still.
This makes the pad move the cursor too, at 5 on the stick's 1 to 9 scale (about half of a full push), only when the stick is not pushed, so a stick still wins. Only
src/sdl2/controller.cchanges. I did not touch the SDL 1 controller code.Tested
linux/Makefile(SDL 2.32).(0,0); pad left, up, and right+down give(-5,0),(0,-5)and(5,5); a pushed stick still wins over the pad ((9,0)with the pad held the other way); the confirm button still reports as the left click. Without this change the three pad cases give(0,0). I can add the test to the repo if you want it, but the project has none for the controller, so I left it out.gptokeybturning the pad into mouse movement), which fixed the menu. I did not run a build with this change on the device.