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

Rumble problem - Xbox Series S controller #311

Closed
5 of 24 tasks
777Raim opened this issue Aug 30, 2021 · 30 comments · Fixed by #320
Closed
5 of 24 tasks

Rumble problem - Xbox Series S controller #311

777Raim opened this issue Aug 30, 2021 · 30 comments · Fixed by #320

Comments

@777Raim
Copy link

777Raim commented Aug 30, 2021

Version of xpadneo

With last commit 67585b3

Controller Model

  • Xbox One S controller
  • Xbox Elite 2 controller
  • Xbox Series X|S controller
  • Other:

Connection mode

  • Bluetooth connection
  • Xbox Dongle connection (not yet supported)
  • USB cable (not yet supported)

Installed Software

  • Steam Input (enabled by default via Steam Desktop client)
  • Steam Link (usually via Raspberry Pi or other micro computers)
  • xow (alternative driver using the Xbox dongle)
  • Anti-Micro (may affect button mappings)
  • netstick (shares input devices via network similar to Steam Link)
  • xboxdrv (user-space gamepad driver)

Severity / Impact

  • I've read the docs and the bug reporting instructions
  • I've applied the latest firmware update to the controller
  • It does not work at all
  • It used to work in a previous version
  • It mostly works but sometimes it doesn't
  • I found a work-around
  • I probably didn't figure it all out but it's too early to give up
  • I don't know how to ...
  • It's too complicated
  • Fantastic work but ...
  • I can code and I want to help

Describe the Bug

When I play in GTA V via Wine (Proton GE) and ride the car through grass, my gamepad makes rubmle as usual. But after I stop car, gamepad continues make rumble 5-10 seconds then stops. While gamepad make rumble I tried go to main menu, but rumble didnt stop. I tried change bluetooth latency, change rumble strength - nothing changed. If I plug gamepad via USB - rumble is fine.

Expected Behavior

Rumble stops after car stops

System Information

# uname -a
Linux Raim-PC 5.13.12-200.fc34.x86_64 #1 SMP Wed Aug 18 13:27:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
# 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 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                                                     ...
2986910699 1363

Controller and Bluetooth Information

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

Additional Context

Sorry for my english

@kakra
Copy link
Collaborator

kakra commented Aug 30, 2021

With the XBXS controller, this is most likely a Bluetooth issue we cannot work around in xpadneo directly as it is not a Bluetooth but a HID driver. I tested the latest commit for multiple months now with all three models (XB1S, XBE2, and XBXS) and hand no issues, rumble was more consistent across all games. But there's an issue with bluez that may use wrong latency settings. From your description, I read you already tried those (it's documented in the troubleshoot docs how to set those). Be sure to reboot after you applied the settings, maybe purge the bluez devices cache and remove the device, then pair it again, just to be sure.

But FWIW, could you try the previous commit? It should change nothing about the behavior except that you see more consistent rumble strengths during the game reprogramming the strength a lot of times. If the game sets rumble=0, this will pass through to the controller, as we have a special case handling for this. So everything should be fine.

What you describe (5-10 seconds, maybe even 20s sometimes) is usually a Bluetooth issue I observed, too. According to MS, you should stop using other Bluetooth devices nearby, or on the same Bluetooth adapter. Also, there's the latency issue. You should also upgrade to the latest XBXS firmware using a Windows system (rumor says there has been an update lately, I didn't try it yet). If you changed any settings (latency, firmware version), it usually requires to remove the controller from Bluetooth, purge the Bluetooth cache, then pair it again. The internal controller details seem to be a little quirky. You may even need to pair it to a different computer once to clear its internal state.

There may be a third problem: Steam may use the gamepad in hidraw mode which doesn't work quite so well due to the quirks of the XBXS controller. Try disabling Steam Input for the game or in the global Steam settings. Also check dmesg when the gamepad connected and look for the hidraw number of the device, then revoke all access permissions from it (chmod a-rwx /dev/hidraw#), and start the game without reconnecting the gamepad. Background: When SDL2 uses hidraw mode, it bypasses the quirks and fixes we apply for the controllers.

Try stopping/uninstalling kdeconnectd if you have that.

There's a lot of Bluetooth related information here: https://github.com/atar-axis/xpadneo/projects/11

Sorry for my english

Please don't, I could read everything perfectly. ;-)

@777Raim
Copy link
Author

777Raim commented Aug 31, 2021

Thanks for quick reply!

could you try the previous commit?

I used previous commit before - same behaviour. I thought last commit can help me (throttling fix) - no result, so I have to make new issue.

If you changed any settings (latency, firmware version), it usually requires to remove the controller from Bluetooth, purge the Bluetooth cache, then pair it again. The internal controller details seem to be a little quirky. You may even need to pair it to a different computer once to clear its internal state.

Yes, I updated my gamepad via Windows (now XBXS hasn't any updates). Latency changed before. Tried to do this again - nothing changed. Tried to connect to another device (Android). After that couldnt connect to PC. Connect to Windows via VirtualBox helped me. Now XBXS connect to PC (Linux) without troubles.

revoke all access permissions from it (chmod a-rwx /dev/hidraw#)

Tried that too - nothing changed.

Try stopping/uninstalling kdeconnectd if you have that.

I dont have kdeconnectd. I use GNOME with GSConnect. But it uses wifi.

P.S. I run games not via Steam - directly via wine (just use Proton version)

@kakra
Copy link
Collaborator

kakra commented Aug 31, 2021

GSconnect may exhibit the same behavior as kdeconnectd because they largely are designed from the same code base. kdeconnectd has a bug where it spams (or something triggers it to spam) the Bluetooth radio with scanning requests (no matter how and if your phone is connected) every 10-20s which puts the receiver into discovery mode and lasts for 20s. XBXS and discovery mode do not play nice together. GSconnect may do something similar. Try stopping it and see if the problems are gone. It was covered here: bluez/bluez#123

If you can make the same observations with GSconnect running, you should report that upstream to GSconnect.

@777Raim
Copy link
Author

777Raim commented Aug 31, 2021

I disabled GSConnect (turn off extension), delete bluetooth connection, clear cache, reboot - connect (with 3 time), make chmod (just in case), start game - same behaviour

@777Raim
Copy link
Author

777Raim commented Aug 31, 2021

Tried to disable WiFi - in my feel rumble duration was decreased, but still it's.

@kakra
Copy link
Collaborator

kakra commented Aug 31, 2021

This may feel like it's becoming dumb or silly... But after all, MS suggest that there may be air-time concurrency issues with the controller. If disabling wifi helps the issue, then this sounds like exactly such a problem. Some ideas:

  1. Are your Bluetooth and wifi transceivers placed in close proximity? Try to get some more range between them (at least 1.5-2m).
  2. Do you use a combined BT/wifi dongle? Try using a dedicated BT dongle just for the XBXS controller.
  3. Does your wifi have Bluetooth cooperation features enabled? Try enabling that, or switch from auto-channel to fixed.

Also it may be helpful for diagnostic if you'd look at the output of btmon to watch if there's constant BT radio activity even if you do nothing (the XBXS controller would send a battery report packet every once in a while but no bursts if you leave it sitting idle). If it spools a lot of stuff, that may be active BT scanning and you should try to stop that.

While btmon is running and looks like it's idle, try moving the sticks (moving in circles with a steady motion works best): You should see activity immediately, it should remain as a constant stream while you move the sticks, and you should see it stop immediately if you stop moving the sticks. If there's a delay either in starting or stopping, or intermittent dropouts, there's probably some external interference with the BT protocol. You can also try button clicks while btmon is running to get some clearer picture of latency but you should put your controller on the table and fix it in place with one hand while using the buttons, otherwise you may introduce accidental stick movement which results in a whole lot of messy btmon output.

BTW: Different models work differently when looking at them in btmon, e.g. the XB1S controller sends input events in bursts of at least 20 packets so it may send a little longer than generating actual input. The XBE2 controller seems to send input data for at least 1-2 seconds but that depends a lot of concurrent radio activity, sometimes it constantly sends data and never stops which is probably a bug. My experience with the XBXS controller is that it sends exactly as long as you generate input, and only single packets if you generate only single inputs.

@777Raim
Copy link
Author

777Raim commented Aug 31, 2021

Yes, I have combined BT/WiFi adapter (laptop).

Here some output from btmon (click to button once):

> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2613 [hci0] 411.387322
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000100000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2614 [hci0] 411.387377
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000100000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2615 [hci0] 411.387385
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000100000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2616 [hci0] 411.387432
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000100000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2617 [hci0] 411.407442
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2618 [hci0] 411.452440
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2619 [hci0] 411.453070
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2620 [hci0] 411.474948
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2621 [hci0] 411.497448
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2622 [hci0] 411.519948
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2623 [hci0] 411.553694
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2624 [hci0] 411.564951
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2625 [hci0] 411.587442
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2626 [hci0] 411.609947
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2627 [hci0] 411.632442
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2628 [hci0] 411.654945
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2629 [hci0] 411.677450
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2630 [hci0] 411.699939
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2631 [hci0] 411.722454
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2632 [hci0] 411.756226
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2633 [hci0] 411.767445
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2634 [hci0] 411.789940
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2635 [hci0] 411.812445
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2636 [hci0] 411.857444
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2637 [hci0] 411.858075
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2638 [hci0] 411.879946
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2639 [hci0] 411.902448
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2640 [hci0] 411.924949
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2641 [hci0] 411.958700
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2642 [hci0] 411.969945
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2643 [hci0] 411.992453
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2644 [hci0] 412.014942
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2645 [hci0] 412.059944
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2646 [hci0] 412.060578
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2647 [hci0] 412.082450
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2648 [hci0] 412.104952
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2649 [hci0] 412.127446
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2650 [hci0] 412.161247
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2651 [hci0] 412.172442
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2652 [hci0] 412.194946
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2653 [hci0] 412.217447
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2654 [hci0] 412.273709
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2655 [hci0] 412.274322
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2656 [hci0] 412.284952
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2657 [hci0] 412.307451
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2658 [hci0] 412.329944
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2659 [hci0] 412.363711
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2660 [hci0] 412.374951
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2661 [hci0] 412.397467
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2662 [hci0] 412.419949
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2663 [hci0] 412.442444
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2664 [hci0] 412.464954
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2665 [hci0] 412.487456
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000
> ACL Data RX: Handle 16 flags 0x02 dlen 23                                                    #2666 [hci0] 412.509952
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: ce86a87e4580fb820000000000000000

From output I made conclusion: 45 packages of data was send/recived from XBXS at 1,12263 sec. Data continued enter to log when I released button. Is it normal or not I dont know.

@kakra
Copy link
Collaborator

kakra commented Aug 31, 2021

No that's not how it should work: XBXS should stop sending data immediately (or maybe after 10-15ms). So I suppose your combined adapter may have driver problems because it doesn't communicate back to the gamepad properly. This is handled completely in the Bluetooth stack of the kernel and the bluez daemon, long before xpadneo sees the data.

So here's some ideas to try:

  • Get a cheap BT 4.0 dongle somewhere, one for 10-15€ should do, I'd recommend a dongle with CSR chipset, maybe stick to a well-known brand to not get a quirky China clone. I'm using one from TP-LINK (mine is in micro format and barely sticks out of the USB slot so it can stay connected all the time even in laptops). Use it as a dedicated transceiver for the gamepad.
  • Disable wifi completely
  • Update to the latest kernel
  • Update to latest bluez

@kakra
Copy link
Collaborator

kakra commented Aug 31, 2021

BTW: The controller has an internal rate of 100 Hz for the protocol, so it should send packets at 100 Hz, that is at 10 ms intervals. Your log shows intervals between 20-40 ms, and I assume that's why protocol data queues up and you're seeing delays and latency. You could try changing the source code to throttle the rumbler to 50ms intervals to slow down how much data xpadneo sends TO the controller but you will still see input latency of around 30ms at least which is already quite noticeable during gaming. Usually, we receive input data after 10ms in the worst case with a proper BT dongle.

Not counting internal delays in the controller, this will add another 16.6ms frame latency at 60fps, so you're already near 50ms latency which is already very noticeable.

@777Raim
Copy link
Author

777Raim commented Sep 1, 2021

Get a cheap BT 4.0 dongle somewhere, one for 10-15€ should do, I'd recommend a dongle with CSR chipset

I took new TB4.0:
xpadneo-lsusb-NEW_DONGLE.txt

Some btmon info
xpadneo-btmon-NEW_DONGLE.txt

In the end: nothing changed (even by fully disabling combined BT+WiFi)

upd: added btmonoutput while click button once:

Bluetooth monitor ver 5.61
= Note: Linux version 5.13.12-200.fc34.x86_64 (x86_64)                                                        0.319332
= Note: Bluetooth subsystem version 2.22                                                                      0.319335
= New Index: D4:6A:6A:15:C1:CA (Primary,USB,hci1)                                                      [hci1] 0.319336
= New Index: 00:15:83:FF:16:44 (Primary,USB,hci0)                                                      [hci0] 0.319336
= Open Index: 00:15:83:FF:16:44                                                                        [hci0] 0.319337
= Index Info: 00:15:83:FF:16:44 (Cambridge Silicon Radio)                                              [hci0] 0.319337
@ MGMT Open: bluetoothd (privileged) version 1.20                                                    {0x0001} 0.319338
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #1 [hci0] 3.813727
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000d00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #2 [hci0] 3.813897
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000d00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #3 [hci0] 3.813990
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000d00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #4 [hci0] 3.814355
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #5 [hci0] 3.844376
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #6 [hci0] 3.874376
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #7 [hci0] 3.904367
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #8 [hci0] 3.934370
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                         #9 [hci0] 3.964372
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #10 [hci0] 3.994374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #11 [hci0] 4.024362
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #12 [hci0] 4.054365
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #13 [hci0] 4.084365
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #14 [hci0] 4.114374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #15 [hci0] 4.144371
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #16 [hci0] 4.174374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #17 [hci0] 4.204377
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #18 [hci0] 4.234378
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #19 [hci0] 4.264370
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #20 [hci0] 4.294369
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #21 [hci0] 4.324370
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #22 [hci0] 4.354376
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #23 [hci0] 4.384377
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #24 [hci0] 4.414382
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #25 [hci0] 4.444365
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #26 [hci0] 4.474370
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #27 [hci0] 4.504361
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #28 [hci0] 4.534373
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #29 [hci0] 4.564375
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #30 [hci0] 4.594375
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #31 [hci0] 4.624366
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #32 [hci0] 4.654373
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #33 [hci0] 4.684378
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #34 [hci0] 4.714380
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #35 [hci0] 4.744369
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #36 [hci0] 4.774386
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #37 [hci0] 4.804374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #38 [hci0] 4.834381
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #39 [hci0] 4.864379
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #40 [hci0] 4.894374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #41 [hci0] 4.924383
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #42 [hci0] 4.954375
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #43 [hci0] 4.984367
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #44 [hci0] 5.014377
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #45 [hci0] 5.044378
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #46 [hci0] 5.074383
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #47 [hci0] 5.104385
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #48 [hci0] 5.134376
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #49 [hci0] 5.164385
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #50 [hci0] 5.194378
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #51 [hci0] 5.224367
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #52 [hci0] 5.254374
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000
> ACL Data RX: Handle 69 flags 0x02 dlen 23                                                        #53 [hci0] 5.284383
      ATT: Handle Value Notification (0x1b) len 18
        Handle: 0x001e
          Data: b17f957f1b7ffc810000000000c00000

upd2: Kernel: 5.13.12-200.fc34.x86_64 Bluez: 5.61

@kakra
Copy link
Collaborator

kakra commented Sep 1, 2021

Okay, now things are getting strange... The btmon tells me the device is paired to hci0 which is the CSR dongle - so it should work. But you are still seeing the exact same problems?

@777Raim
Copy link
Author

777Raim commented Sep 1, 2021

Today I did some gamaped test: connect XBXS via new BT dongle and test behaviour rumble in GTAV via Wine and GTAV via Moonlight (stream from Windows). Via Moonlight gamepad rumble works perfects! But via Wine - promblems above.

@kakra
Copy link
Collaborator

kakra commented Sep 1, 2021

In both cases the gamepad is attached to the Linux host, right?

And when you say "wine" - is it upstream wine, or Proton wine? Because those two versions differ a lot in how they use SDL and gamepads.

@777Raim
Copy link
Author

777Raim commented Sep 1, 2021

In both cases the gamepad is attached to the Linux host, right?

Yes

when you say "wine" - is it upstream wine, or Proton wine?

Proton-6.14-GE-2

And I found that rumble strength via Linux more heavy as Windows (real windows machine)

Tomorrow will test default wine and give results

@kakra
Copy link
Collaborator

kakra commented Sep 1, 2021

And I found that rumble strength via Linux more heavy as Windows (real windows machine)

There are multiple possible causes for this:

  • If using hidraw, we cannot control the strength in xpadneo
  • Some drivers (also affects hidraw drivers inside SDL) have a wrong assumption that the rumble strength ranges from 0 to 255 while the HID descriptor only allows 0 to 100. xpadneo scales that correctly, most other drivers don't, some were fixed in later versions (i.e., xow uses the correct 0..100 scale since some update)
  • xpadneo additionally rumbles the triggers, based on the maximum current value of the strong and weak motor multiplied by the pressure of the trigger (with pressure = 0.0..1.0), this may make you perceive the rumble more stronger
  • finally, original Windows may scale the strength down, you can do something similar in xpadneo with module parameters (see modinfo hid-xpadneo, rumble_attenuation), you can also apply scales to main and trigger motors individually

Proton-6.14-GE-2

Could you retry with Proton Experimental? That's the only version I'm testing against because it contains everything that is scheduled for being mainlined to Proton.

@777Raim
Copy link
Author

777Raim commented Sep 7, 2021

So, this my unhurried results: I tried:

  1. wine-6.3-proton-experimental-43c3113-amd64 - same trouble
  2. wine-6.16-amd64 - same trouble
  3. Thought may be wrong rumble behaviour is anti pirate protection, so I tried SteamProton-6.3-6c and Epic Game Launcher to run licensed copy of GTA - same trouble

Tried c_hidraw test utility - all rumble combinations are worked out clearly and new send of data interrupts previous rumble

@kakra
Copy link
Collaborator

kakra commented Sep 7, 2021

Is this on Fedora Core?

I cannot reproduce such behavior here with Gentoo. And your hidraw test shows that it generally works as it should.

So the only explanation left is: in games rumble is sent too fast, overwhelming the controller. In dmesg this is logged as a rumble throttle entry. If you don't see that, the games are bypassing the xpadneo driver and we cannot do anything except trying to force the games into not bypassing our driver.

@777Raim
Copy link
Author

777Raim commented Sep 7, 2021

In dmesg this is logged as a rumble throttle entry

By default I dont see this message in dmesg while gaming. Tried to make chmod a-rwx /dev/hidraw# - message didnt.
Sometime ago I saw throttle message in dmesg, but rumble behaviour was wrong i that time.

trying to force the games into not bypassing our driver

How can I force the game uses xpadneo driver? And how can I know the game uses xpadneo?

ps: some info from dmesg while connecting XBXS

[<   75,730875>] xpadneo 0005:045E:0B13.000F: pretending XB1S Windows wireless mode (changed PID from 0x0B13 to 0x02E0)
[<    0,000009>] xpadneo 0005:045E:0B13.000F: working around wrong SDL2 mappings (changed version from 0x00000507 to 0x00000903)
[<    0,000005>] xpadneo 0005:045E:0B13.000F: report descriptor size: 283 bytes
[<    0,000004>] xpadneo 0005:045E:0B13.000F: fixing up Rx axis
[<    0,000003>] xpadneo 0005:045E:0B13.000F: fixing up Ry axis
[<    0,000002>] xpadneo 0005:045E:0B13.000F: fixing up Z axis
[<    0,000002>] xpadneo 0005:045E:0B13.000F: fixing up Rz axis
[<    0,000002>] xpadneo 0005:045E:0B13.000F: fixing up button mapping
[<    0,000371>] xpadneo 0005:045E:0B13.000F: gamepad detected
[<    0,000002>] xpadneo 0005:045E:0B13.000F: enabling compliance with Linux Gamepad Specification
[<    0,000081>] input: Xbox Wireless Controller as /devices/virtual/misc/uhid/0005:045E:0B13.000F/input/input46
[<    0,000310>] xpadneo 0005:045E:0B13.000F: input,hidraw0: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on 00:15:83:ff:16:44
[<    0,000142>] input: Xbox Wireless Controller Consumer Control as /devices/virtual/misc/uhid/0005:045E:0B13.000F/input/input47
[<    0,000098>] xpadneo 0005:045E:0B13.000F: consumer control added
[<    0,000009>] xpadneo 0005:045E:0B13.000F: controller quirks: 0x00000050
[<    0,000004>] xpadneo xpadneo_welcome_rumble start
[<    0,990951>] xpadneo xpadneo_welcome_rumble took 991ms
[<    0,000023>] xpadneo 0005:045E:0B13.000F: Xbox Wireless Controller [44:16:22:90:19:46] connected

@GavinTao1219
Copy link

GavinTao1219 commented Nov 2, 2021

Exact same issue here. I've tried several games, and non of them are printing log into dmesg while gaming. However, after I uninstalled xpadneo and reboot, I could connect my controller via bluetooth, but the key mappings in the game are completely messed up. So I guess the games were actually using xpadneo when it's installed, and they are not bypassing xpadneo. And thus I think the rumble issue might be an issue of xpadneo itself, and it never print log for some reason (except for the welcome message)

@kakra
Copy link
Collaborator

kakra commented Nov 2, 2021

Well, we can still control what the games see over hidraw: The hidraw reports are patched by xpadneo to show a correct mapping of an emulated original Xbox controller. But we cannot control what SDL2 sends over hidraw. Thus, you'll never see the rumble throttle message if games go via the hidraw device. SDL2 should have a working rumble throttle meanwhile but I'd need to check the source code to confirm this.

Looking at the original description (rumble continues for some time when it's supposed to stop), this still looks like some awkward Bluetooth latency problem to me. The XBXS controller may be especially sensitive here. And this may not be solved by rumble throttling. Do you see any input latency? Please look at #198 (comment) for LE latency parameters to set in your bluez configuration and report back.

@GavinTao1219
Copy link

GavinTao1219 commented Nov 3, 2021

Thank you so much for such detailed explanation Kakra. I've tried the LE config, but unfortunately, the issue persists. Here's my /etc/bluetooth/main.conf file: main.conf.txt
Please remove the .txt extension. I'm adding .txt to it because github doesn't support .conf
(edit: I added ControllerMode = Dual and changed JustWorksRepairing = always to JustWorksRepairing = confirm, but they didn't help. )

And cat /sys/module/bluetooth/parameters/disable_ertm gives N

And I've recorded some log from btmon. Here's the log file: btmon.log
And here's what I do related to the log:

  1. I ran sudo btmon | tee btmon.log and keep the terminal running in background.
  2. I started my Xbox series X controller by press the xbox button on it, and because my computer has paired with it, it connects automatically after I turned it on.
  3. The welcome rumble of Xbox controller as usual.
  4. I opened Steam and started the game Dishonored 2.
  5. I loaded into a scenario which is super windy, and it has light rumbles in the background (which means it's supposed to rumble when I'm doing nothing)
  6. The rumble in step 5 works perfectly
  7. I walk to another scenario which is not that windy, and it has no rumble in the background.
  8. The rumble works fine because it stoped as soon as I walked out of that windy scenario.
  9. I hold LT on my controller for a spell. It's supposed to rumble continuously while I'm holding it.
  10. It did rumble but not as smooth as when the controller is connected with wire. (by saying smooth, I mean for example, 1 stands for hard rumble and 0 stands for light rumble: the correct rumble might be 1010101010101010, but it's like 10101111100011100011100)
  11. I canceled the spell by press X button on the controller
  12. The rumble is supposed to stop instantly when I cancel the spell, but it keeps rumbling for about 5 seconds, and within this 5 seconds, the strengh is getting weaker and weaker
  13. I tried to hold LT again for the spell for around 10 seconds
  14. I cast the spell by releasing LT, and it keeps rumbling for around 10 more seconds after I release.
  15. I quit the game
  16. I Ctrl+C'ed the btmon

Sorry for such a long reply and my bad English. I really don't understand the btmon log, so I really appreciate if you could help me out with this issue. Thank you good sir!

kakra added a commit to kakra/xpadneo that referenced this issue Nov 13, 2021
Also fixes Steam Input which apparently also uses SDL2.

The bug shows up when SDL identifies the controller as being on USB
instead of Bluetooth (SDL Gamepad ID starts with `03` instead of `05`)
which then messes with SDL's expectations for the contents of hidraw.

This fixes two SDL problems:

  * Wrong mappings in hidraw (buttons shifted to other buttons)
  * SDL2 doesn't properly throttle rumble commands (endless rumble)

See-also: atar-axis#286
Maybe-fixes: atar-axis#303
Maybe-fixes: atar-axis#311
Maybe-fixes: atar-axis#314
Signed-off-by: Kai Krakow <kai@kaishome.de>
kakra added a commit that referenced this issue Nov 13, 2021
Also fixes Steam Input which apparently also uses SDL2.

The bug shows up when SDL identifies the controller as being on USB
instead of Bluetooth (SDL Gamepad ID starts with `03` instead of `05`)
which then messes with SDL's expectations for the contents of hidraw.

This fixes two SDL problems:

  * Wrong mappings in hidraw (buttons shifted to other buttons)
  * SDL2 doesn't properly throttle rumble commands (endless rumble)

See-also: #286
Maybe-fixes: #303
Maybe-fixes: #311
Maybe-fixes: #314
Signed-off-by: Kai Krakow <kai@kaishome.de>
@777Raim
Copy link
Author

777Raim commented Nov 15, 2021

After update trouble didn't gone. But rumble behaviour changes: after start game the rumble works. But if I drive via grass the rumble works about 1-3 sec and stops at all (at that time xpadneo logs for dmesg this: throttling rumble reprogramming). After that I tried to test rumble via hidraw tool - the rumble didn't work. To start rumble work again I have to reconnect XBSX.

Some dmesg log:

[<    0,000037>] xpadneo 0005:045E:0B13.0006: pretending XB1S Windows wireless mode (changed PID from 0x0B13 to 0x02E0)
[<    0,000003>] xpadneo 0005:045E:0B13.0006: working around wrong SDL2 mappings (changed version from 0x00000507 to 0x00000903)
[<    0,000003>] xpadneo 0005:045E:0B13.0006: report descriptor size: 283 bytes
[<    0,000003>] xpadneo 0005:045E:0B13.0006: fixing up Rx axis
[<    0,000001>] xpadneo 0005:045E:0B13.0006: fixing up Ry axis
[<    0,000001>] xpadneo 0005:045E:0B13.0006: fixing up Z axis
[<    0,000001>] xpadneo 0005:045E:0B13.0006: fixing up Rz axis
[<    0,000001>] xpadneo 0005:045E:0B13.0006: fixing up button mapping
[<    0,000265>] xpadneo 0005:045E:0B13.0006: gamepad detected
[<    0,000002>] xpadneo 0005:045E:0B13.0006: enabling compliance with Linux Gamepad Specification
[<    0,000061>] input: Xbox Wireless Controller as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input28
[<    0,000249>] xpadneo 0005:045E:0B13.0006: input,hidraw3: BLUETOOTH HID v9.03 Gamepad [Xbox Wireless Controller] on 00:15:83:ff:16:44
[<    0,000094>] input: Xbox Wireless Controller Consumer Control as /devices/virtual/misc/uhid/0005:045E:0B13.0006/input/input29
[<    0,000088>] xpadneo 0005:045E:0B13.0006: consumer control added
[<    0,000009>] xpadneo 0005:045E:0B13.0006: controller quirks: 0x00000050
[<    0,000005>] xpadneo xpadneo_welcome_rumble start
[<    0,990746>] xpadneo xpadneo_welcome_rumble took 991ms
[<    0,000010>] xpadneo 0005:045E:0B13.0006: Xbox Wireless Controller [44:16:22:90:19:46] connected
[<   77,594542>] xpadneo 0005:045E:0B13.0006: throttling rumble reprogramming

@kakra
Copy link
Collaborator

kakra commented Nov 15, 2021

[< 77,594542>] xpadneo 0005:045E:0B13.0006: throttling rumble reprogramming

At least this line tells us that rumble no works through the driver, so we are safe on that side.

[< 0,990746>] xpadneo xpadneo_welcome_rumble took 991ms

This looks like the kernel timing may be off a little bit: The duration is too short, it's designed to run 997ms, and usually I'm seeing values between 995 and 998, your's falls quite out of this range.

I'm not sure if you can figure out how to adjust the source code on your own and trying to install it from there... But in the file hid-xpadneo/src/xpadneo.h is a constant XPADNEO_RUMBLE_THROTTLE_DELAY where you could set the throttling from 10 to 15 ms to see if it improves things. Another thing to try would be upgrading to the latest version of bluez.

The workqueue timer is quite coarse in the kernel but usually it should not "undershoot". Could you tell me the output of zgrep _HZ /proc/config.gz? Thanks.

BTW: The issue shouldn't have been auto-closed.

@kakra kakra reopened this Nov 15, 2021
@777Raim
Copy link
Author

777Raim commented Nov 15, 2021

But in the file hid-xpadneo/src/xpadneo.h is a constant XPADNEO_RUMBLE_THROTTLE_DELAY where you could set the throttling from 10 to 15 ms

Tried change XPADNEO_RUMBLE_THROTTLE_DELAY - nothing changed:

[<    0,990999>] xpadneo xpadneo_welcome_rumble took 991ms

Maybe I reinstalled it wrong? (#./uninstall.sh -> edit hid-xpadneo/src/xpadneo.h -> #./install.sh)

Another thing to try would be upgrading to the latest version of bluez

My bluez version is 5.62-1.fc34

Could you tell me the output of zgrep _HZ /proc/config.gz? Thanks.

$ zgrep _HZ /proc/config.gz
gzip: /proc/config.gz: No such file or directory

@kakra
Copy link
Collaborator

kakra commented Nov 15, 2021

[< 0,990999>] xpadneo xpadneo_welcome_rumble took 991ms

This line won't change by editing the file: The initial rumbler uses fixed rumble lengths. But you may see a different result during the game.

gzip: /proc/config.gz: No such file or directory

Okay, your kernel has no config.gz support. You could try running getconf CLK_TCK, although that just seems to return 100 anywhere.

kakra added a commit to kakra/xpadneo that referenced this issue Nov 17, 2021
Also fixes Steam Input which apparently also uses SDL2.

The bug shows up when SDL identifies the controller as being on USB
instead of Bluetooth (SDL Gamepad ID starts with `03` instead of `05`)
which then messes with SDL's expectations for the contents of hidraw.

This fixes two SDL problems:

  * Wrong mappings in hidraw (buttons shifted to other buttons)
  * SDL2 doesn't properly throttle rumble commands (endless rumble)

See-also: atar-axis#286
Maybe-fixes: atar-axis#303
Maybe-fixes: atar-axis#311
Maybe-fixes: atar-axis#314
Signed-off-by: Kai Krakow <kai@kaishome.de>
@777Raim
Copy link
Author

777Raim commented Nov 17, 2021

This line won't change by editing the file: The initial rumbler uses fixed rumble lengths. But you may see a different result during the game.

I didn't try this yet, but I noticed this: if XPADNEO_RUMBLE_THROTTLE_DELAY is 15 the rumble don't work at all.

You could try running getconf CLK_TCK

$ getconf CLK_TCK
100

Today will try to check last commit and various XPADNEO_RUMBLE_THROTTLE_DELAY values

@kakra
Copy link
Collaborator

kakra commented Nov 17, 2021

if XPADNEO_RUMBLE_THROTTLE_DELAY is 15 the rumble don't work at all.

This is strange, didn't happen when I experimented with it. Did you keep the msecs_to_jiffies function around the value? It's important to let the kernel convert that properly.

@777Raim
Copy link
Author

777Raim commented Nov 17, 2021

Today tried all values (10-15) of XPADNEO_RUMBLE_THROTTLE_DELAY - every time same behaviour: the rumble works 1-3 sec and stops at all.

Did you keep the msecs_to_jiffies function around the value? It's important to let the kernel convert that properly.

Of course, I kept msecs_to_jiffies function

@kakra
Copy link
Collaborator

kakra commented Nov 17, 2021

Okay, so we are on a false track here: If 15ms changes nothing at all, there's no timing issue.

If rumble stops, do inputs still work normally?

@777Raim
Copy link
Author

777Raim commented Nov 18, 2021

If rumble stops, do inputs still work normally?

Yes, input still works as usual

@kakra kakra closed this as completed in 74ea7c1 Apr 30, 2022
kakra added a commit to kakra/xpadneo that referenced this issue Apr 30, 2022
Firmware 5.13 and later (all BLE models) queue rumble effects if we
send rumble commands faster than 20 Hz. This commit fixes it and
actually matches the rate the ff-memless emulation is supposed to send
us for single effects. ff-memless may still combine several effects
and send them at higher update rates thus we need to limit it here.

Fixes: atar-axis#337
Fixes: atar-axis#311
Maybe-affects: atar-axis#347
Maybe-fixes: atar-axis#319
Maybe-fixes: atar-axis#180
Signed-off-by: Kai Krakow <kai@kaishome.de>
kakra added a commit that referenced this issue May 26, 2022
Also fixes Steam Input which apparently also uses SDL2.

The bug shows up when SDL identifies the controller as being on USB
instead of Bluetooth (SDL Gamepad ID starts with `03` instead of `05`)
which then messes with SDL's expectations for the contents of hidraw.

This fixes two SDL problems:

  * Wrong mappings in hidraw (buttons shifted to other buttons)
  * SDL2 doesn't properly throttle rumble commands (endless rumble)

See-also: #286
Maybe-fixes: #303
Maybe-fixes: #311
Maybe-fixes: #314
Signed-off-by: Kai Krakow <kai@kaishome.de>
kakra added a commit that referenced this issue May 26, 2022
Firmware 5.13 and later (all BLE models) queue rumble effects if we
send rumble commands faster than 20 Hz. This commit fixes it and
actually matches the rate the ff-memless emulation is supposed to send
us for single effects. ff-memless may still combine several effects
and send them at higher update rates thus we need to limit it here.

Fixes: #337
Fixes: #311
Maybe-affects: #347
Maybe-fixes: #319
Maybe-fixes: #180
Signed-off-by: Kai Krakow <kai@kaishome.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants