We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4395 - [PATCH][REGRESSION] HIDAPI uses incorrect mapping for Xbox One S BT (0x045e 0x02e0)
Summary: [PATCH][REGRESSION] HIDAPI uses incorrect mapping for Xbox One S BT (0x045e 0...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.9
Hardware: x86 macOS 10.13
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-20 06:19 UTC by Cameron Gutman
Modified: 2019-06-08 17:30 UTC (History)
1 user (show)

See Also:


Attachments
Patch to ignore this old firmware for HIDAPI (1.03 KB, patch)
2019-05-01 03:45 UTC, Cameron Gutman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2018-11-20 06:19:51 UTC
The new HIDAPI support is causing an issue for a user with an Xbox One S controller connected via Bluetooth (VID = 0x045e, PID = 0x02e0). The code in SDL_hidapi_xbox360.c for handling input reports from Xbox One S gamepads only handles a single button mapping, however early Xbox One S firmwares had a different Bluetooth button mapping.

In case you weren't aware, the Xbox One S controllers change BT PID when their firmware is updated, so 0x02e0 is simply an older firmware on the same exact hardware that would later report 0x02fd when updated.

You can see the difference in SDL_gamecontrollerdb.h, where the mappings for the old firmware (030000005e040000e002000003090000) are different than mappings for the new firmware (030000005e040000fd02000003090000).

Because HIDAPI is overriding the native macOS joystick support, the existing correct mappings from SDL 2.0.8 don't work anymore after updating to SDL 2.0.9 (unless we set SDL_JOYSTICK_HIDAPI=0).

Original bug: https://github.com/moonlight-stream/moonlight-qt/issues/133
Comment 1 Sam Lantinga 2018-11-20 15:47:32 UTC
I don't have access to the older firmware. Can you provide a tested patch?

Thanks!
Comment 2 Cameron Gutman 2018-11-20 18:17:36 UTC
I'm in the same boat too. I might be able to get the user to test some changes though.

How do you prefer I solve this? Should we handle it in HIDAPI_DriverXboxOneS_HandleStatePacket() itself or could/should we make a separate mapping for HIDAPI's joystick GUID for this device?
Comment 3 Sam Lantinga 2018-11-21 18:32:02 UTC
The mapping for all HIDAPI controllers is fixed, we should handle it in HIDAPI_DriverXboxOneS_HandleStatePacket()
Comment 4 Cameron Gutman 2019-05-01 03:45:12 UTC
Created attachment 3772 [details]
Patch to ignore this old firmware for HIDAPI

I can't seem to get my hands on this older firmware, so I've posted this patch as a workaround. Rather than having to set SDL_HINT_JOYSTICK_HIDAPI_XBOX=0 and disable all HIDAPI support for Xbox gamepads, we can just ignore the single broken one and leave the others intact. The Cocoa joystick code will handle this gamepad properly using the existing mapping that ships with SDL.
Comment 5 Sam Lantinga 2019-06-08 17:30:31 UTC
That works for me...
https://hg.libsdl.org/SDL/rev/096f2f3c4bdc