Skip to content

Don't duplicate SDL_JOY... events on SDL_CONTROLLERs#305

Merged
daid merged 1 commit into
daid:masterfrom
oznogon:avoid-joystick-vs-controller-inconsistency
Mar 19, 2026
Merged

Don't duplicate SDL_JOY... events on SDL_CONTROLLERs#305
daid merged 1 commit into
daid:masterfrom
oznogon:avoid-joystick-vs-controller-inconsistency

Conversation

@oznogon

@oznogon oznogon commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

SDL simultaneously reports two different device axes for each analog trigger on an Xbox controller:

  • an SDL Joystick axis, in a range of -1 to 1 to EE (-16384 to 16384 raw) with -1 (-16384) when released and 0 in the middle
  • an SDL Gamecontroller axis, in a range of 0 to 1 to EE (0 to 32768 raw) with 0 when released and 16384 in the middle.

HotkeyBinder logic picks up whichever one crosses the threshold first, which is usually the joystick axis because a smaller positive/fabs raw value crosses 0.5. However, if you pull the trigger fast enough and EE is slow enough, the trigger can still win.

For example, this can result in the left trigger binding inconsistently as either Axis 4 or Left trigger on Linux. The resulting behaviors are inconsistent, since Axis 4 can exceed threshold at rest and hit its deadzone at half pressure, while Left trigger works more as expected.

To avoid this, skip SDL_JOY... events if the event is coming from a GameController device.

@daid
daid merged commit 0cd1988 into daid:master Mar 19, 2026
6 checks passed
@oznogon
oznogon deleted the avoid-joystick-vs-controller-inconsistency branch March 19, 2026 16:43
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.

2 participants