]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: hid-playstation: DS4: Update rumble and lightbar together
authorMax Staudt <max@enpas.org>
Sun, 11 Aug 2024 13:09:06 +0000 (22:09 +0900)
committerJiri Kosina <jkosina@suse.com>
Wed, 21 Aug 2024 22:24:09 +0000 (00:24 +0200)
Some 3rd party gamepads expect updates to rumble and lightbar together,
and setting one may cancel the other.

Let's maximise compatibility by always sending rumble and lightbar
updates together, even when only one has been scheduled.

Further background reading:

- Apparently the PS4 always sends rumble and lightbar updates together:

  https://eleccelerator.com/wiki/index.php?title=DualShock_4#0x11_2

- 3rd party gamepads may not implement lightbar_blink, and may simply
  ignore updates with 0x07 set, according to:

  https://github.com/Ryochan7/DS4Windows/pull/1839

[jkosina@suse.com: fix shortlog]
Acked-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Max Staudt <max@enpas.org>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-playstation.c

index e7c309cfe3a01f37e3fd949102091a3bc1d51fb6..0d90d7ee693c1dae55682b547b798c551f9aa294 100644 (file)
@@ -2143,6 +2143,26 @@ static void dualshock4_output_worker(struct work_struct *work)
 
        spin_lock_irqsave(&ds4->base.lock, flags);
 
+       /*
+        * Some 3rd party gamepads expect updates to rumble and lightbar
+        * together, and setting one may cancel the other.
+        *
+        * Let's maximise compatibility by always sending rumble and lightbar
+        * updates together, even when only one has been scheduled, resulting
+        * in:
+        *
+        *   ds4->valid_flag0 >= 0x03
+        *
+        * Hopefully this will maximise compatibility with third-party pads.
+        *
+        * Any further update bits, such as 0x04 for lightbar blinking, will
+        * be or'd on top of this like before.
+        */
+       if (ds4->update_rumble || ds4->update_lightbar) {
+               ds4->update_rumble = true; /* 0x01 */
+               ds4->update_lightbar = true; /* 0x02 */
+       }
+
        if (ds4->update_rumble) {
                /* Select classic rumble style haptics and enable it. */
                common->valid_flag0 |= DS4_OUTPUT_VALID_FLAG0_MOTOR;