Lines Matching refs:usage
63 #define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
64 #define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
65 #define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
66 #define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
68 #define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
70 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
73 static bool match_scancode(struct hid_usage *usage, in match_scancode() argument
76 return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode; in match_scancode()
79 static bool match_keycode(struct hid_usage *usage, in match_keycode() argument
85 return (usage->type == EV_KEY && usage->code == keycode); in match_keycode()
88 static bool match_index(struct hid_usage *usage, in match_index() argument
94 typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage,
104 struct hid_usage *usage; in hidinput_find_key() local
110 usage = report->field[i]->usage + j; in hidinput_find_key()
111 if (usage->type == EV_KEY || usage->type == 0) { in hidinput_find_key()
112 if (match(usage, cur_idx, value)) { in hidinput_find_key()
115 return usage; in hidinput_find_key()
130 struct hid_usage *usage; in hidinput_locate_usage() local
134 usage = hidinput_find_key(hid, match_index, ke->index, index); in hidinput_locate_usage()
136 usage = hidinput_find_key(hid, match_scancode, scancode, index); in hidinput_locate_usage()
138 usage = NULL; in hidinput_locate_usage()
140 return usage; in hidinput_locate_usage()
147 struct hid_usage *usage; in hidinput_getkeycode() local
150 usage = hidinput_locate_usage(hid, ke, &index); in hidinput_getkeycode()
151 if (usage) { in hidinput_getkeycode()
152 ke->keycode = usage->type == EV_KEY ? in hidinput_getkeycode()
153 usage->code : KEY_RESERVED; in hidinput_getkeycode()
155 scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE); in hidinput_getkeycode()
169 struct hid_usage *usage; in hidinput_setkeycode() local
171 usage = hidinput_locate_usage(hid, ke, NULL); in hidinput_setkeycode()
172 if (usage) { in hidinput_setkeycode()
173 *old_keycode = usage->type == EV_KEY ? in hidinput_setkeycode()
174 usage->code : KEY_RESERVED; in hidinput_setkeycode()
175 usage->code = ke->keycode; in hidinput_setkeycode()
178 set_bit(usage->code, dev->keybit); in hidinput_setkeycode()
180 usage->code, usage->hid); in hidinput_setkeycode()
405 if (field->usage->hid != HID_DC_BATTERYSTRENGTH) in hidinput_setup_battery()
489 struct hid_usage *usage) in hidinput_configure_usage() argument
507 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) { in hidinput_configure_usage()
513 usage, &bit, &max); in hidinput_configure_usage()
520 switch (usage->hid & HID_USAGE_PAGE) { in hidinput_configure_usage()
527 if ((usage->hid & HID_USAGE) < 256) { in hidinput_configure_usage()
528 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore; in hidinput_configure_usage()
529 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]); in hidinput_configure_usage()
536 code = ((usage->hid - 1) & HID_USAGE); in hidinput_configure_usage()
567 switch (usage->hid & 0xffff) { in hidinput_configure_usage()
578 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ in hidinput_configure_usage()
579 switch (usage->hid & 0xf) { in hidinput_configure_usage()
600 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */ in hidinput_configure_usage()
601 switch (usage->hid) { in hidinput_configure_usage()
602 case HID_GD_UP: usage->hat_dir = 1; break; in hidinput_configure_usage()
603 case HID_GD_DOWN: usage->hat_dir = 5; break; in hidinput_configure_usage()
604 case HID_GD_RIGHT: usage->hat_dir = 3; break; in hidinput_configure_usage()
605 case HID_GD_LEFT: usage->hat_dir = 7; break; in hidinput_configure_usage()
616 switch (usage->hid) { in hidinput_configure_usage()
621 map_rel(usage->hid & 0xf); in hidinput_configure_usage()
623 map_abs_clear(usage->hid & 0xf); in hidinput_configure_usage()
628 map_rel(usage->hid & 0xf); in hidinput_configure_usage()
630 map_abs(usage->hid & 0xf); in hidinput_configure_usage()
634 usage->hat_min = field->logical_minimum; in hidinput_configure_usage()
635 usage->hat_max = field->logical_maximum; in hidinput_configure_usage()
648 switch (usage->hid & 0xffff) { /* HID-Value: */ in hidinput_configure_usage()
666 switch (usage->hid & 0xff) { in hidinput_configure_usage()
716 usage->type = EV_MSC; in hidinput_configure_usage()
717 usage->code = MSC_SERIAL; in hidinput_configure_usage()
727 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
750 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
929 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
948 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
966 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
992 hidinput, field, usage, &bit, &max) < 0) in hidinput_configure_usage()
995 set_bit(usage->type, input->evbit); in hidinput_configure_usage()
997 while (usage->code <= max && test_and_set_bit(usage->code, bit)) in hidinput_configure_usage()
998 usage->code = find_next_zero_bit(bit, max + 1, usage->code); in hidinput_configure_usage()
1000 if (usage->code > max) in hidinput_configure_usage()
1004 if (usage->type == EV_ABS) { in hidinput_configure_usage()
1009 if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) { in hidinput_configure_usage()
1015 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); in hidinput_configure_usage()
1016 else input_set_abs_params(input, usage->code, a, b, 0, 0); in hidinput_configure_usage()
1018 input_abs_set_res(input, usage->code, in hidinput_configure_usage()
1019 hidinput_calc_abs_res(field, usage->code)); in hidinput_configure_usage()
1022 if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0) in hidinput_configure_usage()
1026 if (usage->type == EV_ABS && in hidinput_configure_usage()
1027 (usage->hat_min < usage->hat_max || usage->hat_dir)) { in hidinput_configure_usage()
1029 for (i = usage->code; i < usage->code + 2 && i <= max; i++) { in hidinput_configure_usage()
1033 if (usage->hat_dir && !field->dpad) in hidinput_configure_usage()
1034 field->dpad = usage->code; in hidinput_configure_usage()
1041 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) && in hidinput_configure_usage()
1042 (usage->code == ABS_VOLUME)) { in hidinput_configure_usage()
1047 if (usage->type == EV_KEY) { in hidinput_configure_usage()
1057 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, _… in hidinput_hid_event() argument
1067 if (!usage->type) in hidinput_hid_event()
1070 if (usage->hat_min < usage->hat_max || usage->hat_dir) { in hidinput_hid_event()
1071 int hat_dir = usage->hat_dir; in hidinput_hid_event()
1073 hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1; in hidinput_hid_event()
1075 input_event(input, usage->type, usage->code , hid_hat_to_axis[hat_dir].x); in hidinput_hid_event()
1076 input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y); in hidinput_hid_event()
1080 if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */ in hidinput_hid_event()
1085 if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */ in hidinput_hid_event()
1087 input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1); in hidinput_hid_event()
1090 input_event(input, usage->type, usage->code, 0); in hidinput_hid_event()
1091 input_event(input, usage->type, BTN_TOOL_RUBBER, 0); in hidinput_hid_event()
1095 if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */ in hidinput_hid_event()
1101 if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */ in hidinput_hid_event()
1106 if (usage->hid == (HID_UP_PID | 0x7fUL)) { in hidinput_hid_event()
1111 if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */ in hidinput_hid_event()
1114 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) && in hidinput_hid_event()
1115 (usage->code == ABS_VOLUME)) { in hidinput_hid_event()
1158 usage->usage_index < field->maxusage && in hidinput_hid_event()
1159 value == field->value[usage->usage_index]) in hidinput_hid_event()
1163 if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value) in hidinput_hid_event()
1164 input_event(input, EV_MSC, MSC_SCAN, usage->hid); in hidinput_hid_event()
1166 input_event(input, usage->type, usage->code, value); in hidinput_hid_event()
1168 if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY)) in hidinput_hid_event()
1169 input_event(input, usage->type, usage->code, 0); in hidinput_hid_event()
1193 if ((*field)->usage[j].type == type && (*field)->usage[j].code == code) in hidinput_find_field()
1213 if (field->usage[j].type == EV_LED) in hidinput_get_led_field()
1234 if (field->usage[j].type == EV_LED && in hidinput_count_leds()
1348 rep->field[i]->usage + j); in report_features()
1467 if (IS_INPUT_APPLICATION(col->usage)) in hidinput_connect()
1496 report->field[i]->usage + j); in hidinput_connect()