Skip to content

Commit 38c433e

Browse files
committed
HID: wacom: Set eraser status when either 'Eraser' or 'Invert' usage is set
JIRA: https://issues.redhat.com/browse/RHEL-102058 Upstream Status: since v6.13 commit a025b0d Author: Jason Gerecke <jason.gerecke@wacom.com> Date: Thu Oct 17 11:31:13 2024 -0700 HID: wacom: Set eraser status when either 'Eraser' or 'Invert' usage is set Microsoft defines two slightly different behaviors for pens that are being used to erase. The first one, for pens that can be used while inverted specifies that both 'Invert' and 'Eraser' usages should be set while the pen is in contact and erasing. For pens that use an eraser button though, they specify that only the 'Eraser' usage should be set (while hovering, only the 'Invert' usage is to be set). We used our internal 'invert_state' flag to determine if a pen has an intent to erase (whether hovering or not). That flag was previously only depending on the 'Invert' usage, which was sufficient for the first type of pen (EMR) but not the second type (AES). This commit makes the flag depend on either usage being set, and also renames it to make its function more clear. This change should not normally have an impact on userspace due to both the existing driver and firmware design. The driver already only determines tool type based on the first event in an interaction (e.g. it will see the 'Invert' bit set when the eraser comes into prox and then report BTN_TOOL_RUBBER for the rest of the interaction, even if 'Invert' is cleared). AES firmware is also careful to send reports that work through a set of defined state transitions, even in the corner-case where the eraser button is pressed when the pen is already in contact with the display (Prox|Tip -> Prox -> 0 -> Invert -> Eraser). Regardless, it seems reasonable to ensure the driver's state variables match programmer expectation. Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 11e2849 commit 38c433e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/hid/wacom_wac.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,9 +2422,11 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
24222422
wacom_wac->hid_data.sense_state = value;
24232423
return;
24242424
case HID_DG_INVERT:
2425-
wacom_wac->hid_data.invert_state = value;
2425+
wacom_wac->hid_data.eraser |= value;
24262426
return;
24272427
case HID_DG_ERASER:
2428+
wacom_wac->hid_data.eraser |= value;
2429+
fallthrough;
24282430
case HID_DG_TIPSWITCH:
24292431
wacom_wac->hid_data.tipswitch |= value;
24302432
return;
@@ -2565,7 +2567,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
25652567

25662568
if (entering_range) { /* first in range */
25672569
/* Going into range select tool */
2568-
if (wacom_wac->hid_data.invert_state)
2570+
if (wacom_wac->hid_data.eraser)
25692571
wacom_wac->tool[0] = BTN_TOOL_RUBBER;
25702572
else if (wacom_wac->features.quirks & WACOM_QUIRK_AESPEN)
25712573
wacom_wac->tool[0] = BTN_TOOL_PEN;
@@ -2619,6 +2621,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
26192621
}
26202622

26212623
wacom_wac->hid_data.tipswitch = false;
2624+
wacom_wac->hid_data.eraser = false;
26222625

26232626
input_sync(input);
26242627
}

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ struct hid_data {
300300
__s16 inputmode_index; /* InputMode HID feature index in the report */
301301
bool sense_state;
302302
bool inrange_state;
303-
bool invert_state;
303+
bool eraser;
304304
bool tipswitch;
305305
bool barrelswitch;
306306
bool barrelswitch2;

0 commit comments

Comments
 (0)