-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
gamepad: native standard layout for Linux #2587
Conversation
46a20c7
to
9f8cdcb
Compare
9f8cdcb
to
f467942
Compare
In Ebitengine, we squash all the commits and rebase it onto the latest commit. So, if you don't want them to be squashed, please send a separate PR. (I recommend separating it for easy reviews) |
Done that; note that I did not push to this branch, but rather pushed HEAD^ to the other PR, so if that PR is merged first, this one will no longer contain its first commit. |
Damn, looks like all this work was for nothing - I had hoped you'd review this BEFORE splitting up into separate PRs so I don't get into merge conflict hell all the time. Now I will have to do lots of duplicate work :( |
Sorry I don't understand the current situation. I want to review each PR one by one. |
Yeah, it was a big mistake to try to already get this to work for Linux. |
fccd6a8
to
75f4867
Compare
… in the per-platform implementations. (#2588) Refactors native standard layout so standard axes and buttons can be implemented using any of axes, buttons or hats. This is required to be able to implement a native standard layout mapping for Linux, as e.g. shoulder buttons can be backed either by an analog or digital input. Precedes #2587 Updates #2052
75f4867
to
483f853
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good.
483f853
to
c9fb1a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
One thing actually - if you want, I can change the standard mapping function to use ABS_HAT0X and ABS_HAT1X even when referring to the Y axis. That would allow removing some of the constants, and would allow to still skip the hat indexes. Do you want me to do that? I find the current version cleaner as it's easier to compare to SDL's implementation. |
Wouldn't this be a breaking change? |
It would not break as nothing would be accessing the fields for the second hat axis anymore (like before), but it'd be more confusing (but shorter code). For that reason I'd prefer keeping it the way it is now in this change. |
Note that gamepaddb entries still have priority.
c9fb1a7
to
db99ea9
Compare
Done that now (replying here as I can't find this comment on github).
Am Fr., 3. März 2023 um 07:50 Uhr schrieb Hajime Hoshi <
***@***.***>:
… ***@***.**** commented on this pull request.
------------------------------
In internal/gamepad/gamepad_linux.go
<#2587 (comment)>:
> + // so we can just overwrite rather than checking.
+
+ // BTN_GAMEPAD implies that the kernel module implements standard mapping.
+ if b := g.keyMap[_BTN_GAMEPAD-_BTN_MISC]; b < 0 {
+ return
+ }
+
+ // A and B buttons go by name.
+ if b := g.keyMap[_BTN_A-_BTN_MISC]; b >= 0 {
+ g.stdButtonMap[gamepaddb.StandardButtonRightBottom] = buttonMappingInput{g: g, button: b}
+ }
+ if b := g.keyMap[_BTN_B-_BTN_MISC]; b >= 0 {
+ g.stdButtonMap[gamepaddb.StandardButtonRightRight] = buttonMappingInput{g: g, button: b}
+ }
+ if vendor == 0x054c /* USB_VENDOR_SONY */ {
+ // Sony uses WEST/NORTH buttons.
Optional: we might want a comment that this is opposite from the kernal
document.
—
Reply to this email directly, view it on GitHub
<#2587 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5NMEJRYKKMBUCOES3YJ3W2IHN3ANCNFSM6AAAAAAVOASJXY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hm I see. So skipping the values might be very slightly efficent but the code would be hacky, right? I prefer the current style then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
Sorry I removed the comment. Thank you for adding the comment! |
What issue is this addressing?
Closes #2052
What type of issue is this addressing?
feature
What this PR does | solves
Implements native standard layout for Linux gamepads by using the kernel-provided button IDs, thereby expanding support to gamepads not listed in
gamecontrollerdb.txt
.Requires #2588
Linux's docs: https://www.kernel.org/doc/Documentation/input/gamepad.txt
SDL2's source: https://fossies.org/linux/SDL2/src/joystick/linux/SDL_sysjoystick.c#l_1740
Note that I am NOT 100% convinced about the X/Y swap between Xbox and PlayStation controllers - the Xbox compatible pad I have however does have
BTN_NORTH
andBTN_WEST
swapped (and thusBTN_X
andBTN_Y
assigned right), which confirms SDL's logic and opposes the kernel docs.Tested with this gamepad: "20d6:2802 BDA Xbox ONE Core controller", label says "PowerA Model 1508491-02" - even after clearing out
gamecontrollerdb.txt
,examples/gamepad
shows a 100% correct mapping.