Lines Matching refs:usage
51 #define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
52 #define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
53 #define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
54 #define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
56 #define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
58 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
61 static bool match_scancode(struct hid_usage *usage,
64 return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
67 static bool match_keycode(struct hid_usage *usage,
73 return (usage->type == EV_KEY && usage->code == keycode);
76 static bool match_index(struct hid_usage *usage,
82 typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage,
92 struct hid_usage *usage;
98 usage = report->field[i]->usage + j;
99 if (usage->type == EV_KEY || usage->type == 0) {
100 if (match(usage, cur_idx, value)) {
103 return usage;
118 struct hid_usage *usage;
122 usage = hidinput_find_key(hid, match_index, ke->index, index);
124 usage = hidinput_find_key(hid, match_scancode, scancode, index);
126 usage = NULL;
128 return usage;
135 struct hid_usage *usage;
138 usage = hidinput_locate_usage(hid, ke, &index);
139 if (usage) {
140 ke->keycode = usage->type == EV_KEY ?
141 usage->code : KEY_RESERVED;
143 scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE);
157 struct hid_usage *usage;
159 usage = hidinput_locate_usage(hid, ke, NULL);
160 if (usage) {
161 *old_keycode = usage->type == EV_KEY ?
162 usage->code : KEY_RESERVED;
163 usage->code = ke->keycode;
166 set_bit(usage->code, dev->keybit);
167 dbg_hid("Assigned keycode %d to HID usage code %x\n",
168 usage->code, usage->hid);
567 struct hid_usage *usage)
585 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
591 usage, &bit, &max);
598 switch (usage->hid & HID_USAGE_PAGE) {
605 if ((usage->hid & HID_USAGE) < 256) {
606 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore;
607 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
614 code = ((usage->hid - 1) & HID_USAGE);
645 switch (usage->hid & 0xffff) {
656 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
657 switch (usage->hid & 0xf) {
678 if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
679 switch (usage->hid & 0xf) {
686 if ((usage->hid & 0xf0) == 0xb0) { /* SC - Display */
687 switch (usage->hid & 0xf) {
703 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
704 switch (usage->hid) {
705 case HID_GD_UP: usage->hat_dir = 1; break;
706 case HID_GD_DOWN: usage->hat_dir = 5; break;
707 case HID_GD_RIGHT: usage->hat_dir = 3; break;
708 case HID_GD_LEFT: usage->hat_dir = 7; break;
719 switch (usage->hid) {
720 /* These usage IDs map directly to the usage codes. */
724 map_rel(usage->hid & 0xf);
726 map_abs_clear(usage->hid & 0xf);
734 map_abs(usage->hid & 0xf);
739 map_rel(usage->hid & 0xf);
741 map_abs(usage->hid & 0xf);
745 usage->hat_min = field->logical_minimum;
746 usage->hat_max = field->logical_maximum;
768 switch (usage->hid & 0xffff) { /* HID-Value: */
791 switch (usage->hid & 0xff) {
814 usage->type = EV_PWR;
843 * Actual eraser (BTN_TOOL_RUBBER) is set by Invert usage when
855 usage->type = EV_MSC;
856 usage->code = MSC_SERIAL;
866 switch (usage->hid & HID_USAGE) {
889 switch (usage->hid & HID_USAGE) {
1079 switch (usage->hid) {
1082 usage->type = EV_PWR;
1089 switch (usage->hid & HID_USAGE) {
1108 switch (usage->hid & HID_USAGE) {
1131 switch (usage->hid & HID_USAGE) {
1161 device->driver->input_mapped(device, hidinput, field, usage,
1165 * of the usage is desired.
1170 set_bit(usage->type, input->evbit);
1187 while (usage->code <= max && test_and_set_bit(usage->code, bit)) {
1189 usage->code = find_next_zero_bit(bit,
1191 usage->code);
1198 if (usage->code > max)
1201 if (usage->type == EV_ABS) {
1206 if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
1212 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4);
1213 else input_set_abs_params(input, usage->code, a, b, 0, 0);
1215 input_abs_set_res(input, usage->code,
1216 hidinput_calc_abs_res(field, usage->code));
1219 if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0)
1223 if (usage->type == EV_ABS &&
1224 (usage->hat_min < usage->hat_max || usage->hat_dir)) {
1226 for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
1230 if (usage->hat_dir && !field->dpad)
1231 field->dpad = usage->code;
1234 /* for those devices which produce Consumer volume usage as relative,
1238 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
1239 (usage->code == ABS_VOLUME)) {
1244 if (usage->type == EV_KEY) {
1252 usage->type = 0;
1253 usage->code = 0;
1256 static void hidinput_handle_scroll(struct hid_usage *usage,
1266 if (usage->code == REL_WHEEL_HI_RES)
1277 hi_res = value * 120/usage->resolution_multiplier;
1279 usage->wheel_accumulated += hi_res;
1280 lo_res = usage->wheel_accumulated/120;
1282 usage->wheel_accumulated -= lo_res * 120;
1285 input_event(input, EV_REL, usage->code, hi_res);
1288 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
1293 if (!usage->type)
1296 if (usage->type == EV_PWR) {
1306 if (usage->type == EV_ABS &&
1307 (((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X) ||
1308 ((*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y))) {
1312 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
1313 int hat_dir = usage->hat_dir;
1315 hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
1317 input_event(input, usage->type, usage->code , hid_hat_to_axis[hat_dir].x);
1318 input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
1322 if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */
1327 if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */
1329 input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
1332 input_event(input, usage->type, usage->code, 0);
1333 input_event(input, usage->type, BTN_TOOL_RUBBER, 0);
1337 if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */
1343 if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
1348 if (usage->hid == (HID_UP_PID | 0x7fUL)) {
1353 if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
1356 if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES ||
1357 usage->code == REL_HWHEEL_HI_RES)) {
1358 hidinput_handle_scroll(usage, input, value);
1362 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
1363 (usage->code == ABS_VOLUME)) {
1414 usage->usage_index < field->maxusage &&
1415 value == field->value[usage->usage_index])
1418 /* report the usage code as scancode if the key status has changed */
1419 if (usage->type == EV_KEY &&
1420 (!test_bit(usage->code, input->key)) == value)
1421 input_event(input, EV_MSC, MSC_SCAN, usage->hid);
1423 input_event(input, usage->type, usage->code, value);
1426 usage->type == EV_KEY && value) {
1428 input_event(input, usage->type, usage->code, 0);
1453 if ((*field)->usage[j].type == type && (*field)->usage[j].code == code)
1473 if (field->usage[j].type == EV_LED)
1494 if (field->usage[j].type == EV_LED &&
1592 struct hid_usage *usage;
1613 usage = &report->field[i]->usage[j];
1615 if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
1675 struct hid_usage *usage;
1686 usage = &rep->field[i]->usage[j];
1689 if (usage->hid == HID_DC_BATTERYSTRENGTH)
1694 drv->feature_mapping(hid, rep->field[i], usage);
1888 report->field[i]->usage + j);
1915 if (IS_INPUT_APPLICATION(col->usage))