Skip to content

Commit dc9dc86

Browse files
Ping ChengJiri Kosina
authored andcommitted
HID: wacom: set initial hardware touch switch state to 'off'
Wacom touch devices have two types of touch switches: softkey touch toggle and hardware touch switch. For softkey toggle, we assume touch is on by default in the driver. However the hardware touch switch is controlled by end users. We don't know if it's on or off before getting the status event. This patch sets touch off for devices with a hardware switch until we get the status. This is a bit safer for users who leave the switch "off" and don't want any accidental touches. The tradeoff is a slight delay between device connection and touch becoming enabled for users who leave the switch "on". Signed-off-by: Ping Cheng <ping.cheng@wacom.com> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Tested-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 7cc8524 commit dc9dc86

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

drivers/hid/wacom_sys.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,13 @@ static void wacom_set_shared_values(struct wacom_wac *wacom_wac)
22872287

22882288
if (wacom_wac->has_mute_touch_switch) {
22892289
wacom_wac->shared->has_mute_touch_switch = true;
2290-
wacom_wac->shared->is_touch_on = true;
2290+
/* Hardware touch switch may be off. Wait until
2291+
* we know the switch state to decide is_touch_on.
2292+
* Softkey state should be initialized to "on" to
2293+
* match historic default.
2294+
*/
2295+
if (wacom_wac->is_soft_touch_switch)
2296+
wacom_wac->shared->is_touch_on = true;
22912297
}
22922298

22932299
if (wacom_wac->shared->has_mute_touch_switch &&

drivers/hid/wacom_wac.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,14 +1987,17 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
19871987
features->numbered_buttons++;
19881988
features->device_type |= WACOM_DEVICETYPE_PAD;
19891989
break;
1990-
case WACOM_HID_WD_TOUCHONOFF:
19911990
case WACOM_HID_WD_MUTE_DEVICE:
1991+
/* softkey touch switch */
1992+
wacom_wac->is_soft_touch_switch = true;
1993+
fallthrough;
1994+
case WACOM_HID_WD_TOUCHONOFF:
19921995
/*
1993-
* This usage, which is used to mute touch events, comes
1994-
* from the pad packet, but is reported on the touch
1996+
* These two usages, which are used to mute touch events, come
1997+
* from the pad packet, but are reported on the touch
19951998
* interface. Because the touch interface may not have
19961999
* been created yet, we cannot call wacom_map_usage(). In
1997-
* order to process this usage when we receive it, we set
2000+
* order to process the usages when we receive them, we set
19982001
* the usage type and code directly.
19992002
*/
20002003
wacom_wac->has_mute_touch_switch = true;
@@ -3835,6 +3838,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
38353838
input_dev->evbit[0] |= BIT_MASK(EV_SW);
38363839
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
38373840
wacom_wac->has_mute_touch_switch = true;
3841+
wacom_wac->is_soft_touch_switch = true;
38383842
}
38393843
fallthrough;
38403844

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ struct wacom_wac {
352352
int mode_value;
353353
struct hid_data hid_data;
354354
bool has_mute_touch_switch;
355+
bool is_soft_touch_switch;
355356
bool has_mode_change;
356357
bool is_direct_mode;
357358
bool is_invalid_bt_frame;

0 commit comments

Comments
 (0)