@@ -1372,6 +1372,117 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
1372
1372
}
1373
1373
}
1374
1374
1375
+ static void wacom_wac_finger_usage_mapping (struct hid_device * hdev ,
1376
+ struct hid_field * field , struct hid_usage * usage )
1377
+ {
1378
+ struct wacom * wacom = hid_get_drvdata (hdev );
1379
+ struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
1380
+ struct input_dev * input = wacom_wac -> input ;
1381
+ unsigned touch_max = wacom_wac -> features .touch_max ;
1382
+
1383
+ switch (usage -> hid ) {
1384
+ case HID_GD_X :
1385
+ if (touch_max == 1 )
1386
+ wacom_map_usage (wacom , usage , field , EV_ABS , ABS_X , 4 );
1387
+ else
1388
+ wacom_map_usage (wacom , usage , field , EV_ABS ,
1389
+ ABS_MT_POSITION_X , 4 );
1390
+ break ;
1391
+ case HID_GD_Y :
1392
+ if (touch_max == 1 )
1393
+ wacom_map_usage (wacom , usage , field , EV_ABS , ABS_Y , 4 );
1394
+ else
1395
+ wacom_map_usage (wacom , usage , field , EV_ABS ,
1396
+ ABS_MT_POSITION_Y , 4 );
1397
+ break ;
1398
+ case HID_DG_CONTACTID :
1399
+ input_mt_init_slots (input , wacom_wac -> features .touch_max ,
1400
+ INPUT_MT_DIRECT );
1401
+ break ;
1402
+ case HID_DG_INRANGE :
1403
+ break ;
1404
+ case HID_DG_INVERT :
1405
+ break ;
1406
+ case HID_DG_TIPSWITCH :
1407
+ wacom_map_usage (wacom , usage , field , EV_KEY , BTN_TOUCH , 0 );
1408
+ break ;
1409
+ }
1410
+ }
1411
+
1412
+ static int wacom_wac_finger_event (struct hid_device * hdev ,
1413
+ struct hid_field * field , struct hid_usage * usage , __s32 value )
1414
+ {
1415
+ struct wacom * wacom = hid_get_drvdata (hdev );
1416
+ struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
1417
+
1418
+ switch (usage -> hid ) {
1419
+ case HID_GD_X :
1420
+ wacom_wac -> hid_data .x = value ;
1421
+ break ;
1422
+ case HID_GD_Y :
1423
+ wacom_wac -> hid_data .y = value ;
1424
+ break ;
1425
+ case HID_DG_CONTACTID :
1426
+ wacom_wac -> hid_data .id = value ;
1427
+ break ;
1428
+ case HID_DG_TIPSWITCH :
1429
+ wacom_wac -> hid_data .tipswitch = value ;
1430
+ break ;
1431
+ }
1432
+
1433
+
1434
+ return 0 ;
1435
+ }
1436
+
1437
+ static void wacom_wac_finger_mt_report (struct wacom_wac * wacom_wac ,
1438
+ struct input_dev * input , bool touch )
1439
+ {
1440
+ int slot ;
1441
+ struct hid_data * hid_data = & wacom_wac -> hid_data ;
1442
+
1443
+ slot = input_mt_get_slot_by_key (input , hid_data -> id );
1444
+
1445
+ input_mt_slot (input , slot );
1446
+ input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
1447
+ if (touch ) {
1448
+ input_report_abs (input , ABS_MT_POSITION_X , hid_data -> x );
1449
+ input_report_abs (input , ABS_MT_POSITION_Y , hid_data -> y );
1450
+ }
1451
+ input_mt_sync_frame (input );
1452
+ }
1453
+
1454
+ static void wacom_wac_finger_single_touch_report (struct wacom_wac * wacom_wac ,
1455
+ struct input_dev * input , bool touch )
1456
+ {
1457
+ struct hid_data * hid_data = & wacom_wac -> hid_data ;
1458
+
1459
+ if (touch ) {
1460
+ input_report_abs (input , ABS_X , hid_data -> x );
1461
+ input_report_abs (input , ABS_Y , hid_data -> y );
1462
+ }
1463
+ input_report_key (input , BTN_TOUCH , touch );
1464
+ }
1465
+
1466
+ static void wacom_wac_finger_report (struct hid_device * hdev ,
1467
+ struct hid_report * report )
1468
+ {
1469
+ struct wacom * wacom = hid_get_drvdata (hdev );
1470
+ struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
1471
+ struct input_dev * input = wacom_wac -> input ;
1472
+ bool touch = wacom_wac -> hid_data .tipswitch &&
1473
+ !wacom_wac -> shared -> stylus_in_proximity ;
1474
+ unsigned touch_max = wacom_wac -> features .touch_max ;
1475
+
1476
+ if (touch_max > 1 )
1477
+ wacom_wac_finger_mt_report (wacom_wac , input , touch );
1478
+ else
1479
+ wacom_wac_finger_single_touch_report (wacom_wac , input , touch );
1480
+ input_sync (input );
1481
+
1482
+ /* keep touch state for pen event */
1483
+ wacom_wac -> shared -> touch_down = touch ;
1484
+ }
1485
+
1375
1486
#define WACOM_PEN_FIELD (f ) (((f)->logical == HID_DG_STYLUS) || \
1376
1487
((f)->physical == HID_DG_STYLUS))
1377
1488
#define WACOM_FINGER_FIELD (f ) (((f)->logical == HID_DG_FINGER) || \
@@ -1389,6 +1500,9 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
1389
1500
1390
1501
if (WACOM_PEN_FIELD (field ))
1391
1502
return wacom_wac_pen_usage_mapping (hdev , field , usage );
1503
+
1504
+ if (WACOM_FINGER_FIELD (field ))
1505
+ return wacom_wac_finger_usage_mapping (hdev , field , usage );
1392
1506
}
1393
1507
1394
1508
int wacom_wac_event (struct hid_device * hdev , struct hid_field * field ,
@@ -1402,6 +1516,9 @@ int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
1402
1516
if (WACOM_PEN_FIELD (field ))
1403
1517
return wacom_wac_pen_event (hdev , field , usage , value );
1404
1518
1519
+ if (WACOM_FINGER_FIELD (field ))
1520
+ return wacom_wac_finger_event (hdev , field , usage , value );
1521
+
1405
1522
return 0 ;
1406
1523
}
1407
1524
@@ -1416,6 +1533,9 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
1416
1533
1417
1534
if (WACOM_PEN_FIELD (field ))
1418
1535
return wacom_wac_pen_report (hdev , report );
1536
+
1537
+ if (WACOM_FINGER_FIELD (field ))
1538
+ return wacom_wac_finger_report (hdev , report );
1419
1539
}
1420
1540
1421
1541
static int wacom_bpt_touch (struct wacom_wac * wacom )
0 commit comments