@@ -1811,7 +1811,9 @@ int wacom_equivalent_usage(int usage)
18111811 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
18121812 usage == WACOM_HID_WD_TOUCHRING ||
18131813 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1814- usage == WACOM_HID_WD_REPORT_VALID ) {
1814+ usage == WACOM_HID_WD_REPORT_VALID ||
1815+ usage == WACOM_HID_WD_BARRELSWITCH3 ||
1816+ usage == WACOM_HID_WD_SEQUENCENUMBER ) {
18151817 return usage ;
18161818 }
18171819
@@ -2196,8 +2198,11 @@ static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
21962198 if (!(features -> quirks & WACOM_QUIRK_AESPEN ) &&
21972199 wacom_wac -> hid_data .barrelswitch &&
21982200 wacom_wac -> hid_data .barrelswitch2 &&
2199- wacom_wac -> hid_data .serialhi )
2201+ wacom_wac -> hid_data .serialhi &&
2202+ !wacom_wac -> hid_data .barrelswitch3 ) {
22002203 input_set_capability (input , EV_KEY , BTN_STYLUS3 );
2204+ features -> quirks |= WACOM_QUIRK_PEN_BUTTON3 ;
2205+ }
22012206}
22022207
22032208static void wacom_wac_pen_usage_mapping (struct hid_device * hdev ,
@@ -2261,6 +2266,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22612266 features -> quirks |= WACOM_QUIRK_TOOLSERIAL ;
22622267 wacom_map_usage (input , usage , field , EV_MSC , MSC_SERIAL , 0 );
22632268 break ;
2269+ case HID_DG_SCANTIME :
2270+ wacom_map_usage (input , usage , field , EV_MSC , MSC_TIMESTAMP , 0 );
2271+ break ;
22642272 case WACOM_HID_WD_SENSE :
22652273 features -> quirks |= WACOM_QUIRK_SENSE ;
22662274 wacom_map_usage (input , usage , field , EV_KEY , BTN_TOOL_PEN , 0 );
@@ -2274,6 +2282,11 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
22742282 input_set_capability (input , EV_KEY , BTN_TOOL_AIRBRUSH );
22752283 wacom_map_usage (input , usage , field , EV_ABS , ABS_WHEEL , 0 );
22762284 break ;
2285+ case WACOM_HID_WD_BARRELSWITCH3 :
2286+ wacom_wac -> hid_data .barrelswitch3 = true;
2287+ wacom_map_usage (input , usage , field , EV_KEY , BTN_STYLUS3 , 0 );
2288+ features -> quirks &= ~WACOM_QUIRK_PEN_BUTTON3 ;
2289+ break ;
22772290 }
22782291}
22792292
@@ -2390,6 +2403,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
23902403 case WACOM_HID_WD_REPORT_VALID :
23912404 wacom_wac -> is_invalid_bt_frame = !value ;
23922405 return ;
2406+ case WACOM_HID_WD_BARRELSWITCH3 :
2407+ wacom_wac -> hid_data .barrelswitch3 = value ;
2408+ return ;
2409+ case WACOM_HID_WD_SEQUENCENUMBER :
2410+ if (wacom_wac -> hid_data .sequence_number != value )
2411+ hid_warn (hdev , "Dropped %hu packets" , value - wacom_wac -> hid_data .sequence_number );
2412+ wacom_wac -> hid_data .sequence_number = value + 1 ;
2413+ return ;
23932414 }
23942415
23952416 /* send pen events only when touch is up or forced out
@@ -2442,12 +2463,15 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
24422463
24432464 if (!delay_pen_events (wacom_wac ) && wacom_wac -> tool [0 ]) {
24442465 int id = wacom_wac -> id [0 ];
2445- int sw_state = wacom_wac -> hid_data .barrelswitch |
2446- (wacom_wac -> hid_data .barrelswitch2 << 1 );
2447-
2448- input_report_key (input , BTN_STYLUS , sw_state == 1 );
2449- input_report_key (input , BTN_STYLUS2 , sw_state == 2 );
2450- input_report_key (input , BTN_STYLUS3 , sw_state == 3 );
2466+ if (wacom_wac -> features .quirks & WACOM_QUIRK_PEN_BUTTON3 &&
2467+ wacom_wac -> hid_data .barrelswitch & wacom_wac -> hid_data .barrelswitch2 ) {
2468+ wacom_wac -> hid_data .barrelswitch = 0 ;
2469+ wacom_wac -> hid_data .barrelswitch2 = 0 ;
2470+ wacom_wac -> hid_data .barrelswitch3 = 1 ;
2471+ }
2472+ input_report_key (input , BTN_STYLUS , wacom_wac -> hid_data .barrelswitch );
2473+ input_report_key (input , BTN_STYLUS2 , wacom_wac -> hid_data .barrelswitch2 );
2474+ input_report_key (input , BTN_STYLUS3 , wacom_wac -> hid_data .barrelswitch3 );
24512475
24522476 /*
24532477 * Non-USI EMR tools should have their IDs mangled to
@@ -2529,6 +2553,9 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
25292553 field -> logical_maximum = 255 ;
25302554 }
25312555 break ;
2556+ case HID_DG_SCANTIME :
2557+ wacom_map_usage (input , usage , field , EV_MSC , MSC_TIMESTAMP , 0 );
2558+ break ;
25322559 }
25332560}
25342561
0 commit comments