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
2.01k stars 114 forks source link

Vibration not work on Gamesir T4 Nova Lite #484

Open BakaJzon opened 3 months ago

BakaJzon commented 3 months ago

Version of xpadneo

xpadneo-dkms-git & xpadneo-dkms 0.9.6-1 from AUR -git means using the latest commit on master branch to build

Controller Model

Connection mode

Installed Software

Protocol Information

Please help us identify at which layer the problem can be found if you want to report mapping errors or if the controller fails to be detected:

Please describe how it is failing below in the next sections.

Severity / Impact

Describe the Bug

I am writing to report an issue with the GameSir Nova Lite (T4NL) gamepad that resembles the one described in #462. The gamepad has only a main vibration motor. Here are the details of the issue:

Connection Modes:

Hidraw Test:

Steps to Reproduce

  1. Connect gamepad into xbox controller mode
  2. Check vibration in any game

Expected Behavior

Gamepad must vibrate

Screenshots / GIFs / Videos

System Information

# uname -a
Linux bkjzme 6.10.1-zen1-1.1-zen #1 ZEN SMP PREEMPT_DYNAMIC Fri, 26 Jul 2024 03:22:07 +0000 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

Additional Context

"Portal 2" is the only game that can trigger the vibration, and it does so only when both the red and blue portal shooting buttons are pressed simultaneously (an action not allowed by the game).

hithere-at commented 1 month ago

Hello, i am also facing the same issue on firmware v4200 (which is the last firmware to support Bluetooth Xinput mode) and have no vibrations. Did you find a workaround?

BakaJzon commented 1 month ago

Sorry for not including debug files. xpadneo-btmon.txt xpadneo-dmesg.txt

$ lsusb
Bus 001 Device 004: ID 8087:0026 Intel Corp. AX201 Bluetooth

xpadneo-lsusb.txt

kakra commented 1 month ago

It looks like your controller may have swapped motor enable bits. There's a test program in misc/examples/c_hidraw which you can use to check whether the motor enable bits a properly assigned or work at all.

Just run make hidraw in that directory, you may need to install some dev libraries, e.g. ncurses-dev, to make it work. Then connect your controller, run dmesg to find the current hidraw device name, and run sudo ./hidraw /dev/<HIDRAWNAMEHERE>.

hithere-at commented 1 month ago

I just did the hidraw test and found that the controller vibrates when all of the MotorEnable bits (STR, WEA, LTR, RTR) is turned to 1. The strength bits also affects the strength of the vibration, but only STR and WEA bit works.

I dont know if this information is relevant, but i am using TP-Link UB500 Bluetooth dongle. Also, should i try loading the xpadneo kernel module with some parameters?

kakra commented 1 month ago

Thanks, this is valuable information. Do you really need ALL motor bits set? Or does any bit correspond to some motor?

We already have quirks flags to reverse the bit mask (128) and disable the motor mask complete (4), but the latter just leaves the bits 0. Maybe we should change them to 1 instead:

// hid-xpadneo.c, line 274
    /* do not send these bits if not supported */
    if (unlikely(xdata->quirks & XPADNEO_QUIRK_NO_MOTOR_MASK))
        r->ff.enable = 0;

If you find the remaining information needed, I can create a proper patch. Please leave this open then, I will close this issue via commit.

hithere-at commented 1 month ago

Based on my testing, all of the motor bits has to be set in order for the vibration to work. It seems that any unset motor bit will NOT vibrate the controller. As for the quirks flag, i have tried loading the xpadneo kernel module with +4, +128, +132, -4, -128, and -132 but vibration is still not working. I am testing the vibration with Wine control panel in the Game Controllers menu. Also the controller has dual vibration motor and does NOT have trigger rumble.

This is the commands i used to unload and load the kernel module: sudo modprobe -r hid-xpadneo # unload sudo modprobe hid-xpadneo quirks=ed:bc:9a:85:33:6c{+|-}{quirks} # load

kakra commented 1 month ago

I'll create a PR for you to test.

kakra commented 1 month ago

sudo modprobe hid-xpadneo quirks=ed:bc:9a:85:33:6c{+|-}{quirks} # load

Your MAC OUI seems to differ from the original reporter's. Can you send the dmesg output of the controller connecting? Is it the same manufacturer?

hithere-at commented 1 month ago

I am pretty sure i have the same controller as the original reporter. I will compare the reporter's dmesg output and mine. This is the dmesg output. xpadneo-dmesg-log.txt

hithere-at commented 1 month ago

Oh yes, it is different. If you need more system information, i have attached the output of my controller's device descriptor and my uname -a output.

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
Linux zhezhi 6.9.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 28 Jun 2024 04:32:50 +0000 x86_64 GNU/Linux
kakra commented 1 month ago

Please try the pull request.

hithere-at commented 1 month ago

Thank you, but im sorry i cannot test the pull request right now because im at school. I will get back to you when i get back home.

hithere-at commented 1 month ago

Hello, it is with great news that the controller now vibrates instead of pure silence. Great work guys. Thank you very much :DDD

The only thing i noticed is that the welcome rumble takes some good amount of time (around 10 seconds i think) but that can be disabled using a kernel parameter. Again, thank you very much.

BakaJzon commented 1 month ago

Thanks. This patch works on my devices too!

Looking forward to it being merged into the master branch! XD

BakaJzon commented 1 month ago

I am pretty sure i have the same controller as the original reporter. I will compare the reporter's dmesg output and mine. This is the dmesg output. xpadneo-dmesg-log.txt

It's strange. Did you update the firmware? And the controller LED should be blue.

kakra commented 1 month ago

The only thing i noticed is that the welcome rumble takes some good amount of time (around 10 seconds i think)

Okay, then this is another important fix we need to do. It means that the controller doesn't currently correctly handle our rumble stop command in the initial rumble test (the welcome rumble is actually a test to easily see if the controller behaves as expected).

kakra commented 1 month ago

It's strange. Did you update the firmware? And the controller LED should be blue.

Looks like this is a cheap Chinese manufacturer who actually uses unofficial unassigned MAC OUIs. I couldn't find your OUIs in any database. I'm not sure if this is officially allowed in most countries because the MAC is sent on radio. Using the device in some countries may thus not be covered by laws if unofficial OUIs are in use. But we don't need to care about that in xpadneo, it only means these controllers will probably have a lot of different random OUIs and we cannot cover all in the driver. I've already updated the docs to reflect that. Maybe we can detect this device in a more general manner if it has a specific size of HID report descriptor, or specific bytes at specific positions.

hithere-at commented 1 month ago

It's strange. Did you update the firmware? And the controller LED should be blue.

Yes, the controller LED is blue and the firmware is updated to v4200. Its the last firmware to support XInput on Bluetooth. Firmware v5700 and v6900 now changed the Bluetooth XInput mode to DInput (PS4) as far as i know.

Maybe you're on a different firmware than mine?

BakaJzon commented 1 month ago

It's strange. Did you update the firmware? And the controller LED should be blue.

Yes, the controller LED is blue and the firmware is updated to v4200. Its the last firmware to support XInput on Bluetooth. Firmware v5700 and v6900 now changed the Bluetooth XInput mode to DInput (PS4) as far as i know.

Maybe you're on a different firmware than mine?

v4200 as well. T4N_lite_V63_2024-07-17.ufw Wait, the version number is quite confusing, the date of the latest one(im using) is 20240721 MD5 for this firmware: 6a3bf88a4f2ffbcdd8a57f2e8e65137b from this page, this link

So the manufacturer is probably using random MACs. But it is so cheap!

hithere-at commented 1 month ago

Wait, v6300 exists? I need to check them

hithere-at commented 1 month ago

Well looks like firmware 6300 is not available on the Gamesir Android app, but its available on the website that you attached. Anyways, controller now vibrates and we can wait for the PR to be merged. Thank you everyone for all of the informations.

kakra commented 1 week ago

Can you guys check if https://github.com/atar-axis/xpadneo/pull/496 actually fixes your problem?

hithere-at commented 6 days ago

Do you mean the vibration? Then yes, it now vibrates the controller, but welcome rumble still takes around ~20 seconds before it stops vibrating.

kakra commented 6 days ago

but welcome rumble still takes around ~20 seconds before it stops vibrating.

Okay then we still need some tweaking. I guess we need to send an explicit "strength 0" then to stop it because it doesn't obey the haptic timer parameters.

(actually the welcome rumble is mostly there to test exactly that so I learn how to implement haptic feedback in the future)

hithere-at commented 5 days ago

I just found out that adding the XPADNEO_QUIRK_NO_PULSE quirk makes the welcome rumble behave correctly.

hithere-at commented 5 days ago

And yes, it does need the strength set to 0 (both STR and WEA on hidraw test) to stop the vibration.

kakra commented 4 days ago

I'll add that then. Thanks.

hithere-at commented 3 days ago

You're welcome. Thank you for the Nova Lite support by the way, really amazing work.

BakaJzon commented 2 days ago

I bought a new controller, and its MAC address is 6A:07:14:8F:07:7B. Clearly, this manufacturer is using randomly generated MAC addresses. That's bad.

Anyway, thanks for your awesome work.

kakra commented 2 days ago

Maybe we can find a common trait of those types of controllers, a specific byte in the HID descriptor, a specific length of the descriptor. It could be useful if we could collect some descriptor dumps to see if they differ between firmware versions.

I'm not sure if I can integrate such a detection easily into the source code, but we can give it a try.

hithere-at commented 1 day ago

It could be useful if we could collect some descriptor dumps to see if they differ between firmware versions.

I see. I will check them when i have time.

hithere-at commented 1 day ago

I just checked the descriptor dump between firmware v3800 to v4200. There are no difference. Even the descriptors are the same with the one from the first comment. dump_v3800.txt dump_v4200.txt dump_v4000.txt