34
34
*/
35
35
#define WACOM_CONTACT_AREA_SCALE 2607
36
36
37
+ static bool touch_arbitration = 1 ;
38
+ module_param (touch_arbitration , bool , 0644 );
39
+ MODULE_PARM_DESC (touch_arbitration , " on (Y) off (N)" );
40
+
37
41
static void wacom_report_numbered_buttons (struct input_dev * input_dev ,
38
42
int button_count , int mask );
39
43
@@ -882,6 +886,16 @@ static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
882
886
wacom_schedule_work (wacom_wac , WACOM_WORKER_REMOTE );
883
887
}
884
888
889
+ static inline bool report_touch_events (struct wacom_wac * wacom )
890
+ {
891
+ return (touch_arbitration ? !wacom -> shared -> stylus_in_proximity : 1 );
892
+ }
893
+
894
+ static inline bool delay_pen_events (struct wacom_wac * wacom )
895
+ {
896
+ return (wacom -> shared -> touch_down && touch_arbitration );
897
+ }
898
+
885
899
static int wacom_intuos_general (struct wacom_wac * wacom )
886
900
{
887
901
struct wacom_features * features = & wacom -> features ;
@@ -895,7 +909,7 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
895
909
data [0 ] != WACOM_REPORT_INTUOS_PEN )
896
910
return 0 ;
897
911
898
- if (wacom -> shared -> touch_down )
912
+ if (delay_pen_events ( wacom ) )
899
913
return 1 ;
900
914
901
915
/* don't report events if we don't know the tool ID */
@@ -1155,7 +1169,7 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1155
1169
1156
1170
if (touch_max == 1 )
1157
1171
return test_bit (BTN_TOUCH , input -> key ) &&
1158
- ! wacom -> shared -> stylus_in_proximity ;
1172
+ report_touch_events ( wacom ) ;
1159
1173
1160
1174
for (i = 0 ; i < input -> mt -> num_slots ; i ++ ) {
1161
1175
struct input_mt_slot * ps = & input -> mt -> slots [i ];
@@ -1196,7 +1210,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
1196
1210
1197
1211
for (i = 0 ; i < contacts_to_send ; i ++ ) {
1198
1212
int offset = (byte_per_packet * i ) + 1 ;
1199
- bool touch = (data [offset ] & 0x1 ) && ! wacom -> shared -> stylus_in_proximity ;
1213
+ bool touch = (data [offset ] & 0x1 ) && report_touch_events ( wacom ) ;
1200
1214
int slot = input_mt_get_slot_by_key (input , data [offset + 1 ]);
1201
1215
1202
1216
if (slot < 0 )
@@ -1260,7 +1274,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
1260
1274
1261
1275
for (i = 0 ; i < contacts_to_send ; i ++ ) {
1262
1276
int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset ) * i + 3 ;
1263
- bool touch = (data [offset ] & 0x1 ) && ! wacom -> shared -> stylus_in_proximity ;
1277
+ bool touch = (data [offset ] & 0x1 ) && report_touch_events ( wacom ) ;
1264
1278
int id = get_unaligned_le16 (& data [offset + 1 ]);
1265
1279
int slot = input_mt_get_slot_by_key (input , id );
1266
1280
@@ -1294,7 +1308,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1294
1308
1295
1309
for (i = 0 ; i < 2 ; i ++ ) {
1296
1310
int p = data [1 ] & (1 << i );
1297
- bool touch = p && ! wacom -> shared -> stylus_in_proximity ;
1311
+ bool touch = p && report_touch_events ( wacom ) ;
1298
1312
1299
1313
input_mt_slot (input , i );
1300
1314
input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1318,7 +1332,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1318
1332
{
1319
1333
unsigned char * data = wacom -> data ;
1320
1334
struct input_dev * input = wacom -> touch_input ;
1321
- bool prox = ! wacom -> shared -> stylus_in_proximity ;
1335
+ bool prox = report_touch_events ( wacom ) ;
1322
1336
int x = 0 , y = 0 ;
1323
1337
1324
1338
if (wacom -> features .touch_max > 1 || len > WACOM_PKGLEN_TPC2FG )
@@ -1363,8 +1377,10 @@ static int wacom_tpc_pen(struct wacom_wac *wacom)
1363
1377
/* keep pen state for touch events */
1364
1378
wacom -> shared -> stylus_in_proximity = prox ;
1365
1379
1366
- /* send pen events only when touch is up or forced out */
1367
- if (!wacom -> shared -> touch_down ) {
1380
+ /* send pen events only when touch is up or forced out
1381
+ * or touch arbitration is off
1382
+ */
1383
+ if (!delay_pen_events (wacom )) {
1368
1384
input_report_key (input , BTN_STYLUS , data [1 ] & 0x02 );
1369
1385
input_report_key (input , BTN_STYLUS2 , data [1 ] & 0x10 );
1370
1386
input_report_abs (input , ABS_X , le16_to_cpup ((__le16 * )& data [2 ]));
@@ -1506,8 +1522,10 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1506
1522
return 0 ;
1507
1523
}
1508
1524
1509
- /* send pen events only when touch is up or forced out */
1510
- if (!usage -> type || wacom_wac -> shared -> touch_down )
1525
+ /* send pen events only when touch is up or forced out
1526
+ * or touch arbitration is off
1527
+ */
1528
+ if (!usage -> type || delay_pen_events (wacom_wac ))
1511
1529
return 0 ;
1512
1530
1513
1531
input_event (input , usage -> type , usage -> code , value );
@@ -1537,8 +1555,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
1537
1555
/* keep pen state for touch events */
1538
1556
wacom_wac -> shared -> stylus_in_proximity = prox ;
1539
1557
1540
- /* send pen events only when touch is up or forced out */
1541
- if (!wacom_wac -> shared -> touch_down ) {
1558
+ if (!delay_pen_events (wacom_wac )) {
1542
1559
input_report_key (input , BTN_TOUCH ,
1543
1560
wacom_wac -> hid_data .tipswitch );
1544
1561
input_report_key (input , wacom_wac -> tool [0 ], prox );
@@ -1609,7 +1626,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
1609
1626
struct hid_data * hid_data = & wacom_wac -> hid_data ;
1610
1627
bool mt = wacom_wac -> features .touch_max > 1 ;
1611
1628
bool prox = hid_data -> tipswitch &&
1612
- ! wacom_wac -> shared -> stylus_in_proximity ;
1629
+ report_touch_events ( wacom_wac ) ;
1613
1630
1614
1631
wacom_wac -> hid_data .num_received ++ ;
1615
1632
if (wacom_wac -> hid_data .num_received > wacom_wac -> hid_data .num_expected )
@@ -1835,15 +1852,8 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
1835
1852
1836
1853
for (i = 0 ; i < 2 ; i ++ ) {
1837
1854
int offset = (data [1 ] & 0x80 ) ? (8 * i ) : (9 * i );
1838
- bool touch = data [offset + 3 ] & 0x80 ;
1839
-
1840
- /*
1841
- * Touch events need to be disabled while stylus is
1842
- * in proximity because user's hand is resting on touchpad
1843
- * and sending unwanted events. User expects tablet buttons
1844
- * to continue working though.
1845
- */
1846
- touch = touch && !wacom -> shared -> stylus_in_proximity ;
1855
+ bool touch = report_touch_events (wacom )
1856
+ && (data [offset + 3 ] & 0x80 );
1847
1857
1848
1858
input_mt_slot (input , i );
1849
1859
input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1880,7 +1890,7 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1880
1890
if (slot < 0 )
1881
1891
return ;
1882
1892
1883
- touch = touch && ! wacom -> shared -> stylus_in_proximity ;
1893
+ touch = touch && report_touch_events ( wacom ) ;
1884
1894
1885
1895
input_mt_slot (input , slot );
1886
1896
input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1993,7 +2003,7 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
1993
2003
}
1994
2004
1995
2005
wacom -> shared -> stylus_in_proximity = prox ;
1996
- if (wacom -> shared -> touch_down )
2006
+ if (delay_pen_events ( wacom ) )
1997
2007
return 0 ;
1998
2008
1999
2009
if (prox ) {
@@ -2087,7 +2097,7 @@ static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2087
2097
2088
2098
for (id = 0 ; id < wacom -> features .touch_max ; id ++ ) {
2089
2099
valid = !!(prefix & BIT (id )) &&
2090
- ! wacom -> shared -> stylus_in_proximity ;
2100
+ report_touch_events ( wacom ) ;
2091
2101
2092
2102
input_mt_slot (input , id );
2093
2103
input_mt_report_slot_state (input , MT_TOOL_FINGER , valid );
@@ -2109,8 +2119,7 @@ static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2109
2119
input_report_key (input , BTN_RIGHT , prefix & 0x80 );
2110
2120
2111
2121
/* keep touch state for pen event */
2112
- wacom -> shared -> touch_down = !!prefix &&
2113
- !wacom -> shared -> stylus_in_proximity ;
2122
+ wacom -> shared -> touch_down = !!prefix && report_touch_events (wacom );
2114
2123
2115
2124
return 1 ;
2116
2125
}
0 commit comments