Commit 61cbfaf9 authored by Cameron Gutman's avatar Cameron Gutman Committed by Kamal Mostafa

Input: xpad - prevent spurious input from wired Xbox 360 controllers

commit 1ff5fa3c upstream.

After initially connecting a wired Xbox 360 controller or sending it
a command to change LEDs, a status/response packet is interpreted as
controller input. This causes the state of buttons represented in
byte 2 of the controller data packet to be incorrect until the next
valid input packet. Wireless Xbox 360 controllers are not affected.

Writing a new value to the LED device while holding the Start button
and running jstest is sufficient to reproduce this bug. An event will
come through with the Start button released.

Xboxdrv also won't attempt to read controller input from a packet
where byte 0 is non-zero. It also checks that byte 1 is 0x14, but
that value differs between wired and wireless controllers and this
code is shared by both. I think just checking byte 0 is enough to
eliminate unwanted packets.

The following are some examples of 3-byte status packets I saw:
01 03 02
02 03 00
03 03 03
08 03 00
Signed-off-by: default avatarCameron Gutman <aicommander@gmail.com>
Signed-off-by: default avatarPavel Rojtberg <rojtberg@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent fe839817
...@@ -432,6 +432,10 @@ static void xpad360_process_packet(struct usb_xpad *xpad, ...@@ -432,6 +432,10 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
{ {
struct input_dev *dev = xpad->dev; struct input_dev *dev = xpad->dev;
/* valid pad data */
if (data[0] != 0x00)
return;
/* digital pad */ /* digital pad */
if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
/* dpad as buttons (left, right, up, down) */ /* dpad as buttons (left, right, up, down) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment