Skip to content
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

HID driver ignores most non-standard buttons #1527

Open
connorjclark opened this issue Jan 14, 2024 · 7 comments · Fixed by #1530
Open

HID driver ignores most non-standard buttons #1527

connorjclark opened this issue Jan 14, 2024 · 7 comments · Fixed by #1530

Comments

@connorjclark
Copy link
Contributor

Here is the output for all buttons found on my Xbox One controller:

0x10751f810 type: 2 usage: 1
0x10751f960 type: 2 usage: 2
0x10751f180 type: 2 usage: 3
0x10751fc10 type: 2 usage: 4
0x10751fd60 type: 2 usage: 5
0x10751feb0 type: 2 usage: 6
0x107520000 type: 2 usage: 7
0x107520150 type: 2 usage: 8
0x1075202a0 type: 2 usage: 9
0x1075203f0 type: 2 usage: 10
0x107520540 type: 2 usage: 11
0x107520690 type: 2 usage: 12
0x107520930 type: 2 usage: 13
0x107520a80 type: 2 usage: 14
0x107520bd0 type: 2 usage: 15
0x107520d20 type: 2 usage: 548

The last one is the select button (opposite of the start button, looks like two interlacing squares), but being over the max _AL_MAX_JOYSTICK_BUTTONS it is dropped.

Do the usage values here have any particular meaning? I've been trying to find documentation on how HID gaming controllers work, but can't seem to find a standard definition for the usage codes of gaming controllers. If there is no such standardization, are we free to just accept the first 32 (value of _AL_MAX_JOYSTICK_BUTTONS) buttons, instead of just the ones less than 32?

@connorjclark
Copy link
Contributor Author

Could this constant simply be bumped to something like 1024? Might end up doing that in my fork.

SiegeLord added a commit to SiegeLord/allegro5 that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes liballeg#1527
SiegeLord added a commit to SiegeLord/allegro5 that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes liballeg#1527
SiegeLord added a commit to SiegeLord/allegro5 that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes liballeg#1527
SiegeLord added a commit to SiegeLord/allegro5 that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes liballeg#1527
SiegeLord pushed a commit to SiegeLord/allegro5 that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes liballeg#1527
SiegeLord pushed a commit that referenced this issue Feb 11, 2024
Add a compatibility config option, "[compatibility] joystick_version=xx.yy.zz"
if it is necessary to restore the old behavior.

Fixes #1527
@connorjclark
Copy link
Contributor Author

connorjclark commented Feb 15, 2024

For some reason the select button on this X360 controller is mapped to usage page 0xC, kHIDPage_Consumer, not a button - so the recent PR still doesn't allow the select button to be used.

Maybe it mapping to a consumer input is by design, and this is meant to be a system button? Except I'd then expect the big center Xbox Logo home button to be a consumer input too, but that's actually in the button usage page!

Does the HID controller/driver code live on a device, or is this something Apple messed up? Is the fix here "don't use HID"? 🤷

EDIT:

This is a bluetooth X360 controller. I learned Apple is the one providing the driver for this to work as a HID device. Drivers are packaged in OS updates. I'm on 12.6 Monterey still, will update to 14.3.1 Sonoma and see if there is a better driver.

EDIT v2:

Nope :/

@connorjclark
Copy link
Contributor Author

FWIW, the SDL backend works just fine for all buttons.

The examples on the official website don't work with gamepads, since they haven't been updated, but when I fixed that bug I uploaded demos here.

@SiegeLord
Copy link
Member

The reason I added a page check was because for my controller the select button was mapped to both a button, and also a 'back' system action, so I figured I'd just filter them out that way. We can take a look at what other libraries do for this (if they use HID)

@SiegeLord SiegeLord reopened this Feb 15, 2024
@SiegeLord
Copy link
Member

Looks like SDL admits both kHIDPage_Consumer and kHIDPage_Button, so we can do the same here.

@SiegeLord
Copy link
Member

Well... I guess it admits actually quite a few pages. GLFW does as well. Probably just need to copy over the logic in its entirety to match the behavior.

@connorjclark
Copy link
Contributor Author

connorjclark commented Feb 15, 2024

I see in SDL's hidapi that it seems to collect all usages, and yeah it treats button and consumer the same way. Interesting to see how it uses all the other types.

FWIW this is the commit where they added handling consumer type: libsdl-org/SDL@9c51c4a

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 a pull request may close this issue.

2 participants