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

Add support for XB1S BLE firmware update #315

Closed kakra closed 2 years ago

kakra commented 2 years ago

Microsoft added BLE support to existing controllers.

This PR adds support for binding xpadneo to controllers flashed with the new firmware version which exposes the device under a new PID. It is still work in progress as we may add mapping fixups and quirk handling.

CutestNekoAqua commented 2 years ago

need this as I just got a controller some days ago, and I had no other option as to flash the newest firmware, as, according to xpadneos troubleshooting page, the stock firmware doesn't work. Is it able to be tested already?

kakra commented 2 years ago

Yes, checkout this very PR branch and please test, report back what you find. I'm still waiting for a chance to update my own XB1S controller to the new firmware. It's likely that the PID of the device is different, so please post what you get from it.

This PR is the single thing that mostly holds back a version bump of the v0.9 branch because I want to get it into that version.

CutestNekoAqua commented 2 years ago

Also maybe important: with the stock version, I got a rumble on bluetooth pairing, steam detected the controller, xbox logo didn't stop blinking, with the updated firmware, I get no rumble, steam doesn't detect controller, but the xbox logo stops blinking

Which are the best steps to test/ debug this version if I may ask?

kakra commented 2 years ago

Is Steam Input enabled or disabled? Do you have RGB software installed?

You probably get no rumble because xpadneo doesn't bind to the device. Could you show your dmesg after pairing?

CutestNekoAqua commented 2 years ago

Can report that after installing this beta driver, stopping pc, pairing controller to phone, starting and pairing controller to pc it in fact works. Here is my dmesg:


[  116.064299] hid-generic 0005:045E:0B13.0006: input,hidraw5: BLUETOOTH HID v5.09 Gamepad [Xbox Wireless Controller] on 5c:f3:70:a4:a9:83
[  116.072826] loaded hid-xpadneo v0.9-91-gf54deb9
[  116.185496] xpadneo 0005:045E:0B13.0006: pretending XB1S Windows wireless mode (changed PID from 0x0B13 to 0x02E0)
[  116.185503] xpadneo 0005:045E:0B13.0006: working around wrong SDL2 mappings (changed version from 0x00000509 to 0x00000903)
[  116.185507] xpadneo 0005:045E:0B13.0006: report descriptor size: 283 bytes
[  116.185510] xpadneo 0005:045E:0B13.0006: fixing up Rx axis
[  116.185513] xpadneo 0005:045E:0B13.0006: fixing up Ry axis
[  116.185514] xpadneo 0005:045E:0B13.0006: fixing up Z axis
[  116.185516] xpadneo 0005:045E:0B13.0006: fixing up Rz axis
[  116.185518] xpadneo 0005:045E:0B13.0006: fixing up button mapping
[  116.185726] xpadneo 0005:045E:0B13.0006: gamepad detected
[  116.185728] xpadneo 0005:045E:0B13.0006: enabling compliance with Linux Gamepad Specification
[  116.185768] input: Xbox Wireless Controller as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input24
[  116.185926] xpadneo 0005:045E:0B13.0006: input,hidraw5: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on 5c:f3:70:a4:a9:83
[  116.185971] input: Xbox Wireless Controller Consumer Control as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input25
[  116.186041] xpadneo 0005:045E:0B13.0006: consumer control added
[  116.186045] xpadneo 0005:045E:0B13.0006: controller quirks: 0x00000050
[  116.186047] xpadneo xpadneo_welcome_rumble start
[  117.168634] xpadneo xpadneo_welcome_rumble took 980ms
[  117.168659] xpadneo 0005:045E:0B13.0006: Xbox Wireless Controller [f4:6a:d7:57:37:82] connected
[  117.401662] xpadneo 0005:045E:0B13.0006: report descriptor size: 283 bytes
[  117.401673] xpadneo 0005:045E:0B13.0006: fixing up Rx axis
[  117.401678] xpadneo 0005:045E:0B13.0006: fixing up Ry axis
[  117.401682] xpadneo 0005:045E:0B13.0006: fixing up Z axis
[  117.401686] xpadneo 0005:045E:0B13.0006: fixing up Rz axis
[  117.401689] xpadneo 0005:045E:0B13.0006: fixing up button mapping
[  117.402086] xpadneo 0005:045E:0B13.0006: gamepad detected
[  117.402089] xpadneo 0005:045E:0B13.0006: enabling compliance with Linux Gamepad Specification
[  117.402205] input: Xbox Wireless Controller as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input26
[  117.402440] xpadneo 0005:045E:0B13.0006: input,hidraw5: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on 5c:f3:70:a4:a9:83
[  117.402515] input: Xbox Wireless Controller Consumer Control as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input27
[  117.402586] xpadneo 0005:045E:0B13.0006: consumer control added
[  117.402596] xpadneo 0005:045E:0B13.0006: controller quirks: 0x00000010
[  117.402600] xpadneo xpadneo_welcome_rumble start
[  118.385393] xpadneo xpadneo_welcome_rumble took 984ms
[  118.385417] xpadneo 0005:045E:0B13.0006: Xbox Wireless Controller [f4:6a:d7:57:37:82] connected
[  120.156518] input: Microsoft X-Box 360 pad as /devices/virtual/input/input28```
CutestNekoAqua commented 2 years ago

vibrator and steam also works. (Tested with ultimate chicken horse and shellshock live)

kakra commented 2 years ago

Do all buttons work as expected? (check with evtest please)

XirXes commented 2 years ago

Just did some retesting and confirmed only the XB1S controller models on this new 5.11.3118.0 firmware don't map the select(view) button correctly. It isn't registered at all on the XB1S(1708) controller but does work correctly on the XBS(1914). Otherwise they seem to work correctly on this branch, though.

Seems @UnrealValentin has an XBS(1914) model, those are still detected with the same ID they had before the firmware update. 0x0B13

You can downgrade the controller firmware using the xbox console with these instructions if you need to bypass this issue for now. The newest firmware version available for the XBS(1914) controller on Windows is 5.9.2709.0. https://support.xbox.com/en-US/help/hardware-network/settings-updates/whats-new-xbox-one-system-updates

CutestNekoAqua commented 2 years ago

Seems @UnrealValentin has an XBS(1914) model, those are still detected with the same ID they had before the firmware update. 0x0B13

Still didn't work before this version of xpadneo for me, for some reason.

Do all buttons work as expected? (check with evtest please)

All buttons (except xbox logo) work for me.

XirXes commented 2 years ago

Seems @UnrealValentin has an XBS(1914) model, those are still detected with the same ID they had before the firmware update. 0x0B13

Still didn't work before this version of xpadneo for me, for some reason.

Do all buttons work as expected? (check with evtest please)

All buttons (except xbox logo) work for me.

The xbox logo button registers on a different device when used with xpadneo, that's normal its not detected with the rest of the inputs

ThomasCr commented 2 years ago

hi, I tested today this patch on top of version 0.9.1 with my updated XBOX One S Controller connected via BT. Before (with version 0.9.1) Rumble was not working and with the patch, the normal rumble is working, but not the trigger rumble. I tested with the provided python_evdev_rumble example. On start it rumbles once, but then the Playing FF effect does nothing.

Also the test with fftest works only for effect 4 and 5 (see below)

I tested to capture the things from python_evdev_rumble with btmon, but got no output at all (also not where the first rumble was running).

My Blutetooth Controller is the integrated one from Intel® Dual Band Wireless-AC 8260, a Dual Mode Bluetooth® 4.2, BLE

# lsb_release -ds
Ubuntu Jammy Jellyfish (development branch)

# uname -a
Linux ub-tc 5.15.0-17-generic #17-Ubuntu SMP Thu Jan 13 16:27:23 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/modprobe.d/99-xpadneo-options.conf
options hid_xpadneo disable_deadzones=0 rumble_attenuation=0 trigger_rumble_mode=0

# fftest /dev/input/event19 
Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event19 opened
Features:
  * Absolute axes: X, Y, Z, RX, RY, RZ, Hat 0 X, Hat 0 Y, Misc ,
    [3F 00 03 00 00 01 00 00 ]
  * Relative axes: 
    [00 00 ]
  * Force feedback effects types: Periodic, Rumble, Gain, 
    Force feedback periodic effects: Square, Triangle, Sine, 
    [00 00 00 00 00 00 00 00 00 00 03 07 01 00 00 00 ]
  * Number of simultaneous effects: 16

Setting master gain to 75% ... OK
Uploading effect #0 (Periodic sinusoidal) ... OK (id 0)
Uploading effect #1 (Constant) ... Error: Invalid argument
Uploading effect #2 (Spring) ... Error: Invalid argument
Uploading effect #3 (Damper) ... Error: Invalid argument
Uploading effect #4 (Strong rumble, with heavy motor) ... OK (id 1)
Uploading effect #5 (Weak rumble, with light motor) ... OK (id 2)
Enter effect number, -1 to exit

# sudo xxd -c20 -g1 /sys/module/hid_xpadneo/drivers/hid:xpadneo/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 33 09 34 15 00  .....u.........3.4..
00000028: 27 ff ff 00 00 95 02 75 10 81 02 c0 05 01 09 32 15 00 26 ff  '......u.......2..&.
0000003c: 03 95 01 75 0a 81 02 15 00 25 00 75 06 95 01 81 03 05 01 09  ...u.....%.u........
00000050: 35 15 00 26 ff 03 95 01 75 0a 81 02 15 00 25 00 75 06 95 01  5..&....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 0c 15 00 25 01 75 01 95 0c 81 02 15 00 25 00  ....)...%.u.......%.
000000a0: 75 01 95 04 81 03 05 0c 0a 24 02 15 00 25 01 95 01 75 01 81  u........$...%...u..
000000b4: 02 15 00 25 00 75 07 95 01 81 03 05 0c 09 01 85 02 a1 01 05  ...%.u..............
000000c8: 0c 0a 23 02 15 00 25 01 95 01 75 01 81 02 15 00 25 00 75 07  ..#...%...u.....%.u.
000000dc: 95 01 81 03 c0 05 0f 09 21 85 03 a1 02 09 97 15 00 25 01 75  ........!........%.u
000000f0: 04 95 01 91 02 15 00 25 00 75 04 95 01 91 03 09 70 15 00 25  .......%.u......p..%
00000104: 64 75 08 95 04 91 02 09 50 66 01 10 55 0e 15 00 26 ff 00 75  du......Pf..U...&..u
00000118: 08 95 01 91 02 09 a7 15 00 26 ff 00 75 08 95 01 91 02 65 00  .........&..u.....e.
0000012c: 55 00 09 7c 15 00 26 ff 00 75 08 95 01 91 02 c0 05 06 09 20  U..|..&..u......... 
00000140: 85 04 15 00 26 ff 00 75 08 95 01 81 02 c0                    ....&..u......
3560615638 1558

# dmesg output
[ 8115.543524] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 8115.543532] Bluetooth: HIDP socket layer initialized
[ 8115.544388] hid-generic 0005:045E:02FD.0009: unknown main item tag 0x0
[ 8115.544510] input: Xbox Wireless Controller as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.0009/input/input39
[ 8115.545484] input: Xbox Wireless Controller Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.0009/input/input40
[ 8115.545874] hid-generic 0005:045E:02FD.0009: input,hidraw5: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on a4:34:d9:92:46:d5
[ 8115.549061] hid_xpadneo: loading out-of-tree module taints kernel.
[ 8115.549108] hid_xpadneo: module verification failed: signature and/or required key missing - tainting kernel
[ 8115.549439] loaded hid-xpadneo 0.9.1
[ 8115.653326] xpadneo 0005:045E:02FD.0009: pretending XB1S Windows wireless mode (changed PID from 0x02FD to 0x02E0)
[ 8115.653334] xpadneo 0005:045E:02FD.0009: report descriptor size: 335 bytes
[ 8115.653337] xpadneo 0005:045E:02FD.0009: fixing up report descriptor size
[ 8115.653338] xpadneo 0005:045E:02FD.0009: fixing up Rx axis
[ 8115.653339] xpadneo 0005:045E:02FD.0009: fixing up Ry axis
[ 8115.653340] xpadneo 0005:045E:02FD.0009: fixing up Z axis
[ 8115.653342] xpadneo 0005:045E:02FD.0009: fixing up Rz axis
[ 8115.653346] xpadneo 0005:045E:02FD.0009: fixing up button mapping
[ 8115.653545] xpadneo 0005:045E:02FD.0009: battery detected
[ 8115.653548] xpadneo 0005:045E:02FD.0009: enabling compliance with Linux Gamepad Specification
[ 8115.653613] input: Xbox Wireless Controller as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.0009/input/input41
[ 8115.654196] xpadneo 0005:045E:02FD.0009: input,hidraw5: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on a4:34:d9:92:46:d5
[ 8115.654204] xpadneo 0005:045E:02FD.0009: controller quirks: 0x00000010
[ 8116.638578] xpadneo 0005:045E:02FD.0009: Xbox Wireless Controller [98:7a:14:0e:45:a7] connected
[ 8116.761658] xpadneo 0005:045E:02FD.0009: report descriptor size: 335 bytes
[ 8116.761668] xpadneo 0005:045E:02FD.0009: fixing up report descriptor size
[ 8116.761672] xpadneo 0005:045E:02FD.0009: fixing up Rx axis
[ 8116.761675] xpadneo 0005:045E:02FD.0009: fixing up Ry axis
[ 8116.761677] xpadneo 0005:045E:02FD.0009: fixing up Z axis
[ 8116.761680] xpadneo 0005:045E:02FD.0009: fixing up Rz axis
[ 8116.761683] xpadneo 0005:045E:02FD.0009: fixing up button mapping
[ 8116.762109] xpadneo 0005:045E:02FD.0009: battery detected
[ 8116.762113] xpadneo 0005:045E:02FD.0009: enabling compliance with Linux Gamepad Specification
[ 8116.762235] input: Xbox Wireless Controller as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:045E:02FD.0009/input/input42
[ 8116.762797] xpadneo 0005:045E:02FD.0009: input,hidraw5: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on a4:34:d9:92:46:d5
[ 8116.762812] xpadneo 0005:045E:02FD.0009: controller quirks: 0x00000010
[ 8117.747242] xpadneo 0005:045E:02FD.0009: Xbox Wireless Controller [98:7a:14:0e:45:a7] connected
[ 8118.043690] xpadneo 0005:045E:02FD.0009: battery registered

xpadneo-btmon.txt

kakra commented 2 years ago

the normal rumble is working, but not the trigger rumble

I'm not sure if you're aware of that but please depress the triggers while testing the rumble: the effect depends on the pressure you apply to the triggers.

redegg89 commented 2 years ago

From what I've gathered, for some reason, my back button is now bound to the share button. I'm not too sure if this is an issue for just me, but here's a bit of background, as well as what I've figured out. I tried using the main fork, but that had the same problem. I tried an older version of this branch and my problem was fixed. Now, it's started to happen again. I know that isn't mush help, but I've attached a file with the output of evtest. From what I've gathered, key code 314 (the back button) is activated when I hit the share button, while pressing the back button does nothing. I know this doesn't really help, but I'd be happy to get more info if I could

Kernel: 5.16.10-artix1-1 Init system: OpenRC XBController23.txt

EwokExile commented 2 years ago

(from Discord)

btmon.txt

Menu/Select button:

> ACL Data RX: Handle 71 flags 0x02 dlen 23                  #5 [hci0] 4.012222
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: 928bc288908117880000000000000400
> ACL Data RX: Handle 71 flags 0x02 dlen 23                  #6 [hci0] 4.012650
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: 928bc288908117880000000000000000

A button:

> ACL Data RX: Handle 71 flags 0x02 dlen 23                 #18 [hci0] 3.491109
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: 928bc288908117880000000000010000
> ACL Data RX: Handle 71 flags 0x02 dlen 23                 #19 [hci0] 3.506112
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: 928bc288908117880000000000000000
codeclimate[bot] commented 2 years ago

Code Climate has analyzed commit db05d8c9 and detected 0 issues on this pull request.

View more on Code Climate.

EwokExile commented 2 years ago

From my testing this afternoon both the 1708 and 1914 controller mappings are correct on the 5.11 firmware.

Rumble on the other hand is not working correctly. Using Generation Zero as a sample here:

Steam input enabled- No rumble. Steam input disabled- Rumble seems to trigger twice, so the effect lingers long after releasing the trigger when firing a gun.

This happens on both controllers, 1708 and 1914

kakra commented 2 years ago

Do you use qmk or OpenRGB?

EwokExile commented 2 years ago

No, none of that installed on this pc

kakra commented 2 years ago

Could be an issue in bluez then... There's a hidraw rumble tester in the misc/examples/c_hidraw: compile it for your local system by running make (you may need to install ncurses dev headers), then run sudo ./hidraw /dev/hidraw## (get the hidraw name from dmesg -W). With it, you can program different rumble commands and send them on pressing "enter". If it reacts immediately and does not double-send, then the problem is somewhere outside of xpadneo. If it also shows the problem, it may be in bluez but not in xpadneo.

EwokExile commented 2 years ago

Seems to be working correctly there

Bit more testing: Rumble works as expected for me in both Remnant: From The Ashes and Absolute Drift outside of Steam. Rumble double-sends in the steam beta client with steam input disabled, no rumble with it enabled in Generation Zero Rumble does not work regardless of steam input setting in regular (non-beta) Steam in Generation Zero

kakra commented 2 years ago

Then I'd say it's caused by Steam Input or SDL... Maybe try disabling Xbox controller support for Steam Input - I've not seen such an issue. Also check the permissions of the hidraw device, it should not be writable for your user. If it is, it can explain why rumble is acting weird because SDL bypasses xpadneo then and directly tries to send rumble commands. If it is readable but not writable, it would explain why some games cannot rumble at all. Currently, the best solution is to revoke all permissions from the hidraw device. xpadneo rules usually take care of it but some other software (like qmk or OpenRGB) may have deployed udev rules that unconditionally make the hidraw devices world readable and writable (which is bad for other reasons).

KeyserSoze1 commented 2 years ago

Tested this on my model 1708 with the latest firmware. Everything works great except the select button is not functional. Nothing registers and button 6 is never activated. Looks like this was mentioned above but thought I would add my result here.

kakra commented 2 years ago

Tested this on my model 1708 with the latest firmware. Everything works great except the select button is not functional. Nothing registers and button 6 is never activated. Looks like this was mentioned above but thought I would add my result here.

How did you test the buttons? Did you try evtest?

KeyserSoze1 commented 2 years ago

Tested this on my model 1708 with the latest firmware. Everything works great except the select button is not functional. Nothing registers and button 6 is never activated. Looks like this was mentioned above but thought I would add my result here.

How did you test the buttons? Did you try evtest?

Should have been more specific. Tested with jstest and evtest. No response from the select button. Uninstalling xpadneo and the select button shows as button 10 in jstest and registers in evtest as BTN_SELECT.

kakra commented 2 years ago

Are you sure you tried this particular branch?

KeyserSoze1 commented 2 years ago

Are you sure you tried this particular branch?

Yes. Using kakra/feature/xb1s-0b20 branch. Last commit hash db05d8c9e34623c069f522a0ff130ae2fe0ea178.

Some more testing and I'm not sure what is happening. It is currently working but I disconnected/reconnected multiple times to get that to work. The first time I paired and ran evtest immediately and carefully only pressed the select button I got the below report. Pressing the button again and I received no response.

Event: time 1646581004.887823, type 3 (EV_ABS), code 0 (ABS_X), value 2539 Event: time 1646581004.887823, type 3 (EV_ABS), code 1 (ABS_Y), value -749 Event: time 1646581004.887823, type 3 (EV_ABS), code 3 (ABS_RX), value 1887 Event: time 1646581004.887823, type 3 (EV_ABS), code 4 (ABS_RY), value 6919 Event: time 1646581004.887823, -------------- SYN_REPORT ------------

However on disconnect/reconnect the select button is now working. I'll update if I discover anything else. If anyone has any ideas they want me to try let me know.

EwokExile commented 2 years ago

Here's a rumble packet in btmon using the c_hidraw test

< ACL Data TX: Handle 16 flags 0x00 dlen 15                  #1 [hci0] 9.440042
      ATT: Write Request (0x12) len 10
        Handle: 0x0022
          Data: 0f1414281e050503
> HCI Event: Number of Completed Packets (0x13) plen 5       #2 [hci0] 9.562554
        Num handles: 1
        Handle: 16
        Count: 1
> ACL Data RX: Handle 16 flags 0x02 dlen 5                   #3 [hci0] 9.577123
      ATT: Write Response (0x13) len 0

And I've attached the rumble test btmon log from Rise of The Tomb Raider (outside of Steam using Wine Staging) where I saw the extended rumble effect btmon-rumble-test-2.txt

kakra commented 2 years ago

However on disconnect/reconnect the select button is now working. I'll update if I discover anything else.

This sounds weird. Why would it suddenly work after some reconnects? This either means the Bluetooth stack is acting weird (but that itself would not affect mappings) or xpadneo does not bind correctly to the device (module and/or udev rules not reloaded?).

First, be sure that xpadneo actually initialized the device. It will be shown in dmesg but xpadneo also sends three short rumble bursts to the motors (weak motor, strong motor, trigger motors, in that order).

I'd like to merge this patch, and if your problem persists, it should be tracked in a new issue report.

KeyserSoze1 commented 2 years ago

Seems reasonable. I haven't been able to reproduce but I also haven't rebooted my machine since. I will open an issue if I'm able to consistently reproduce the issue.