Lines Matching refs:usage
52 __u32 usage; /* the HID usage associated */
56 unsigned int slot_overwrite; /* for globals: allows to set the usage
80 .usage = HID_DG_ERASER,
83 .usage = HID_DG_INVERT,
86 .usage = HID_DG_TIPSWITCH,
89 .usage = HID_DG_TIPPRESSURE,
92 .usage = HID_DG_INRANGE,
96 #define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
97 #define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
98 #define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
99 #define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
100 #define map_msc(c) hid_map_usage(hidinput, usage, &bit, &max, EV_MSC, (c))
102 #define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
104 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
107 static bool match_scancode(struct hid_usage *usage,
110 return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
113 static bool match_keycode(struct hid_usage *usage,
119 return (usage->type == EV_KEY && usage->code == keycode);
122 static bool match_index(struct hid_usage *usage,
128 typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage,
138 struct hid_usage *usage;
144 usage = report->field[i]->usage + j;
145 if (usage->type == EV_KEY || usage->type == 0) {
146 if (match(usage, cur_idx, value)) {
149 return usage;
164 struct hid_usage *usage;
168 usage = hidinput_find_key(hid, match_index, ke->index, index);
170 usage = hidinput_find_key(hid, match_scancode, scancode, index);
172 usage = NULL;
174 return usage;
181 struct hid_usage *usage;
184 usage = hidinput_locate_usage(hid, ke, &index);
185 if (usage) {
186 ke->keycode = usage->type == EV_KEY ?
187 usage->code : KEY_RESERVED;
189 scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE);
203 struct hid_usage *usage;
205 usage = hidinput_locate_usage(hid, ke, NULL);
206 if (usage) {
207 *old_keycode = usage->type == EV_KEY ?
208 usage->code : KEY_RESERVED;
209 usage->type = EV_KEY;
210 usage->code = ke->keycode;
213 set_bit(usage->code, dev->keybit);
214 dbg_hid("Assigned keycode %d to HID usage code %x\n",
215 usage->code, usage->hid);
643 unsigned int usage, int value)
645 switch (usage) {
671 unsigned int usage, int value)
678 unsigned int type, unsigned int usage)
682 collection = &device->collection[field->usage->collection_index];
684 return collection->type == type && collection->usage == usage;
688 struct hid_usage *usage, unsigned int usage_index)
708 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
714 if (usage->hid == hidinput_usages_priorities[i].usage) {
736 usage, &bit, &max);
743 switch (usage->hid & HID_USAGE_PAGE) {
750 if ((usage->hid & HID_USAGE) < 256) {
751 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore;
752 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
759 code = ((usage->hid - 1) & HID_USAGE);
801 switch (usage->hid & 0xffff) {
812 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
813 switch (usage->hid & 0xf) {
834 if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
835 switch (usage->hid & 0xf) {
842 if ((usage->hid & 0xf0) == 0xb0) { /* SC - Display */
843 switch (usage->hid & 0xf) {
859 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
860 switch (usage->hid) {
861 case HID_GD_UP: usage->hat_dir = 1; break;
862 case HID_GD_DOWN: usage->hat_dir = 5; break;
863 case HID_GD_RIGHT: usage->hat_dir = 3; break;
864 case HID_GD_LEFT: usage->hat_dir = 7; break;
875 switch (usage->hid) {
876 /* These usage IDs map directly to the usage codes. */
880 map_rel(usage->hid & 0xf);
882 map_abs_clear(usage->hid & 0xf);
890 map_abs(usage->hid & 0xf);
895 map_rel(usage->hid & 0xf);
897 map_abs(usage->hid & 0xf);
901 usage->hat_min = field->logical_minimum;
902 usage->hat_max = field->logical_maximum;
925 switch (usage->hid & 0xffff) { /* HID-Value: */
948 switch (usage->hid & 0xff) {
992 usage->type = EV_PWR;
1047 switch (usage->hid & HID_USAGE) {
1070 switch (usage->hid & HID_USAGE) {
1264 switch (usage->hid) {
1267 usage->type = EV_PWR;
1273 switch (usage->hid) {
1276 usage->type = EV_PWR;
1279 usage->type = EV_PWR;
1284 switch (usage->hid & HID_USAGE) {
1296 switch (usage->hid & HID_USAGE) {
1315 switch (usage->hid & HID_USAGE) {
1338 switch (usage->hid & HID_USAGE) {
1368 device->driver->input_mapped(device, hidinput, field, usage,
1372 * of the usage is desired.
1377 set_bit(usage->type, input->evbit);
1394 while (usage->code <= max && test_and_set_bit(usage->code, bit)) {
1396 usage->code = find_next_zero_bit(bit,
1398 usage->code);
1405 if (usage->code > max)
1408 if (usage->type == EV_ABS) {
1413 if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
1419 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4);
1420 else input_set_abs_params(input, usage->code, a, b, 0, 0);
1422 input_abs_set_res(input, usage->code,
1423 hidinput_calc_abs_res(field, usage->code));
1426 if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0)
1430 if (usage->type == EV_ABS &&
1431 (usage->hat_min < usage->hat_max || usage->hat_dir)) {
1433 for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
1437 if (usage->hat_dir && !field->dpad)
1438 field->dpad = usage->code;
1441 /* for those devices which produce Consumer volume usage as relative,
1445 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
1446 (usage->code == ABS_VOLUME)) {
1451 if (usage->type == EV_KEY) {
1459 usage->type = 0;
1460 usage->code = 0;
1463 static void hidinput_handle_scroll(struct hid_usage *usage,
1473 if (usage->code == REL_WHEEL_HI_RES)
1484 hi_res = value * 120/usage->resolution_multiplier;
1486 usage->wheel_accumulated += hi_res;
1487 lo_res = usage->wheel_accumulated/120;
1489 usage->wheel_accumulated -= lo_res * 120;
1492 input_event(input, EV_REL, usage->code, hi_res);
1523 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
1529 if (!usage->type)
1532 if (usage->type == EV_PWR) {
1533 bool handled = hidinput_set_battery_charge_status(hid, usage->hid, value);
1546 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
1547 int hat_dir = usage->hat_dir;
1549 hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1;
1551 input_event(input, usage->type, usage->code , hid_hat_to_axis[hat_dir].x);
1552 input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
1580 switch (usage->hid) {
1630 report->tool = usage->code;
1635 hid_report_release_tool(report, input, usage->code);
1674 switch (usage->type) {
1676 if (usage->code == 0) /* Key 0 is "unassigned", not KEY_UNKNOWN */
1681 if (usage->code == REL_WHEEL_HI_RES ||
1682 usage->code == REL_HWHEEL_HI_RES) {
1683 hidinput_handle_scroll(usage, input, value);
1690 usage->code == ABS_VOLUME) {
1703 } else if (((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X) ||
1704 ((*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y))
1722 usage->usage_index < field->maxusage &&
1723 value == field->value[usage->usage_index])
1726 /* report the usage code as scancode if the key status has changed */
1727 if (usage->type == EV_KEY &&
1728 (!test_bit(usage->code, input->key)) == value)
1729 input_event(input, EV_MSC, MSC_SCAN, usage->hid);
1731 input_event(input, usage->type, usage->code, value);
1734 usage->type == EV_KEY && value) {
1736 input_event(input, usage->type, usage->code, 0);
1762 if ((*field)->usage[j].type == type && (*field)->usage[j].code == code)
1781 if (field->usage[j].type == EV_LED)
1802 if (field->usage[j].type == EV_LED &&
1900 struct hid_usage *usage;
1921 usage = &report->field[i]->usage[j];
1923 if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
1983 struct hid_usage *usage;
1994 usage = &rep->field[i]->usage[j];
1997 if (usage->hid == HID_DC_BATTERYSTRENGTH)
2002 drv->feature_mapping(hid, rep->field[i], usage);
2225 /* ignore fields without usage */
2232 if (prev_collection_index != field->usage->collection_index) {
2233 prev_collection_index = field->usage->collection_index;
2241 if (slot_collection_index == field->usage->collection_index) {
2248 if (field->usage[j].hid == HID_DG_CONTACTID) {
2249 slot_collection_index = field->usage->collection_index;
2266 report->field[i]->usage + j,
2294 if (IS_INPUT_APPLICATION(col->usage))