Lines Matching refs:usage
56 #define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
57 #define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
58 #define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
59 #define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
61 #define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, &max, EV_ABS, (c))
62 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, &max, EV_KEY, (c))
64 static bool match_scancode(struct hid_usage *usage, unsigned int cur_idx, unsigned int scancode)
66 return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
69 static bool match_keycode(struct hid_usage *usage, unsigned int cur_idx, unsigned int keycode)
74 return (usage->type == EV_KEY && usage->code == keycode);
77 static bool match_index(struct hid_usage *usage, unsigned int cur_idx, unsigned int idx)
82 typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage, unsigned int cur_idx, unsigned int val);
89 struct hid_usage *usage;
96 usage = report->field[i]->usage + j;
97 if (usage->type == EV_KEY || usage->type == 0) {
98 if (match(usage, cur_idx, value)) {
102 return usage;
116 struct hid_usage *usage;
120 usage = hidinput_find_key(hid, match_index, ke->index, index);
122 usage = hidinput_find_key(hid, match_scancode, scancode, index);
124 usage = NULL;
127 return usage;
133 struct hid_usage *usage;
136 usage = hidinput_locate_usage(hid, ke, &index);
137 if (usage) {
138 ke->keycode = usage->type == EV_KEY ? usage->code : KEY_RESERVED;
140 scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE);
152 struct hid_usage *usage;
154 usage = hidinput_locate_usage(hid, ke, NULL);
155 if (usage) {
156 *old_keycode = usage->type == EV_KEY ? usage->code : KEY_RESERVED;
157 usage->code = ke->keycode;
160 set_bit(usage->code, dev->keybit);
161 dbg_hid("Assigned keycode %d to HID usage code %x\n", usage->code, usage->hid);
538 static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, struct hid_usage *usage)
557 if (field->report_type == HID_OUTPUT_REPORT && (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
562 int ret = device->driver->input_mapping(device, hidinput, field, usage, &bit, &max);
571 switch (usage->hid & HID_USAGE_PAGE) {
578 if ((usage->hid & HID_USAGE) < 0x100) {
579 if (!hid_keyboard[usage->hid & HID_USAGE]) {
582 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
590 code = ((usage->hid - 1) & HID_USAGE);
632 switch (usage->hid & 0xffff) {
654 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
655 switch (usage->hid & 0xf) {
707 if ((usage->hid & 0xf0) == 0xb0) { /* SC - Display */
708 switch (usage->hid & 0xf) {
728 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
729 switch (usage->hid) {
731 usage->hat_dir = 1;
734 usage->hat_dir = 0x5;
737 usage->hat_dir = 0x3;
740 usage->hat_dir = 0x7;
753 switch (usage->hid) {
754 /* These usage IDs map directly to the usage codes. */
762 map_rel(usage->hid & 0xf);
764 map_abs_clear(usage->hid & 0xf);
773 map_abs(usage->hid & 0xf);
779 map_rel(usage->hid & 0xf);
781 map_abs(usage->hid & 0xf);
786 usage->hat_min = field->logical_minimum;
787 usage->hat_max = field->logical_maximum;
814 switch (usage->hid & 0xffff) { /* HID-Value: */
861 switch (usage->hid & 0xff) {
890 usage->type = EV_PWR;
919 * Actual eraser (BTN_TOOL_RUBBER) is set by Invert usage when
931 usage->type = EV_MSC;
932 usage->code = MSC_SERIAL;
943 switch (usage->hid & HID_USAGE) {
1001 switch (usage->hid & HID_USAGE) {
1511 switch (usage->hid) {
1514 usage->type = EV_PWR;
1523 switch (usage->hid & HID_USAGE) {
1567 switch (usage->hid & HID_USAGE) {
1597 switch (usage->hid & HID_USAGE) {
1630 if (device->driver->input_mapped && device->driver->input_mapped(device, hidinput, field, usage, &bit, &max) < 0) {
1633 * of the usage is desired.
1638 set_bit(usage->type, input->evbit);
1655 while (usage->code <= max && test_and_set_bit(usage->code, bit)) {
1657 usage->code = find_next_zero_bit(bit, max + 1, usage->code);
1664 if (usage->code > max) {
1668 if (usage->type == EV_ABS) {
1672 if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
1678 input_set_abs_params(input, usage->code, a, b, (b - a) >> 0x8, (b - a) >> 0x4);
1680 input_set_abs_params(input, usage->code, a, b, 0, 0);
1683 input_abs_set_res(input, usage->code, hidinput_calc_abs_res(field, usage->code));
1686 if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0) {
1691 if (usage->type == EV_ABS && (usage->hat_min < usage->hat_max || usage->hat_dir)) {
1693 for (i = usage->code; i < usage->code + 0x2 && i <= max; i++) {
1697 if (usage->hat_dir && !field->dpad) {
1698 field->dpad = usage->code;
1702 /* for those devices which produce Consumer volume usage as relative,
1706 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->code == ABS_VOLUME)) {
1711 if (usage->type == EV_KEY) {
1719 usage->type = 0;
1720 usage->code = 0;
1723 static void hidinput_handle_scroll(struct hid_usage *usage, struct input_dev *input, __s32 value)
1732 if (usage->code == REL_WHEEL_HI_RES) {
1744 hi_res = value * 0x78 / usage->resolution_multiplier;
1746 usage->wheel_accumulated += hi_res;
1747 lo_res = usage->wheel_accumulated / 0x78;
1749 usage->wheel_accumulated -= lo_res * 0x78;
1753 input_event(input, EV_REL, usage->code, hi_res);
1756 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
1761 if (!usage->type) {
1765 if (usage->type == EV_PWR) {
1776 if (usage->type == EV_ABS &&
1777 (((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X) ||
1778 ((*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y))) {
1782 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
1783 int hat_dir = usage->hat_dir;
1785 hat_dir = (value - usage->hat_min) * 0x8 / (usage->hat_max - usage->hat_min + 1) + 1;
1790 input_event(input, usage->type, usage->code, hid_hat_to_axis[hat_dir].x);
1791 input_event(input, usage->type, usage->code + 1, hid_hat_to_axis[hat_dir].y);
1795 if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */
1800 if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */
1802 input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
1805 input_event(input, usage->type, usage->code, 0);
1806 input_event(input, usage->type, BTN_TOOL_RUBBER, 0);
1810 if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */
1816 if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
1821 if (usage->hid == (HID_UP_PID | 0x7fUL)) {
1826 if ((usage->type == EV_KEY) && (usage->code == 0)) { /* Key 0 is "unassigned", not KEY_UNKNOWN */
1830 if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES || usage->code == REL_HWHEEL_HI_RES)) {
1831 hidinput_handle_scroll(usage, input, value);
1835 if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->code == ABS_VOLUME)) {
1880 (field->flags & HID_MAIN_ITEM_VARIABLE) && usage->usage_index < field->maxusage &&
1881 value == field->value[usage->usage_index]) {
1885 /* report the usage code as scancode if the key status has changed */
1886 if (usage->type == EV_KEY && (!test_bit(usage->code, input->key)) == value) {
1887 input_event(input, EV_MSC, MSC_SCAN, usage->hid);
1890 input_event(input, usage->type, usage->code, value);
1892 if ((field->flags & HID_MAIN_ITEM_RELATIVE) && usage->type == EV_KEY && value) {
1894 input_event(input, usage->type, usage->code, 0);
1920 if ((*field)->usage[j].type == type && (*field)->usage[j].code == code) {
1941 if (field->usage[j].type == EV_LED) {
1963 if (field->usage[j].type == EV_LED && field->value[j]) {
2065 struct hid_usage *usage;
2086 usage = &report->field[i]->usage[j];
2088 if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER) {
2147 struct hid_usage *usage;
2159 usage = &rep->field[i]->usage[j];
2162 if (usage->hid == HID_DC_BATTERYSTRENGTH) {
2167 drv->feature_mapping(hid, rep->field[i], usage);
2371 hidinput_configure_usage(hidinput, report->field[i], report->field[i]->usage + j);
2399 if (IS_INPUT_APPLICATION(col->usage)) {