From 358966df05457820f9582b29b681eaecf766374e Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 8 Oct 2024 13:30:37 -0700 Subject: [PATCH] HID: wacom: Set invert_state 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 they specify that only the 'Eraser' usage should be set (while hovering, only the 'Invert' usage is to be set). We use our internal 'invert_state' flag to determine if a pen has an intent to erase (whether hovering or not). Right now that flag only depends on the 'Invert' usage, which is sufficient for the first type of pen (i.e. EMR), but not the second type (i.e. AES). This commit updates the logic so that 'invert_state' will be set whenever either of the two usages are. This should ensure that userspace gets the correct BTN_TOOL_PEN / BTN_TOOL_RUBBER indication for AES pens. Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states --- 4.18/wacom_wac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/4.18/wacom_wac.c b/4.18/wacom_wac.c index 304e2042..e589e7d3 100644 --- a/4.18/wacom_wac.c +++ b/4.18/wacom_wac.c @@ -2447,9 +2447,11 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.sense_state = value; return; case HID_DG_INVERT: - wacom_wac->hid_data.invert_state = value; + wacom_wac->hid_data.invert_state |= value; return; case HID_DG_ERASER: + wacom_wac->hid_data.invert_state |= value; + fallthrough; case HID_DG_TIPSWITCH: wacom_wac->hid_data.tipswitch |= value; return; @@ -2644,6 +2646,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev, } wacom_wac->hid_data.tipswitch = false; + wacom_wac->hid_data.invert_state = false; input_sync(input); }