Skip to content

Commit

Permalink
HID: wacom: Fix logic used for 3rd barrel switch emulation
Browse files Browse the repository at this point in the history
commit f77810f upstream.

When support was added for devices using an explicit 3rd barrel switch,
the logic used by devices emulating this feature was broken. The 'if'
statement / block that was introduced only handles the case where the
button is pressed (i.e. 'barrelswitch' and 'barrelswitch2' are both set)
but not the case where it is released (i.e. one or both being cleared).
This results in a BTN_STYLUS3 "down" event being sent when the button
is pressed, but no "up" event ever being sent afterwards.

This patch restores the previously-used logic for determining button
states in the emulated case so that switches are reported correctly
again.

Link: linuxwacom/xf86-input-wacom#292
Fixes: 6d09085 ("HID: wacom: Adding Support for new usages")
CC: stable@vger.kernel.org #v5.19+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jigpu authored and gregkh committed Nov 16, 2022
1 parent 14891b8 commit 8f8c1e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/hid/wacom_wac.c
Expand Up @@ -2522,11 +2522,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev,

if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
int id = wacom_wac->id[0];
if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
wacom_wac->hid_data.barrelswitch = 0;
wacom_wac->hid_data.barrelswitch2 = 0;
wacom_wac->hid_data.barrelswitch3 = 1;
if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3) {
int sw_state = wacom_wac->hid_data.barrelswitch |
(wacom_wac->hid_data.barrelswitch2 << 1);
wacom_wac->hid_data.barrelswitch = sw_state == 1;
wacom_wac->hid_data.barrelswitch2 = sw_state == 2;
wacom_wac->hid_data.barrelswitch3 = sw_state == 3;
}
input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
Expand Down

0 comments on commit 8f8c1e0

Please sign in to comment.