HID: wiimote: fix nunchuck button parser
authorDavid Herrmann <dh.herrmann@gmail.com>
Mon, 18 Feb 2013 00:47:15 +0000 (01:47 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 18 Feb 2013 09:41:52 +0000 (10:41 +0100)
The buttons of the Wii Remote Nunchuck extension are actually active low.
Fix the parser to forward the inverted values. The comment in the function
always said "0 == pressed" but the implementation was wrong from the
beginning.

Cc: stable@vger.kernel.org
Reported-by: Victor Quicksilver <victor.quicksilver@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-wiimote-ext.c

index 38ae87772e96d18144a5b2e256192fd67b4bde55..0472191d4a7272dff8ea9709aef2e7814dd6be2a 100644 (file)
@@ -403,14 +403,14 @@ static void handler_nunchuck(struct wiimote_ext *ext, const __u8 *payload)
 
        if (ext->motionp) {
                input_report_key(ext->input,
-                       wiiext_keymap[WIIEXT_KEY_Z], !!(payload[5] & 0x04));
+                       wiiext_keymap[WIIEXT_KEY_Z], !(payload[5] & 0x04));
                input_report_key(ext->input,
-                       wiiext_keymap[WIIEXT_KEY_C], !!(payload[5] & 0x08));
+                       wiiext_keymap[WIIEXT_KEY_C], !(payload[5] & 0x08));
        } else {
                input_report_key(ext->input,
-                       wiiext_keymap[WIIEXT_KEY_Z], !!(payload[5] & 0x01));
+                       wiiext_keymap[WIIEXT_KEY_Z], !(payload[5] & 0x01));
                input_report_key(ext->input,
-                       wiiext_keymap[WIIEXT_KEY_C], !!(payload[5] & 0x02));
+                       wiiext_keymap[WIIEXT_KEY_C], !(payload[5] & 0x02));
        }
 
        input_sync(ext->input);