Skip to content

joystick: Improve Xbox controller mapping with xpad quirks #13305

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

Merged
merged 2 commits into from
Jul 29, 2025

Conversation

endrift
Copy link
Contributor

@endrift endrift commented Jul 1, 2025

xpad has a series of questionable design choices when it comes to button mapping. Notably, BTN_TRIGGER_HAPPY1-4 are used for the D-pad on dance mats instead of the typical BTN_DPAD_*, and maps the paddles to BTN_TRIGGER_HAPPY5-8. This commit plumbs through driver detection for a udev device and adds special exceptions for xpad's quirks. When not using xpad, it assumes that the paddles are instead mapped to BTN_TRIGGER_HAPPY1-4, which is what upcoming driver projects use instead.

It also exposes KEY_RECORD as the share button regardless of vendor, which had previously been gated behind being a Microsoft controller. All Xbox Series controllers can include this button, and many third party ones do.

I've noticed that there is a special exception to Xbox 360 wireless controller mapping of the D-pad in SDL_PrivateGetGamepadMappingForNameAndGUID in SDL_gamepad.c. I don't have the wireless adapter mentioned so I can't test how this affects that, which should probably be checked before merging.

@endrift endrift marked this pull request as draft July 12, 2025 00:04
xpad has a series of questionable design choices when it comes to button
mapping. Notably, BTN_TRIGGER_HAPPY1-4 are used for the D-pad on dance mats
instead of the typical BTN_DPAD_*, and maps the paddles to
BTN_TRIGGER_HAPPY5-8. This commit plumbs through driver detection for a udev
device and adds special exceptions for xpad's quirks.

Newer kernels (6.17+) add the BTN_GRIP* mappings for paddles on controllers. We
should prefer that if available, as its meaning and mapping is unambiguous.
However, since it's only in new kernels, we need to maintain the older mappings
where we know they exist.

It also exposes KEY_RECORD as the share button regardless of vendor, which had
previously been gated behind being a Microsoft controller. All Xbox Series
controllers can include this button, and many third party ones do.
@endrift endrift marked this pull request as ready for review July 29, 2025 02:09
@endrift
Copy link
Contributor Author

endrift commented Jul 29, 2025

My BTN_GRIP* patch series got merged into the kernel's input branch, though it missed the 6.16 release window. I've updated the PR to use the BTN_GRIP* mappings if available, but only if available, and otherwise just using the old mappings.

@slouken slouken merged commit 5f4416b into libsdl-org:main Jul 29, 2025
2 checks passed
@endrift endrift deleted the xpad-paddles branch July 29, 2025 07:44
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