aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Loup A. Griffais <githubpublic@plagman.net>2015-12-09 16:40:37 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-01-04 14:39:46 -0500
commit2a6d7527b35cf987260800807e328d167aef22ac (patch)
tree3760bab1b66c9a561bb52eae8ff19d80d6eead0c
parent7fc595f4c02636eadaeeecfe7bbc45b57c173004 (diff)
Input: xpad - update Xbox One Force Feedback Support
There's apparently a serial number woven into both input and output packets; neglecting to specify a valid serial number causes the controller to ignore the rumble packets. The scale of the rumble was also apparently halved in the packets. The initialization packet had to be changed to allow force feedback to work. see https://github.com/paroj/xpad/issues/7 for details. Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/joystick/xpad.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 285f0b753c25..aa6586043a6c 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -348,6 +348,7 @@ struct usb_xpad {
348 struct urb *irq_out; /* urb for interrupt out report */ 348 struct urb *irq_out; /* urb for interrupt out report */
349 bool irq_out_active; /* we must not use an active URB */ 349 bool irq_out_active; /* we must not use an active URB */
350 unsigned char *odata; /* output data */ 350 unsigned char *odata; /* output data */
351 u8 odata_serial; /* serial number for xbox one protocol */
351 dma_addr_t odata_dma; 352 dma_addr_t odata_dma;
352 spinlock_t odata_lock; 353 spinlock_t odata_lock;
353 354
@@ -923,7 +924,10 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
923 /* Xbox one controller needs to be initialized. */ 924 /* Xbox one controller needs to be initialized. */
924 packet->data[0] = 0x05; 925 packet->data[0] = 0x05;
925 packet->data[1] = 0x20; 926 packet->data[1] = 0x20;
926 packet->len = 2; 927 packet->data[2] = xpad->odata_serial++; /* packet serial */
928 packet->data[3] = 0x01; /* rumble bit enable? */
929 packet->data[4] = 0x00;
930 packet->len = 5;
927 packet->pending = true; 931 packet->pending = true;
928 932
929 /* Reset the sequence so we send out start packet first */ 933 /* Reset the sequence so we send out start packet first */
@@ -998,17 +1002,18 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
998 case XTYPE_XBOXONE: 1002 case XTYPE_XBOXONE:
999 packet->data[0] = 0x09; /* activate rumble */ 1003 packet->data[0] = 0x09; /* activate rumble */
1000 packet->data[1] = 0x08; 1004 packet->data[1] = 0x08;
1001 packet->data[2] = 0x00; 1005 packet->data[2] = xpad->odata_serial++;
1002 packet->data[3] = 0x08; /* continuous effect */ 1006 packet->data[3] = 0x08; /* continuous effect */
1003 packet->data[4] = 0x00; /* simple rumble mode */ 1007 packet->data[4] = 0x00; /* simple rumble mode */
1004 packet->data[5] = 0x03; /* L and R actuator only */ 1008 packet->data[5] = 0x03; /* L and R actuator only */
1005 packet->data[6] = 0x00; /* TODO: LT actuator */ 1009 packet->data[6] = 0x00; /* TODO: LT actuator */
1006 packet->data[7] = 0x00; /* TODO: RT actuator */ 1010 packet->data[7] = 0x00; /* TODO: RT actuator */
1007 packet->data[8] = strong / 256; /* left actuator */ 1011 packet->data[8] = strong / 512; /* left actuator */
1008 packet->data[9] = weak / 256; /* right actuator */ 1012 packet->data[9] = weak / 512; /* right actuator */
1009 packet->data[10] = 0x80; /* length of pulse */ 1013 packet->data[10] = 0x80; /* length of pulse */
1010 packet->data[11] = 0x00; /* stop period of pulse */ 1014 packet->data[11] = 0x00; /* stop period of pulse */
1011 packet->len = 12; 1015 packet->data[12] = 0x00;
1016 packet->len = 13;
1012 packet->pending = true; 1017 packet->pending = true;
1013 break; 1018 break;
1014 1019