HID: sony: Fix Sixaxis cable state detection
authorFrank Praznik <frank.praznik@oh.rr.com>
Sat, 15 Mar 2014 13:41:15 +0000 (09:41 -0400)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 Apr 2014 16:44:06 +0000 (18:44 +0200)
Byte 31 of the Sixaxis report can change depending on whether or not the
controller is rumbling.  Using bit 3 is the only reliable way to detect the
state of the cable regardless of rumble activity.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-sony.c

index b1aa6f00c827574eee039a597a81b7f7a481d4b9..31ba01a39e819defa0f3a216190309fec498d319 100644 (file)
@@ -864,7 +864,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
                battery_capacity = sixaxis_battery_capacity[index];
                battery_charging = 0;
        }
-       cable_state = !((rd[31] >> 4) & 0x01);
+       cable_state = !(rd[31] & 0x04);
 
        spin_lock_irqsave(&sc->lock, flags);
        sc->cable_state = cable_state;