Skip to content

Conversation

@riccardobl
Copy link
Member

@riccardobl riccardobl commented Jan 12, 2026

JME already does some remapping to make sense of different gamepad layouts. However, this isn't always enough: mappings can be broken by the driver itself or differ across platforms.

This PR addresses that by implementing input handling via GLFWGamepadState.

When a controller is recognized by GLFW, GLFWGamepadState automatically remaps it to an Xbox-like layout. If the controller isn't recognized, the code falls back to the previous behavior (raw mapping + JME's own remapping).

This behavior is controlled by two new AppSettings:

  • TriggerToButtonThreshold : how much you need to press an analog trigger to fire a button press (-1 disable, default 0.5)
  • XboxLikeControllerLayout : if false: never use GLFWGamepadState (default true)

To avoid breaking existing code, I also added an extra remapping layer so the new inputs match the layout used by TestJoystick.

Finally, I added Xbox-named aliases to both JoystickAxis and JoystickButton, making bindings more intuitive going forward.

Tested on

  • Fedora 43 , wired Xbox 360 Controller
  • Fedora 43 , wired BSP-D3 (presents itself as PS4-like)
  • Fedora 43 , wired 8BitDo Ultimate 2C

Needs more testing with different platforms and controllers

Rumble

Rumble still doesn't work because GLFW doesn't support it. I explored a few workarounds, and the most promising option is to switch to SDL for input (which includes haptics). SDL support should be available via LWJGL 3.4 once that release is stable.

@riccardobl riccardobl changed the title Fix gamepad weirdness by mapping them to Xbox-like layout Fix gamepad weirdness by remapping to Xbox-like layout Jan 12, 2026
@riccardobl riccardobl changed the title Fix gamepad weirdness by remapping to Xbox-like layout Fix gamepads weirdness by remapping to Xbox-like layout Jan 12, 2026
@riccardobl riccardobl added enhancement defect Something that is supposed to work, but doesn't. Less severe than a "bug" labels Jan 12, 2026
addButton( JoystickButton.BUTTON_XBOX_DPAD_UP, 96, 512 - 174, 40, 38 );
addButton( JoystickButton.BUTTON_XBOX_DPAD_RIGHT, 128, 512 - 208, 40, 38 );
addButton( JoystickButton.BUTTON_XBOX_DPAD_DOWN, 96, 512 - 239, 40, 38 );
addButton( JoystickButton.BUTTON_XBOX_DPAD_LEFT, 65, 512 - 208, 40, 38 );
Copy link
Member Author

Choose a reason for hiding this comment

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

binding dpad buttons is more intuitive, however the POV axis is still supported

@riccardobl riccardobl changed the title Fix gamepads weirdness by remapping to Xbox-like layout Fix gamepads weirdness by remapping to Xbox-like layout in lwjgl3 backend Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defect Something that is supposed to work, but doesn't. Less severe than a "bug" enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant