Skip to content

Move the menu cursor with the directional pad too - #83

Merged
sergiou87 merged 1 commit into
sergiou87:masterfrom
dmaglio:dpad-moves-menu-cursor
Oct 23, 2026
Merged

sergiou87 merged 1 commit into
sergiou87:masterfrom
dmaglio:dpad-moves-menu-cursor

Conversation

@dmaglio

@dmaglio dmaglio commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

On a controller without an analog stick, the menu cursor can't be moved. gameControllerEmulateMouse reads only the left stick, while in a level the directional pad already works (getGameControllerAxis falls 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.c changes. I did not touch the SDL 1 controller code.

Tested

  • Builds with linux/Makefile (SDL 2.32).
  • A small test with SDL's virtual joystick (a game controller with a hat mapped as the pad): at rest the cursor speed is (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.
  • On the Brick itself I only tried a workaround from outside the game (PortMaster's gptokeyb turning the pad into mouse movement), which fixed the menu. I did not run a build with this change on the device.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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

@sergiou87
sergiou87 merged commit 2ae9e58 into sergiou87:master Oct 23, 2026
16 checks passed
@sergiou87

Copy link
Copy Markdown
Owner

Thank you for this! 💖

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.

3 participants