* [PATCH] HID: wiimote: fix nunchuck button parser
@ 2013-02-18 0:47 David Herrmann
2013-02-18 9:42 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: David Herrmann @ 2013-02-18 0:47 UTC (permalink / raw)
To: linux-input; +Cc: Jiri Kosina, Victor Quicksilver, David Herrmann, stable
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>
---
drivers/hid/hid-wiimote-ext.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-wiimote-ext.c b/drivers/hid/hid-wiimote-ext.c
index 38ae877..0472191 100644
--- a/drivers/hid/hid-wiimote-ext.c
+++ b/drivers/hid/hid-wiimote-ext.c
@@ -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);
--
1.8.1.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HID: wiimote: fix nunchuck button parser
2013-02-18 0:47 [PATCH] HID: wiimote: fix nunchuck button parser David Herrmann
@ 2013-02-18 9:42 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2013-02-18 9:42 UTC (permalink / raw)
To: David Herrmann; +Cc: linux-input, Victor Quicksilver, stable
On Mon, 18 Feb 2013, David Herrmann wrote:
> 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>
> ---
> drivers/hid/hid-wiimote-ext.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hid/hid-wiimote-ext.c b/drivers/hid/hid-wiimote-ext.c
> index 38ae877..0472191 100644
> --- a/drivers/hid/hid-wiimote-ext.c
> +++ b/drivers/hid/hid-wiimote-ext.c
> @@ -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);
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-18 9:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-18 0:47 [PATCH] HID: wiimote: fix nunchuck button parser David Herrmann
2013-02-18 9:42 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).