diff mbox series

[3/4] input: xpad: Implement trigger rumble for Xbox One controllers

Message ID 20220410220701.5279-1-dbdaniel42@gmail.com (mailing list archive)
State New, archived
Headers show
Series input: Implement an API for trigger rumble motors | expand

Commit Message

Daniel Bomar April 10, 2022, 10:07 p.m. UTC
Signed-off-by: Daniel Bomar <dbdaniel42@gmail.com>
---
 drivers/input/joystick/xpad.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 18190b529bca..0ac59ce03e58 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1251,6 +1251,8 @@  static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
 	struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX];
 	__u16 strong;
 	__u16 weak;
+	__u16 trigger_left;
+	__u16 trigger_right;
 	int retval;
 	unsigned long flags;
 
@@ -1259,6 +1261,8 @@  static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
 
 	strong = effect->u.rumble.strong_magnitude;
 	weak = effect->u.rumble.weak_magnitude;
+	trigger_left = effect->u.rumble.trigger_left;
+	trigger_right = effect->u.rumble.trigger_right;
 
 	spin_lock_irqsave(&xpad->odata_lock, flags);
 
@@ -1311,8 +1315,8 @@  static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
 		packet->data[3] = 0x09;
 		packet->data[4] = 0x00;
 		packet->data[5] = 0x0F;
-		packet->data[6] = 0x00;
-		packet->data[7] = 0x00;
+		packet->data[6] = trigger_left / 512;
+		packet->data[7] = trigger_right / 512;
 		packet->data[8] = strong / 512;	/* left actuator */
 		packet->data[9] = weak / 512;	/* right actuator */
 		packet->data[10] = 0xFF; /* on period */