@@ -569,6 +569,16 @@ static void hidinput_update_battery(struct hid_device *dev, int value)
569569}
570570#endif /* CONFIG_HID_BATTERY_STRENGTH */
571571
572+ static bool hidinput_field_in_collection (struct hid_device * device , struct hid_field * field ,
573+ unsigned int type , unsigned int usage )
574+ {
575+ struct hid_collection * collection ;
576+
577+ collection = & device -> collection [field -> usage -> collection_index ];
578+
579+ return collection -> type == type && collection -> usage == usage ;
580+ }
581+
572582static void hidinput_configure_usage (struct hid_input * hidinput , struct hid_field * field ,
573583 struct hid_usage * usage )
574584{
@@ -634,6 +644,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
634644 else
635645 code += BTN_TRIGGER_HAPPY - 0x10 ;
636646 break ;
647+ case HID_CP_CONSUMER_CONTROL :
648+ if (hidinput_field_in_collection (device , field ,
649+ HID_COLLECTION_NAMED_ARRAY ,
650+ HID_CP_PROGRAMMABLEBUTTONS )) {
651+ if (code <= 0x1d )
652+ code += KEY_MACRO1 ;
653+ else
654+ code += BTN_TRIGGER_HAPPY - 0x1e ;
655+ } else {
656+ goto ignore ;
657+ }
658+ break ;
637659 default :
638660 switch (field -> physical ) {
639661 case HID_GD_MOUSE :
@@ -1318,12 +1340,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
13181340 return ;
13191341 }
13201342
1321- if (usage -> hid == ( HID_UP_DIGITIZER | 0x003c )) { /* Invert */
1343+ if (usage -> hid == HID_DG_INVERT ) {
13221344 * quirks = value ? (* quirks | HID_QUIRK_INVERT ) : (* quirks & ~HID_QUIRK_INVERT );
13231345 return ;
13241346 }
13251347
1326- if (usage -> hid == ( HID_UP_DIGITIZER | 0x0032 )) { /* InRange */
1348+ if (usage -> hid == HID_DG_INRANGE ) {
13271349 if (value ) {
13281350 input_event (input , usage -> type , (* quirks & HID_QUIRK_INVERT ) ? BTN_TOOL_RUBBER : usage -> code , 1 );
13291351 return ;
@@ -1333,7 +1355,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
13331355 return ;
13341356 }
13351357
1336- if (usage -> hid == ( HID_UP_DIGITIZER | 0x0030 ) && (* quirks & HID_QUIRK_NOTOUCH )) { /* Pressure */
1358+ if (usage -> hid == HID_DG_TIPPRESSURE && (* quirks & HID_QUIRK_NOTOUCH )) {
13371359 int a = field -> logical_minimum ;
13381360 int b = field -> logical_maximum ;
13391361 input_event (input , EV_KEY , BTN_TOUCH , value > a + ((b - a ) >> 3 ));
0 commit comments