atar-axis / xpadneo

Advanced Linux Driver for Xbox One Wireless Controller (shipped with Xbox One S)
https://atar-axis.github.io/xpadneo/
GNU General Public License v3.0
1.92k stars 111 forks source link

Xbox One S controller on new firmware has incorrect mapping #314

Closed XirXes closed 2 years ago

XirXes commented 2 years ago

Version of xpadneo

Controller Model

1708 Firmware 5.11.3116.0

Connection mode

Installed Software

Severity / Impact

Describe the Bug

This controller is running the new beta firmware with double press to toggle between bluetooth and xbox wireless. I believe the firmware version matches the Series controllers; 5.11.3116.0 The controller connects to bluetooth fine and is detected by games and Steam, but the layout is wrong and some buttons don't work. It doesn't do the vibration that xpadneo usually does, I don't think it connects to xpadneo at all, its descriptor is always under /sys/module/hid_generic/drivers/hid\:hid-generic/0005:045E:*/report_descriptor.

Steps to Reproduce

Expected Behavior

Screenshots / GIFs / Videos

System Information

# uname -a
Linux nexus 5.14.11-xanmod1-1 #1 SMP PREEMPT Mon, 11 Oct 2021 01:35:41 +0000 x86_64 GNU/Linux
# xxd -c20 -g1 /sys/module/hid_xpadneo/drivers/hid:xpadneo/0005:045E:*/report_descriptor | tee >(cksum)

$ xxd -c20 -g1 /sys/module/hid_generic/drivers/hid\:hid-generic/0005:045E:*/report_descriptor | tee >(cksum)
00000000: 05 01 09 05 a1 01 85 01 09 01 a1 00 09 30 09 31 15 00 27 ff  .............0.1..'.
00000014: ff 00 00 95 02 75 10 81 02 c0 09 01 a1 00 09 32 09 35 15 00  .....u.........2.5..
00000028: 27 ff ff 00 00 95 02 75 10 81 02 c0 05 02 09 c5 15 00 26 ff  '......u..........&.
0000003c: 03 95 01 75 0a 81 02 15 00 25 00 75 06 95 01 81 03 05 02 09  ...u.....%.u........
00000050: c4 15 00 26 ff 03 95 01 75 0a 81 02 15 00 25 00 75 06 95 01  ...&....u.....%.u...
00000064: 81 03 05 01 09 39 15 01 25 08 35 00 46 3b 01 66 14 00 75 04  .....9..%.5.F;.f..u.
00000078: 95 01 81 42 75 04 95 01 15 00 25 00 35 00 45 00 65 00 81 03  ...Bu.....%.5.E.e...
0000008c: 05 09 19 01 29 0f 15 00 25 01 75 01 95 0f 81 02 15 00 25 00  ....)...%.u.......%.
000000a0: 75 01 95 01 81 03 05 0c 0a b2 00 15 00 25 01 95 01 75 01 81  u............%...u..
000000b4: 02 15 00 25 00 75 07 95 01 81 03 05 0f 09 21 85 03 a1 02 09  ...%.u........!.....
000000c8: 97 15 00 25 01 75 04 95 01 91 02 15 00 25 00 75 04 95 01 91  ...%.u.......%.u....
000000dc: 03 09 70 15 00 25 64 75 08 95 04 91 02 09 50 66 01 10 55 0e  ..p..%du......Pf..U.
000000f0: 15 00 26 ff 00 75 08 95 01 91 02 09 a7 15 00 26 ff 00 75 08  ..&..u.........&..u.
00000104: 95 01 91 02 65 00 55 00 09 7c 15 00 26 ff 00 75 08 95 01 91  ....e.U..|..&..u....
00000118: 02 c0 c0

Controller and Bluetooth Information

0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0

xpadneo-btmon.txt xpadneo-dmesg.txt xpadneo-lsusb.txt

Additional Context

kakra commented 2 years ago

If you got the descriptor from hid-generic, this looks good and we have something to work with. Next step would be to continue using hid-generic and generate a control mapping using evtest. Please post the initial output of it for your device. The press each button and take note of which key code it actually generates.

kakra commented 2 years ago

This looks at least like it should be able to be detected and used by xpadneo:

[33449.020866] hid-generic 0005:045E:0B20.0024: input,hidraw0: BLUETOOTH HID v5.11 Gamepad [Xbox Wireless Controller] on 5c:f3:70:64:14:54
[33632.964263] input: Xbox One Wireless Controller as /devices/virtual/input/input80
[33633.679035] input: Microsoft X-Box 360 pad as /devices/virtual/input/input81
[33651.325910] input: Xbox Wireless Controller as /devices/virtual/misc/uhid/0005:045E:0B20.0025/input/input82
[33651.326237] hid-generic 0005:045E:0B20.0025: input,hidraw0: BLUETOOTH HID v5.11 Gamepad [Xbox Wireless Controller] on 5c:f3:70:64:14:54

So what does it tell us:

XirXes commented 2 years ago

I think the 360 pad is Steam input, I may not have closed Steam completely when testing, and I run with Xbox controller configuration enabled. Either that or XOW masking the controller, disregard it for sure. I had the rf paired and was toggling the controller mode to connect to bluetooth.

That is the MAC address of the controller, just confirmed here. I'll be happy to run a build here to test, but it may be easiest to test with the changes actually pushed to the repo, I'd just have to rebuild the dkms package in that case.

I'll run through evtest this evening, just in case it differs from the layout from the Series controllers.

kakra commented 2 years ago

@XirXes Oh yes, running Steam Input with Xbox controller support enabled actually steals input devices from us and re-emits them as normal non-HID devices. You should probably disable it for the time running the tests as it will interfere with the basic driver setup and adjustment otherwise. We need to test and improve each layer isolated, that is we start with the detection and plain unmodified descriptor (done), then continue to test the HID layer isolated (with evtest). Only then, we'll check for user-space compatibility (Steam, games, etc).

xow should not interfere as it doesn't understand and talk HID devices (which Bluetooth-mode actually uses).

kakra commented 2 years ago

I've created a PR for this: https://github.com/atar-axis/xpadneo/pull/315

To use it, run git remote add kakra https://github.com/kakra/xpadneo.git once in your existing checkout, then fetch all remotes and switch to my branch firmware/xb1s-0b20.

If you run any tests against it, please explicitly tell if you did run with the driver loaded or via hid-generic. Also, for evtest results, I'd need to know the matching descriptor as xpadneo patches descriptors when loaded (usually, this can be detected by the trailing NUL byte at the end of the descriptor which xpadneo strips but hid-generic doesn't but it seems MS has finally fixed that).

XirXes commented 2 years ago

evtest on hid-generic

A   304     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001     type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
B   305     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002     type 1 (EV_KEY), code 305 (BTN_EAST), value 1
X   307     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004     type 1 (EV_KEY), code 307 (BTN_NORTH), value 1
Y   308     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90005     type 1 (EV_KEY), code 308 (BTN_WEST), value 1
LB  310     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90007     type 1 (EV_KEY), code 310 (BTN_TL), value 1
RB  311     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90008     type 1 (EV_KEY), code 311 (BTN_TR), value 1
VIEW    314 type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000b     type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
MENU    315 type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000c     type 1 (EV_KEY), code 315 (BTN_START), value 1
GUIDE   316 type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000d     type 1 (EV_KEY), code 316 (BTN_MODE), value 1
L3  317     type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000e     type 1 (EV_KEY), code 317 (BTN_THUMBL), value 1
R3  318     type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000f     type 1 (EV_KEY), code 318 (BTN_THUMBR), value 1
D           type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 1
R           type 3 (EV_ABS), code 16 (ABS_HAT0X), value 1
L           type 3 (EV_ABS), code 16 (ABS_HAT0X), value -1
U           type 3 (EV_ABS), code 17 (ABS_HAT0Y), value -1
LS D        type 3 (EV_ABS), code 1 (ABS_Y), value 65535    
LS R        type 3 (EV_ABS), code 0 (ABS_X), value 65535
LS L        type 3 (EV_ABS), code 0 (ABS_X), value 0  
LS U        type 3 (EV_ABS), code 1 (ABS_Y), value 0 
RS D        type 3 (EV_ABS), code 5 (ABS_RZ), value 65535  
RS R        type 3 (EV_ABS), code 2 (ABS_Z), value 65535  
RS L        type 3 (EV_ABS), code 2 (ABS_Z), value 0  
RS U        type 3 (EV_ABS), code 5 (ABS_RZ), value 0 
LT          type 3 (EV_ABS), code 10 (ABS_BRAKE), value 0-1023 
RT          type 3 (EV_ABS), code 9 (ABS_GAS), value 0-1023
XirXes commented 2 years ago

That button test is on the HID driver

XirXes commented 2 years ago

I've created a PR for this: #315

To use it, run git remote add kakra https://github.com/kakra/xpadneo.git once in your existing checkout, then fetch all remotes and switch to my branch firmware/xb1s-0b20.

If you run any tests against it, please explicitly tell if you did run with the driver loaded or via hid-generic. Also, for evtest results, I'd need to know the matching descriptor as xpadneo patches descriptors when loaded (usually, this can be detected by the trailing NUL byte at the end of the descriptor which xpadneo strips but hid-generic doesn't but it seems MS has finally fixed that).

I set this up and installed it with dkms and it connected up properly, vibration included. The buttons are mostly correct, but not quite. Great start though!

kakra commented 2 years ago

Could you also run evtest on the xpadneo driver and show the mappings that are wrong?

kakra commented 2 years ago

In your evtest dump, does L3 and R3 mean "left/right thumb stick button", and LB/RB are the shoulder buttons?

Also, I'm missing the A button, but it should be MSC value 90001 key code 304 - that can probably not go wrong anyways.

XirXes commented 2 years ago

In your evtest dump, does L3 and R3 mean "left/right thumb stick button", and LB/RB are the shoulder buttons?

Also, I'm missing the A button, but it should be MSC value 90001 key code 304 - that can probably not go wrong anyways.

Correct, L3 and R3 are the sticks, and LB/RB are shoulders. I had the formatting messed up on my evtest, should be fixed now with A present.

XirXes commented 2 years ago

evtest with xpadneo enabled

A       304     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001     type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
B       305     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002     type 1 (EV_KEY), code 305 (BTN_EAST), value 1
X       307     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003     type 1 (EV_KEY), code 307 (BTN_NORTH), value 1
Y       308     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90004     type 1 (EV_KEY), code 308 (BTN_WEST), value 1
LB      310     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90005     type 1 (EV_KEY), code 310 (BTN_TL), value 1
RB      311     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90006     type 1 (EV_KEY), code 311 (BTN_TR), value 1
VIEW    Not mapped
MENU    315 type 4 (EV_MSC), code 4 (MSC_SCAN), value 90008     type 1 (EV_KEY), code 315 (BTN_START), value 1
GUIDE   *373 type 1 (EV_KEY), code 373 (KEY_MODE), value 1
L3  317     type 4 (EV_MSC), code 4 (MSC_SCAN), value 90009     type 1 (EV_KEY), code 317 (BTN_THUMBL), value 1
R3  318     type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000a     type 1 (EV_KEY), code 318 (BTN_THUMBR), value 1
D           type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 1
R           type 3 (EV_ABS), code 16 (ABS_HAT0X), value 1
L           type 3 (EV_ABS), code 16 (ABS_HAT0X), value -1
U           type 3 (EV_ABS), code 17 (ABS_HAT0Y), value -1
LS D        type 3 (EV_ABS), code 1 (ABS_Y), value 32767    
LS R        type 3 (EV_ABS), code 0 (ABS_X), value 32767
LS L        type 3 (EV_ABS), code 1 (ABS_X), value -32768  
LS U        type 3 (EV_ABS), code 1 (ABS_Y), value -32768 
RS D        type 3 (EV_ABS), code 4 (ABS_RY), value 32767  
RS R        type 3 (EV_ABS), code 3 (ABS_RX), value 32767  
RS L        type 3 (EV_ABS), code 3 (ABS_RX), value -32768  
RS U        type 3 (EV_ABS), code 4 (ABS_RZ), value -32768 
LT          type 3 (EV_ABS), code 2 (ABS_Z), value 1023   type 3 (EV_ABS), code 40 (ABS_MISC), value -1023
RT          type 3 (EV_ABS), code 5 (ABS_RZ), value 1023    type 3 (EV_ABS), code 40 (ABS_MISC), value 1023

* Second event device "Xbox Wireless Controller Consumer Control"
kakra commented 2 years ago

Okay, thanks. I think I can work with that and get the mapping right. But I'm not sure when I have some spare time for it. May take a few days.

XirXes commented 2 years ago

My controller just got updated to 5.11.3118.0. I'll run some more tests tonight.

Confirmed the HID_Generic evtest didn't change, and neither did the device ID.

kakra commented 2 years ago

Thanks for the heads up.

kakra commented 2 years ago

@XirXes Can you retest with the latest PR #315 which should fix SDL2 mapping fixups for PID 0xB20?

XirXes commented 2 years ago

I'm sorry I didn't see this earlier, I just tested with the updated changes to PR #315 and everything but the 'View' button is working perfectly. It isn't making any event under either device.

kakra commented 2 years ago

What's the view button? The left one with the two windows icon?

XirXes commented 2 years ago

Yeah, the select button, my guess is its getting filtered, its HID ID was 9000b, which collides with the Xbox logo button. Line 125 in hid-xpadneo.c mentions it.

I did try with the latest commits updated 50-xpadneo-fixup-steamlink.rules I'm pretty sure that fixed most of the keymap issues.

I also now have a Series X model controller with the beta firmware and can confirm it works perfectly with the same module, all buttons mapped correctly.

kakra commented 2 years ago

This should not have been auto-closed, reopening...

Yeah, the select button, my guess is its getting filtered, its HID ID was 9000b, which collides with the Xbox logo button. Line 125 in hid-xpadneo.c mentions it.

Please check if both thumb stick buttons act correctly. If not, the buttons are shifted and a wrong mapping is assumed somewhere. If they do work correctly, we may need some model quirk which handles this single button.

XirXes commented 2 years ago

Just double checked, the thumbsticks are both working correctly. The mode button is also getting mapped properly to the Xbox Wireless Controller Consumer Control event device. Only the select button not registering is left.

kakra commented 2 years ago

Are you able to create an annotated btmon log of each button press?

XirXes commented 2 years ago

Not until this evening, but I'd be happy to.

kakra commented 2 years ago

Ok, thanks. Probably exclude the sticks: We know those are correct, and you won't be able to click them without moving them, which creates a lot of useless noise in the log. Unless that's your secret superpower... ;-)

XirXes commented 2 years ago

xpadneo-btmon-211116-1.txt

Timestamps 29 A 41 B 56 X 70 Y 96 LB 106 RB 184 Select 198 Start 212 Mode

XirXes commented 2 years ago

Verified controller model 1914 is working perfectly on the build of xpadneo I'm running. The elite series 2 also connects and works correctly, with mapping correct, but the mode button and the profile button both register under the base xbox wireless controller, and its no longer listed as an xbox elite controller, evtest just showed Xbox Wireless Controller and Xbox Wireless Controller Consumer Control.

XirXes commented 2 years ago

I made an updated fork of the firmware/xb1s-0b20 branch with the latest changes from master, and confirmed every button is mapped correctly on 1708 running 5.11.3118.0 with select(view) still being filtered and not functioning.

1914 running 5.11.3118.0 has no issues with keymaps.

XirXes commented 2 years ago

Did not mean to close this, select button still doesn't register on model 1708 on firmware 5.11.3118.0.

kakra commented 2 years ago

Which is the 1708 model? The original XB1S controller?

Also, any idea if we finally can officially get the 5.11 firmware through Windows Update? I'd like to test this on my own models and fix the final things to get this merged. It's the only thing that blocking the next (and probably final) v0.9 release...

XirXes commented 2 years ago

1708 is the XB1S, correct.

I will know later today if its on Windows. The biggest problem I have is all of my controllers are up to date through the xbox. I might be able to downgrade one of them.

tmg0mes commented 2 years ago

Hey, any news on the select button issue on 1708 model?

kakra commented 2 years ago

I think MS still doesn't deploy this update via Windows, and I have no access to an Xbox through one of my friends. So I cannot test this myself yet. Does anyone know if the new firmware is available through Windows already?

kakra commented 2 years ago

Please check again with latest master.

XirXes commented 2 years ago

I spotted a Reddit thread saying they've updated Xbox Accessories in Windows 10 and 11 and the new update includes firmware 5.13.3143. link

As for retesting with a new build, I just did and I still don't get any response from btn_select, and it does enable the record button even though this controller doesn't have one.

Input device ID: bus 0x5 vendor 0x45e product 0x2e0 version 0x903
Input device name: "Xbox Wireless Controller Consumer Control"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 167 (KEY_RECORD)
    Event code 373 (KEY_MODE)
kakra commented 2 years ago

Thanks for spotting this. I tried all my models and only the XBXS was updated to 5.13. My XB1S and XBE2 remained at 4.8. The updates probably roll out in waves.

Regarding the buttons, xpadneo will currently report all buttons available across all models even if that particular model does not have each button.

All buttons worked as they should. I'll probably have to wait for my older models to update to 5.13.

ryannathans commented 2 years ago

I spotted a Reddit thread saying they've updated Xbox Accessories in Windows 10 and 11 and the new update includes firmware 5.13.3143. link

As for retesting with a new build, I just did and I still don't get any response from btn_select, and it does enable the record button even though this controller doesn't have one.

Input device ID: bus 0x5 vendor 0x45e product 0x2e0 version 0x903
Input device name: "Xbox Wireless Controller Consumer Control"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 167 (KEY_RECORD)
    Event code 373 (KEY_MODE)

for me on xbox series x controller it seems select and share are swapped in the latest master issue doesn't exist in the last xpadneo release

XirXes commented 2 years ago

Thanks for spotting this. I tried all my models and only the XBXS was updated to 5.13. My XB1S and XBE2 remained at 4.8. The updates probably roll out in waves.

Regarding the buttons, xpadneo will currently report all buttons available across all models even if that particular model does not have each button.

All buttons worked as they should. I'll probably have to wait for my older models to update to 5.13.

I have confirmed what @ryannathans said, there was a second update to the Xbox Accessories app and it does include firmware 5.13.3143 for the 1708 model controllers, so you should be able to get your One S controllers updated now.

The only big note about the controller update in my eyes is if you need non LE bluetooth on your controller for anything, you are best off staying on or reverting to the old firmware.

You can also now downgrade controllers from Windows by entering this URL in the Run dialog box;

xboxaccessories:\\firmwareupdate?legacyDowngrade=true
kakra commented 2 years ago

I have confirmed what @ryannathans said, there was a second update to the Xbox Accessories app and it does include firmware 5.13.3143 for the 1708 model controllers, so you should be able to get your One S controllers updated now.

I can confirm that for all my three models. Although the app says "no update available" it will still apply an update to 5.13 when I click the update button. I can now test this stuff and already fixed two problems in the source code but currently my XBE2 controller no longer connects to Bluetooth and just says:

[275473.672782] Bluetooth: hci0: unexpected SMP command 0x08 from 98:7a:14:61:17:4d
[275473.673563] Bluetooth: hci0: unexpected SMP command 0x09 from 98:7a:14:61:17:4d

It then semi-connects (xpadneo sees the device) but it won't work and eventually timeout:

[275294.926036] Bluetooth: hci0: No such LE device 98:7a:14:61:17:4d (0x0)

It seems that with version 5.13, both models XB1S and XBXS use the same PID now (0B13). The button mapping is correct for both models.

XirXes commented 2 years ago

It seems that with version 5.13, both models XB1S and XBXS use the same PID now (0B13). The button mapping is correct for both models.

I can confirm that with the latest commit 4fd620c and modprobing hid-xpadneo before I connect the controller my select button now registers! With that the keymap issues I was having on 5.13 are completely resolved. I'll close this issue, now that you have the new firmware in hand I'm sure if there's anything else wrong you'll find it.