@@ -1065,6 +1065,28 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1065
1065
return 0 ;
1066
1066
}
1067
1067
1068
+ static int wacom_wac_finger_count_touches (struct wacom_wac * wacom )
1069
+ {
1070
+ struct input_dev * input = wacom -> input ;
1071
+ unsigned touch_max = wacom -> features .touch_max ;
1072
+ int count = 0 ;
1073
+ int i ;
1074
+
1075
+ /* non-HID_GENERIC single touch input doesn't call this routine */
1076
+ if ((touch_max == 1 ) && (wacom -> features .type == HID_GENERIC ))
1077
+ return wacom -> hid_data .tipswitch &&
1078
+ !wacom -> shared -> stylus_in_proximity ;
1079
+
1080
+ for (i = 0 ; i < input -> mt -> num_slots ; i ++ ) {
1081
+ struct input_mt_slot * ps = & input -> mt -> slots [i ];
1082
+ int id = input_mt_get_value (ps , ABS_MT_TRACKING_ID );
1083
+ if (id >= 0 )
1084
+ count ++ ;
1085
+ }
1086
+
1087
+ return count ;
1088
+ }
1089
+
1068
1090
static int wacom_24hdt_irq (struct wacom_wac * wacom )
1069
1091
{
1070
1092
struct input_dev * input = wacom -> input ;
@@ -1075,7 +1097,6 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
1075
1097
int num_contacts_left = 4 ; /* maximum contacts per packet */
1076
1098
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET ;
1077
1099
int y_offset = 2 ;
1078
- static int contact_with_no_pen_down_count = 0 ;
1079
1100
1080
1101
if (wacom -> features .type == WACOM_27QHDT ) {
1081
1102
current_num_contacts = data [63 ];
@@ -1088,10 +1109,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
1088
1109
* First packet resets the counter since only the first
1089
1110
* packet in series will have non-zero current_num_contacts.
1090
1111
*/
1091
- if (current_num_contacts ) {
1112
+ if (current_num_contacts )
1092
1113
wacom -> num_contacts_left = current_num_contacts ;
1093
- contact_with_no_pen_down_count = 0 ;
1094
- }
1095
1114
1096
1115
contacts_to_send = min (num_contacts_left , wacom -> num_contacts_left );
1097
1116
@@ -1124,15 +1143,14 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
1124
1143
input_report_abs (input , ABS_MT_WIDTH_MINOR , min (w , h ));
1125
1144
input_report_abs (input , ABS_MT_ORIENTATION , w > h );
1126
1145
}
1127
- contact_with_no_pen_down_count ++ ;
1128
1146
}
1129
1147
}
1130
1148
input_mt_sync_frame (input );
1131
1149
1132
1150
wacom -> num_contacts_left -= contacts_to_send ;
1133
1151
if (wacom -> num_contacts_left <= 0 ) {
1134
1152
wacom -> num_contacts_left = 0 ;
1135
- wacom -> shared -> touch_down = ( contact_with_no_pen_down_count > 0 );
1153
+ wacom -> shared -> touch_down = wacom_wac_finger_count_touches ( wacom );
1136
1154
}
1137
1155
return 1 ;
1138
1156
}
@@ -1145,7 +1163,6 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
1145
1163
int current_num_contacts = data [2 ];
1146
1164
int contacts_to_send = 0 ;
1147
1165
int x_offset = 0 ;
1148
- static int contact_with_no_pen_down_count = 0 ;
1149
1166
1150
1167
/* MTTPC does not support Height and Width */
1151
1168
if (wacom -> features .type == MTTPC || wacom -> features .type == MTTPC_B )
@@ -1155,10 +1172,8 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
1155
1172
* First packet resets the counter since only the first
1156
1173
* packet in series will have non-zero current_num_contacts.
1157
1174
*/
1158
- if (current_num_contacts ) {
1175
+ if (current_num_contacts )
1159
1176
wacom -> num_contacts_left = current_num_contacts ;
1160
- contact_with_no_pen_down_count = 0 ;
1161
- }
1162
1177
1163
1178
/* There are at most 5 contacts per packet */
1164
1179
contacts_to_send = min (5 , wacom -> num_contacts_left );
@@ -1179,15 +1194,14 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
1179
1194
int y = get_unaligned_le16 (& data [offset + x_offset + 9 ]);
1180
1195
input_report_abs (input , ABS_MT_POSITION_X , x );
1181
1196
input_report_abs (input , ABS_MT_POSITION_Y , y );
1182
- contact_with_no_pen_down_count ++ ;
1183
1197
}
1184
1198
}
1185
1199
input_mt_sync_frame (input );
1186
1200
1187
1201
wacom -> num_contacts_left -= contacts_to_send ;
1188
1202
if (wacom -> num_contacts_left <= 0 ) {
1189
1203
wacom -> num_contacts_left = 0 ;
1190
- wacom -> shared -> touch_down = ( contact_with_no_pen_down_count > 0 );
1204
+ wacom -> shared -> touch_down = wacom_wac_finger_count_touches ( wacom );
1191
1205
}
1192
1206
return 1 ;
1193
1207
}
@@ -1196,7 +1210,6 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1196
1210
{
1197
1211
struct input_dev * input = wacom -> input ;
1198
1212
unsigned char * data = wacom -> data ;
1199
- int contact_with_no_pen_down_count = 0 ;
1200
1213
int i ;
1201
1214
1202
1215
for (i = 0 ; i < 2 ; i ++ ) {
@@ -1211,13 +1224,12 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1211
1224
1212
1225
input_report_abs (input , ABS_MT_POSITION_X , x );
1213
1226
input_report_abs (input , ABS_MT_POSITION_Y , y );
1214
- contact_with_no_pen_down_count ++ ;
1215
1227
}
1216
1228
}
1217
1229
input_mt_sync_frame (input );
1218
1230
1219
1231
/* keep touch state for pen event */
1220
- wacom -> shared -> touch_down = ( contact_with_no_pen_down_count > 0 );
1232
+ wacom -> shared -> touch_down = wacom_wac_finger_count_touches ( wacom );
1221
1233
1222
1234
return 1 ;
1223
1235
}
@@ -1545,29 +1557,6 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
1545
1557
return 0 ;
1546
1558
}
1547
1559
1548
- static int wacom_wac_finger_count_touches (struct hid_device * hdev )
1549
- {
1550
- struct wacom * wacom = hid_get_drvdata (hdev );
1551
- struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
1552
- struct input_dev * input = wacom_wac -> input ;
1553
- unsigned touch_max = wacom_wac -> features .touch_max ;
1554
- int count = 0 ;
1555
- int i ;
1556
-
1557
- if (touch_max == 1 )
1558
- return wacom_wac -> hid_data .tipswitch &&
1559
- !wacom_wac -> shared -> stylus_in_proximity ;
1560
-
1561
- for (i = 0 ; i < input -> mt -> num_slots ; i ++ ) {
1562
- struct input_mt_slot * ps = & input -> mt -> slots [i ];
1563
- int id = input_mt_get_value (ps , ABS_MT_TRACKING_ID );
1564
- if (id >= 0 )
1565
- count ++ ;
1566
- }
1567
-
1568
- return count ;
1569
- }
1570
-
1571
1560
static void wacom_wac_finger_report (struct hid_device * hdev ,
1572
1561
struct hid_report * report )
1573
1562
{
@@ -1582,7 +1571,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
1582
1571
input_sync (input );
1583
1572
1584
1573
/* keep touch state for pen event */
1585
- wacom_wac -> shared -> touch_down = wacom_wac_finger_count_touches (hdev );
1574
+ wacom_wac -> shared -> touch_down = wacom_wac_finger_count_touches (wacom_wac );
1586
1575
}
1587
1576
1588
1577
void wacom_wac_usage_mapping (struct hid_device * hdev ,
@@ -1642,7 +1631,6 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
1642
1631
struct input_dev * pad_input = wacom -> pad_input ;
1643
1632
unsigned char * data = wacom -> data ;
1644
1633
int i ;
1645
- int contact_with_no_pen_down_count = 0 ;
1646
1634
1647
1635
if (data [0 ] != 0x02 )
1648
1636
return 0 ;
@@ -1670,7 +1658,6 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
1670
1658
}
1671
1659
input_report_abs (input , ABS_MT_POSITION_X , x );
1672
1660
input_report_abs (input , ABS_MT_POSITION_Y , y );
1673
- contact_with_no_pen_down_count ++ ;
1674
1661
}
1675
1662
}
1676
1663
@@ -1680,20 +1667,20 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
1680
1667
input_report_key (pad_input , BTN_FORWARD , (data [1 ] & 0x04 ) != 0 );
1681
1668
input_report_key (pad_input , BTN_BACK , (data [1 ] & 0x02 ) != 0 );
1682
1669
input_report_key (pad_input , BTN_RIGHT , (data [1 ] & 0x01 ) != 0 );
1683
- wacom -> shared -> touch_down = ( contact_with_no_pen_down_count > 0 );
1670
+ wacom -> shared -> touch_down = wacom_wac_finger_count_touches ( wacom );
1684
1671
1685
1672
return 1 ;
1686
1673
}
1687
1674
1688
- static int wacom_bpt3_touch_msg (struct wacom_wac * wacom , unsigned char * data , int last_touch_count )
1675
+ static void wacom_bpt3_touch_msg (struct wacom_wac * wacom , unsigned char * data )
1689
1676
{
1690
1677
struct wacom_features * features = & wacom -> features ;
1691
1678
struct input_dev * input = wacom -> input ;
1692
1679
bool touch = data [1 ] & 0x80 ;
1693
1680
int slot = input_mt_get_slot_by_key (input , data [0 ]);
1694
1681
1695
1682
if (slot < 0 )
1696
- return 0 ;
1683
+ return ;
1697
1684
1698
1685
touch = touch && !wacom -> shared -> stylus_in_proximity ;
1699
1686
@@ -1725,9 +1712,7 @@ static int wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data, in
1725
1712
input_report_abs (input , ABS_MT_POSITION_Y , y );
1726
1713
input_report_abs (input , ABS_MT_TOUCH_MAJOR , width );
1727
1714
input_report_abs (input , ABS_MT_TOUCH_MINOR , height );
1728
- last_touch_count ++ ;
1729
1715
}
1730
- return last_touch_count ;
1731
1716
}
1732
1717
1733
1718
static void wacom_bpt3_button_msg (struct wacom_wac * wacom , unsigned char * data )
@@ -1752,7 +1737,6 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
1752
1737
unsigned char * data = wacom -> data ;
1753
1738
int count = data [1 ] & 0x07 ;
1754
1739
int i ;
1755
- int contact_with_no_pen_down_count = 0 ;
1756
1740
1757
1741
if (data [0 ] != 0x02 )
1758
1742
return 0 ;
@@ -1763,15 +1747,13 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
1763
1747
int msg_id = data [offset ];
1764
1748
1765
1749
if (msg_id >= 2 && msg_id <= 17 )
1766
- contact_with_no_pen_down_count =
1767
- wacom_bpt3_touch_msg (wacom , data + offset ,
1768
- contact_with_no_pen_down_count );
1750
+ wacom_bpt3_touch_msg (wacom , data + offset );
1769
1751
else if (msg_id == 128 )
1770
1752
wacom_bpt3_button_msg (wacom , data + offset );
1771
1753
1772
1754
}
1773
1755
input_mt_sync_frame (input );
1774
- wacom -> shared -> touch_down = ( contact_with_no_pen_down_count > 0 );
1756
+ wacom -> shared -> touch_down = wacom_wac_finger_count_touches ( wacom );
1775
1757
1776
1758
return 1 ;
1777
1759
}
0 commit comments