Skip to content

Commit f77810f

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Fix logic used for 3rd barrel switch emulation
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: [email protected] #v5.19+ Signed-off-by: Jason Gerecke <[email protected]> Tested-by: Joshua Dickens <[email protected]> Reviewed-by: Ping Cheng <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b5bcb94 commit f77810f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/hid/wacom_wac.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,11 +2520,12 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
25202520

25212521
if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
25222522
int id = wacom_wac->id[0];
2523-
if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
2524-
wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
2525-
wacom_wac->hid_data.barrelswitch = 0;
2526-
wacom_wac->hid_data.barrelswitch2 = 0;
2527-
wacom_wac->hid_data.barrelswitch3 = 1;
2523+
if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3) {
2524+
int sw_state = wacom_wac->hid_data.barrelswitch |
2525+
(wacom_wac->hid_data.barrelswitch2 << 1);
2526+
wacom_wac->hid_data.barrelswitch = sw_state == 1;
2527+
wacom_wac->hid_data.barrelswitch2 = sw_state == 2;
2528+
wacom_wac->hid_data.barrelswitch3 = sw_state == 3;
25282529
}
25292530
input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
25302531
input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);

0 commit comments

Comments
 (0)