@@ -824,6 +824,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
824824 return 0 ;
825825}
826826
827+ static inline bool touch_is_muted (struct wacom_wac * wacom_wac )
828+ {
829+ return wacom_wac -> probe_complete &&
830+ wacom_wac -> shared -> has_mute_touch_switch &&
831+ !wacom_wac -> shared -> is_touch_on ;
832+ }
833+
827834static inline bool report_touch_events (struct wacom_wac * wacom )
828835{
829836 return (touch_arbitration ? !wacom -> shared -> stylus_in_proximity : 1 );
@@ -1525,11 +1532,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
15251532 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET ;
15261533 int y_offset = 2 ;
15271534
1528- if (wacom -> shared -> has_mute_touch_switch &&
1529- !wacom -> shared -> is_touch_on ) {
1530- if (!wacom -> shared -> touch_down )
1531- return 0 ;
1532- }
1535+ if (touch_is_muted (wacom ) && !wacom -> shared -> touch_down )
1536+ return 0 ;
15331537
15341538 if (wacom -> features .type == WACOM_27QHDT ) {
15351539 current_num_contacts = data [63 ];
@@ -1987,14 +1991,17 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
19871991 features -> numbered_buttons ++ ;
19881992 features -> device_type |= WACOM_DEVICETYPE_PAD ;
19891993 break ;
1990- case WACOM_HID_WD_TOUCHONOFF :
19911994 case WACOM_HID_WD_MUTE_DEVICE :
1995+ /* softkey touch switch */
1996+ wacom_wac -> is_soft_touch_switch = true;
1997+ fallthrough ;
1998+ case WACOM_HID_WD_TOUCHONOFF :
19921999 /*
1993- * This usage , which is used to mute touch events, comes
1994- * from the pad packet, but is reported on the touch
2000+ * These two usages , which are used to mute touch events, come
2001+ * from the pad packet, but are reported on the touch
19952002 * interface. Because the touch interface may not have
19962003 * been created yet, we cannot call wacom_map_usage(). In
1997- * order to process this usage when we receive it , we set
2004+ * order to process the usages when we receive them , we set
19982005 * the usage type and code directly.
19992006 */
20002007 wacom_wac -> has_mute_touch_switch = true;
@@ -2533,8 +2540,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
25332540 bool prox = hid_data -> tipswitch &&
25342541 report_touch_events (wacom_wac );
25352542
2536- if (wacom_wac -> shared -> has_mute_touch_switch &&
2537- !wacom_wac -> shared -> is_touch_on ) {
2543+ if (touch_is_muted (wacom_wac )) {
25382544 if (!wacom_wac -> shared -> touch_down )
25392545 return ;
25402546 prox = false;
@@ -2548,8 +2554,17 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
25482554 int slot ;
25492555
25502556 slot = input_mt_get_slot_by_key (input , hid_data -> id );
2551- if (slot < 0 )
2557+ if (slot < 0 ) {
25522558 return ;
2559+ } else {
2560+ struct input_mt_slot * ps = & input -> mt -> slots [slot ];
2561+ int mt_id = input_mt_get_value (ps , ABS_MT_TRACKING_ID );
2562+
2563+ if (!prox && mt_id < 0 ) {
2564+ // No data to send for this slot; short-circuit
2565+ return ;
2566+ }
2567+ }
25532568
25542569 input_mt_slot (input , slot );
25552570 input_mt_report_slot_state (input , MT_TOOL_FINGER , prox );
@@ -2581,6 +2596,9 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
25812596 unsigned equivalent_usage = wacom_equivalent_usage (usage -> hid );
25822597 struct wacom_features * features = & wacom -> wacom_wac .features ;
25832598
2599+ if (touch_is_muted (wacom_wac ) && !wacom_wac -> shared -> touch_down )
2600+ return ;
2601+
25842602 if (wacom_wac -> is_invalid_bt_frame )
25852603 return ;
25862604
@@ -2630,6 +2648,9 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,
26302648 struct hid_data * hid_data = & wacom_wac -> hid_data ;
26312649 int i ;
26322650
2651+ if (touch_is_muted (wacom_wac ) && !wacom_wac -> shared -> touch_down )
2652+ return ;
2653+
26332654 wacom_wac -> is_invalid_bt_frame = false;
26342655
26352656 for (i = 0 ; i < report -> maxfield ; i ++ ) {
@@ -2681,6 +2702,10 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
26812702 struct input_dev * input = wacom_wac -> touch_input ;
26822703 unsigned touch_max = wacom_wac -> features .touch_max ;
26832704
2705+ /* if there was nothing to process, don't send an empty sync */
2706+ if (wacom_wac -> hid_data .num_expected == 0 )
2707+ return ;
2708+
26842709 /* If more packets of data are expected, give us a chance to
26852710 * process them rather than immediately syncing a partial
26862711 * update.
@@ -3835,6 +3860,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
38353860 input_dev -> evbit [0 ] |= BIT_MASK (EV_SW );
38363861 __set_bit (SW_MUTE_DEVICE , input_dev -> swbit );
38373862 wacom_wac -> has_mute_touch_switch = true;
3863+ wacom_wac -> is_soft_touch_switch = true;
38383864 }
38393865 fallthrough ;
38403866
0 commit comments