Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-usb-hid.c
Line
Count
Source
1
/* packet-usb-hid.c
2
 *
3
 * USB HID dissector
4
 * By Adam Nielsen <a.nielsen@shikadi.net> 2009
5
 *
6
 * SPDX-License-Identifier: GPL-2.0-or-later
7
 */
8
9
/* See specification at
10
 * https://www.usb.org/sites/default/files/hid1_11.pdf
11
 * https://www.usb.org/sites/default/files/hut1_22.pdf
12
 */
13
14
#include "config.h"
15
16
17
#include <epan/packet.h>
18
#include "wsutil/sign_ext.h"
19
#include "wsutil/pint.h"
20
#include "packet-usb.h"
21
#include "packet-usb-hid.h"
22
#include "packet-btsdp.h"
23
24
25
void proto_register_usb_hid(void);
26
void proto_reg_handoff_usb_hid(void);
27
28
/* Dissector handles */
29
static dissector_handle_t usb_hid_control_handle;
30
static dissector_handle_t usb_hid_interrupt_handle;
31
static dissector_handle_t usb_hid_descr_handle;
32
33
/* protocols and header fields */
34
static int proto_usb_hid;
35
static int hf_usb_hid_item_bSize;
36
static int hf_usb_hid_item_bType;
37
static int hf_usb_hid_mainitem_bTag;
38
static int hf_usb_hid_globalitem_bTag;
39
static int hf_usb_hid_localitem_bTag;
40
static int hf_usb_hid_longitem_bTag;
41
static int hf_usb_hid_item_bDataSize;
42
static int hf_usb_hid_item_bLongItemTag;
43
static int hf_usb_hid_item_unk_data;
44
45
static int hf_usb_hid_mainitem_bit0;
46
static int hf_usb_hid_mainitem_bit1;
47
static int hf_usb_hid_mainitem_bit2;
48
static int hf_usb_hid_mainitem_bit3;
49
static int hf_usb_hid_mainitem_bit4;
50
static int hf_usb_hid_mainitem_bit5;
51
static int hf_usb_hid_mainitem_bit6;
52
static int hf_usb_hid_mainitem_bit7;
53
static int hf_usb_hid_mainitem_bit7_input;
54
static int hf_usb_hid_mainitem_bit8;
55
static int hf_usb_hid_mainitem_colltype;
56
57
static int hf_usb_hid_globalitem_usage;
58
static int hf_usb_hid_globalitem_log_min;
59
static int hf_usb_hid_globalitem_log_max;
60
static int hf_usb_hid_globalitem_phy_min;
61
static int hf_usb_hid_globalitem_phy_max;
62
static int hf_usb_hid_globalitem_unit_exp;
63
static int hf_usb_hid_globalitem_unit_sys;
64
static int hf_usb_hid_globalitem_unit_len;
65
static int hf_usb_hid_globalitem_unit_mass;
66
static int hf_usb_hid_globalitem_unit_time;
67
static int hf_usb_hid_globalitem_unit_temp;
68
static int hf_usb_hid_globalitem_unit_current;
69
static int hf_usb_hid_globalitem_unit_brightness;
70
static int hf_usb_hid_globalitem_report_size;
71
static int hf_usb_hid_globalitem_report_id;
72
static int hf_usb_hid_globalitem_report_count;
73
static int hf_usb_hid_globalitem_push;
74
static int hf_usb_hid_globalitem_pop;
75
76
static int hf_usb_hid_localitem_usage;
77
static int hf_usb_hid_localitem_usage_min;
78
static int hf_usb_hid_localitem_usage_max;
79
static int hf_usb_hid_localitem_desig_index;
80
static int hf_usb_hid_localitem_desig_min;
81
static int hf_usb_hid_localitem_desig_max;
82
static int hf_usb_hid_localitem_string_index;
83
static int hf_usb_hid_localitem_string_min;
84
static int hf_usb_hid_localitem_string_max;
85
static int hf_usb_hid_localitem_delimiter;
86
87
static int ett_usb_hid_report;
88
static int ett_usb_hid_item_header;
89
static int ett_usb_hid_wValue;
90
static int ett_usb_hid_descriptor;
91
static int ett_usb_hid_data;
92
static int ett_usb_hid_unknown_data;
93
static int ett_usb_hid_array;
94
95
static int hf_usb_hid_request;
96
static int hf_usb_hid_value;
97
static int hf_usb_hid_index;
98
static int hf_usb_hid_length;
99
static int hf_usb_hid_report_type;
100
static int hf_usb_hid_report_id;
101
static int hf_usb_hid_duration;
102
static int hf_usb_hid_zero;
103
104
static int hf_usb_hid_bcdHID;
105
static int hf_usb_hid_bCountryCode;
106
static int hf_usb_hid_bNumDescriptors;
107
static int hf_usb_hid_bDescriptorIndex;
108
static int hf_usb_hid_bDescriptorType;
109
static int hf_usb_hid_wInterfaceNumber;
110
static int hf_usb_hid_wDescriptorLength;
111
112
static int hf_usbhid_boot_report_keyboard_modifier_right_gui;
113
static int hf_usbhid_boot_report_keyboard_modifier_right_alt;
114
static int hf_usbhid_boot_report_keyboard_modifier_right_shift;
115
static int hf_usbhid_boot_report_keyboard_modifier_right_ctrl;
116
static int hf_usbhid_boot_report_keyboard_modifier_left_gui;
117
static int hf_usbhid_boot_report_keyboard_modifier_left_alt;
118
static int hf_usbhid_boot_report_keyboard_modifier_left_shift;
119
static int hf_usbhid_boot_report_keyboard_modifier_left_ctrl;
120
static int hf_usbhid_boot_report_keyboard_reserved;
121
static int hf_usbhid_boot_report_keyboard_keycode_1;
122
static int hf_usbhid_boot_report_keyboard_keycode_2;
123
static int hf_usbhid_boot_report_keyboard_keycode_3;
124
static int hf_usbhid_boot_report_keyboard_keycode_4;
125
static int hf_usbhid_boot_report_keyboard_keycode_5;
126
static int hf_usbhid_boot_report_keyboard_keycode_6;
127
static int hf_usbhid_boot_report_keyboard_leds_constants;
128
static int hf_usbhid_boot_report_keyboard_leds_kana;
129
static int hf_usbhid_boot_report_keyboard_leds_compose;
130
static int hf_usbhid_boot_report_keyboard_leds_scroll_lock;
131
static int hf_usbhid_boot_report_keyboard_leds_caps_lock;
132
static int hf_usbhid_boot_report_keyboard_leds_num_lock;
133
static int hf_usbhid_boot_report_mouse_button_8;
134
static int hf_usbhid_boot_report_mouse_button_7;
135
static int hf_usbhid_boot_report_mouse_button_6;
136
static int hf_usbhid_boot_report_mouse_button_5;
137
static int hf_usbhid_boot_report_mouse_button_4;
138
static int hf_usbhid_boot_report_mouse_button_middle;
139
static int hf_usbhid_boot_report_mouse_button_right;
140
static int hf_usbhid_boot_report_mouse_button_left;
141
static int hf_usbhid_boot_report_mouse_x_displacement;
142
static int hf_usbhid_boot_report_mouse_y_displacement;
143
static int hf_usbhid_boot_report_mouse_horizontal_scroll_wheel;
144
static int hf_usbhid_boot_report_mouse_vertical_scroll_wheel;
145
static int hf_usbhid_data;
146
static int hf_usbhid_unknown_data;
147
static int hf_usbhid_vendor_data;
148
static int hf_usbhid_report_id;
149
static int hf_usbhid_padding;
150
static int hf_usbhid_axis_x;
151
static int hf_usbhid_axis_y;
152
static int hf_usbhid_axis_z;
153
static int hf_usbhid_axis_rx;
154
static int hf_usbhid_axis_ry;
155
static int hf_usbhid_axis_rz;
156
static int hf_usbhid_axis_slider;
157
static int hf_usbhid_axis_vx;
158
static int hf_usbhid_axis_vy;
159
static int hf_usbhid_axis_vz;
160
static int hf_usbhid_axis_vbrx;
161
static int hf_usbhid_axis_vbry;
162
static int hf_usbhid_axis_vbrz;
163
static int hf_usbhid_axis_vno;
164
static int hf_usbhid_button;
165
static int hf_usbhid_key;
166
static int hf_usbhid_array;
167
static int hf_usbhid_array_usage;
168
169
static const true_false_string tfs_mainitem_bit0 = {"Constant", "Data"};
170
static const true_false_string tfs_mainitem_bit1 = {"Variable", "Array"};
171
static const true_false_string tfs_mainitem_bit2 = {"Relative", "Absolute"};
172
static const true_false_string tfs_mainitem_bit3 = {"Wrap", "No Wrap"};
173
static const true_false_string tfs_mainitem_bit4 = {"Non Linear", "Linear"};
174
static const true_false_string tfs_mainitem_bit5 = {"No Preferred", "Preferred State"};
175
static const true_false_string tfs_mainitem_bit6 = {"Null state", "No Null position"};
176
static const true_false_string tfs_mainitem_bit7 = {"Volatile", "Non Volatile"};
177
static const true_false_string tfs_mainitem_bit8 = {"Buffered Bytes", "Bit Field"};
178
179
180
struct usb_hid_global_state {
181
    unsigned int usage_page;
182
};
183
184
static wmem_tree_t *report_descriptors;
185
186
187
/* local items */
188
0
#define HID_USAGE_MIN       (1 << 0)
189
#define HID_USAGE_MAX       (1 << 1)
190
191
/* global items */
192
0
#define HID_REPORT_ID       (1 << 2)
193
0
#define HID_REPORT_COUNT    (1 << 3)
194
0
#define HID_REPORT_SIZE     (1 << 4)
195
0
#define HID_LOGICAL_MIN     (1 << 5)
196
0
#define HID_LOGICAL_MAX     (1 << 6)
197
0
#define HID_USAGE_PAGE      (1 << 7)
198
199
/* main items */
200
#define HID_INPUT           (1 << 8)
201
#define HID_OUTPUT          (1 << 9)
202
#define HID_FEATURE         (1 << 10)
203
204
0
#define HID_EXTENDED_USAGE  (1 << 11)
205
206
/* masks */
207
208
0
#define HID_GLOBAL_MASK     (HID_REPORT_ID | \
209
0
                             HID_REPORT_COUNT | \
210
0
                             HID_REPORT_SIZE | \
211
0
                             HID_LOGICAL_MIN | \
212
0
                             HID_LOGICAL_MAX | \
213
0
                             HID_USAGE_PAGE)
214
215
0
#define HID_REQUIRED_MASK   (HID_REPORT_COUNT | \
216
0
                             HID_REPORT_SIZE | \
217
0
                             HID_LOGICAL_MIN | \
218
0
                             HID_LOGICAL_MAX)
219
220
221
#define HID_MAIN_CONSTANT       (1 << 0) /* data / constant                 */
222
0
#define HID_MAIN_TYPE           (1 << 1) /* array / variable                */
223
#define HID_MAIN_RELATIVE       (1 << 2) /* absolute / relative             */
224
#define HID_MAIN_WRAP           (1 << 3) /* no wrap / wrap                  */
225
#define HID_MAIN_NON_LINEAR     (1 << 4) /* linear / non linear             */
226
#define HID_MAIN_NO_PREFERRED   (1 << 5) /* preferred state / no preferred  */
227
#define HID_MAIN_NULL_STATE     (1 << 6) /* no null position / null state   */
228
#define HID_MAIN_BUFFERED_BYTES (1 << 8) /* bit field / buffered bytes      */
229
230
231
0
#define HID_MAIN_ARRAY          (0 << 1)
232
#define HID_MAIN_VARIABLE       (1 << 1)
233
234
235
#define HID_USAGE_UNSET         0
236
#define HID_USAGE_SINGLE        1
237
#define HID_USAGE_RANGE         2
238
239
240
0
#define USAGE_ID(usage)    (usage & 0x0000FFFF)
241
0
#define USAGE_PAGE(usage) ((usage & 0xFFFF0000) >> 16)
242
243
typedef struct _hid_field hid_field_t;
244
245
struct _hid_field {
246
    wmem_array_t   *usages;
247
248
    uint32_t        report_id;  /* optional */
249
    uint32_t        report_count;
250
    uint32_t        report_size;
251
    int32_t         logical_min;
252
    int32_t         logical_max;
253
    uint32_t        properties;
254
255
    hid_field_t *next;
256
};
257
258
259
typedef struct _report_descriptor report_descriptor_t;
260
261
struct _report_descriptor {
262
    uint16_t                bus_id;
263
    uint16_t                device_address;
264
    uint8_t                 interface;
265
266
    int                     desc_length;
267
    uint8_t                *desc_body;
268
269
    bool                    uses_report_id;
270
    wmem_array_t           *fields_in;
271
    wmem_array_t           *fields_out;
272
    /* TODO: features */
273
274
    report_descriptor_t    *next;
275
};
276
277
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_X           0x0030
278
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_Y           0x0031
279
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_Z           0x0032
280
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_RX          0x0033
281
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_RY          0x0034
282
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_RZ          0x0035
283
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_SLIDER      0x0036
284
285
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VX          0x0040
286
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VY          0x0041
287
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VZ          0x0042
288
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VBRX        0x0043
289
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VBRY        0x0044
290
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VBRZ        0x0045
291
0
#define USBHID_GENERIC_DESKTOP_CONTROLS_VNO         0x0046
292
293
/* HID class specific descriptor types */
294
0
#define USB_DT_HID        0x21
295
0
#define USB_DT_HID_REPORT 0x22
296
static const value_string hid_descriptor_type_vals[] = {
297
    {USB_DT_HID, "HID"},
298
    {USB_DT_HID_REPORT, "HID Report"},
299
    {0, NULL}
300
};
301
static value_string_ext hid_descriptor_type_vals_ext =
302
               VALUE_STRING_EXT_INIT(hid_descriptor_type_vals);
303
304
305
86.3k
#define USBHID_SIZE_MASK  0x03
306
86.3k
#define USBHID_TYPE_MASK  0x0C
307
86.3k
#define USBHID_TAG_MASK   0xF0
308
309
static const value_string usb_hid_item_bSize_vals[] = {
310
    {0, "0 bytes"},
311
    {1, "1 byte"},
312
    {2, "2 bytes"},
313
    {3, "4 bytes"},
314
    {0, NULL}
315
};
316
317
156k
#define USBHID_ITEMTYPE_MAIN    0
318
34.7k
#define USBHID_ITEMTYPE_GLOBAL  1
319
45.0k
#define USBHID_ITEMTYPE_LOCAL   2
320
#define USBHID_ITEMTYPE_LONG    3
321
static const value_string usb_hid_item_bType_vals[] = {
322
    {USBHID_ITEMTYPE_MAIN,   "Main"},
323
    {USBHID_ITEMTYPE_GLOBAL, "Global"},
324
    {USBHID_ITEMTYPE_LOCAL,  "Local"},
325
    {USBHID_ITEMTYPE_LONG,   "Long item"},
326
    {0, NULL}
327
};
328
329
2.96k
#define USBHID_MAINITEM_TAG_INPUT           8
330
5.94k
#define USBHID_MAINITEM_TAG_OUTPUT          9
331
3.34k
#define USBHID_MAINITEM_TAG_FEATURE        11
332
37.0k
#define USBHID_MAINITEM_TAG_COLLECTION     10
333
33.5k
#define USBHID_MAINITEM_TAG_ENDCOLLECTION  12
334
static const value_string usb_hid_mainitem_bTag_vals[] = {
335
    {USBHID_MAINITEM_TAG_INPUT,         "Input"},
336
    {USBHID_MAINITEM_TAG_OUTPUT,        "Output"},
337
    {USBHID_MAINITEM_TAG_FEATURE,       "Feature"},
338
    {USBHID_MAINITEM_TAG_COLLECTION,    "Collection"},
339
    {USBHID_MAINITEM_TAG_ENDCOLLECTION, "End Collection"},
340
    {0, NULL}
341
};
342
3.53k
#define USBHID_GLOBALITEM_TAG_USAGE_PAGE    0
343
741
#define USBHID_GLOBALITEM_TAG_LOG_MIN       1
344
1.79k
#define USBHID_GLOBALITEM_TAG_LOG_MAX       2
345
1.49k
#define USBHID_GLOBALITEM_TAG_PHY_MIN       3
346
1.76k
#define USBHID_GLOBALITEM_TAG_PHY_MAX       4
347
945
#define USBHID_GLOBALITEM_TAG_UNIT_EXP      5
348
900
#define USBHID_GLOBALITEM_TAG_UNIT          6
349
927
#define USBHID_GLOBALITEM_TAG_REPORT_SIZE   7
350
911
#define USBHID_GLOBALITEM_TAG_REPORT_ID     8
351
988
#define USBHID_GLOBALITEM_TAG_REPORT_COUNT  9
352
868
#define USBHID_GLOBALITEM_TAG_PUSH         10
353
920
#define USBHID_GLOBALITEM_TAG_POP          11
354
static const value_string usb_hid_globalitem_bTag_vals[] = {
355
    {USBHID_GLOBALITEM_TAG_USAGE_PAGE,   "Usage Page"},
356
    {USBHID_GLOBALITEM_TAG_LOG_MIN,      "Logical Minimum"},
357
    {USBHID_GLOBALITEM_TAG_LOG_MAX,      "Logical Maximum"},
358
    {USBHID_GLOBALITEM_TAG_PHY_MIN,      "Physical Minimum"},
359
    {USBHID_GLOBALITEM_TAG_PHY_MAX,      "Physical Maximum"},
360
    {USBHID_GLOBALITEM_TAG_UNIT_EXP,     "Unit Exponent"},
361
    {USBHID_GLOBALITEM_TAG_UNIT,         "Unit"},
362
    {USBHID_GLOBALITEM_TAG_REPORT_SIZE,  "Report Size"},
363
    {USBHID_GLOBALITEM_TAG_REPORT_ID,    "Report ID"},
364
    {USBHID_GLOBALITEM_TAG_REPORT_COUNT, "Report Count"},
365
    {USBHID_GLOBALITEM_TAG_PUSH,         "Push"},
366
    {USBHID_GLOBALITEM_TAG_POP,          "Pop"},
367
    {12, "[Reserved]"},
368
    {13, "[Reserved]"},
369
    {14, "[Reserved]"},
370
    {15, "[Reserved]"},
371
    {0, NULL}
372
};
373
9.30k
#define USBHID_LOCALITEM_TAG_USAGE          0
374
1.40k
#define USBHID_LOCALITEM_TAG_USAGE_MIN      1
375
1.53k
#define USBHID_LOCALITEM_TAG_USAGE_MAX      2
376
1.29k
#define USBHID_LOCALITEM_TAG_DESIG_INDEX    3
377
1.56k
#define USBHID_LOCALITEM_TAG_DESIG_MIN      4
378
1.08k
#define USBHID_LOCALITEM_TAG_DESIG_MAX      5
379
/* No 6 in spec */
380
949
#define USBHID_LOCALITEM_TAG_STRING_INDEX   7
381
808
#define USBHID_LOCALITEM_TAG_STRING_MIN     8
382
1.04k
#define USBHID_LOCALITEM_TAG_STRING_MAX     9
383
701
#define USBHID_LOCALITEM_TAG_DELIMITER     10 /* Also listed as reserved in spec! */
384
static const value_string usb_hid_localitem_bTag_vals[] = {
385
    {USBHID_LOCALITEM_TAG_USAGE,        "Usage"},
386
    {USBHID_LOCALITEM_TAG_USAGE_MIN,    "Usage Minimum"},
387
    {USBHID_LOCALITEM_TAG_USAGE_MAX,    "Usage Maximum"},
388
    {USBHID_LOCALITEM_TAG_DESIG_INDEX,  "Designator Index"},
389
    {USBHID_LOCALITEM_TAG_DESIG_MIN,    "Designator Minimum"},
390
    {USBHID_LOCALITEM_TAG_DESIG_MAX,    "Designator Maximum"},
391
    {USBHID_LOCALITEM_TAG_STRING_INDEX, "String Index"},
392
    {USBHID_LOCALITEM_TAG_STRING_MIN,   "String Minimum"},
393
    {USBHID_LOCALITEM_TAG_STRING_MAX,   "String Maximum"},
394
    {USBHID_LOCALITEM_TAG_DELIMITER,    "Delimiter"},
395
    {11, "[Reserved]"},
396
    {12, "[Reserved]"},
397
    {13, "[Reserved]"},
398
    {14, "[Reserved]"},
399
    {15, "[Reserved]"},
400
    {0, NULL}
401
};
402
static const value_string usb_hid_longitem_bTag_vals[] = {
403
    {15, "Long item"},
404
    {0, NULL}
405
};
406
407
static const range_string usb_hid_mainitem_colltype_vals[] = {
408
    {0x00, 0x00, "Physical"},
409
    {0x01, 0x01, "Application"},
410
    {0x02, 0x02, "Logical"},
411
    {0x03, 0x03, "Report"},
412
    {0x04, 0x04, "Named array"},
413
    {0x05, 0x05, "Usage switch"},
414
    {0x06, 0x06, "Usage modifier"},
415
    {0x07, 0x7F, "[Reserved]"},
416
    {0x80, 0xFF, "[Vendor-defined]"},
417
    {0, 0, NULL}
418
};
419
420
static const value_string usb_hid_globalitem_unit_exp_vals[] = {
421
    {0x0, "n^0"},
422
    {0x1, "n^1"},
423
    {0x2, "n^2"},
424
    {0x3, "n^3"},
425
    {0x4, "n^4"},
426
    {0x5, "n^5"},
427
    {0x6, "n^6"},
428
    {0x7, "n^7"},
429
    {0x8, "n^-8"},
430
    {0x9, "n^-7"},
431
    {0xA, "n^-6"},
432
    {0xB, "n^-5"},
433
    {0xC, "n^-4"},
434
    {0xD, "n^-3"},
435
    {0xE, "n^-2"},
436
    {0xF, "n^-1"},
437
    {0, NULL}
438
};
439
440
204
#define GENERIC_DESKTOP_CONTROLS_PAGE   0x01
441
336
#define SIMULATION_CONTROLS_PAGE        0x02
442
111
#define VR_CONTROLS_PAGE                0x03
443
204
#define SPORT_CONTROLS_PAGE             0x04
444
632
#define GAME_CONTROLS_PAGE              0x05
445
223
#define GENERIC_DEVICE_CONTROLS_PAGE    0x06
446
191
#define KEYBOARD_KEYPAD_PAGE            0x07
447
188
#define LED_PAGE                        0x08
448
895
#define BUTTON_PAGE                     0x09
449
60
#define ORDINAL_PAGE                    0x0A
450
9
#define TELEPHONY_PAGE                  0x0B
451
242
#define CONSUMER_PAGE                   0x0C
452
766
#define DIGITIZER_PAGE                  0x0D
453
388
#define HAPTICS_PAGE                    0x0E
454
51
#define PID_PAGE                        0x0F
455
78
#define UNICODE_PAGE                    0x10
456
57
#define SOC_PAGE                        0x11
457
48
#define EYE_AND_HEAD_TRACKER_PAGE       0x12
458
1
#define ALPHANUMERIC_DISPLAY_PAGE       0x14
459
278
#define SENSOR_PAGE                     0x20
460
85
#define MEDICAL_INSTRUMENTS_PAGE        0x40
461
51
#define BRAILLE_DISPLAY_PAGE            0x41
462
97
#define LIGHTING_AND_ILLUMINATION_PAGE  0x59
463
30
#define USB_MONITOR_PAGE                0x80
464
38
#define USB_ENUMERATED_VALUES_PAGE      0x81
465
56
#define VESA_VIRTUAL_CONTROLS_PAGE      0x82
466
207
#define POWER_DEVICE_PAGE               0x84
467
34
#define BATTERY_SYSTEM_PAGE             0x85
468
0
#define BARCODE_SCANNER_PAGE            0x8C
469
27
#define WEIGHING_PAGE                   0x8D
470
2
#define MSR_PAGE                        0x8E
471
#define RESERVED_POS_PAGE               0x8F
472
26
#define CAMERA_CONTROL_PAGE             0x90
473
139
#define ARCADE_PAGE                     0x91
474
#define GAMING_DEVICE_PAGE              0x92
475
0
#define FIDO_ALLIANCE_PAGE              0xF1D0
476
8.41k
#define VENDOR_PAGE_HBYTE               0xFF00
477
static const value_string usb_hid_item_usage_page_vals[] = {
478
    {0x00, "Undefined"},
479
    {GENERIC_DESKTOP_CONTROLS_PAGE,     "Generic Desktop Controls"},
480
    {SIMULATION_CONTROLS_PAGE,          "Simulation Controls"},
481
    {VR_CONTROLS_PAGE,                  "VR Controls"},
482
    {SPORT_CONTROLS_PAGE,               "Sport Controls"},
483
    {GAME_CONTROLS_PAGE,                "Game Controls"},
484
    {GENERIC_DEVICE_CONTROLS_PAGE,      "Generic Device Controls"},
485
    {KEYBOARD_KEYPAD_PAGE,              "Keyboard/Keypad"},
486
    {LED_PAGE,                          "LED"},
487
    {BUTTON_PAGE,                       "Button"},
488
    {ORDINAL_PAGE,                      "Ordinal"},
489
    {TELEPHONY_PAGE,                    "Telephony"},
490
    {CONSUMER_PAGE,                     "Consumer"},
491
    {DIGITIZER_PAGE,                    "Digitizer"},
492
    {HAPTICS_PAGE,                      "Haptics"},
493
    {PID_PAGE,                          "Physical Interface Device (PID)"},
494
    {UNICODE_PAGE,                      "Unicode"},
495
    {SOC_PAGE,                          "System-on-Chip"},
496
    {EYE_AND_HEAD_TRACKER_PAGE,         "Eye and Head Tracker"},
497
    {ALPHANUMERIC_DISPLAY_PAGE,         "Alphanumeric Display"},
498
    {SENSOR_PAGE,                       "Sensor"},
499
    {MEDICAL_INSTRUMENTS_PAGE,          "Medical Instruments"},
500
    {BRAILLE_DISPLAY_PAGE,              "Braille Display"},
501
    {LIGHTING_AND_ILLUMINATION_PAGE,    "Lighting and Illumination"},
502
    {USB_MONITOR_PAGE,                  "USB Monitor"},
503
    {USB_ENUMERATED_VALUES_PAGE,        "USB Enumerated Values"},
504
    {VESA_VIRTUAL_CONTROLS_PAGE,        "VESA Virtual Controls"},
505
    {POWER_DEVICE_PAGE,                 "Power Device"},
506
    {BATTERY_SYSTEM_PAGE,               "Battery Device"},
507
    {BARCODE_SCANNER_PAGE,              "Barcode Scanner"},
508
    {WEIGHING_PAGE,                     "Weighing"},
509
    {MSR_PAGE,                          "Magnetic Stripe Reading (MSR) Devices"},
510
    {RESERVED_POS_PAGE,                 "[Reserved Point of Sale page]"},
511
    {CAMERA_CONTROL_PAGE,               "Camera Control Page"},
512
    {ARCADE_PAGE,                       "Arcade"},
513
    {GAMING_DEVICE_PAGE,                "Gaming Device"},
514
    {FIDO_ALLIANCE_PAGE ,               "FIDO Alliance"},
515
    {0, NULL}
516
};
517
518
static const value_string usb_hid_generic_desktop_controls_usage_page_vals[] = {
519
    {0x00, "Undefined"},
520
    {0x01, "Pointer"},
521
    {0x02, "Mouse"},
522
    {0x04, "Joystick"},
523
    {0x05, "Game Pad"},
524
    {0x06, "Keyboard"},
525
    {0x07, "Keypad"},
526
    {0x08, "Multi-axis Controller"},
527
    {0x09, "Tablet PC System Controls"},
528
    {0x0A, "Water Cooling Device"},
529
    {0x0B, "Computer Chassis Device"},
530
    {0x0C, "Wireless Radio Controls"},
531
    {0x0D, "Portable Device Control"},
532
    {0x0E, "System Multi-Axis Controller"},
533
    {0x0F, "Spatial Controller"},
534
    {0x10, "Assistive Control"},
535
    {0x11, "Device Dock"},
536
    {0x12, "Dockable Device"},
537
    {0x13, "Call State Management Control"},
538
    {0x30, "X"},
539
    {0x31, "Y"},
540
    {0x32, "Z"},
541
    {0x33, "Rx"},
542
    {0x34, "Ry"},
543
    {0x35, "Rz"},
544
    {0x36, "Slider"},
545
    {0x37, "Dial"},
546
    {0x38, "Wheel"},
547
    {0x39, "Hat switch"},
548
    {0x3A, "Counted Buffer"},
549
    {0x3B, "Byte Count"},
550
    {0x3C, "Motion Wakeup"},
551
    {0x3D, "Start"},
552
    {0x3E, "Select"},
553
    {0x40, "Vx"},
554
    {0x41, "Vy"},
555
    {0x42, "Vz"},
556
    {0x43, "Vbrx"},
557
    {0x44, "Vbry"},
558
    {0x45, "Vbrz"},
559
    {0x46, "Vno"},
560
    {0x47, "Feature Notification"},
561
    {0x48, "Resolution Multiplier"},
562
    {0x49, "Qx"},
563
    {0x4A, "Qy"},
564
    {0x4B, "Qz"},
565
    {0x4C, "Qw"},
566
    {0x80, "System Control"},
567
    {0x81, "System Power Down"},
568
    {0x82, "System Sleep"},
569
    {0x83, "System Wake Up"},
570
    {0x84, "System Context Menu"},
571
    {0x85, "System Main Menu"},
572
    {0x86, "System App Menu"},
573
    {0x87, "System Menu Help"},
574
    {0x88, "System Menu Exit"},
575
    {0x89, "System Menu Select"},
576
    {0x8A, "System Menu Right"},
577
    {0x8B, "System Menu Left"},
578
    {0x8C, "System Menu Up"},
579
    {0x8D, "System Menu Down"},
580
    {0x8E, "System Cold Restart"},
581
    {0x8F, "System Warm Restart"},
582
    {0x90, "D-pad Up"},
583
    {0x91, "D-pad Down"},
584
    {0x92, "D-pad Right"},
585
    {0x93, "D-pad Left"},
586
    {0x94, "Index Trigger"},
587
    {0x95, "Palm Trigger"},
588
    {0x96, "Thumbstick"},
589
    {0x97, "System Function Shift"},
590
    {0x98, "System Function Shift Lock"},
591
    {0x99, "System Function Shift Lock Indicator"},
592
    {0x9A, "System Dismiss Notification"},
593
    {0x9B, "System Do Not Disturb"},
594
    {0xA0, "System Dock"},
595
    {0xA1, "System Undock"},
596
    {0xA2, "System Setup"},
597
    {0xA3, "System Break"},
598
    {0xA4, "System Debugger Break"},
599
    {0xA5, "Application Break"},
600
    {0xA6, "Application Debugger Break"},
601
    {0xA7, "System Speaker Mute"},
602
    {0xA8, "System Hibernate"},
603
    {0xA9, "System Microphone Mute"},
604
    {0xB0, "System Display Invert"},
605
    {0xB1, "System Display Internal"},
606
    {0xB2, "System Display External"},
607
    {0xB3, "System Display Both"},
608
    {0xB4, "System Display Dual"},
609
    {0xB5, "System Display Toggle Int/Ext"},
610
    {0xB6, "System Display Swap Primary/Secondary"},
611
    {0xB7, "System Display LCD Autoscale"},
612
    {0xC0, "Sensor Zone"},
613
    {0xC1, "RPM"},
614
    {0xC2, "Coolant Level"},
615
    {0xC3, "Coolant Critical Level"},
616
    {0xC4, "Coolant Pump"},
617
    {0xC5, "Chassis Enclosure"},
618
    {0xC6, "Wireless Radio Button"},
619
    {0xC7, "Wireless Radio LED"},
620
    {0xC8, "Wireless Radio Slider Switch"},
621
    {0xC9, "System Display Rotation Lock Button"},
622
    {0xCA, "System Display Rotation Lock Slider Switch"},
623
    {0xCB, "Control Enable"},
624
    {0xD0, "Dockable Device Unique ID"},
625
    {0xD1, "Dockable Device Vendor ID"},
626
    {0xD2, "Dockable Device Primary Usage Page"},
627
    {0xD3, "Dockable Device Primary Usage ID"},
628
    {0xD4, "Dockable Device Docking State"},
629
    {0xD5, "Dockable Device Display Occlusion"},
630
    {0xD6, "Dockable Device Object Type"},
631
    {0xE0, "Call Active LED"},
632
    {0xE1, "Call Mute Toggle"},
633
    {0xE2, "Call Mute LED"},
634
    {0, NULL}
635
};
636
static const value_string usb_hid_simulation_control_usage_page_vals[] = {
637
    {0x00, "Undefined"},
638
    {0x01, "Flight Simulation Device"},
639
    {0x02, "Automobile Simulation Device"},
640
    {0x03, "Tank Simulation Device"},
641
    {0x04, "Spaceship Simulation Device"},
642
    {0x05, "Submarine Simulation Device"},
643
    {0x06, "Sailing Simulation Device"},
644
    {0x07, "Motorcycle Simulation Device"},
645
    {0x08, "Sports Simulation Device"},
646
    {0x09, "Airplane Simulation Device"},
647
    {0x0A, "Helicopter Simulation Device"},
648
    {0x0B, "Magic Carpet Simulation Device"},
649
    {0x0C, "Bicycle Simulation Device"},
650
    {0x20, "Flight Control Stick"},
651
    {0x21, "Flight Stick"},
652
    {0x22, "Cyclic Control"},
653
    {0x23, "Cyclic Trim"},
654
    {0x24, "Flight Yoke"},
655
    {0x25, "Track Control"},
656
    {0xB0, "Aileron"},
657
    {0xB1, "Aileron Trim"},
658
    {0xB2, "Anti-Torque Control"},
659
    {0xB3, "Autopilot Enable"},
660
    {0xB4, "Chaff Release"},
661
    {0xB5, "Collective Control"},
662
    {0xB6, "Dive Brake"},
663
    {0xB7, "Electronic Countermeasures"},
664
    {0xB8, "Elevator"},
665
    {0xB9, "Elevator Trim"},
666
    {0xBA, "Rudder"},
667
    {0xBB, "Throttle"},
668
    {0xBC, "Flight Communications"},
669
    {0xBD, "Flare Release"},
670
    {0xBE, "Landing Gear"},
671
    {0xBF, "Toe Brake"},
672
    {0xC0, "Trigger"},
673
    {0xC1, "Weapons Arm"},
674
    {0xC2, "Weapons Select"},
675
    {0xC3, "Wing Flaps"},
676
    {0xC4, "Accelerator"},
677
    {0xC5, "Brake"},
678
    {0xC6, "Clutch"},
679
    {0xC7, "Shifter"},
680
    {0xC8, "Steering"},
681
    {0xC9, "Turret Direction"},
682
    {0xCA, "Barrel Elevation"},
683
    {0xCB, "Dive Plane"},
684
    {0xCC, "Ballast"},
685
    {0xCD, "Bicycle Crank"},
686
    {0xCE, "Handle Bars"},
687
    {0xCF, "Front Brake"},
688
    {0xD0, "Rear Brake"},
689
    {0, NULL}
690
};
691
static const value_string usb_hid_vr_controls_usage_page_vals[] = {
692
    {0x00, "Undefined"},
693
    {0x01, "Belt"},
694
    {0x02, "Body Suit"},
695
    {0x03, "Flexor"},
696
    {0x04, "Glove"},
697
    {0x05, "Head Tracker"},
698
    {0x06, "Head Mounted Display"},
699
    {0x07, "Hand Tracker"},
700
    {0x08, "Oculometer"},
701
    {0x09, "Vest"},
702
    {0x0A, "Animatronic Device"},
703
    {0x20, "Stereo Enable"},
704
    {0x21, "Display Enable"},
705
    {0, NULL}
706
};
707
static const value_string usb_hid_sport_controls_usage_page_vals[] = {
708
    {0x00, "Undefined"},
709
    {0x01, "Baseball Bat"},
710
    {0x02, "Golf Club"},
711
    {0x03, "Rowing Machine"},
712
    {0x04, "Treadmill"},
713
    {0x30, "Oar"},
714
    {0x31, "Slope"},
715
    {0x32, "Rate"},
716
    {0x33, "Stick Speed"},
717
    {0x34, "Stick Face Angle"},
718
    {0x35, "Stick Heel/Toe"},
719
    {0x36, "Stick Follow Through"},
720
    {0x37, "Stick Tempo"},
721
    {0x38, "Stick Type"},
722
    {0x39, "Stick Height"},
723
    {0x50, "Putter"},
724
    {0x51, "1 Iron"},
725
    {0x52, "2 Iron"},
726
    {0x53, "3 Iron"},
727
    {0x54, "4 Iron"},
728
    {0x55, "5 Iron"},
729
    {0x56, "6 Iron"},
730
    {0x57, "7 Iron"},
731
    {0x58, "8 Iron"},
732
    {0x59, "9 Iron"},
733
    {0x5A, "10 Iron"},
734
    {0x5B, "11 Iron"},
735
    {0x5C, "Sand Wedge"},
736
    {0x5D, "Loft Wedge"},
737
    {0x5E, "Power Wedge"},
738
    {0x5F, "1 Wood"},
739
    {0x60, "3 Wood"},
740
    {0x61, "5 Wood"},
741
    {0x62, "7 Wood"},
742
    {0x63, "9 Wood"},
743
    {0, NULL}
744
};
745
static const value_string usb_hid_game_controls_usage_page_vals[] = {
746
    {0x00, "Undefined"},
747
    {0x01, "3D Game Controller"},
748
    {0x02, "Pinball Device"},
749
    {0x03, "Gun Device"},
750
    {0x20, "Point of View"},
751
    {0x21, "Turn Right/Left"},
752
    {0x22, "Pitch Forward/Backward"},
753
    {0x23, "Roll Right/Left"},
754
    {0x24, "Move Right/Left"},
755
    {0x25, "Move Forward/Backward"},
756
    {0x26, "Move Up/Down"},
757
    {0x27, "Lean Right/Left"},
758
    {0x28, "Lean Forward/Backward"},
759
    {0x29, "Height of POV"},
760
    {0x2A, "Flipper"},
761
    {0x2B, "Secondary Flipper"},
762
    {0x2C, "Bump"},
763
    {0x2D, "New Game"},
764
    {0x2E, "Shoot Ball"},
765
    {0x2F, "Player"},
766
    {0x30, "Gun Bolt"},
767
    {0x31, "Gun Clip"},
768
    {0x32, "Gun Selector"},
769
    {0x33, "Gun Single Shot"},
770
    {0x34, "Gun Burst"},
771
    {0x35, "Gun Automatic"},
772
    {0x36, "Gun Safety"},
773
    {0x37, "Gamepad Fire/Jump"},
774
    {0x39, "Gamepad Trigger"},
775
    {0x3A, "Form-fitting Gamepad"},
776
    {0, NULL}
777
};
778
static const value_string usb_hid_generic_device_controls_usage_page_vals[] = {
779
    {0x00, "Undefined"},
780
    {0x01, "Background/Nonuser Controls"},
781
    {0x20, "Battery Strength"},
782
    {0x21, "Wireless Channel"},
783
    {0x22, "Wireless ID"},
784
    {0x23, "Discover Wireless Control"},
785
    {0x24, "Security Code Character Entered"},
786
    {0x25, "Security Code Character Erased"},
787
    {0x26, "Security Code Cleared"},
788
    {0x27, "Sequence ID"},
789
    {0x28, "Sequence ID Reset"},
790
    {0x29, "RF Signal Strength"},
791
    {0x2A, "Software Version"},
792
    {0x2B, "Protocol Version"},
793
    {0x2C, "Hardware Version"},
794
    {0x2D, "Major"},
795
    {0x2E, "Minor"},
796
    {0x2F, "Revision"},
797
    {0x30, "Handedness"},
798
    {0x31, "Either Hand"},
799
    {0x32, "Left Hand"},
800
    {0x33, "Right Hand"},
801
    {0x34, "Both Hands"},
802
    {0x40, "Grip Pose Offset"},
803
    {0x41, "Pointer Pose Offset"},
804
    {0, NULL}
805
};
806
static const value_string usb_hid_keyboard_keypad_usage_page_vals[] = {
807
    {0x00, "Reserved (no event indicated)"},
808
    {0x01, "Keyboard ErrorRollOver"},
809
    {0x02, "Keyboard POSTFail"},
810
    {0x03, "Keyboard ErrorUndefined"},
811
    {0x04, "Keyboard a and A"},
812
    {0x05, "Keyboard b and B"},
813
    {0x06, "Keyboard c and C"},
814
    {0x07, "Keyboard d and D"},
815
    {0x08, "Keyboard e and E"},
816
    {0x09, "Keyboard f and F"},
817
    {0x0A, "Keyboard g and G"},
818
    {0x0B, "Keyboard h and H"},
819
    {0x0C, "Keyboard i and I"},
820
    {0x0D, "Keyboard j and J"},
821
    {0x0E, "Keyboard k and K"},
822
    {0x0F, "Keyboard l and L"},
823
    {0x10, "Keyboard m and M"},
824
    {0x11, "Keyboard n and N"},
825
    {0x12, "Keyboard o and O"},
826
    {0x13, "Keyboard p and P"},
827
    {0x14, "Keyboard q and Q"},
828
    {0x15, "Keyboard r and R"},
829
    {0x16, "Keyboard s and S"},
830
    {0x17, "Keyboard t and T"},
831
    {0x18, "Keyboard u and U"},
832
    {0x19, "Keyboard v and V"},
833
    {0x1A, "Keyboard w and W"},
834
    {0x1B, "Keyboard x and X"},
835
    {0x1C, "Keyboard y and Y"},
836
    {0x1D, "Keyboard z and Z"},
837
    {0x1E, "Keyboard 1 and !"},
838
    {0x1F, "Keyboard 2 and @"},
839
    {0x20, "Keyboard 3 and #"},
840
    {0x21, "Keyboard 4 and $"},
841
    {0x22, "Keyboard 5 and %"},
842
    {0x23, "Keyboard 6 and ^"},
843
    {0x24, "Keyboard 7 and &"},
844
    {0x25, "Keyboard 8 and *"},
845
    {0x26, "Keyboard 9 and ("},
846
    {0x27, "Keyboard 0 and )"},
847
    {0x28, "Keyboard Return (ENTER)"},
848
    {0x29, "Keyboard ESCAPE"},
849
    {0x2A, "Keyboard DELETE (Backspace)"},
850
    {0x2B, "Keyboard Tab"},
851
    {0x2C, "Keyboard Spacebar"},
852
    {0x2D, "Keyboard - and (underscore)"},
853
    {0x2E, "Keyboard = and +"},
854
    {0x2F, "Keyboard [ and {"},
855
    {0x30, "Keyboard ] and }"},
856
    {0x31, "Keyboard \\ and |"},
857
    {0x32, "Keyboard Non-US # and ~"},
858
    {0x33, "Keyboard ; and :"},
859
    {0x34, "Keyboard ' and \""},
860
    {0x35, "Keyboard Grave Accent and Tilde"},
861
    {0x36, "Keyboard , and <"},
862
    {0x37, "Keyboard . and >"},
863
    {0x38, "Keyboard / and ?"},
864
    {0x39, "Keyboard Caps Lock"},
865
    {0x3A, "Keyboard F1"},
866
    {0x3B, "Keyboard F2"},
867
    {0x3C, "Keyboard F3"},
868
    {0x3D, "Keyboard F4"},
869
    {0x3E, "Keyboard F5"},
870
    {0x3F, "Keyboard F6"},
871
    {0x40, "Keyboard F7"},
872
    {0x41, "Keyboard F8"},
873
    {0x42, "Keyboard F9"},
874
    {0x43, "Keyboard F10"},
875
    {0x44, "Keyboard F11"},
876
    {0x45, "Keyboard F12"},
877
    {0x46, "Keyboard PrintScreen"},
878
    {0x47, "Keyboard Scroll Lock"},
879
    {0x48, "Keyboard Pause"},
880
    {0x49, "Keyboard Insert"},
881
    {0x4A, "Keyboard Home"},
882
    {0x4B, "Keyboard PageUp"},
883
    {0x4C, "Keyboard Delete Forward"},
884
    {0x4D, "Keyboard End"},
885
    {0x4E, "Keyboard PageDown"},
886
    {0x4F, "Keyboard RightArrow"},
887
    {0x50, "Keyboard LeftArrow"},
888
    {0x51, "Keyboard DownArrow"},
889
    {0x52, "Keyboard UpArrow"},
890
    {0x53, "Keypad Num Lock and Clear"},
891
    {0x54, "Keypad /"},
892
    {0x55, "Keypad *"},
893
    {0x56, "Keypad -"},
894
    {0x57, "Keypad +"},
895
    {0x58, "Keypad ENTER"},
896
    {0x59, "Keypad 1 and End"},
897
    {0x5A, "Keypad 2 and Down Arrow"},
898
    {0x5B, "Keypad 3 and PageDn"},
899
    {0x5C, "Keypad 4 and Left Arrow"},
900
    {0x5D, "Keypad 5"},
901
    {0x5E, "Keypad 6 and Right Arrow"},
902
    {0x5F, "Keypad 7 and Home"},
903
    {0x60, "Keypad 8 and Up Arrow"},
904
    {0x61, "Keypad 9 and PageUp"},
905
    {0x62, "Keypad 0 and Insert"},
906
    {0x63, "Keypad . and Delete"},
907
    {0x64, "Keyboard Non-US \\ and |"},
908
    {0x65, "Keyboard Application"},
909
    {0x66, "Keyboard Power"},
910
    {0x67, "Keypad ="},
911
    {0x68, "Keyboard F13"},
912
    {0x69, "Keyboard F14"},
913
    {0x6A, "Keyboard F15"},
914
    {0x6B, "Keyboard F16"},
915
    {0x6C, "Keyboard F17"},
916
    {0x6D, "Keyboard F18"},
917
    {0x6E, "Keyboard F19"},
918
    {0x6F, "Keyboard F20"},
919
    {0x70, "Keyboard F21"},
920
    {0x71, "Keyboard F22"},
921
    {0x72, "Keyboard F23"},
922
    {0x73, "Keyboard F24"},
923
    {0x74, "Keyboard Execute"},
924
    {0x75, "Keyboard Help"},
925
    {0x76, "Keyboard Menu"},
926
    {0x77, "Keyboard Select"},
927
    {0x78, "Keyboard Stop"},
928
    {0x79, "Keyboard Again"},
929
    {0x7A, "Keyboard Undo"},
930
    {0x7B, "Keyboard Cut"},
931
    {0x7C, "Keyboard Copy"},
932
    {0x7D, "Keyboard Paste"},
933
    {0x7E, "Keyboard Find"},
934
    {0x7F, "Keyboard Mute"},
935
    {0x80, "Keyboard Volume Up"},
936
    {0x81, "Keyboard Volume Down"},
937
    {0x82, "Keyboard Locking Caps Lock"},
938
    {0x83, "Keyboard Locking Num Lock"},
939
    {0x84, "Keyboard Locking Scroll Lock"},
940
    {0x85, "Keypad Comma"},
941
    {0x86, "Keypad Equal Sign"},
942
    {0x87, "Keyboard International1"},
943
    {0x88, "Keyboard International2"},
944
    {0x89, "Keyboard International3"},
945
    {0x8A, "Keyboard International4"},
946
    {0x8B, "Keyboard International5"},
947
    {0x8C, "Keyboard International6"},
948
    {0x8D, "Keyboard International7"},
949
    {0x8E, "Keyboard International8"},
950
    {0x8F, "Keyboard International9"},
951
    {0x90, "Keyboard LANG1"},
952
    {0x91, "Keyboard LANG2"},
953
    {0x92, "Keyboard LANG3"},
954
    {0x93, "Keyboard LANG4"},
955
    {0x94, "Keyboard LANG5"},
956
    {0x95, "Keyboard LANG6"},
957
    {0x96, "Keyboard LANG7"},
958
    {0x97, "Keyboard LANG8"},
959
    {0x98, "Keyboard LANG9"},
960
    {0x99, "Keyboard Alternate Erase"},
961
    {0x9A, "Keyboard SysReq/Attention"},
962
    {0x9B, "Keyboard Cancel"},
963
    {0x9C, "Keyboard Clear"},
964
    {0x9D, "Keyboard Prior"},
965
    {0x9E, "Keyboard Return"},
966
    {0x9F, "Keyboard Separator"},
967
    {0xA0, "Keyboard Out"},
968
    {0xA1, "Keyboard Oper"},
969
    {0xA2, "Keyboard Clear/Again"},
970
    {0xA3, "Keyboard CrSel/Props"},
971
    {0xA4, "Keyboard ExSel"},
972
    {0xB0, "Keypad 00"},
973
    {0xB1, "Keypad 000"},
974
    {0xB2, "Thousands Separator"},
975
    {0xB3, "Decimal Separator"},
976
    {0xB4, "Currency Unit"},
977
    {0xB5, "Currency Sub-unit"},
978
    {0xB6, "Keypad ("},
979
    {0xB7, "Keypad )"},
980
    {0xB8, "Keypad {"},
981
    {0xB9, "Keypad }"},
982
    {0xBA, "Keypad Tab"},
983
    {0xBB, "Keypad Backspace"},
984
    {0xBC, "Keypad A"},
985
    {0xBD, "Keypad B"},
986
    {0xBE, "Keypad C"},
987
    {0xBF, "Keypad D"},
988
    {0xC0, "Keypad E"},
989
    {0xC1, "Keypad F"},
990
    {0xC2, "Keypad XOR"},
991
    {0xC3, "Keypad ^"},
992
    {0xC4, "Keypad %"},
993
    {0xC5, "Keypad <"},
994
    {0xC6, "Keypad >"},
995
    {0xC7, "Keypad &"},
996
    {0xC8, "Keypad &&"},
997
    {0xC9, "Keypad |"},
998
    {0xCA, "Keypad ||"},
999
    {0xCB, "Keypad :"},
1000
    {0xCC, "Keypad #"},
1001
    {0xCD, "Keypad Space"},
1002
    {0xCE, "Keypad @"},
1003
    {0xCF, "Keypad !"},
1004
    {0xD0, "Keypad Memory Store"},
1005
    {0xD1, "Keypad Memory Recall"},
1006
    {0xD2, "Keypad Memory Clear"},
1007
    {0xD3, "Keypad Memory Add"},
1008
    {0xD4, "Keypad Memory Subtract"},
1009
    {0xD5, "Keypad Memory Multiply"},
1010
    {0xD6, "Keypad Memory Divide"},
1011
    {0xD7, "Keypad +/-"},
1012
    {0xD8, "Keypad Clear"},
1013
    {0xD9, "Keypad Clear Entry"},
1014
    {0xDA, "Keypad Binary"},
1015
    {0xDB, "Keypad Octal"},
1016
    {0xDC, "Keypad Decimal"},
1017
    {0xDD, "Keypad Hexadecimal"},
1018
    {0xE0, "Keyboard LeftControl"},
1019
    {0xE1, "Keyboard LeftShift"},
1020
    {0xE2, "Keyboard LeftAlt"},
1021
    {0xE3, "Keyboard Left GUI"},
1022
    {0xE4, "Keyboard RightControl"},
1023
    {0xE5, "Keyboard RightShift"},
1024
    {0xE6, "Keyboard RightAlt"},
1025
    {0xE7, "Keyboard Right GUI"},
1026
    {0, NULL}
1027
};
1028
static const value_string usb_hid_led_usage_page_vals[] = {
1029
    {0x00, "Undefined"},
1030
    {0x01, "Num Lock"},
1031
    {0x02, "Caps Lock"},
1032
    {0x03, "Scroll Lock"},
1033
    {0x04, "Compose"},
1034
    {0x05, "Kana"},
1035
    {0x06, "Power"},
1036
    {0x07, "Shift"},
1037
    {0x08, "Do Not Disturb"},
1038
    {0x09, "Mute"},
1039
    {0x0A, "Tone Enable"},
1040
    {0x0B, "High Cut Filter"},
1041
    {0x0C, "Low Cut Filter"},
1042
    {0x0D, "Equalizer Enable"},
1043
    {0x0E, "Sound Field On"},
1044
    {0x0F, "Surround On"},
1045
    {0x10, "Repeat"},
1046
    {0x11, "Stereo"},
1047
    {0x12, "Sampling Rate Detect"},
1048
    {0x13, "Spinning"},
1049
    {0x14, "CAV"},
1050
    {0x15, "CLV"},
1051
    {0x16, "Recording Format Detect"},
1052
    {0x17, "Off-Hook"},
1053
    {0x18, "Ring"},
1054
    {0x19, "Message Waiting"},
1055
    {0x1A, "Data Mode"},
1056
    {0x1B, "Battery Operation"},
1057
    {0x1C, "Battery OK"},
1058
    {0x1D, "Battery Low"},
1059
    {0x1E, "Speaker"},
1060
    {0x1F, "Head Set"},
1061
    {0x20, "Hold"},
1062
    {0x21, "Microphone"},
1063
    {0x22, "Coverage"},
1064
    {0x23, "Night Mode"},
1065
    {0x24, "Send Calls"},
1066
    {0x25, "Call Pickup"},
1067
    {0x26, "Conference"},
1068
    {0x27, "Stand-by"},
1069
    {0x28, "Camera On"},
1070
    {0x29, "Camera Off"},
1071
    {0x2A, "On-Line"},
1072
    {0x2B, "Off-Line"},
1073
    {0x2C, "Busy"},
1074
    {0x2D, "Ready"},
1075
    {0x2E, "Paper-Out"},
1076
    {0x2F, "Paper-Jam"},
1077
    {0x30, "Remote"},
1078
    {0x31, "Forward"},
1079
    {0x32, "Reverse"},
1080
    {0x33, "Stop"},
1081
    {0x34, "Rewind"},
1082
    {0x35, "Fast Forward"},
1083
    {0x36, "Play"},
1084
    {0x37, "Pause"},
1085
    {0x38, "Record"},
1086
    {0x39, "Error"},
1087
    {0x3A, "Usage Selected Indicator"},
1088
    {0x3B, "Usage In Use Indicator"},
1089
    {0x3C, "Usage Multi Mode Indicator"},
1090
    {0x3D, "Indicator On"},
1091
    {0x3E, "Indicator Flash"},
1092
    {0x3F, "Indicator Slow Blink"},
1093
    {0x40, "Indicator Fast Blink"},
1094
    {0x41, "Indicator Off"},
1095
    {0x42, "Flash On Time"},
1096
    {0x43, "Slow Blink On Time"},
1097
    {0x44, "Slow Blink Off Time"},
1098
    {0x45, "Fast Blink On Time"},
1099
    {0x46, "Fast Blink Off Time"},
1100
    {0x47, "Usage Indicator Color"},
1101
    {0x48, "Indicator Red"},
1102
    {0x49, "Indicator Green"},
1103
    {0x4A, "Indicator Amber"},
1104
    {0x4B, "Generic Indicator"},
1105
    {0x4C, "System Suspend"},
1106
    {0x4D, "External Power Connected"},
1107
    {0x4E, "Indicator Blue"},
1108
    {0x4F, "Indicator Orange"},
1109
    {0x50, "Good Status"},
1110
    {0x51, "Warning Status"},
1111
    {0x52, "RGB LED"},
1112
    {0x53, "Red LED Channel"},
1113
    {0x54, "Blue LED Channel"},
1114
    {0x55, "Green LED Channel"},
1115
    {0x56, "LED Intensity"},
1116
    {0x57, "System Microphone Mute"},
1117
    {0x60, "Player Indicator"},
1118
    {0x61, "Player 1"},
1119
    {0x62, "Player 2"},
1120
    {0x63, "Player 3"},
1121
    {0x64, "Player 4"},
1122
    {0x65, "Player 5"},
1123
    {0x66, "Player 6"},
1124
    {0x67, "Player 7"},
1125
    {0x68, "Player 8"},
1126
    {0, NULL}
1127
};
1128
static const value_string usb_hid_button_usage_page_vals[] = {
1129
    {0x00, "No button pressed"},
1130
    {0x01, "Button 1 (primary/trigger)"},
1131
    {0x02, "Button 2 (secondary)"},
1132
    {0x03, "Button 3 (tertiary)"},
1133
    /* Other Buttons parsed as "Button %u" in get_usage_page_item_string */
1134
    {0, NULL}
1135
};
1136
static const value_string usb_hid_ordinal_usage_page_vals[] = {
1137
    {0x00, "Reserved"},
1138
    /* Instances parsed as "Instance %u" in get_usage_page_item_string */
1139
    {0, NULL}
1140
};
1141
static const value_string usb_hid_telephony_device_usage_page_vals[] = {
1142
    {0x000, "Undefined"},
1143
    {0x001, "Phone"},
1144
    {0x002, "Answering Machine"},
1145
    {0x003, "Message Controls"},
1146
    {0x004, "Handset"},
1147
    {0x005, "Headset"},
1148
    {0x006, "Telephony Key Pad"},
1149
    {0x007, "Programmable Button"},
1150
    {0x020, "Hook Switch"},
1151
    {0x021, "Flash"},
1152
    {0x022, "Feature"},
1153
    {0x023, "Hold"},
1154
    {0x024, "Redial"},
1155
    {0x025, "Transfer"},
1156
    {0x026, "Drop"},
1157
    {0x027, "Park"},
1158
    {0x028, "Forward Calls"},
1159
    {0x029, "Alternate Function"},
1160
    {0x02A, "Line"},
1161
    {0x02B, "Speaker Phone"},
1162
    {0x02C, "Conference"},
1163
    {0x02D, "Ring Enable"},
1164
    {0x02E, "Ring Select"},
1165
    {0x02F, "Phone Mute"},
1166
    {0x030, "Caller ID"},
1167
    {0x031, "Send"},
1168
    {0x050, "Speed Dial"},
1169
    {0x051, "Store Number"},
1170
    {0x052, "Recall Number"},
1171
    {0x053, "Phone Directory"},
1172
    {0x070, "Voice Mail"},
1173
    {0x071, "Screen Calls"},
1174
    {0x072, "Do Not Disturb"},
1175
    {0x073, "Message"},
1176
    {0x074, "Answer On/Off"},
1177
    {0x090, "Inside Dial Tone"},
1178
    {0x091, "Outside Dial Tone"},
1179
    {0x092, "Inside Ring Tone"},
1180
    {0x093, "Outside Ring Tone"},
1181
    {0x094, "Priority Ring Tone"},
1182
    {0x095, "Inside Ringback"},
1183
    {0x096, "Priority Ringback"},
1184
    {0x097, "Line Busy Tone"},
1185
    {0x098, "Reorder Tone"},
1186
    {0x099, "Call Waiting Tone"},
1187
    {0x09A, "Confirmation Tone 1"},
1188
    {0x09B, "Confirmation Tone 2"},
1189
    {0x09C, "Tones Off"},
1190
    {0x09D, "Outside Ringback"},
1191
    {0x09E, "Ringer"},
1192
    {0x0B0, "Phone Key 0"},
1193
    {0x0B1, "Phone Key 1"},
1194
    {0x0B2, "Phone Key 2"},
1195
    {0x0B3, "Phone Key 3"},
1196
    {0x0B4, "Phone Key 4"},
1197
    {0x0B5, "Phone Key 5"},
1198
    {0x0B6, "Phone Key 6"},
1199
    {0x0B7, "Phone Key 7"},
1200
    {0x0B8, "Phone Key 8"},
1201
    {0x0B9, "Phone Key 9"},
1202
    {0x0BA, "Phone Key Star"},
1203
    {0x0BB, "Phone Key Pound"},
1204
    {0x0BC, "Phone Key A"},
1205
    {0x0BD, "Phone Key B"},
1206
    {0x0BE, "Phone Key C"},
1207
    {0x0BF, "Phone Key D"},
1208
    {0x0C0, "Phone Call History Key"},
1209
    {0x0C1, "Phone Caller ID Key"},
1210
    {0x0C2, "Phone Settings Key"},
1211
    {0x0F0, "Host Control"},
1212
    {0x0F1, "Host Available"},
1213
    {0x0F2, "Host Call Active"},
1214
    {0x0F3, "Activate Handset Audio"},
1215
    {0x0F4, "Ring Type"},
1216
    {0x0F5, "Re-dialable Phone Number"},
1217
    {0x0F8, "Stop Ring Tone"},
1218
    {0x0F9, "PSTN Ring Tone"},
1219
    {0x0FA, "Host Ring Tone"},
1220
    {0x0FB, "Alert Sound Error"},
1221
    {0x0FC, "Alert Sound Confirm"},
1222
    {0x0FD, "Alert Sound Notification"},
1223
    {0x0FE, "Silent Ring"},
1224
    {0x108, "Email Message Waiting"},
1225
    {0x109, "Voicemail Message Waiting"},
1226
    {0x10A, "Host Hold"},
1227
    {0x110, "Incoming Call History Count"},
1228
    {0x111, "Outgoing Call History Count"},
1229
    {0x112, "Incoming Call History"},
1230
    {0x113, "Outgoing Call History"},
1231
    {0x114, "Phone Locale"},
1232
    {0x140, "Phone Time Second"},
1233
    {0x141, "Phone Time Minute"},
1234
    {0x142, "Phone Time Hour"},
1235
    {0x143, "Phone Date Day"},
1236
    {0x144, "Phone Date Month"},
1237
    {0x145, "Phone Date Year"},
1238
    {0x146, "Handset Nickname"},
1239
    {0x147, "Address Book ID"},
1240
    {0x14A, "Call Duration"},
1241
    {0x14B, "Dual Mode Phone"},
1242
    {0, NULL}
1243
};
1244
static const value_string usb_hid_consumer_usage_page_vals[] = {
1245
    {0x000, "Undefined"},
1246
    {0x001, "Consumer Control"},
1247
    {0x002, "Numeric Key Pad"},
1248
    {0x003, "Programmable Buttons"},
1249
    {0x004, "Microphone"},
1250
    {0x005, "Headphone"},
1251
    {0x006, "Graphic Equalizer"},
1252
    {0x020, "+10"},
1253
    {0x021, "+100"},
1254
    {0x022, "AM/PM"},
1255
    {0x030, "Power"},
1256
    {0x031, "Reset"},
1257
    {0x032, "Sleep"},
1258
    {0x033, "Sleep After"},
1259
    {0x034, "Sleep Mode"},
1260
    {0x035, "Illumination"},
1261
    {0x036, "Function Buttons"},
1262
    {0x040, "Menu"},
1263
    {0x041, "Menu Pick"},
1264
    {0x042, "Menu Up"},
1265
    {0x043, "Menu Down"},
1266
    {0x044, "Menu Left"},
1267
    {0x045, "Menu Right"},
1268
    {0x046, "Menu Escape"},
1269
    {0x047, "Menu Value Increase"},
1270
    {0x048, "Menu Value Decrease"},
1271
    {0x060, "Data On Screen"},
1272
    {0x061, "Closed Caption"},
1273
    {0x062, "Closed Caption Select"},
1274
    {0x063, "VCR/TV"},
1275
    {0x064, "Broadcast Mode"},
1276
    {0x065, "Snapshot"},
1277
    {0x066, "Still"},
1278
    {0x067, "Picture-in-Picture Toggle"},
1279
    {0x068, "Picture-in-Picture Swap"},
1280
    {0x069, "Red Menu Button"},
1281
    {0x06A, "Green Menu Button"},
1282
    {0x06B, "Blue Menu Button"},
1283
    {0x06C, "Yellow Menu Button"},
1284
    {0x06D, "Aspect"},
1285
    {0x06E, "3D Mode Select"},
1286
    {0x06F, "Display Brightness Increment"},
1287
    {0x070, "Display Brightness Decrement"},
1288
    {0x071, "Display Brightness"},
1289
    {0x072, "Display Backlight Toggle"},
1290
    {0x073, "Display Set Brightness to Minimum"},
1291
    {0x074, "Display Set Brightness to Maximum"},
1292
    {0x075, "Display Set Auto Brightness"},
1293
    {0x076, "Camera Access Enabled"},
1294
    {0x077, "Camera Access Disabled"},
1295
    {0x078, "Camera Access Toggle"},
1296
    {0x079, "Keyboard Brightness Increment"},
1297
    {0x07A, "Keyboard Brightness Decrement"},
1298
    {0x07B, "Keyboard Backlight Set Level"},
1299
    {0x07C, "Keyboard Backlight OOC"},
1300
    {0x07D, "Keyboard Backlight Set Minimum"},
1301
    {0x07E, "Keyboard Backlight Set Maximum"},
1302
    {0x07F, "Keyboard Backlight Auto"},
1303
    {0x080, "Selection"},
1304
    {0x081, "Assign Selection"},
1305
    {0x082, "Mode Step"},
1306
    {0x083, "Recall Last"},
1307
    {0x084, "Enter Channel"},
1308
    {0x085, "Order Movie"},
1309
    {0x086, "Channel"},
1310
    {0x087, "Media Selection"},
1311
    {0x088, "Media Select Computer"},
1312
    {0x089, "Media Select TV"},
1313
    {0x08A, "Media Select WWW"},
1314
    {0x08B, "Media Select DVD"},
1315
    {0x08C, "Media Select Telephone"},
1316
    {0x08D, "Media Select Program Guide"},
1317
    {0x08E, "Media Select Video Phone"},
1318
    {0x08F, "Media Select Games"},
1319
    {0x090, "Media Select Messages"},
1320
    {0x091, "Media Select CD"},
1321
    {0x092, "Media Select VCR"},
1322
    {0x093, "Media Select Tuner"},
1323
    {0x094, "Quit"},
1324
    {0x095, "Help"},
1325
    {0x096, "Media Select Tape"},
1326
    {0x097, "Media Select Cable"},
1327
    {0x098, "Media Select Satellite"},
1328
    {0x099, "Media Select Security"},
1329
    {0x09A, "Media Select Home"},
1330
    {0x09B, "Media Select Call"},
1331
    {0x09C, "Channel Increment"},
1332
    {0x09D, "Channel Decrement"},
1333
    {0x09E, "Media Select SAP"},
1334
    {0x0A0, "VCR Plus"},
1335
    {0x0A1, "Once"},
1336
    {0x0A2, "Daily"},
1337
    {0x0A3, "Weekly"},
1338
    {0x0A4, "Monthly"},
1339
    {0x0B0, "Play"},
1340
    {0x0B1, "Pause"},
1341
    {0x0B2, "Record"},
1342
    {0x0B3, "Fast Forward"},
1343
    {0x0B4, "Rewind"},
1344
    {0x0B5, "Scan Next Track"},
1345
    {0x0B6, "Scan Previous Track"},
1346
    {0x0B7, "Stop"},
1347
    {0x0B8, "Eject"},
1348
    {0x0B9, "Random Play"},
1349
    {0x0BA, "Select Disc"},
1350
    {0x0BB, "Enter Disc"},
1351
    {0x0BC, "Repeat"},
1352
    {0x0BD, "Tracking"},
1353
    {0x0BE, "Track Normal"},
1354
    {0x0BF, "Slow Tracking"},
1355
    {0x0C0, "Frame Forward"},
1356
    {0x0C1, "Frame Back"},
1357
    {0x0C2, "Mark"},
1358
    {0x0C3, "Clear Mark"},
1359
    {0x0C4, "Repeat From Mark"},
1360
    {0x0C5, "Return To Mark"},
1361
    {0x0C6, "Search Mark Forward"},
1362
    {0x0C7, "Search Mark Backwards"},
1363
    {0x0C8, "Counter Reset"},
1364
    {0x0C9, "Show Counter"},
1365
    {0x0CA, "Tracking Increment"},
1366
    {0x0CB, "Tracking Decrement"},
1367
    {0x0CC, "Stop/Eject"},
1368
    {0x0CD, "Play/Pause"},
1369
    {0x0CE, "Play/Skip"},
1370
    {0x0CF, "Voice Command"},
1371
    {0x0D0, "Invoke Capture Interface"},
1372
    {0x0D1, "Start or Stop Game Recording"},
1373
    {0x0D2, "Historical Game Capture"},
1374
    {0x0D3, "Capture Game Screenshot"},
1375
    {0x0D4, "Show or Hide Recording Indicator"},
1376
    {0x0D5, "Start or Stop Microphone Capture"},
1377
    {0x0D6, "Start or Stop Camera Capture"},
1378
    {0x0D7, "Start or Stop Game Broadcast"},
1379
    {0x0D8, "Start or Stop Voice Dictation Session"},
1380
    {0x0D9, "Invoke/Dismiss Emoji Picker"},
1381
    {0x0E0, "Volume"},
1382
    {0x0E1, "Balance"},
1383
    {0x0E2, "Mute"},
1384
    {0x0E3, "Bass"},
1385
    {0x0E4, "Treble"},
1386
    {0x0E5, "Bass Boost"},
1387
    {0x0E6, "Surround Mode"},
1388
    {0x0E7, "Loudness"},
1389
    {0x0E8, "MPX"},
1390
    {0x0E9, "Volume Increment"},
1391
    {0x0EA, "Volume Decrement"},
1392
    {0x0F0, "Speed Select"},
1393
    {0x0F1, "Playback Speed"},
1394
    {0x0F2, "Standard Play"},
1395
    {0x0F3, "Long Play"},
1396
    {0x0F4, "Extended Play"},
1397
    {0x0F5, "Slow"},
1398
    {0x100, "Fan Enable"},
1399
    {0x101, "Fan Speed"},
1400
    {0x102, "Light Enable"},
1401
    {0x103, "Light Illumination Level"},
1402
    {0x104, "Climate Control Enable"},
1403
    {0x105, "Room Temperature"},
1404
    {0x106, "Security Enable"},
1405
    {0x107, "Fire Alarm"},
1406
    {0x108, "Police Alarm"},
1407
    {0x109, "Proximity"},
1408
    {0x10A, "Motion"},
1409
    {0x10B, "Duress Alarm"},
1410
    {0x10C, "Holdup Alarm"},
1411
    {0x10D, "Medical Alarm"},
1412
    {0x150, "Balance Right"},
1413
    {0x151, "Balance Left"},
1414
    {0x152, "Bass Increment"},
1415
    {0x153, "Bass Decrement"},
1416
    {0x154, "Treble Increment"},
1417
    {0x155, "Treble Decrement"},
1418
    {0x160, "Speaker System"},
1419
    {0x161, "Channel Left"},
1420
    {0x162, "Channel Right"},
1421
    {0x163, "Channel Center"},
1422
    {0x164, "Channel Front"},
1423
    {0x165, "Channel Center Front"},
1424
    {0x166, "Channel Side"},
1425
    {0x167, "Channel Surround"},
1426
    {0x168, "Channel Low Frequency Enhancement"},
1427
    {0x169, "Channel Top"},
1428
    {0x16A, "Channel Unknown"},
1429
    {0x170, "Sub-channel"},
1430
    {0x171, "Sub-channel Increment"},
1431
    {0x172, "Sub-channel Decrement"},
1432
    {0x173, "Alternate Audio Increment"},
1433
    {0x174, "Alternate Audio Decrement"},
1434
    {0x180, "Application Launch Buttons"},
1435
    {0x181, "AL Launch Button Configuration Tool"},
1436
    {0x182, "AL Programmable Button Configuration"},
1437
    {0x183, "AL Consumer Control Configuration"},
1438
    {0x184, "AL Word Processor"},
1439
    {0x185, "AL Text Editor"},
1440
    {0x186, "AL Spreadsheet"},
1441
    {0x187, "AL Graphics Editor"},
1442
    {0x188, "AL Presentation App"},
1443
    {0x189, "AL Database App"},
1444
    {0x18A, "AL Email Reader"},
1445
    {0x18B, "AL Newsreader"},
1446
    {0x18C, "AL Voicemail"},
1447
    {0x18D, "AL Contacts/Address Book"},
1448
    {0x18E, "AL Calendar/Schedule"},
1449
    {0x18F, "AL Task/Project Manager"},
1450
    {0x190, "AL Log/Journal/Timecard"},
1451
    {0x191, "AL Checkbook/Finance"},
1452
    {0x192, "AL Calculator"},
1453
    {0x193, "AL A/V Capture/Playback"},
1454
    {0x194, "AL Local Machine Browser"},
1455
    {0x195, "AL LAN/WAN Browser"},
1456
    {0x196, "AL Internet Browser"},
1457
    {0x197, "AL Remote Networking/ISP Connect"},
1458
    {0x198, "AL Network Conference"},
1459
    {0x199, "AL Network Chat"},
1460
    {0x19A, "AL Telephony/Dialer"},
1461
    {0x19B, "AL Logon"},
1462
    {0x19C, "AL Logoff"},
1463
    {0x19D, "AL Logon/Logoff"},
1464
    {0x19E, "AL Terminal Lock/Screensaver"},
1465
    {0x19F, "AL Control Panel"},
1466
    {0x1A0, "AL Command Line Processor/Run"},
1467
    {0x1A1, "AL Process/Task Manager"},
1468
    {0x1A2, "AL Select Task/Application"},
1469
    {0x1A3, "AL Next Task/Application"},
1470
    {0x1A4, "AL Previous Task/Application"},
1471
    {0x1A5, "AL Preemptive Halt Task/Application"},
1472
    {0x1A6, "AL Integrated Help Center"},
1473
    {0x1A7, "AL Documents"},
1474
    {0x1A8, "AL Thesaurus"},
1475
    {0x1A9, "AL Dictionary"},
1476
    {0x1AA, "AL Desktop"},
1477
    {0x1AB, "AL Spell Check"},
1478
    {0x1AC, "AL Grammar Check"},
1479
    {0x1AD, "AL Wireless Status"},
1480
    {0x1AE, "AL Keyboard Layout"},
1481
    {0x1AF, "AL Virus Protection"},
1482
    {0x1B0, "AL Encryption"},
1483
    {0x1B1, "AL Screen Saver"},
1484
    {0x1B2, "AL Alarms"},
1485
    {0x1B3, "AL Clock"},
1486
    {0x1B4, "AL File Browser"},
1487
    {0x1B5, "AL Power Status"},
1488
    {0x1B6, "AL Image Browser"},
1489
    {0x1B7, "AL Audio Browser"},
1490
    {0x1B8, "AL Movie Browser"},
1491
    {0x1B9, "AL Digital Rights Manager"},
1492
    {0x1BA, "AL Digital Wallet"},
1493
    {0x1BC, "AL Instant Messaging"},
1494
    {0x1BD, "AL OEM Features/ Tips/Tutorial Browser"},
1495
    {0x1BE, "AL OEM Help"},
1496
    {0x1BF, "AL Online Community"},
1497
    {0x1C0, "AL Entertainment Content Browser"},
1498
    {0x1C1, "AL Online Shopping Browser"},
1499
    {0x1C2, "AL SmartCard Information/Help"},
1500
    {0x1C3, "AL Market Monitor/Finance Browser"},
1501
    {0x1C4, "AL Customized Corporate News Browser"},
1502
    {0x1C5, "AL Online Activity Browser"},
1503
    {0x1C6, "AL Research/Search Browser"},
1504
    {0x1C7, "AL Audio Player"},
1505
    {0x1C8, "AL Message Status"},
1506
    {0x1C9, "AL Contact Sync"},
1507
    {0x1CA, "AL Navigation"},
1508
    {0x1CB, "AL Context-aware Desktop Assistant"},
1509
    {0x200, "Generic GUI Application Controls"},
1510
    {0x201, "AC New"},
1511
    {0x202, "AC Open"},
1512
    {0x203, "AC Close"},
1513
    {0x204, "AC Exit"},
1514
    {0x205, "AC Maximize"},
1515
    {0x206, "AC Minimize"},
1516
    {0x207, "AC Save"},
1517
    {0x208, "AC Print"},
1518
    {0x209, "AC Properties"},
1519
    {0x21A, "AC Undo"},
1520
    {0x21B, "AC Copy"},
1521
    {0x21C, "AC Cut"},
1522
    {0x21D, "AC Paste"},
1523
    {0x21E, "AC Select All"},
1524
    {0x21F, "AC Find"},
1525
    {0x220, "AC Find and Replace"},
1526
    {0x221, "AC Search"},
1527
    {0x222, "AC Go To"},
1528
    {0x223, "AC Home"},
1529
    {0x224, "AC Back"},
1530
    {0x225, "AC Forward"},
1531
    {0x226, "AC Stop"},
1532
    {0x227, "AC Refresh"},
1533
    {0x228, "AC Previous Link"},
1534
    {0x229, "AC Next Link"},
1535
    {0x22A, "AC Bookmarks"},
1536
    {0x22B, "AC History"},
1537
    {0x22C, "AC Subscriptions"},
1538
    {0x22D, "AC Zoom In"},
1539
    {0x22E, "AC Zoom Out"},
1540
    {0x22F, "AC Zoom"},
1541
    {0x230, "AC Full Screen View"},
1542
    {0x231, "AC Normal View"},
1543
    {0x232, "AC View Toggle"},
1544
    {0x233, "AC Scroll Up"},
1545
    {0x234, "AC Scroll Down"},
1546
    {0x235, "AC Scroll"},
1547
    {0x236, "AC Pan Left"},
1548
    {0x237, "AC Pan Right"},
1549
    {0x238, "AC Pan"},
1550
    {0x239, "AC New Window"},
1551
    {0x23A, "AC Tile Horizontally"},
1552
    {0x23B, "AC Tile Vertically"},
1553
    {0x23C, "AC Format"},
1554
    {0x23D, "AC Edit"},
1555
    {0x23E, "AC Bold"},
1556
    {0x23F, "AC Italics"},
1557
    {0x240, "AC Underline"},
1558
    {0x241, "AC Strikethrough"},
1559
    {0x242, "AC Subscript"},
1560
    {0x243, "AC Superscript"},
1561
    {0x244, "AC All Caps"},
1562
    {0x245, "AC Rotate"},
1563
    {0x246, "AC Resize"},
1564
    {0x247, "AC Flip Horizontal"},
1565
    {0x248, "AC Flip Vertical"},
1566
    {0x249, "AC Mirror Horizontal"},
1567
    {0x24A, "AC Mirror Vertical"},
1568
    {0x24B, "AC Font Select"},
1569
    {0x24C, "AC Font Color"},
1570
    {0x24D, "AC Font Size"},
1571
    {0x24E, "AC Justify Left"},
1572
    {0x24F, "AC Justify Center H"},
1573
    {0x250, "AC Justify Right"},
1574
    {0x251, "AC Justify Block H"},
1575
    {0x252, "AC Justify Top"},
1576
    {0x253, "AC Justify Center V"},
1577
    {0x254, "AC Justify Bottom"},
1578
    {0x255, "AC Justify Block V"},
1579
    {0x256, "AC Indent Decrease"},
1580
    {0x257, "AC Indent Increase"},
1581
    {0x258, "AC Numbered List"},
1582
    {0x259, "AC Restart Numbering"},
1583
    {0x25A, "AC Bulleted List"},
1584
    {0x25B, "AC Promote"},
1585
    {0x25C, "AC Demote"},
1586
    {0x25D, "AC Yes"},
1587
    {0x25E, "AC No"},
1588
    {0x25F, "AC Cancel"},
1589
    {0x260, "AC Catalog"},
1590
    {0x261, "AC Buy/Checkout"},
1591
    {0x262, "AC Add to Cart"},
1592
    {0x263, "AC Expand"},
1593
    {0x264, "AC Expand All"},
1594
    {0x265, "AC Collapse"},
1595
    {0x266, "AC Collapse All"},
1596
    {0x267, "AC Print Preview"},
1597
    {0x268, "AC Paste Special"},
1598
    {0x269, "AC Insert Mode"},
1599
    {0x26A, "AC Delete"},
1600
    {0x26B, "AC Lock"},
1601
    {0x26C, "AC Unlock"},
1602
    {0x26D, "AC Protect"},
1603
    {0x26E, "AC Unprotect"},
1604
    {0x26F, "AC Attach Comment"},
1605
    {0x270, "AC Delete Comment"},
1606
    {0x271, "AC View Comment"},
1607
    {0x272, "AC Select Word"},
1608
    {0x273, "AC Select Sentence"},
1609
    {0x274, "AC Select Paragraph"},
1610
    {0x275, "AC Select Column"},
1611
    {0x276, "AC Select Row"},
1612
    {0x277, "AC Select Table"},
1613
    {0x278, "AC Select Object"},
1614
    {0x279, "AC Redo/Repeat"},
1615
    {0x27A, "AC Sort"},
1616
    {0x27B, "AC Sort Ascending"},
1617
    {0x27C, "AC Sort Descending"},
1618
    {0x27D, "AC Filter"},
1619
    {0x27E, "AC Set Clock"},
1620
    {0x27F, "AC View Clock"},
1621
    {0x280, "AC Select Time Zone"},
1622
    {0x281, "AC Edit Time Zones"},
1623
    {0x282, "AC Set Alarm"},
1624
    {0x283, "AC Clear Alarm"},
1625
    {0x284, "AC Snooze Alarm"},
1626
    {0x285, "AC Reset Alarm"},
1627
    {0x286, "AC Synchronize"},
1628
    {0x287, "AC Send/Receive"},
1629
    {0x288, "AC Send To"},
1630
    {0x289, "AC Reply"},
1631
    {0x28A, "AC Reply All"},
1632
    {0x28B, "AC Forward Msg"},
1633
    {0x28C, "AC Send"},
1634
    {0x28D, "AC Attach File"},
1635
    {0x28E, "AC Upload"},
1636
    {0x28F, "AC Download (Save Target As)"},
1637
    {0x290, "AC Set Borders"},
1638
    {0x291, "AC Insert Row"},
1639
    {0x292, "AC Insert Column"},
1640
    {0x293, "AC Insert File"},
1641
    {0x294, "AC Insert Picture"},
1642
    {0x295, "AC Insert Object"},
1643
    {0x296, "AC Insert Symbol"},
1644
    {0x297, "AC Save and Close"},
1645
    {0x298, "AC Rename"},
1646
    {0x299, "AC Merge"},
1647
    {0x29A, "AC Split"},
1648
    {0x29B, "AC Distribute Horizontally"},
1649
    {0x29C, "AC Distribute Vertically"},
1650
    {0x29D, "AC Next Keyboard Layout Select"},
1651
    {0x29E, "AC Navigation Guidance"},
1652
    {0x29F, "AC Desktop Show All Windows"},
1653
    {0x2A0, "AC Soft Key Left"},
1654
    {0x2A1, "AC Soft Key Right"},
1655
    {0x2A2, "AC Desktop Show All Applications"},
1656
    {0x2B0, "AC Idle Keep Alive"},
1657
    {0x2C0, "Extended Keyboard Attributes Collection"},
1658
    {0x2C1, "Keyboard Form Factor"},
1659
    {0x2C2, "Keyboard Key Type"},
1660
    {0x2C3, "Keyboard Physical Layout"},
1661
    {0x2C4, "Vendor-Specific Keyboard Physical Layout"},
1662
    {0x2C5, "Keyboard IETF Language Tag Index"},
1663
    {0x2C6, "Implemented Keyboard Input Assist Controls"},
1664
    {0x2C7, "Keyboard Input Assist Previous"},
1665
    {0x2C8, "Keyboard Input Assist Next"},
1666
    {0x2C9, "Keyboard Input Assist Previous Group"},
1667
    {0x2CA, "Keyboard Input Assist Next Group"},
1668
    {0x2CB, "Keyboard Input Assist Accept"},
1669
    {0x2CC, "Keyboard Input Assist Cancel"},
1670
    {0x2D0, "Privacy Screen Toggle"},
1671
    {0x2D1, "Privacy Screen Level Decrement"},
1672
    {0x2D2, "Privacy Screen Level Increment"},
1673
    {0x2D3, "Privacy Screen Level Minimum"},
1674
    {0x2D4, "Privacy Screen Level Maximum"},
1675
    {0x500, "Contact Edited"},
1676
    {0x501, "Contact Added"},
1677
    {0x502, "Contact Record Active"},
1678
    {0x503, "Contact Index"},
1679
    {0x504, "Contact Nickname"},
1680
    {0x505, "Contact First Name"},
1681
    {0x506, "Contact Last Name"},
1682
    {0x507, "Contact Full Name"},
1683
    {0x508, "Contact Phone Number Personal"},
1684
    {0x509, "Contact Phone Number Business"},
1685
    {0x50A, "Contact Phone Number Mobile"},
1686
    {0x50B, "Contact Phone Number Pager"},
1687
    {0x50C, "Contact Phone Number Fax"},
1688
    {0x50D, "Contact Phone Number Other"},
1689
    {0x50E, "Contact Email Personal"},
1690
    {0x50F, "Contact Email Business"},
1691
    {0x510, "Contact Email Other"},
1692
    {0x511, "Contact Email Main"},
1693
    {0x512, "Contact Speed Dial Number"},
1694
    {0x513, "Contact Status Flag"},
1695
    {0x514, "Contact Misc."},
1696
    {0, NULL}
1697
};
1698
static const value_string usb_hid_digitizers_usage_page_vals[] = {
1699
    {0x00, "Undefined"},
1700
    {0x01, "Digitizer"},
1701
    {0x02, "Pen"},
1702
    {0x03, "Light Pen"},
1703
    {0x04, "Touch Screen"},
1704
    {0x05, "Touch Pad"},
1705
    {0x06, "Whiteboard"},
1706
    {0x07, "Coordinate Measuring Machine"},
1707
    {0x08, "3D Digitizer"},
1708
    {0x09, "Stereo Plotter"},
1709
    {0x0A, "Articulated Arm"},
1710
    {0x0B, "Armature"},
1711
    {0x0C, "Multiple Point Digitizer"},
1712
    {0x0D, "Free Space Wand"},
1713
    {0x0E, "Device Configuration"},
1714
    {0x0F, "Capacitive Heat Map Digitizer"},
1715
    {0x20, "Stylus"},
1716
    {0x21, "Puck"},
1717
    {0x22, "Finger"},
1718
    {0x23, "Device settings"},
1719
    {0x24, "Character Gesture"},
1720
    {0x30, "Tip Pressure"},
1721
    {0x31, "Barrel Pressure"},
1722
    {0x32, "In Range"},
1723
    {0x33, "Touch"},
1724
    {0x34, "Untouch"},
1725
    {0x35, "Tap"},
1726
    {0x36, "Quality"},
1727
    {0x37, "Data Valid"},
1728
    {0x38, "Transducer Index"},
1729
    {0x39, "Tablet Function Keys"},
1730
    {0x3A, "Program Change Keys"},
1731
    {0x3B, "Battery Strength"},
1732
    {0x3C, "Invert"},
1733
    {0x3D, "X Tilt"},
1734
    {0x3E, "Y Tilt"},
1735
    {0x3F, "Azimuth"},
1736
    {0x40, "Altitude"},
1737
    {0x41, "Twist"},
1738
    {0x42, "Tip Switch"},
1739
    {0x43, "Secondary Tip Switch"},
1740
    {0x44, "Barrel Switch"},
1741
    {0x45, "Eraser"},
1742
    {0x46, "Tablet Pick"},
1743
    {0x47, "Touch Valid"},
1744
    {0x48, "Width"},
1745
    {0x49, "Height"},
1746
    {0x51, "Contact Identifier"},
1747
    {0x52, "Device Mode"},
1748
    {0x53, "Device Identifier"},
1749
    {0x54, "Contact Count"},
1750
    {0x55, "Contact Count Maximum"},
1751
    {0x56, "Scan Time"},
1752
    {0x57, "Surface Switch"},
1753
    {0x58, "Button Switch"},
1754
    {0x59, "Pad Type"},
1755
    {0x5A, "Secondary Barrel Switch"},
1756
    {0x5B, "Transducer Serial Number"},
1757
    {0x5C, "Preferred Color"},
1758
    {0x5D, "Preferred Color is Locked"},
1759
    {0x5E, "Preferred Line Width"},
1760
    {0x5F, "Preferred Line Width is Locked"},
1761
    {0x60, "Latency Mode"},
1762
    {0x61, "Gesture Character Quality"},
1763
    {0x62, "Character Gesture Data Length"},
1764
    {0x63, "Character Gesture Data"},
1765
    {0x64, "Gesture Character Encoding"},
1766
    {0x65, "UTF8 Character Gesture Encoding"},
1767
    {0x66, "UTF16 Little Endian Character Gesture Encoding"},
1768
    {0x67, "UTF16 Big Endian Character Gesture Encoding"},
1769
    {0x68, "UTF32 Little Endian Character Gesture Encoding"},
1770
    {0x69, "UTF32 Big Endian Character Gesture Encoding"},
1771
    {0x6A, "Capacitive Heat Map Protocol Vendor ID"},
1772
    {0x6B, "Capacitive Heat Map Protocol Version"},
1773
    {0x6C, "Capacitive Heat Map Frame Data"},
1774
    {0x6D, "Gesture Character Enable"},
1775
    {0x6E, "Transducer Serial Number Part 2"},
1776
    {0x6F, "No Preferred Color"},
1777
    {0x70, "Preferred Line Style"},
1778
    {0x71, "Preferred Line Style is Locked"},
1779
    {0x72, "Ink"},
1780
    {0x73, "Pencil"},
1781
    {0x74, "Highlighter"},
1782
    {0x75, "Chisel Marker"},
1783
    {0x76, "Brush"},
1784
    {0x77, "No Preference"},
1785
    {0x80, "Digitizer Diagnostic"},
1786
    {0x81, "Digitizer Error"},
1787
    {0x82, "Err Normal Status"},
1788
    {0x83, "Err Transducers Exceeded"},
1789
    {0x84, "Err Full Trans Features Unavailable"},
1790
    {0x85, "Err Charge Low"},
1791
    {0x90, "Transducer Software Info"},
1792
    {0x91, "Transducer Vendor Id"},
1793
    {0x92, "Transducer Product Id"},
1794
    {0x93, "Device Supported Protocols"},
1795
    {0x94, "Transducer Supported Protocols"},
1796
    {0x95, "No Protocol"},
1797
    {0x96, "Wacom AES Protocol"},
1798
    {0x97, "USI Protocol"},
1799
    {0x98, "Microsoft Pen Protocol"},
1800
    {0xA0, "Supported Report Rates"},
1801
    {0xA1, "Report Rate"},
1802
    {0xA2, "Transducer Connected"},
1803
    {0xA3, "Switch Disabled"},
1804
    {0xA4, "Switch Unimplemented"},
1805
    {0xA5, "Transducer Switches"},
1806
    {0xA6, "Transducer Index Selector"},
1807
    {0xB0, "Button Press Threshold"},
1808
    {0, NULL}
1809
};
1810
static const value_string usb_hid_haptic_usage_page_vals[] = {
1811
    {0x0000, "Undefined"},
1812
    {0x0001, "Simple Haptic Controller"},
1813
    {0x0010, "Waveform List"},
1814
    {0x0011, "Duration List"},
1815
    {0x0020, "Auto Trigger"},
1816
    {0x0021, "Manual Trigger"},
1817
    {0x0022, "Auto Trigger Associated Control"},
1818
    {0x0023, "Intensity"},
1819
    {0x0024, "Repeat Count"},
1820
    {0x0025, "Retrigger Period"},
1821
    {0x0026, "Waveform Vendor Page"},
1822
    {0x0027, "Waveform Vendor ID"},
1823
    {0x0028, "Waveform Cutoff Time"},
1824
    {0x1001, "Waveform None"},
1825
    {0x1002, "Waveform Stop"},
1826
    {0x1003, "Waveform Click"},
1827
    {0x1004, "Waveform Buzz Continuous"},
1828
    {0x1005, "Waveform Rumble Continuous"},
1829
    {0x1006, "Waveform Press"},
1830
    {0x1007, "Waveform Release"},
1831
    {0x1008, "Waveform Hover"},
1832
    {0x1009, "Waveform Success"},
1833
    {0x100A, "Waveform Error"},
1834
    {0x100B, "Waveform Ink Continuous"},
1835
    {0x100C, "Waveform Pencil Continuous"},
1836
    {0x100D, "Waveform Marker Continuous"},
1837
    {0x100E, "Waveform Chisel Marker Continuous"},
1838
    {0x100F, "Waveform Brush Continuous"},
1839
    {0x1010, "Waveform Eraser Continuous"},
1840
    {0x1011, "Waveform Sparkle Continuous"},
1841
    {0, NULL}
1842
};
1843
static const value_string usb_hid_physical_input_device_usage_page_vals[] = {
1844
    {0x00, "Undefined"},
1845
    {0x01, "Physical Interface Device"},
1846
    {0x20, "Normal"},
1847
    {0x21, "Set Effect Report"},
1848
    {0x22, "Effect Block Index"},
1849
    {0x23, "Parameter Block Offset"},
1850
    {0x24, "ROM Flag"},
1851
    {0x25, "Effect Type"},
1852
    {0x26, "ET Constant Force"},
1853
    {0x27, "ET Ramp"},
1854
    {0x28, "ET Custom Force Data"},
1855
    {0x30, "ET Square"},
1856
    {0x31, "ET Sine"},
1857
    {0x32, "ET Triangle"},
1858
    {0x33, "ET Sawtooth Up"},
1859
    {0x34, "ET Sawtooth Down"},
1860
    {0x40, "ET Spring"},
1861
    {0x41, "ET Damper"},
1862
    {0x42, "ET Inertia"},
1863
    {0x43, "ET Friction"},
1864
    {0x50, "Duration"},
1865
    {0x51, "Sample Period"},
1866
    {0x52, "Gain"},
1867
    {0x53, "Trigger Button"},
1868
    {0x54, "Trigger Repeat Interval"},
1869
    {0x55, "Axes Enable"},
1870
    {0x56, "Direction Enable"},
1871
    {0x57, "Direction"},
1872
    {0x58, "Type Specific Block Offset"},
1873
    {0x59, "Block Type"},
1874
    {0x5A, "Set Envelope Report"},
1875
    {0x5B, "Attack Level"},
1876
    {0x5C, "Attack Time"},
1877
    {0x5D, "Fade Level"},
1878
    {0x5E, "Fade Time"},
1879
    {0x5F, "Set Condition Report"},
1880
    {0x60, "CP Offset"},
1881
    {0x61, "Positive Coefficient"},
1882
    {0x62, "Negative Coefficient"},
1883
    {0x63, "Positive Saturation"},
1884
    {0x64, "Negative Saturation"},
1885
    {0x65, "Dead Band"},
1886
    {0x66, "Download Force Sample"},
1887
    {0x67, "Isoch Custom Force Enable"},
1888
    {0x68, "Custom Force Data Report"},
1889
    {0x69, "Custom Force Data"},
1890
    {0x6A, "Custom Force Vendor Defined Data"},
1891
    {0x6B, "Set Custom Force Report"},
1892
    {0x6C, "Custom Force Data Offset"},
1893
    {0x6D, "Sample Count"},
1894
    {0x6E, "Set Periodic Report"},
1895
    {0x6F, "Offset"},
1896
    {0x70, "Magnitude"},
1897
    {0x71, "Phase"},
1898
    {0x72, "Period"},
1899
    {0x73, "Set Constant Force Report"},
1900
    {0x74, "Set Ramp Force Report"},
1901
    {0x75, "Ramp Start"},
1902
    {0x76, "Ramp End"},
1903
    {0x77, "Effect Operation Report"},
1904
    {0x78, "Effect Operation"},
1905
    {0x79, "Op Effect Start"},
1906
    {0x7A, "Op Effect Start Solo"},
1907
    {0x7B, "Op Effect Stop"},
1908
    {0x7C, "Loop Count"},
1909
    {0x7D, "Device Gain Report"},
1910
    {0x7E, "Device Gain"},
1911
    {0x7F, "PID Pool Report"},
1912
    {0x80, "RAM Pool Size"},
1913
    {0x81, "ROM Pool Size"},
1914
    {0x82, "ROM Effect Block Count"},
1915
    {0x83, "Simultaneous Effects Max"},
1916
    {0x84, "Pool Alignment"},
1917
    {0x85, "PID Pool Move Report"},
1918
    {0x86, "Move Source"},
1919
    {0x87, "Move Destination"},
1920
    {0x88, "Move Length"},
1921
    {0x89, "PID Block Load Report"},
1922
    {0x8B, "Block Load Status"},
1923
    {0x8C, "Block Load Success"},
1924
    {0x8D, "Block Load Full"},
1925
    {0x8E, "Block Load Error"},
1926
    {0x8F, "Block Handle"},
1927
    {0x90, "PID Block Free Report"},
1928
    {0x91, "Type Specific Block Handle"},
1929
    {0x92, "PID State Report"},
1930
    {0x94, "Effect Playing"},
1931
    {0x95, "PID Device Control Report"},
1932
    {0x96, "PID Device Control"},
1933
    {0x97, "DC Enable Actuators"},
1934
    {0x98, "DC Disable Actuators"},
1935
    {0x99, "DC Stop All Effects"},
1936
    {0x9A, "DC Device Reset"},
1937
    {0x9B, "DC Device Pause"},
1938
    {0x9C, "DC Device Continue"},
1939
    {0x9F, "Device Paused"},
1940
    {0xA0, "Actuators Enabled"},
1941
    {0xA4, "Safety Switch"},
1942
    {0xA5, "Actuator Override Switch"},
1943
    {0xA6, "Actuator Power"},
1944
    {0xA7, "Start Delay"},
1945
    {0xA8, "Parameter Block Size"},
1946
    {0xA9, "Device Managed Pool"},
1947
    {0xAA, "Shared Parameter Blocks"},
1948
    {0xAB, "Create New Effect Report"},
1949
    {0xAC, "RAM Pool Available"},
1950
    {0, NULL}
1951
};
1952
static const value_string usb_hid_soc_usage_page_vals[] = {
1953
    {0x00, "Undefined"},
1954
    {0x01, "SocControl"},
1955
    {0x02, "FirmwareTransfer"},
1956
    {0x03, "FirmwareFileId"},
1957
    {0x04, "FileOffsetInBytes"},
1958
    {0x05, "FileTransferSizeMaxInBytes"},
1959
    {0x06, "FilePayload"},
1960
    {0x07, "FilePayloadSizeInBytes"},
1961
    {0x08, "FilePayloadContainsLastBytes"},
1962
    {0x09, "FileTransferStop"},
1963
    {0x0A, "FileTransferTillEnd"},
1964
    {0, NULL}
1965
};
1966
static const value_string usb_hid_eye_and_head_tracker_usage_page_vals[] = {
1967
    {0x0000, "Undefined"},
1968
    {0x0001, "Eye Tracker"},
1969
    {0x0002, "Head Tracker"},
1970
    {0x0010, "Tracking Data"},
1971
    {0x0011, "Capabilities"},
1972
    {0x0012, "Configuration"},
1973
    {0x0013, "Status"},
1974
    {0x0014, "Control"},
1975
    {0x0020, "Sensor Timestamp"},
1976
    {0x0021, "Position X"},
1977
    {0x0022, "Position Y"},
1978
    {0x0023, "Position Z"},
1979
    {0x0024, "Gaze Point"},
1980
    {0x0025, "Left Eye Position"},
1981
    {0x0026, "Right Eye Position"},
1982
    {0x0027, "Head Position"},
1983
    {0x0028, "Head Direction Point"},
1984
    {0x0029, "Rotation about X axis"},
1985
    {0x002A, "Rotation about Y axis"},
1986
    {0x002B, "Rotation about Z axis"},
1987
    {0x0100, "Tracker Quality"},
1988
    {0x0101, "Minimum Tracking Distance"},
1989
    {0x0102, "Optimum Tracking Distance"},
1990
    {0x0103, "Maximum Tracking Distance"},
1991
    {0x0104, "Maximum Screen Plane Width"},
1992
    {0x0105, "Maximum Screen Plane Height"},
1993
    {0x0200, "Display Manufacturer ID"},
1994
    {0x0201, "Display Product ID"},
1995
    {0x0202, "Display Serial Number"},
1996
    {0x0203, "Display Manufacturer Date"},
1997
    {0x0204, "Calibrated Screen Width"},
1998
    {0x0205, "Calibrated Screen Height"},
1999
    {0x0300, "Sampling Frequency"},
2000
    {0x0301, "Configuration Status"},
2001
    {0x0400, "Device Mode Request"},
2002
    {0, NULL}
2003
};
2004
static const value_string usb_hid_alphanumeric_display_usage_page_vals[] = {
2005
    {0x00, "Undefined"},
2006
    {0x01, "Alphanumeric Display"},
2007
    {0x02, "Auxiliary Display"},
2008
    {0x20, "Display Attributes Report"},
2009
    {0x21, "ASCII Character Set"},
2010
    {0x22, "Data Read Back"},
2011
    {0x23, "Font Read Back"},
2012
    {0x24, "Display Control Report"},
2013
    {0x25, "Clear Display"},
2014
    {0x26, "Display Enable"},
2015
    {0x27, "Screen Saver Delay"},
2016
    {0x28, "Screen Saver Enable"},
2017
    {0x29, "Vertical Scroll"},
2018
    {0x2A, "Horizontal Scroll"},
2019
    {0x2B, "Character Report"},
2020
    {0x2C, "Display Data"},
2021
    {0x2D, "Display Status"},
2022
    {0x2E, "Stat Not Ready"},
2023
    {0x2F, "Stat Ready"},
2024
    {0x30, "Err Not a loadable character"},
2025
    {0x31, "Err Font data cannot be read"},
2026
    {0x32, "Cursor Position Report"},
2027
    {0x33, "Row"},
2028
    {0x34, "Column"},
2029
    {0x35, "Rows"},
2030
    {0x36, "Columns"},
2031
    {0x37, "Cursor Pixel Positioning"},
2032
    {0x38, "Cursor Mode"},
2033
    {0x39, "Cursor Enable"},
2034
    {0x3A, "Cursor Blink"},
2035
    {0x3B, "Font Report"},
2036
    {0x3C, "Font Data"},
2037
    {0x3D, "Character Width"},
2038
    {0x3E, "Character Height"},
2039
    {0x3F, "Character Spacing Horizontal"},
2040
    {0x40, "Character Spacing Vertical"},
2041
    {0x41, "Unicode Character Set"},
2042
    {0x42, "Font 7-Segment"},
2043
    {0x43, "7-Segment Direct Map"},
2044
    {0x44, "Font 14-Segment"},
2045
    {0x45, "14-Segment Direct Map"},
2046
    {0x46, "Display Brightness"},
2047
    {0x47, "Display Contrast"},
2048
    {0x48, "Character Attribute"},
2049
    {0x49, "Attribute Readback"},
2050
    {0x4A, "Attribute Data"},
2051
    {0x4B, "Char Attr Enhance"},
2052
    {0x4C, "Char Attr Underline"},
2053
    {0x4D, "Char Attr Blink"},
2054
    {0x80, "Bitmap Size X"},
2055
    {0x81, "Bitmap Size Y"},
2056
    {0x82, "Max Blit Size"},
2057
    {0x83, "Bit Depth Format"},
2058
    {0x84, "Display Orientation"},
2059
    {0x85, "Palette Report"},
2060
    {0x86, "Palette Data Size"},
2061
    {0x87, "Palette Data Offset"},
2062
    {0x88, "Palette Data"},
2063
    {0x8A, "Blit Report"},
2064
    {0x8B, "Blit Rectangle X1"},
2065
    {0x8C, "Blit Rectangle Y1"},
2066
    {0x8D, "Blit Rectangle X2"},
2067
    {0x8E, "Blit Rectangle Y2"},
2068
    {0x8F, "Blit Data"},
2069
    {0x90, "Soft Button"},
2070
    {0x91, "Soft Button ID"},
2071
    {0x92, "Soft Button Side"},
2072
    {0x93, "Soft Button Offset 1"},
2073
    {0x94, "Soft Button Offset 2"},
2074
    {0x95, "Soft Button Report"},
2075
    {0xC2, "Soft Keys"},
2076
    {0xCC, "Display Data Extensions"},
2077
    {0xCF, "Character Mapping"},
2078
    {0xDD, "Unicode Equivalent"},
2079
    {0xDF, "Character Page Mapping"},
2080
    {0xFF, "Request Report"},
2081
    {0, NULL}
2082
};
2083
static const value_string usb_hid_sensor_usage_page_vals[] = {
2084
    {0x0000, "Undefined"},
2085
    {0x0001, "Sensor"},
2086
    {0x0010, "Biometric"},
2087
    {0x0011, "Biometric: Human Presence"},
2088
    {0x0012, "Biometric: Human Proximity"},
2089
    {0x0013, "Biometric: Human Touch"},
2090
    {0x0014, "Biometric: Blood Pressure"},
2091
    {0x0015, "Biometric: Body Temperature"},
2092
    {0x0016, "Biometric: Heart Rate"},
2093
    {0x0017, "Biometric: Heart Rate Variability"},
2094
    {0x0018, "Biometric: Peripheral Oxygen Saturation"},
2095
    {0x0019, "Biometric: Respiratory Rate"},
2096
    {0x0020, "Electrical"},
2097
    {0x0021, "Electrical: Capacitance"},
2098
    {0x0022, "Electrical: Current"},
2099
    {0x0023, "Electrical: Power"},
2100
    {0x0024, "Electrical: Inductance"},
2101
    {0x0025, "Electrical: Resistance"},
2102
    {0x0026, "Electrical: Voltage"},
2103
    {0x0027, "Electrical: Potentiometer"},
2104
    {0x0028, "Electrical: Frequency"},
2105
    {0x0029, "Electrical: Period"},
2106
    {0x0030, "Environmental"},
2107
    {0x0031, "Environmental: Atmospheric Pressure"},
2108
    {0x0032, "Environmental: Humidity"},
2109
    {0x0033, "Environmental: Temperature"},
2110
    {0x0034, "Environmental: Wind Direction"},
2111
    {0x0035, "Environmental: Wind Speed"},
2112
    {0x0036, "Environmental: Air Quality"},
2113
    {0x0037, "Environmental: Heat Index"},
2114
    {0x0038, "Environmental: Surface Temperature"},
2115
    {0x0039, "Environmental: Volatile Organic Compounds"},
2116
    {0x003A, "Environmental: Object Presence"},
2117
    {0x003B, "Environmental: Object Proximity"},
2118
    {0x0040, "Light"},
2119
    {0x0041, "Light: Ambient Light"},
2120
    {0x0042, "Light: Consumer Infrared"},
2121
    {0x0043, "Light: Infrared Light"},
2122
    {0x0044, "Light: Visible Light"},
2123
    {0x0045, "Light: Ultraviolet Light"},
2124
    {0x0050, "Location"},
2125
    {0x0051, "Location: Broadcast"},
2126
    {0x0052, "Location: Dead Reckoning"},
2127
    {0x0053, "Location: GPS (Global Positioning System)"},
2128
    {0x0054, "Location: Lookup"},
2129
    {0x0055, "Location: Other"},
2130
    {0x0056, "Location: Static"},
2131
    {0x0057, "Location: Triangulation"},
2132
    {0x0060, "Mechanical"},
2133
    {0x0061, "Mechanical: Boolean Switch"},
2134
    {0x0062, "Mechanical: Boolean Switch Array"},
2135
    {0x0063, "Mechanical: Multivalue Switch"},
2136
    {0x0064, "Mechanical: Force"},
2137
    {0x0065, "Mechanical: Pressure"},
2138
    {0x0066, "Mechanical: Strain"},
2139
    {0x0067, "Mechanical: Weight"},
2140
    {0x0068, "Mechanical: Haptic Vibrator"},
2141
    {0x0069, "Mechanical: Hall Effect Switch"},
2142
    {0x0070, "Motion"},
2143
    {0x0071, "Motion: Accelerometer 1D"},
2144
    {0x0072, "Motion: Accelerometer 2D"},
2145
    {0x0073, "Motion: Accelerometer 3D"},
2146
    {0x0074, "Motion: Gyrometer 1D"},
2147
    {0x0075, "Motion: Gyrometer 2D"},
2148
    {0x0076, "Motion: Gyrometer 3D"},
2149
    {0x0077, "Motion: Motion Detector"},
2150
    {0x0078, "Motion: Speedometer"},
2151
    {0x0079, "Motion: Accelerometer"},
2152
    {0x007A, "Motion: Gyrometer"},
2153
    {0x007B, "Motion: Gravity Vector"},
2154
    {0x007C, "Motion: Linear Accelerometer"},
2155
    {0x0080, "Orientation"},
2156
    {0x0081, "Orientation: Compass 1D"},
2157
    {0x0082, "Orientation: Compass 2D"},
2158
    {0x0083, "Orientation: Compass 3D"},
2159
    {0x0084, "Orientation: Inclinometer 1D"},
2160
    {0x0085, "Orientation: Inclinometer 2D"},
2161
    {0x0086, "Orientation: Inclinometer 3D"},
2162
    {0x0087, "Orientation: Distance 1D"},
2163
    {0x0088, "Orientation: Distance 2D"},
2164
    {0x0089, "Orientation: Distance 3D"},
2165
    {0x008A, "Orientation: Device Orientation"},
2166
    {0x008B, "Orientation: Compass"},
2167
    {0x008C, "Orientation: Inclinometer"},
2168
    {0x008D, "Orientation: Distance"},
2169
    {0x008E, "Orientation: Relative Orientation"},
2170
    {0x008F, "Orientation: Simple Orientation"},
2171
    {0x0090, "Scanner"},
2172
    {0x0091, "Scanner: Barcode"},
2173
    {0x0092, "Scanner: RFID"},
2174
    {0x0093, "Scanner: NFC"},
2175
    {0x00A0, "Time"},
2176
    {0x00A1, "Time: Alarm Timer"},
2177
    {0x00A2, "Time: Real Time Clock"},
2178
    {0x00B0, "Personal Activity"},
2179
    {0x00B1, "Personal Activity: Activity Detection"},
2180
    {0x00B2, "Personal Activity: Device Position"},
2181
    {0x00B3, "Personal Activity: Floor Tracker"},
2182
    {0x00B4, "Personal Activity: Pedometer"},
2183
    {0x00B5, "Personal Activity: Step Detection"},
2184
    {0x00C0, "Orientation Extended"},
2185
    {0x00C1, "Orientation Extended: Geomagnetic Orientation"},
2186
    {0x00C2, "Orientation Extended: Magnetometer"},
2187
    {0x00D0, "Gesture"},
2188
    {0x00D1, "Gesture: Chassis Flip Gesture"},
2189
    {0x00D2, "Gesture: Hinge Fold Gesture"},
2190
    {0x00E0, "Other"},
2191
    {0x00E1, "Other: Custom"},
2192
    {0x00E2, "Other: Generic"},
2193
    {0x00E3, "Other: Generic Enumerator"},
2194
    {0x00E4, "Other: Hinge Angle"},
2195
    {0x0200, "Event"},
2196
    {0x0201, "Event: Sensor State"},
2197
    {0x0202, "Event: Sensor Event"},
2198
    {0x0300, "Property"},
2199
    {0x0301, "Property: Friendly Name"},
2200
    {0x0302, "Property: Persistent Unique ID"},
2201
    {0x0303, "Property: Sensor Status"},
2202
    {0x0304, "Property: Minimum Report Interval"},
2203
    {0x0305, "Property: Sensor Manufacturer"},
2204
    {0x0306, "Property: Sensor Model"},
2205
    {0x0307, "Property: Sensor Serial Number"},
2206
    {0x0308, "Property: Sensor Description"},
2207
    {0x0309, "Property: Sensor Connection Type"},
2208
    {0x030A, "Property: Sensor Device Path"},
2209
    {0x030B, "Property: Hardware Revision"},
2210
    {0x030C, "Property: Firmware Version"},
2211
    {0x030D, "Property: Release Date"},
2212
    {0x030E, "Property: Report Interval"},
2213
    {0x030F, "Property: Change Sensitivity Absolute"},
2214
    {0x0310, "Property: Change Sensitivity Percent of Range"},
2215
    {0x0311, "Property: Change Sensitivity Percent Relative"},
2216
    {0x0312, "Property: Accuracy"},
2217
    {0x0313, "Property: Resolution"},
2218
    {0x0314, "Property: Maximum"},
2219
    {0x0315, "Property: Minimum"},
2220
    {0x0316, "Property: Reporting State"},
2221
    {0x0317, "Property: Sampling Rate"},
2222
    {0x0318, "Property: Response Curve"},
2223
    {0x0319, "Property: Power State"},
2224
    {0x031A, "Property: Maximum FIFO Events"},
2225
    {0x031B, "Property: Report Latency"},
2226
    {0x031C, "Property: Flush FIFO Events"},
2227
    {0x031D, "Property: Maximum Power Consumption"},
2228
    {0x031E, "Property: Is Primary"},
2229
    {0x031F, "Property: Human Presence Detection Type"},
2230
    {0x0400, "Data Field: Location"},
2231
    {0x0401, "Reserved (Data Field: Location)"},
2232
    {0x0402, "Data Field: Altitude Antenna Sea Level"},
2233
    {0x0403, "Data Field: Differential Reference Station ID"},
2234
    {0x0404, "Data Field: Altitude Ellipsoid Error"},
2235
    {0x0405, "Data Field: Altitude Ellipsoid"},
2236
    {0x0406, "Data Field: Altitude Sea Level Error"},
2237
    {0x0407, "Data Field: Altitude Sea Level"},
2238
    {0x0408, "Data Field: Differential GPS Data Age"},
2239
    {0x0409, "Data Field: Error Radius"},
2240
    {0x040A, "Data Field: Fix Quality"},
2241
    {0x040B, "Data Field: Fix Type"},
2242
    {0x040C, "Data Field: Geoidal Separation"},
2243
    {0x040D, "Data Field: GPS Operation Mode"},
2244
    {0x040E, "Data Field: GPS Selection Mode"},
2245
    {0x040F, "Data Field: GPS Status"},
2246
    {0x0410, "Data Field: Position Dilution of Precision"},
2247
    {0x0411, "Data Field: Horizontal Dilution of Precision"},
2248
    {0x0412, "Data Field: Vertical Dilution of Precision"},
2249
    {0x0413, "Data Field: Latitude"},
2250
    {0x0414, "Data Field: Longitude"},
2251
    {0x0415, "Data Field: True Heading"},
2252
    {0x0416, "Data Field: Magnetic Heading"},
2253
    {0x0417, "Data Field: Magnetic Variation"},
2254
    {0x0418, "Data Field: Speed"},
2255
    {0x0419, "Data Field: Satellites in View"},
2256
    {0x041A, "Data Field: Satellites in View Azimuth"},
2257
    {0x041B, "Data Field: Satellites in View Elevation"},
2258
    {0x041C, "Data Field: Satellites in View IDs"},
2259
    {0x041D, "Data Field: Satellites in View PRNs"},
2260
    {0x041E, "Data Field: Satellites in View S/N Ratios"},
2261
    {0x041F, "Data Field: Satellites Used Count"},
2262
    {0x0420, "Data Field: Satellites Used PRNs"},
2263
    {0x0421, "Data Field: NMEA Sentence"},
2264
    {0x0422, "Data Field: Address Line 1"},
2265
    {0x0423, "Data Field: Address Line 2"},
2266
    {0x0424, "Data Field: City"},
2267
    {0x0425, "Data Field: State or Province"},
2268
    {0x0426, "Data Field: Country or Region"},
2269
    {0x0427, "Data Field: Postal Code"},
2270
    {0x042A, "Property: Location"},
2271
    {0x042B, "Property: Location Desired Accuracy"},
2272
    {0x0430, "Data Field: Environmental"},
2273
    {0x0431, "Data Field: Atmospheric Pressure"},
2274
    {0x0432, "Reserved (Data Field: Environmental)"},
2275
    {0x0433, "Data Field: Relative Humidity"},
2276
    {0x0434, "Data Field: Temperature"},
2277
    {0x0435, "Data Field: Wind Direction"},
2278
    {0x0436, "Data Field: Wind Speed"},
2279
    {0x0437, "Data Field: Air Quality Index"},
2280
    {0x0438, "Data Field: Equivalent CO2"},
2281
    {0x0439, "Data Field: Volatile Organic Compound Concentration"},
2282
    {0x043A, "Data Field: Object Presence"},
2283
    {0x043B, "Data Field: Object Proximity Range"},
2284
    {0x043C, "Data Field: Object Proximity Out of Range"},
2285
    {0x0440, "Property: Environmental"},
2286
    {0x0441, "Property: Reference Pressure"},
2287
    {0x0450, "Data Field: Motion"},
2288
    {0x0451, "Data Field: Motion State"},
2289
    {0x0452, "Data Field: Acceleration"},
2290
    {0x0453, "Data Field: Acceleration Axis X"},
2291
    {0x0454, "Data Field: Acceleration Axis Y"},
2292
    {0x0455, "Data Field: Acceleration Axis Z"},
2293
    {0x0456, "Data Field: Angular Velocity"},
2294
    {0x0457, "Data Field: Angular Velocity about X Axis"},
2295
    {0x0458, "Data Field: Angular Velocity about Y Axis"},
2296
    {0x0459, "Data Field: Angular Velocity about Z Axis"},
2297
    {0x045A, "Data Field: Angular Position"},
2298
    {0x045B, "Data Field: Angular Position about X Axis"},
2299
    {0x045C, "Data Field: Angular Position about Y Axis"},
2300
    {0x045D, "Data Field: Angular Position about Z Axis"},
2301
    {0x045E, "Data Field: Motion Speed"},
2302
    {0x045F, "Data Field: Motion Intensity"},
2303
    {0x0470, "Data Field: Orientation"},
2304
    {0x0471, "Data Field: Heading"},
2305
    {0x0472, "Data Field: Heading X Axis"},
2306
    {0x0473, "Data Field: Heading Y Axis"},
2307
    {0x0474, "Data Field: Heading Z Axis"},
2308
    {0x0475, "Data Field: Heading Compensated Magnetic North"},
2309
    {0x0476, "Data Field: Heading Compensated True North"},
2310
    {0x0477, "Data Field: Heading Magnetic North"},
2311
    {0x0478, "Data Field: Heading True North"},
2312
    {0x0479, "Data Field: Distance"},
2313
    {0x047A, "Data Field: Distance X Axis"},
2314
    {0x047B, "Data Field: Distance Y Axis"},
2315
    {0x047C, "Data Field: Distance Z Axis"},
2316
    {0x047D, "Data Field: Distance Out-of-Range"},
2317
    {0x047E, "Data Field: Tilt"},
2318
    {0x047F, "Data Field: Tilt X Axis"},
2319
    {0x0480, "Data Field: Tilt Y Axis"},
2320
    {0x0481, "Data Field: Tilt Z Axis"},
2321
    {0x0482, "Data Field: Rotation Matrix"},
2322
    {0x0483, "Data Field: Quaternion"},
2323
    {0x0484, "Data Field: Magnetic Flux"},
2324
    {0x0485, "Data Field: Magnetic Flux X Axis"},
2325
    {0x0486, "Data Field: Magnetic Flux Y Axis"},
2326
    {0x0487, "Data Field: Magnetic Flux Z Axis"},
2327
    {0x0488, "Data Field: Magnetometer Accuracy"},
2328
    {0x0489, "Data Field: Simple Orientation Direction"},
2329
    {0x0490, "Data Field: Mechanical"},
2330
    {0x0491, "Data Field: Boolean Switch State"},
2331
    {0x0492, "Data Field: Boolean Switch Array States"},
2332
    {0x0493, "Data Field: Multivalue Switch Value"},
2333
    {0x0494, "Data Field: Force"},
2334
    {0x0495, "Data Field: Absolute Pressure"},
2335
    {0x0496, "Data Field: Gauge Pressure"},
2336
    {0x0497, "Data Field: Strain"},
2337
    {0x0498, "Data Field: Weight"},
2338
    {0x04A0, "Property: Mechanical"},
2339
    {0x04A1, "Property: Vibration State"},
2340
    {0x04A2, "Property: Forward Vibration Speed"},
2341
    {0x04A3, "Property: Backward Vibration Speed"},
2342
    {0x04B0, "Data Field: Biometric"},
2343
    {0x04B1, "Data Field: Human Presence"},
2344
    {0x04B2, "Data Field: Human Proximity Range"},
2345
    {0x04B3, "Data Field: Human Proximity Out of Range"},
2346
    {0x04B4, "Data Field: Human Touch State"},
2347
    {0x04B5, "Data Field: Blood Pressure"},
2348
    {0x04B6, "Data Field: Blood Pressure Diastolic"},
2349
    {0x04B7, "Data Field: Blood Pressure Systolic"},
2350
    {0x04B8, "Data Field: Heart Rate"},
2351
    {0x04B9, "Data Field: Resting Heart Rate"},
2352
    {0x04BA, "Data Field: Heartbeat Interval"},
2353
    {0x04BB, "Data Field: Respiratory Rate"},
2354
    {0x04BC, "Data Field: SpO2"},
2355
    {0x04BD, "Data Field: Human Attention Detected"},
2356
    {0x04BE, "Data Field: Human Head Azimuth"},
2357
    {0x04BF, "Data Field: Human Head Altitude"},
2358
    {0x04C0, "Data Field: Human Head Roll"},
2359
    {0x04C1, "Data Field: Human Head Pitch"},
2360
    {0x04C2, "Data Field: Human Head Yaw"},
2361
    {0x04C3, "Data Field: Human Correlation Id"},
2362
    {0x04D0, "Data Field: Light"},
2363
    {0x04D1, "Data Field: Illuminance"},
2364
    {0x04D2, "Data Field: Color Temperature"},
2365
    {0x04D3, "Data Field: Chromaticity"},
2366
    {0x04D4, "Data Field: Chromaticity X"},
2367
    {0x04D5, "Data Field: Chromaticity Y"},
2368
    {0x04D6, "Data Field: Consumer IR Sentence Receive"},
2369
    {0x04D7, "Data Field: Infrared Light"},
2370
    {0x04D8, "Data Field: Red Light"},
2371
    {0x04D9, "Data Field: Green Light"},
2372
    {0x04DA, "Data Field: Blue Light"},
2373
    {0x04DB, "Data Field: Ultraviolet A Light"},
2374
    {0x04DC, "Data Field: Ultraviolet B Light"},
2375
    {0x04DD, "Data Field: Ultraviolet Index"},
2376
    {0x04DE, "Data Field: Near Infrared Light"},
2377
    {0x04DF, "Property: Light"},
2378
    {0x04E0, "Property: Consumer IR Sentence Send"},
2379
    {0x04E2, "Property: Auto Brightness Preferred"},
2380
    {0x04E3, "Property: Auto Color Preferred"},
2381
    {0x04F0, "Data Field: Scanner"},
2382
    {0x04F1, "Data Field: RFID Tag 40 Bit"},
2383
    {0x04F2, "Data Field: NFC Sentence Receive"},
2384
    {0x04F8, "Property: Scanner"},
2385
    {0x04F9, "Property: NFC Sentence Send"},
2386
    {0x0500, "Data Field: Electrical"},
2387
    {0x0501, "Data Field: Capacitance"},
2388
    {0x0502, "Data Field: Current"},
2389
    {0x0503, "Data Field: Electrical Power"},
2390
    {0x0504, "Data Field: Inductance"},
2391
    {0x0505, "Data Field: Resistance"},
2392
    {0x0506, "Data Field: Voltage"},
2393
    {0x0507, "Data Field: Frequency"},
2394
    {0x0508, "Data Field: Period"},
2395
    {0x0509, "Data Field: Percent of Range"},
2396
    {0x0520, "Data Field: Time"},
2397
    {0x0521, "Data Field: Year"},
2398
    {0x0522, "Data Field: Month"},
2399
    {0x0523, "Data Field: Day"},
2400
    {0x0524, "Data Field: Day of Week"},
2401
    {0x0525, "Data Field: Hour"},
2402
    {0x0526, "Data Field: Minute"},
2403
    {0x0527, "Data Field: Second"},
2404
    {0x0528, "Data Field: Millisecond"},
2405
    {0x0529, "Data Field: Timestamp"},
2406
    {0x052A, "Data Field: Julian Day of Year"},
2407
    {0x052B, "Data Field: Time Since System Boot"},
2408
    {0x0530, "Property: Time"},
2409
    {0x0531, "Property: Time Zone Offset from UTC"},
2410
    {0x0532, "Property: Time Zone Name"},
2411
    {0x0533, "Property: Daylight Savings Time Observed"},
2412
    {0x0534, "Property: Time Trim Adjustment"},
2413
    {0x0535, "Property: Arm Alarm"},
2414
    {0x0540, "Data Field: Custom"},
2415
    {0x0541, "Data Field: Custom Usage"},
2416
    {0x0542, "Data Field: Custom Boolean Array"},
2417
    {0x0543, "Data Field: Custom Value"},
2418
    {0x0544, "Data Field: Custom Value 1"},
2419
    {0x0545, "Data Field: Custom Value 2"},
2420
    {0x0546, "Data Field: Custom Value 3"},
2421
    {0x0547, "Data Field: Custom Value 4"},
2422
    {0x0548, "Data Field: Custom Value 5"},
2423
    {0x0549, "Data Field: Custom Value 6"},
2424
    {0x054A, "Data Field: Custom Value 7"},
2425
    {0x054B, "Data Field: Custom Value 8"},
2426
    {0x054C, "Data Field: Custom Value 9"},
2427
    {0x054D, "Data Field: Custom Value 10"},
2428
    {0x054E, "Data Field: Custom Value 11"},
2429
    {0x054F, "Data Field: Custom Value 12"},
2430
    {0x0550, "Data Field: Custom Value 13"},
2431
    {0x0551, "Data Field: Custom Value 14"},
2432
    {0x0552, "Data Field: Custom Value 15"},
2433
    {0x0553, "Data Field: Custom Value 16"},
2434
    {0x0554, "Data Field: Custom Value 17"},
2435
    {0x0555, "Data Field: Custom Value 18"},
2436
    {0x0556, "Data Field: Custom Value 19"},
2437
    {0x0557, "Data Field: Custom Value 20"},
2438
    {0x0558, "Data Field: Custom Value 21"},
2439
    {0x0559, "Data Field: Custom Value 22"},
2440
    {0x055A, "Data Field: Custom Value 23"},
2441
    {0x055B, "Data Field: Custom Value 24"},
2442
    {0x055C, "Data Field: Custom Value 25"},
2443
    {0x055D, "Data Field: Custom Value 26"},
2444
    {0x055E, "Data Field: Custom Value 27"},
2445
    {0x055F, "Data Field: Custom Value 28"},
2446
    {0x0560, "Data Field: Generic"},
2447
    {0x0561, "Data Field: Generic GUID or PROPERTYKEY"},
2448
    {0x0562, "Data Field: Generic Category GUID"},
2449
    {0x0563, "Data Field: Generic Type GUID"},
2450
    {0x0564, "Data Field: Generic Event PROPERTYKEY"},
2451
    {0x0565, "Data Field: Generic Property PROPERTYKEY"},
2452
    {0x0566, "Data Field: Generic Data Field PROPERTYKEY"},
2453
    {0x0567, "Data Field: Generic Event"},
2454
    {0x0568, "Data Field: Generic Property"},
2455
    {0x0569, "Data Field: Generic Data Field"},
2456
    {0x056A, "Data Field: Enumerator Table Row Index"},
2457
    {0x056B, "Data Field: Enumerator Table Row Count"},
2458
    {0x056C, "Data Field: Generic GUID or PROPERTYKEY kind"},
2459
    {0x056D, "Data Field: Generic GUID"},
2460
    {0x056E, "Data Field: Generic PROPERTYKEY"},
2461
    {0x056F, "Data Field: Generic Top Level Collection ID"},
2462
    {0x0570, "Data Field: Generic Report ID"},
2463
    {0x0571, "Data Field: Generic Report Item Position Index"},
2464
    {0x0572, "Data Field: Generic Firmware VARTYPE"},
2465
    {0x0573, "Data Field: Generic Unit of Measure"},
2466
    {0x0574, "Data Field: Generic Unit Exponent"},
2467
    {0x0575, "Data Field: Generic Report Size"},
2468
    {0x0576, "Data Field: Generic Report Count"},
2469
    {0x0580, "Property: Generic"},
2470
    {0x0581, "Property: Enumerator Table Row Index"},
2471
    {0x0582, "Property: Enumerator Table Row Count"},
2472
    {0x0590, "Data Field: Personal Activity"},
2473
    {0x0591, "Data Field: Activity Type"},
2474
    {0x0592, "Data Field: Activity State"},
2475
    {0x0593, "Data Field: Device Position"},
2476
    {0x0594, "Data Field: Step Count"},
2477
    {0x0595, "Data Field: Step Count Reset"},
2478
    {0x0596, "Data Field: Step Duration"},
2479
    {0x0597, "Data Field: Step Type"},
2480
    {0x05A0, "Property: Minimum Activity Detection Interval"},
2481
    {0x05A1, "Property: Supported Activity Types"},
2482
    {0x05A2, "Property: Subscribed Activity Types"},
2483
    {0x05A3, "Property: Supported Step Types"},
2484
    {0x05A4, "Property: Subscribed Step Types"},
2485
    {0x05A5, "Property: Floor Height"},
2486
    {0x05B0, "Data Field: Custom Type ID"},
2487
    {0x05C0, "Property: Custom"},
2488
    {0x05C1, "Property: Custom Value 1"},
2489
    {0x05C2, "Property: Custom Value 2"},
2490
    {0x05C3, "Property: Custom Value 3"},
2491
    {0x05C4, "Property: Custom Value 4"},
2492
    {0x05C5, "Property: Custom Value 5"},
2493
    {0x05C6, "Property: Custom Value 6"},
2494
    {0x05C7, "Property: Custom Value 7"},
2495
    {0x05C8, "Property: Custom Value 8"},
2496
    {0x05C9, "Property: Custom Value 9"},
2497
    {0x05CA, "Property: Custom Value 10"},
2498
    {0x05CB, "Property: Custom Value 11"},
2499
    {0x05CC, "Property: Custom Value 12"},
2500
    {0x05CD, "Property: Custom Value 13"},
2501
    {0x05CE, "Property: Custom Value 14"},
2502
    {0x05CF, "Property: Custom Value 15"},
2503
    {0x05D0, "Property: Custom Value 16"},
2504
    {0x05E0, "Data Field: Hinge"},
2505
    {0x05E1, "Data Field: Hinge Angle"},
2506
    {0x05F0, "Data Field: Gesture Sensor"},
2507
    {0x05F1, "Data Field: Gesture State"},
2508
    {0x05F2, "Data Field: Hinge Fold Initial Angle"},
2509
    {0x05F3, "Data Field: Hinge Fold Final Angle"},
2510
    {0x05F4, "Data Field: Hinge Fold Contributing Panel"},
2511
    {0x05F5, "Data Field: Hinge Fold Type"},
2512
    {0x0800, "Sensor State: Undefined"},
2513
    {0x0801, "Sensor State: Ready"},
2514
    {0x0802, "Sensor State: Not Available"},
2515
    {0x0803, "Sensor State: No Data"},
2516
    {0x0804, "Sensor State: Initializing"},
2517
    {0x0805, "Sensor State: Access Denied"},
2518
    {0x0806, "Sensor State: Error"},
2519
    {0x0810, "Sensor Event: Unknown"},
2520
    {0x0811, "Sensor Event: State Changed"},
2521
    {0x0812, "Sensor Event: Property Changed"},
2522
    {0x0813, "Sensor Event: Data Updated"},
2523
    {0x0814, "Sensor Event: Poll Response"},
2524
    {0x0815, "Sensor Event: Change Sensitivity"},
2525
    {0x0816, "Sensor Event: Range Maximum Reached"},
2526
    {0x0817, "Sensor Event: Range Minimum Reached"},
2527
    {0x0818, "Sensor Event: High Threshold Cross Upward"},
2528
    {0x0819, "Sensor Event: High Threshold Cross Downward"},
2529
    {0x081A, "Sensor Event: Low Threshold Cross Upward"},
2530
    {0x081B, "Sensor Event: Low Threshold Cross Downward"},
2531
    {0x081C, "Sensor Event: Zero Threshold Cross Upward"},
2532
    {0x081D, "Sensor Event: Zero Threshold Cross Downward"},
2533
    {0x081E, "Sensor Event: Period Exceeded"},
2534
    {0x081F, "Sensor Event: Frequency Exceeded"},
2535
    {0x0820, "Sensor Event: Complex Trigger"},
2536
    {0x0830, "Connection Type: PC Integrated"},
2537
    {0x0831, "Connection Type: PC Attached"},
2538
    {0x0832, "Connection Type: PC External"},
2539
    {0x0840, "Reporting State: Report No Events"},
2540
    {0x0841, "Reporting State: Report All Events"},
2541
    {0x0842, "Reporting State: Report Threshold Events"},
2542
    {0x0843, "Reporting State: Wake On No Events"},
2543
    {0x0844, "Reporting State: Wake On All Events"},
2544
    {0x0845, "Reporting State: Wake On Threshold Events"},
2545
    {0x0846, "Reporting State: Anytime"},
2546
    {0x0850, "Power State: Undefined"},
2547
    {0x0851, "Power State: D0 Full Power"},
2548
    {0x0852, "Power State: D1 Low Power"},
2549
    {0x0853, "Power State: D2 Standby Power with Wakeup"},
2550
    {0x0854, "Power State: D3 Sleep with Wakeup"},
2551
    {0x0855, "Power State: D4 Power Off"},
2552
    {0x0860, "Accuracy: Default"},
2553
    {0x0861, "Accuracy: High"},
2554
    {0x0862, "Accuracy: Medium"},
2555
    {0x0863, "Accuracy: Low"},
2556
    {0x0870, "Fix Quality: No Fix"},
2557
    {0x0871, "Fix Quality: GPS"},
2558
    {0x0872, "Fix Quality: DGPS"},
2559
    {0x0880, "Fix Type: No Fix"},
2560
    {0x0881, "Fix Type: GPS SPS Mode, Fix Valid"},
2561
    {0x0882, "Fix Type: DGPS SPS Mode, Fix Valid"},
2562
    {0x0883, "Fix Type: GPS PPS Mode, Fix Valid"},
2563
    {0x0884, "Fix Type: Real Time Kinematic"},
2564
    {0x0885, "Fix Type: Float RTK"},
2565
    {0x0886, "Fix Type: Estimated (dead reckoned)"},
2566
    {0x0887, "Fix Type: Manual Input Mode"},
2567
    {0x0888, "Fix Type: Simulator Mode"},
2568
    {0x0890, "GPS Operation Mode: Manual"},
2569
    {0x0891, "GPS Operation Mode: Automatic"},
2570
    {0x08A0, "GPS Selection Mode: Autonomous"},
2571
    {0x08A1, "GPS Selection Mode: DGPS"},
2572
    {0x08A2, "GPS Selection Mode: Estimated (dead reckoned)"},
2573
    {0x08A3, "GPS Selection Mode: Manual Input"},
2574
    {0x08A4, "GPS Selection Mode: Simulator"},
2575
    {0x08A5, "GPS Selection Mode: Data Not Valid"},
2576
    {0x08B0, "GPS Status Data: Valid"},
2577
    {0x08B1, "GPS Status Data: Not Valid"},
2578
    {0x08C0, "Day of Week: Sunday"},
2579
    {0x08C1, "Day of Week: Monday"},
2580
    {0x08C2, "Day of Week: Tuesday"},
2581
    {0x08C3, "Day of Week: Wednesday"},
2582
    {0x08C4, "Day of Week: Thursday"},
2583
    {0x08C5, "Day of Week: Friday"},
2584
    {0x08C6, "Day of Week: Saturday"},
2585
    {0x08D0, "Kind: Category"},
2586
    {0x08D1, "Kind: Type"},
2587
    {0x08D2, "Kind: Event"},
2588
    {0x08D3, "Kind: Property"},
2589
    {0x08D4, "Kind: Data Field"},
2590
    {0x08E0, "Magnetometer Accuracy: Low"},
2591
    {0x08E1, "Magnetometer Accuracy: Medium"},
2592
    {0x08E2, "Magnetometer Accuracy: High"},
2593
    {0x08F0, "Simple Orientation Direction: Not Rotated"},
2594
    {0x08F1, "Simple Orientation Direction: Rotated 90 Degrees CCW"},
2595
    {0x08F2, "Simple Orientation Direction: Rotated 180 Degrees CCW"},
2596
    {0x08F3, "Simple Orientation Direction: Rotated 270 Degrees CCW"},
2597
    {0x08F4, "Simple Orientation Direction: Face Up"},
2598
    {0x08F5, "Simple Orientation Direction: Face Down"},
2599
    {0x0900, "VT_NULL: Empty"},
2600
    {0x0901, "VT_BOOL: Boolean"},
2601
    {0x0902, "VT_UI1: Byte"},
2602
    {0x0903, "VT_I1: Character"},
2603
    {0x0904, "VT_UI2: Unsigned Short"},
2604
    {0x0905, "VT_I2: Short"},
2605
    {0x0906, "VT_UI4: Unsigned Long"},
2606
    {0x0907, "VT_I4: Long"},
2607
    {0x0908, "VT_UI8: Unsigned Long Long"},
2608
    {0x0909, "VT_I8: Long Long"},
2609
    {0x090A, "VT_R4: Float"},
2610
    {0x090B, "VT_R8: Double"},
2611
    {0x090C, "VT_WSTR: Wide String"},
2612
    {0x090D, "VT_STR: Narrow String"},
2613
    {0x090E, "VT_CLSID: Guid"},
2614
    {0x090F, "VT_VECTOR|VT_UI1: Opaque Structure"},
2615
    {0x0910, "VT_F16E0: HID 16-bit Float with Unit Exponent 0"},
2616
    {0x0911, "VT_F16E1: HID 16-bit Float with Unit Exponent 1"},
2617
    {0x0912, "VT_F16E2: HID 16-bit Float with Unit Exponent 2"},
2618
    {0x0913, "VT_F16E3: HID 16-bit Float with Unit Exponent 3"},
2619
    {0x0914, "VT_F16E4: HID 16-bit Float with Unit Exponent 4"},
2620
    {0x0915, "VT_F16E5: HID 16-bit Float with Unit Exponent 5"},
2621
    {0x0916, "VT_F16E6: HID 16-bit Float with Unit Exponent 6"},
2622
    {0x0917, "VT_F16E7: HID 16-bit Float with Unit Exponent 7"},
2623
    {0x0918, "VT_F16E8: HID 16-bit Float with Unit Exponent 8"},
2624
    {0x0919, "VT_F16E9: HID 16-bit Float with Unit Exponent 9"},
2625
    {0x091A, "VT_F16EA: HID 16-bit Float with Unit Exponent A"},
2626
    {0x091B, "VT_F16EB: HID 16-bit Float with Unit Exponent B"},
2627
    {0x091C, "VT_F16EC: HID 16-bit Float with Unit Exponent C"},
2628
    {0x091D, "VT_F16ED: HID 16-bit Float with Unit Exponent D"},
2629
    {0x091E, "VT_F16EE: HID 16-bit Float with Unit Exponent E"},
2630
    {0x091F, "VT_F16EF: HID 16-bit Float with Unit Exponent F"},
2631
    {0x0920, "VT_F32E0: HID 32-bit Float with Unit Exponent 0"},
2632
    {0x0921, "VT_F32E1: HID 32-bit Float with Unit Exponent 1"},
2633
    {0x0922, "VT_F32E2: HID 32-bit Float with Unit Exponent 2"},
2634
    {0x0923, "VT_F32E3: HID 32-bit Float with Unit Exponent 3"},
2635
    {0x0924, "VT_F32E4: HID 32-bit Float with Unit Exponent 4"},
2636
    {0x0925, "VT_F32E5: HID 32-bit Float with Unit Exponent 5"},
2637
    {0x0926, "VT_F32E6: HID 32-bit Float with Unit Exponent 6"},
2638
    {0x0927, "VT_F32E7: HID 32-bit Float with Unit Exponent 7"},
2639
    {0x0928, "VT_F32E8: HID 32-bit Float with Unit Exponent 8"},
2640
    {0x0929, "VT_F32E9: HID 32-bit Float with Unit Exponent 9"},
2641
    {0x092A, "VT_F32EA: HID 32-bit Float with Unit Exponent A"},
2642
    {0x092B, "VT_F32EB: HID 32-bit Float with Unit Exponent B"},
2643
    {0x092C, "VT_F32EC: HID 32-bit Float with Unit Exponent C"},
2644
    {0x092D, "VT_F32ED: HID 32-bit Float with Unit Exponent D"},
2645
    {0x092E, "VT_F32EE: HID 32-bit Float with Unit Exponent E"},
2646
    {0x092F, "VT_F32EF: HID 32-bit Float with Unit Exponent F"},
2647
    {0x0930, "Activity Type: Unknown"},
2648
    {0x0931, "Activity Type: Stationary"},
2649
    {0x0932, "Activity Type: Fidgeting"},
2650
    {0x0933, "Activity Type: Walking"},
2651
    {0x0934, "Activity Type: Running"},
2652
    {0x0935, "Activity Type: In Vehicle"},
2653
    {0x0936, "Activity Type: Biking"},
2654
    {0x0937, "Activity Type: Idle"},
2655
    {0x0940, "Unit: Not Specified"},
2656
    {0x0941, "Unit: Lux"},
2657
    {0x0942, "Unit: Degrees Kelvin"},
2658
    {0x0943, "Unit: Degrees Celsius"},
2659
    {0x0944, "Unit: Pascal"},
2660
    {0x0945, "Unit: Newton"},
2661
    {0x0946, "Unit: Meters/Second"},
2662
    {0x0947, "Unit: Kilogram"},
2663
    {0x0948, "Unit: Meter"},
2664
    {0x0949, "Unit: Meters/Second/Second"},
2665
    {0x094A, "Unit: Farad"},
2666
    {0x094B, "Unit: Ampere"},
2667
    {0x094C, "Unit: Watt"},
2668
    {0x094D, "Unit: Henry"},
2669
    {0x094E, "Unit: Ohm"},
2670
    {0x094F, "Unit: Volt"},
2671
    {0x0950, "Unit: Hertz"},
2672
    {0x0951, "Unit: Bar"},
2673
    {0x0952, "Unit: Degrees Anti-clockwise"},
2674
    {0x0953, "Unit: Degrees Clockwise"},
2675
    {0x0954, "Unit: Degrees"},
2676
    {0x0955, "Unit: Degrees/Second"},
2677
    {0x0956, "Unit: Degrees/Second/Second"},
2678
    {0x0957, "Unit: Knot"},
2679
    {0x0958, "Unit: Percent"},
2680
    {0x0959, "Unit: Second"},
2681
    {0x095A, "Unit: Millisecond"},
2682
    {0x095B, "Unit: G"},
2683
    {0x095C, "Unit: Bytes"},
2684
    {0x095D, "Unit: Milligauss"},
2685
    {0x095E, "Unit: Bits"},
2686
    {0x0960, "Activity State: No State Change"},
2687
    {0x0961, "Activity State: Start Activity"},
2688
    {0x0962, "Activity State: End Activity"},
2689
    {0x0970, "Exponent 0: 1"},
2690
    {0x0971, "Exponent 1: 10"},
2691
    {0x0972, "Exponent 2: 100"},
2692
    {0x0973, "Exponent 3: 1 000"},
2693
    {0x0974, "Exponent 4: 10 000"},
2694
    {0x0975, "Exponent 5: 100 000"},
2695
    {0x0976, "Exponent 6: 1 000 000"},
2696
    {0x0977, "Exponent 7: 10 000 000"},
2697
    {0x0978, "Exponent 8: 0.00 000 001"},
2698
    {0x0979, "Exponent 9: 0.0 000 001"},
2699
    {0x097A, "Exponent A: 0.000 001"},
2700
    {0x097B, "Exponent B: 0.00 001"},
2701
    {0x097C, "Exponent C: 0.0 001"},
2702
    {0x097D, "Exponent D: 0.001"},
2703
    {0x097E, "Exponent E: 0.01"},
2704
    {0x097F, "Exponent F: 0.1"},
2705
    {0x0980, "Device Position: Unknown"},
2706
    {0x0981, "Device Position: Unchanged"},
2707
    {0x0982, "Device Position: On Desk"},
2708
    {0x0983, "Device Position: In Hand"},
2709
    {0x0984, "Device Position: Moving in Bag"},
2710
    {0x0985, "Device Position: Stationary in Bag"},
2711
    {0x0990, "Step Type: Unknown"},
2712
    {0x0991, "Step Type: Running"},
2713
    {0x0992, "Step Type: Walking"},
2714
    {0x09A0, "Gesture State: Unknown"},
2715
    {0x09A1, "Gesture State: Started"},
2716
    {0x09A2, "Gesture State: Completed"},
2717
    {0x09A3, "Gesture State: Cancelled"},
2718
    {0x09B0, "Hinge Fold Contributing Panel: Unknown"},
2719
    {0x09B1, "Hinge Fold Contributing Panel: Panel 1"},
2720
    {0x09B2, "Hinge Fold Contributing Panel: Panel 2"},
2721
    {0x09B3, "Hinge Fold Contributing Panel: Both"},
2722
    {0x09B4, "Hinge Fold Type: Unknown"},
2723
    {0x09B5, "Hinge Fold Type: Increasing"},
2724
    {0x09B6, "Hinge Fold Type: Decreasing"},
2725
    {0x09C0, "Human Presence Detection: Vendor-Defined Non-Biometric"},
2726
    {0x09C1, "Human Presence Detection: Vendor-Defined Biometric"},
2727
    {0x09C2, "Human Presence Detection: Facial Biometric"},
2728
    {0x09C3, "Human Presence Detection: Audio Biometric"},
2729
    {0x1000, "Modifier: Change Sensitivity Absolute"},
2730
    {0x2000, "Modifier: Maximum"},
2731
    {0x3000, "Modifier: Minimum"},
2732
    {0x4000, "Modifier: Accuracy"},
2733
    {0x5000, "Modifier: Resolution"},
2734
    {0x6000, "Modifier: Threshold High"},
2735
    {0x7000, "Modifier: Threshold Low"},
2736
    {0x8000, "Modifier: Calibration Offset"},
2737
    {0x9000, "Modifier: Calibration Multiplier"},
2738
    {0xA000, "Modifier: Report Interval"},
2739
    {0xB000, "Modifier: Frequency Max"},
2740
    {0xC000, "Modifier: Period Max"},
2741
    {0xD000, "Modifier: Change Sensitivity Percent of Range"},
2742
    {0xE000, "Modifier: Change Sensitivity Percent Relative"},
2743
    {0xF000, "Modifier: Vendor Reserved"},
2744
    {0, NULL}
2745
};
2746
static const range_string usb_hid_sensor_usage_page_ranges[] = {
2747
    {0x001A, 0x001F, "Reserved (Biometric)"},
2748
    {0x002A, 0x002F, "Reserved (Electrical)"},
2749
    {0x003C, 0x003F, "Reserved (Environmental)"},
2750
    {0x0046, 0x004F, "Reserved (Light)"},
2751
    {0x0058, 0x005F, "Reserved (Location)"},
2752
    {0x006A, 0x006F, "Reserved (Mechanical)"},
2753
    {0x007D, 0x007F, "Reserved (Motion)"},
2754
    {0x0094, 0x009F, "Reserved (Scanner)"},
2755
    {0x00A3, 0x00AF, "Reserved (Time)"},
2756
    {0x00B5, 0x00BF, "Reserved (Personal Activity)"},
2757
    {0x00C3, 0x00CF, "Reserved (Orientation Extended)"},
2758
    {0x00D3, 0x00DF, "Reserved (Gesture)"},
2759
    {0x00E5, 0x00EF, "Reserved (Other)"},
2760
    {0x00F0, 0x00FF, "Reserved for Vendors/OEMs"},
2761
    {0x031F, 0x03FF, "Reserved (Property)"},
2762
    {0x0428, 0x0429, "Reserved (Data Field: Location)"},
2763
    {0x042C, 0x042F, "Reserved (Property: Location)"},
2764
    {0x043D, 0x043F, "Reserved (Data Field: Environmental)"},
2765
    {0x0442, 0x044F, "Reserved (Property: Environmental)"},
2766
    {0x0460, 0x046F, "Reserved (Data Field: Motion)"},
2767
    {0x048A, 0x048F, "Reserved (Data Field: Orientation)"},
2768
    {0x0499, 0x049F, "Reserved (Data Field: Mechanical)"},
2769
    {0x04A4, 0x04AF, "Reserved (Property: Mechanical)"},
2770
    {0x04BD, 0x04CF, "Reserved (Data Field: Biometric)"},
2771
    {0x04E4, 0x04EF, "Reserved (Property: Light)"},
2772
    {0x04F3, 0x04F7, "Reserved (Data Field: Scanner)"},
2773
    {0x04FA, 0x04FF, "Reserved (Property: Scanner)"},
2774
    {0x050A, 0x051F, "Reserved (Data Field: Electrical)"},
2775
    {0x052C, 0x052F, "Reserved (Data Field: Time)"},
2776
    {0x0536, 0x053F, "Reserved (Property: Time)"},
2777
    {0x0577, 0x057F, "Reserved (Data Field: Generic)"},
2778
    {0x0583, 0x058F, "Reserved (Property: Generic)"},
2779
    {0x0598, 0x059F, "Reserved (Data Field: Personal Activity)"},
2780
    {0x05A6, 0x05AF, "Reserved (Property: Personal Activity)"},
2781
    {0x05B1, 0x05BF, "Reserved (Data Field: Custom)"},
2782
    {0x05C0, 0x07FF, "Reserved for future use as Sensor Types, Data Fields and Properties"},
2783
    {0x0800, 0x09FF, "Reserved for use as Selection Values"},
2784
    {0x1100, 0x17FF, "Reserved for use as Change Sensitivity Absolute modifier range"},
2785
    {0x2100, 0x27FF, "Reserved for use as Maximum modifier range"},
2786
    {0x3100, 0x37FF, "Reserved for use as Minimum modifier range"},
2787
    {0x4100, 0x47FF, "Reserved for use as Accuracy modifier range"},
2788
    {0x5100, 0x57FF, "Reserved for use as Resolution modifier range"},
2789
    {0x6100, 0x67FF, "Reserved for use as Threshold High modifier range"},
2790
    {0x7100, 0x77FF, "Reserved for use as Threshold Low modifier range"},
2791
    {0x8100, 0x87FF, "Reserved for use as Calibration Offset modifier range"},
2792
    {0x9100, 0x97FF, "Reserved for use as Calibration Multiplier modifier range"},
2793
    {0xA100, 0xA7FF, "Reserved for use as Report Interval modifier range"},
2794
    {0xB100, 0xB7FF, "Reserved for use as Frequency Max modifier range"},
2795
    {0xC100, 0xC7FF, "Reserved for use as Period Max modifier range"},
2796
    {0xD100, 0xD7FF, "Reserved for use as Change Sensitivity Percent modifier range"},
2797
    {0xE100, 0xE7FF, "Reserved for use as Change Sensitivity Percent modifier range"},
2798
    {0xF100, 0xF7FF, "Reserved for use as Vendor Reserved modifier range"},
2799
    /* More generic (and overlapping) ranges in case a better match isn't found above */
2800
    {0x1000, 0xEFFF, "Reserved for use as \"Data Fields with Modifiers\""},
2801
    {0xF000, 0xFFFF, "Reserved for Vendors/OEMs"},
2802
    {0, 0, NULL}
2803
};
2804
static const value_string usb_hid_medical_instrument_usage_page_vals[] = {
2805
    {0x00, "Undefined"},
2806
    {0x01, "Medical Ultrasound"},
2807
    {0x20, "VCR/Acquisition"},
2808
    {0x21, "Freeze/Thaw"},
2809
    {0x22, "Clip Store"},
2810
    {0x23, "Update"},
2811
    {0x24, "Next"},
2812
    {0x25, "Save"},
2813
    {0x26, "Print"},
2814
    {0x27, "Microphone Enable"},
2815
    {0x40, "Cine"},
2816
    {0x41, "Transmit Power"},
2817
    {0x42, "Volume"},
2818
    {0x43, "Focus"},
2819
    {0x44, "Depth"},
2820
    {0x60, "Soft Step - Primary"},
2821
    {0x61, "Soft Step - Secondary"},
2822
    {0x70, "Depth Gain Compensation"},
2823
    {0x80, "Zoom Select"},
2824
    {0x81, "Zoom Adjust"},
2825
    {0x82, "Spectral Doppler Mode Select"},
2826
    {0x83, "Spectral Doppler Adjust"},
2827
    {0x84, "Color Doppler Mode Select"},
2828
    {0x85, "Color Doppler Adjust"},
2829
    {0x86, "Motion Mode Select"},
2830
    {0x87, "Motion Mode Adjust"},
2831
    {0x88, "2-D Mode Select"},
2832
    {0x89, "2-D Mode Adjust"},
2833
    {0xA0, "Soft Control Select"},
2834
    {0xA1, "Soft Control Adjust"},
2835
    {0, NULL}
2836
};
2837
static const value_string usb_hid_braille_display_usage_page_vals[] = {
2838
    {0x000, "Undefined"},
2839
    {0x001, "Braille Display"},
2840
    {0x002, "Braille Row"},
2841
    {0x003, "8 Dot Braille Cell"},
2842
    {0x004, "6 Dot Braille Cell"},
2843
    {0x005, "Number of Braille Cells"},
2844
    {0x006, "Screen Reader Control"},
2845
    {0x007, "Screen Reader Identifier"},
2846
    {0x0FA, "Router Set 1"},
2847
    {0x0FB, "Router Set 2"},
2848
    {0x0FC, "Router Set 3"},
2849
    {0x100, "Router Key"},
2850
    {0x101, "Row Router Key"},
2851
    {0x200, "Braille Buttons"},
2852
    {0x201, "Braille Keyboard Dot 1"},
2853
    {0x202, "Braille Keyboard Dot 2"},
2854
    {0x203, "Braille Keyboard Dot 3"},
2855
    {0x204, "Braille Keyboard Dot 4"},
2856
    {0x205, "Braille Keyboard Dot 5"},
2857
    {0x206, "Braille Keyboard Dot 6"},
2858
    {0x207, "Braille Keyboard Dot 7"},
2859
    {0x208, "Braille Keyboard Dot 8"},
2860
    {0x209, "Braille Keyboard Space"},
2861
    {0x20A, "Braille Keyboard Left Space"},
2862
    {0x20B, "Braille Keyboard Right Space"},
2863
    {0x20C, "Braille Face Controls"},
2864
    {0x20D, "Braille Left Controls"},
2865
    {0x20E, "Braille Right Controls"},
2866
    {0x20F, "Braille Top Controls"},
2867
    {0x210, "Braille Joystick Center"},
2868
    {0x211, "Braille Joystick Up"},
2869
    {0x212, "Braille Joystick Down"},
2870
    {0x213, "Braille Joystick Left"},
2871
    {0x214, "Braille Joystick Right"},
2872
    {0x215, "Braille D-Pad Center"},
2873
    {0x216, "Braille D-Pad Up"},
2874
    {0x217, "Braille D-Pad Down"},
2875
    {0x218, "Braille D-Pad Left"},
2876
    {0x219, "Braille D-Pad Right"},
2877
    {0x21A, "Braille Pan Left"},
2878
    {0x21B, "Braille Pan Right"},
2879
    {0x21C, "Braille Rocker Up"},
2880
    {0x21D, "Braille Rocker Down"},
2881
    {0x21E, "Braille Rocker Press"},
2882
    {0, NULL}
2883
};
2884
static const value_string usb_hid_lighting_and_illumination_usage_page_vals[] = {
2885
    {0x00, "Undefined"},
2886
    {0x01, "LampArray"},
2887
    {0x02, "LampArrayAttributesReport"},
2888
    {0x03, "LampCount"},
2889
    {0x04, "BoundingBoxWidthInMicrometers"},
2890
    {0x05, "BoundingBoxHeightInMicrometers"},
2891
    {0x06, "BoundingBoxDepthInMicrometers"},
2892
    {0x07, "LampArrayKind"},
2893
    {0x08, "MinUpdateIntervalInMicroseconds"},
2894
    {0x20, "LampAttributesRequestReport"},
2895
    {0x21, "LampId"},
2896
    {0x22, "LampAttributesResponseReport"},
2897
    {0x23, "PositionXInMicrometers"},
2898
    {0x24, "PositionYInMicrometers"},
2899
    {0x25, "PositionZInMicrometers"},
2900
    {0x26, "LampPurposes"},
2901
    {0x27, "UpdateLatencyInMicroseconds"},
2902
    {0x28, "RedLevelCount"},
2903
    {0x29, "GreenLevelCount"},
2904
    {0x2A, "BlueLevelCount"},
2905
    {0x2B, "IntensityLevelCount"},
2906
    {0x2C, "IsProgrammable"},
2907
    {0x2D, "InputBinding"},
2908
    {0x50, "LampMultiUpdateReport"},
2909
    {0x51, "RedUpdateChannel"},
2910
    {0x52, "GreenUpdateChannel"},
2911
    {0x53, "BlueUpdateChannel"},
2912
    {0x54, "IntensityUpdateChannel"},
2913
    {0x55, "LampUpdateFlags"},
2914
    {0x60, "LampRangeUpdateReport"},
2915
    {0x61, "LampIdStart"},
2916
    {0x62, "LampIdEnd"},
2917
    {0x70, "LampArrayControlReport"},
2918
    {0x71, "AutonomousMode"},
2919
    {0, NULL}
2920
};
2921
static const value_string usb_hid_monitor_usage_page_vals[] = {
2922
    {0x00, "Reserved"},
2923
    {0x01, "Monitor Control"},
2924
    {0x02, "EDID Information"},
2925
    {0x03, "VDIF Information"},
2926
    {0x04, "VESA Version"},
2927
    {0, NULL}
2928
};
2929
static const value_string usb_hid_vesa_virtual_control_usage_page_vals[] = {
2930
    /* Contiguous Controls */
2931
    {0x10, "Brightness"},
2932
    {0x12, "Contrast"},
2933
    {0x16, "Red Video Gain"},
2934
    {0x18, "Green Video Gain"},
2935
    {0x1A, "Blue Video Gain"},
2936
    {0x1C, "Focus"},
2937
    {0x20, "Horizontal Position"},
2938
    {0x22, "Horizontal Size"},
2939
    {0x24, "Horizontal Pincushion"},
2940
    {0x26, "Horizontal Pincushion Balance"},
2941
    {0x28, "Horizontal Misconvergence"},
2942
    {0x2A, "Horizontal Linearity"},
2943
    {0x2C, "Horizontal Linearity Balance"},
2944
    {0x30, "Vertical Position"},
2945
    {0x32, "Vertical Size"},
2946
    {0x34, "Vertical Pincushion"},
2947
    {0x36, "Vertical Pincushion Balance"},
2948
    {0x38, "Vertical Misconvergence"},
2949
    {0x3A, "Vertical Linearity"},
2950
    {0x3C, "Vertical Linearity Balance"},
2951
    {0x40, "Parallelogram Distortion (Key Balance)"},
2952
    {0x42, "Trapezoidal Distortion (Key)"},
2953
    {0x44, "Tilt (Rotation)"},
2954
    {0x46, "Top Corner Distortion Control"},
2955
    {0x48, "Top Corner Distortion Balance"},
2956
    {0x4A, "Bottom Corner Distortion Control"},
2957
    {0x4C, "Bottom Corner Distortion Balance"},
2958
    {0x56, "Horizontal Moire"},
2959
    {0x58, "Vertical Moire"},
2960
    {0x6C, "Red Video Black Level"},
2961
    {0x6E, "Green Video Black Level"},
2962
    {0x70, "Blue Video Black Level"},
2963
    /* Non-contiguous Controls (Read/Write) */
2964
    {0x5E, "Input Level Select"},
2965
    {0x60, "Input Source Select"},
2966
    {0xCA, "On Screen Display"},
2967
    {0xD4, "StereoMode"},
2968
    /* Non-contiguous Controls (Read-only) */
2969
    {0xA2, "Auto Size Center"},
2970
    {0xA4, "Polarity Horizontal Synchronization"},
2971
    {0xA6, "Polarity Vertical Synchronization"},
2972
    {0xA8, "Synchronization Type"},
2973
    {0xAA, "Screen Orientation"},
2974
    {0xAC, "Horizontal Frequency"},
2975
    {0xAE, "Vertical Frequency"},
2976
    /* Non-contiguous Controls (Write-only) */
2977
    {0x01, "Degauss"},
2978
    {0xB0, "Settings"},
2979
    {0, NULL}
2980
};
2981
static const value_string usb_hid_power_device_usage_page_vals[] = {
2982
    {0x00, "Undefined"},
2983
    {0x01, "iName"},
2984
    {0x02, "PresentStatus"},
2985
    {0x03, "ChangedStatus"},
2986
    {0x04, "UPS"},
2987
    {0x05, "PowerSupply"},
2988
    {0x10, "BatterySystem"},
2989
    {0x11, "BatterySystemID"},
2990
    {0x12, "Battery"},
2991
    {0x13, "BatteryID"},
2992
    {0x14, "Charger"},
2993
    {0x15, "ChargerID"},
2994
    {0x16, "PowerConverter"},
2995
    {0x17, "PowerConverterID"},
2996
    {0x18, "OutletSystem"},
2997
    {0x19, "OutletSystemID"},
2998
    {0x1A, "Input"},
2999
    {0x1B, "InputID"},
3000
    {0x1C, "Output"},
3001
    {0x1D, "OutputID"},
3002
    {0x1E, "Flow"},
3003
    {0x1F, "FlowID"},
3004
    {0x20, "Outlet"},
3005
    {0x21, "OutletID"},
3006
    {0x22, "Gang"},
3007
    {0x23, "GangID"},
3008
    {0x24, "PowerSummary"},
3009
    {0x25, "PowerSummaryID"},
3010
    {0x30, "Voltage"},
3011
    {0x31, "Current"},
3012
    {0x32, "Frequency"},
3013
    {0x33, "ApparentPower"},
3014
    {0x34, "ActivePower"},
3015
    {0x35, "PercentLoad"},
3016
    {0x36, "Temperature"},
3017
    {0x37, "Humidity"},
3018
    {0x38, "BadCount"},
3019
    {0x40, "ConfigVoltage"},
3020
    {0x41, "ConfigCurrent"},
3021
    {0x42, "ConfigFrequency"},
3022
    {0x43, "ConfigApparentPower"},
3023
    {0x44, "ConfigActivePower"},
3024
    {0x45, "ConfigPercentLoad"},
3025
    {0x46, "ConfigTemperature"},
3026
    {0x47, "ConfigHumidity"},
3027
    {0x50, "SwitchOnControl"},
3028
    {0x51, "SwitchOffControl"},
3029
    {0x52, "ToggleControl"},
3030
    {0x53, "LowVoltageTransfer"},
3031
    {0x54, "HighVoltageTransfer"},
3032
    {0x55, "DelayBeforeReboot"},
3033
    {0x56, "DelayBeforeStartup"},
3034
    {0x57, "DelayBeforeShutdown"},
3035
    {0x58, "Test"},
3036
    {0x59, "ModuleReset"},
3037
    {0x5A, "AudibleAlarmControl"},
3038
    {0x60, "Present"},
3039
    {0x61, "Good"},
3040
    {0x62, "InternalFailure"},
3041
    {0x63, "VoltageOutOfRange"},
3042
    {0x64, "FrequencyOutOfRange"},
3043
    {0x65, "Overload"},
3044
    {0x66, "OverCharged"},
3045
    {0x67, "OverTemperature"},
3046
    {0x68, "ShutdownRequested"},
3047
    {0x69, "ShutdownImminent"},
3048
    {0x6B, "SwitchOn/Off"},
3049
    {0x6C, "Switchable"},
3050
    {0x6D, "Used"},
3051
    {0x6E, "Boost"},
3052
    {0x6F, "Buck"},
3053
    {0x70, "Initialized"},
3054
    {0x71, "Tested"},
3055
    {0x72, "AwaitingPower"},
3056
    {0x73, "CommunicationLost"},
3057
    {0xFD, "iManufacturer"},
3058
    {0xFE, "iProduct"},
3059
    {0xFF, "iSerialNumber"},
3060
    {0, NULL}
3061
};
3062
static const value_string usb_hid_battery_system_usage_page_vals[] = {
3063
    {0x00, "Undefined"},
3064
    {0x01, "SMBBatteryMode"},
3065
    {0x02, "SMBBatteryStatus"},
3066
    {0x03, "SMBAlarmWarning"},
3067
    {0x04, "SMBChargerMode"},
3068
    {0x05, "SMBChargerStatus"},
3069
    {0x06, "SMBChargerSpecInfo"},
3070
    {0x07, "SMBSelectorState"},
3071
    {0x08, "SMBSelectorPresets"},
3072
    {0x09, "SMBSelectorInfo"},
3073
    {0x10, "OptionalMfgFunction1"},
3074
    {0x11, "OptionalMfgFunction2"},
3075
    {0x12, "OptionalMfgFunction3"},
3076
    {0x13, "OptionalMfgFunction4"},
3077
    {0x14, "OptionalMfgFunction5"},
3078
    {0x15, "ConnectionToSMBus"},
3079
    {0x16, "OutputConnection"},
3080
    {0x17, "ChargerConnection"},
3081
    {0x18, "BatteryInsertion"},
3082
    {0x19, "Usenext"},
3083
    {0x1A, "OKToUse"},
3084
    {0x1B, "BatterySupported"},
3085
    {0x1C, "SelectorRevision"},
3086
    {0x1D, "ChargingIndicator"},
3087
    {0x28, "ManufacturerAccess"},
3088
    {0x29, "RemainingCapacityLimit"},
3089
    {0x2A, "RemainingTimeLimit"},
3090
    {0x2B, "AtRate"},
3091
    {0x2C, "CapacityMode"},
3092
    {0x2D, "BroadcastToCharger"},
3093
    {0x2E, "PrimaryBattery"},
3094
    {0x2F, "ChargeController"},
3095
    {0x40, "TerminateCharge"},
3096
    {0x41, "TerminateDischarge"},
3097
    {0x42, "BelowRemainingCapacityLimit"},
3098
    {0x43, "RemainingTimeLimitExpired"},
3099
    {0x44, "Charging"},
3100
    {0x45, "Discharging"},
3101
    {0x46, "FullyCharged"},
3102
    {0x47, "FullyDischarged"},
3103
    {0x48, "ConditioningFlag"},
3104
    {0x49, "AtRateOK"},
3105
    {0x4A, "SMBErrorCode"},
3106
    {0x4B, "NeedReplacement"},
3107
    {0x60, "AtRateTimeToFull"},
3108
    {0x61, "AtRateTimeToEmpty"},
3109
    {0x62, "AverageCurrent"},
3110
    {0x63, "MaxError"},
3111
    {0x64, "RelativeStateOfCharge"},
3112
    {0x65, "AbsoluteStateOfCharge"},
3113
    {0x66, "RemainingCapacity"},
3114
    {0x67, "FullChargeCapacity"},
3115
    {0x68, "RunTimeToEmpty"},
3116
    {0x69, "AverageTimeToEmpty"},
3117
    {0x6A, "AverageTimeToFull"},
3118
    {0x6B, "CycleCount"},
3119
    {0x80, "BattPackModelLevel"},
3120
    {0x81, "InternalChargeController"},
3121
    {0x82, "PrimaryBatterySupport"},
3122
    {0x83, "DesignCapacity"},
3123
    {0x84, "SpecificationInfo"},
3124
    {0x85, "ManufacturerDate"},
3125
    {0x86, "SerialNumber"},
3126
    {0x87, "iManufacturerName"},
3127
    {0x88, "iDeviceName"},
3128
    {0x89, "iDeviceChemistry"},
3129
    {0x8A, "ManufacturerData"},
3130
    {0x8B, "Rechargeable"},
3131
    {0x8C, "WarningCapacityLimit"},
3132
    {0x8D, "CapacityGranularity1"},
3133
    {0x8E, "CapacityGranularity2"},
3134
    {0x8F, "iOEMInformation"},
3135
    {0xC0, "InhibitCharge"},
3136
    {0xC1, "EnablePolling"},
3137
    {0xC2, "ResetToZero"},
3138
    {0xD0, "ACPresent"},
3139
    {0xD1, "BatteryPresent"},
3140
    {0xD2, "PowerFail"},
3141
    {0xD3, "AlarmInhibited"},
3142
    {0xD4, "ThermistorUnderRange"},
3143
    {0xD5, "ThermistorHot"},
3144
    {0xD6, "ThermistorCold"},
3145
    {0xD7, "ThermistorOverRange"},
3146
    {0xD8, "VoltageOutOfRange"},
3147
    {0xD9, "CurrentOutOfRange"},
3148
    {0xDA, "CurrentNotRegulated"},
3149
    {0xDB, "VoltageNotRegulated"},
3150
    {0xDC, "MasterMode"},
3151
    {0xF0, "ChargerSelectorSupport"},
3152
    {0xF1, "ChargerSpec"},
3153
    {0xF2, "Level2"},
3154
    {0xF3, "Level3"},
3155
    {0, NULL}
3156
};
3157
static const value_string usb_hid_barcode_scanner_usage_page_vals[] = {
3158
    {0x000, "Undefined"},
3159
    {0x001, "Bar Code Badge Reader"},
3160
    {0x002, "Bar Code Scanner"},
3161
    {0x003, "Dumb Bar Code Scanner"},
3162
    {0x004, "Cordless Scanner Base"},
3163
    {0x005, "Bar Code Scanner Cradle"},
3164
    {0x010, "Attribute Report"},
3165
    {0x011, "Settings Report"},
3166
    {0x012, "Scanned Data Report"},
3167
    {0x013, "Raw Scanned Data Report"},
3168
    {0x014, "Trigger Report"},
3169
    {0x015, "Status Report"},
3170
    {0x016, "UPC/EAN Control Report"},
3171
    {0x017, "EAN 2/3 Label Control Report"},
3172
    {0x018, "Code 39 Control Report"},
3173
    {0x019, "Interleaved 2 of 5 Control Report"},
3174
    {0x01A, "Standard 2 of 5 Control Report"},
3175
    {0x01B, "MSI Plessey Control Report"},
3176
    {0x01C, "Codabar Control Report"},
3177
    {0x01D, "Code 128 Control Report"},
3178
    {0x01E, "Misc 1D Control Report"},
3179
    {0x01F, "2D Control Report"},
3180
    {0x030, "Aiming/Pointer Mode"},
3181
    {0x031, "Bar Code Present Sensor"},
3182
    {0x032, "Class 1A Laser"},
3183
    {0x033, "Class 2 Laser"},
3184
    {0x034, "Heater Present"},
3185
    {0x035, "Contact Scanner"},
3186
    {0x036, "Electronic Article Surveillance Notification"},
3187
    {0x037, "Constant Electronic Article Surveillance"},
3188
    {0x038, "Error Indication"},
3189
    {0x039, "Fixed Beeper"},
3190
    {0x03A, "Good Decode Indication"},
3191
    {0x03B, "Hands Free Scanning"},
3192
    {0x03C, "Intrinsically Safe"},
3193
    {0x03D, "Klasse Eins Laser"},
3194
    {0x03E, "Long Range Scanner"},
3195
    {0x03F, "Mirror Speed Control"},
3196
    {0x040, "Not On File Indication"},
3197
    {0x041, "Programmable Beeper"},
3198
    {0x042, "Triggerless"},
3199
    {0x043, "Wand"},
3200
    {0x044, "Water Resistant"},
3201
    {0x045, "Multi-Range Scanner"},
3202
    {0x046, "Proximity Sensor"},
3203
    {0x04D, "Fragment Decoding"},
3204
    {0x04E, "Scanner Read Confidence"},
3205
    {0x04F, "Data Prefix"},
3206
    {0x050, "Prefix AIMI"},
3207
    {0x051, "Prefix None"},
3208
    {0x052, "Prefix Proprietary"},
3209
    {0x055, "Active Time"},
3210
    {0x056, "Aiming Laser Pattern"},
3211
    {0x057, "Bar Code Present"},
3212
    {0x058, "Beeper State"},
3213
    {0x059, "Laser On Time"},
3214
    {0x05A, "Laser State"},
3215
    {0x05B, "Lockout Time"},
3216
    {0x05C, "Motor State"},
3217
    {0x05D, "Motor Timeout"},
3218
    {0x05E, "Power On Reset Scanner"},
3219
    {0x05F, "Prevent Read of Barcodes"},
3220
    {0x060, "Initiate Barcode Read"},
3221
    {0x061, "Trigger State"},
3222
    {0x062, "Trigger Mode"},
3223
    {0x063, "Trigger Mode Blinking Laser On"},
3224
    {0x064, "Trigger Mode Continuous Laser On"},
3225
    {0x065, "Trigger Mode Laser on while Pulled"},
3226
    {0x066, "Trigger Mode Laser stays on after Trigger release"},
3227
    {0x06D, "Commit Parameters to NVM"},
3228
    {0x06E, "Parameter Scanning"},
3229
    {0x06F, "Parameters Changed"},
3230
    {0x070, "Set parameter default values"},
3231
    {0x075, "Scanner In Cradle"},
3232
    {0x076, "Scanner In Range"},
3233
    {0x07A, "Aim Duration"},
3234
    {0x07B, "Good Read Lamp Duration"},
3235
    {0x07C, "Good Read Lamp Intensity"},
3236
    {0x07D, "Good Read LED"},
3237
    {0x07E, "Good Read Tone Frequency"},
3238
    {0x07F, "Good Read Tone Length"},
3239
    {0x080, "Good Read Tone Volume"},
3240
    {0x082, "No Read Message"},
3241
    {0x083, "Not on File Volume"},
3242
    {0x084, "Powerup Beep"},
3243
    {0x085, "Sound Error Beep"},
3244
    {0x086, "Sound Good Read Beep"},
3245
    {0x087, "Sound Not On File Beep"},
3246
    {0x088, "Good Read When to Write"},
3247
    {0x089, "GRWTI After Decode"},
3248
    {0x08A, "GRWTI Beep/Lamp after transmit"},
3249
    {0x08B, "GRWTI No Beep/Lamp use at all"},
3250
    {0x091, "Bookland EAN"},
3251
    {0x092, "Convert EAN 8 to 13 Type"},
3252
    {0x093, "Convert UPC A to EAN-13"},
3253
    {0x094, "Convert UPC-E to A"},
3254
    {0x095, "EAN-13"},
3255
    {0x096, "EAN-8"},
3256
    {0x097, "EAN-99 128_Mandatory"},
3257
    {0x098, "EAN-99 P5/128_Optional"},
3258
    {0x099, "Enable EAN Two Label"},
3259
    {0x09A, "UPC/EAN"},
3260
    {0x09B, "UPC/EAN Coupon Code"},
3261
    {0x09C, "UPC/EAN Periodicals"},
3262
    {0x09D, "UPC-A"},
3263
    {0x09E, "UPC-A with 128 Mandatory"},
3264
    {0x09F, "UPC-A with 128 Optional"},
3265
    {0x0A0, "UPC-A with P5 Optional"},
3266
    {0x0A1, "UPC-E"},
3267
    {0x0A2, "UPC-E1"},
3268
    {0x0A9, "Periodical"},
3269
    {0x0AA, "Periodical Auto-Discriminate + 2"},
3270
    {0x0AB, "Periodical Only Decode with + 2"},
3271
    {0x0AC, "Periodical Ignore + 2"},
3272
    {0x0AD, "Periodical Auto-Discriminate + 5"},
3273
    {0x0AE, "Periodical Only Decode with + 5"},
3274
    {0x0AF, "Periodical Ignore + 5"},
3275
    {0x0B0, "Check"},
3276
    {0x0B1, "Check Disable Price"},
3277
    {0x0B2, "Check Enable 4 digit Price"},
3278
    {0x0B3, "Check Enable 5 digit Price"},
3279
    {0x0B4, "Check Enable European 4 digit Price"},
3280
    {0x0B5, "Check Enable European 5 digit Price"},
3281
    {0x0B7, "EAN Two Label"},
3282
    {0x0B8, "EAN Three Label"},
3283
    {0x0B9, "EAN 8 Flag Digit 1"},
3284
    {0x0BA, "EAN 8 Flag Digit 2"},
3285
    {0x0BB, "EAN 8 Flag Digit 3"},
3286
    {0x0BC, "EAN 13 Flag Digit 1"},
3287
    {0x0BD, "EAN 13 Flag Digit 2"},
3288
    {0x0BE, "EAN 13 Flag Digit 3"},
3289
    {0x0BF, "Add EAN 2/3 Label Definition"},
3290
    {0x0C0, "Clear all EAN 2/3 Label Definitions"},
3291
    {0x0C3, "Codabar"},
3292
    {0x0C4, "Code 128"},
3293
    {0x0C7, "Code 39"},
3294
    {0x0C8, "Code 93 "},
3295
    {0x0C9, "Full ASCII Conversion"},
3296
    {0x0CA, "Interleaved 2 of 5"},
3297
    {0x0CB, "Italian Pharmacy Code"},
3298
    {0x0CC, "MSI/Plessey"},
3299
    {0x0CD, "Standard 2 of 5 IATA"},
3300
    {0x0CE, "Standard 2 of 5"},
3301
    {0x0D3, "Transmit Start/Stop"},
3302
    {0x0D4, "Tri-Optic"},
3303
    {0x0D5, "UCC/EAN-128"},
3304
    {0x0D6, "Check Digit"},
3305
    {0x0D7, "Check Digit Disable"},
3306
    {0x0D8, "Check Digit Enable Interleaved 2 of 5 OPCC"},
3307
    {0x0D9, "Check Digit Enable Interleaved 2 of 5 USS"},
3308
    {0x0DA, "Check Digit Enable Standard 2 of 5 OPCC"},
3309
    {0x0DB, "Check Digit Enable Standard 2 of 5 USS"},
3310
    {0x0DC, "Check Digit Enable One MSI Plessey"},
3311
    {0x0DD, "Check Digit Enable Two MSI Plessey"},
3312
    {0x0DE, "Check Digit Codabar Enable"},
3313
    {0x0DF, "Check Digit Code 39 Enable"},
3314
    {0x0F0, "Transmit Check Digit"},
3315
    {0x0F1, "Disable Check Digit Transmit"},
3316
    {0x0F2, "Enable Check Digit Transmit"},
3317
    {0x0FB, "Symbology Identifier 1"},
3318
    {0x0FC, "Symbology Identifier 2"},
3319
    {0x0FD, "Symbology Identifier 3"},
3320
    {0x0FE, "Decoded Data"},
3321
    {0x0FF, "Decode Data Continued"},
3322
    {0x100, "Bar Space Data"},
3323
    {0x101, "Scanner Data Accuracy"},
3324
    {0x102, "Raw Data Polarity"},
3325
    {0x103, "Polarity Inverted Bar Code"},
3326
    {0x104, "Polarity Normal Bar Code"},
3327
    {0x106, "Minimum Length to Decode"},
3328
    {0x107, "Maximum Length to Decode"},
3329
    {0x108, "First Discrete Length to Decode"},
3330
    {0x109, "Second Discrete Length to Decode"},
3331
    {0x10A, "Data Length Method"},
3332
    {0x10B, "DL Method Read any"},
3333
    {0x10C, "DL Method Check in Range"},
3334
    {0x10D, "DL Method Check for Discrete"},
3335
    {0x110, "Aztec Code"},
3336
    {0x111, "BC412"},
3337
    {0x112, "Channel Code"},
3338
    {0x113, "Code 16"},
3339
    {0x114, "Code 32"},
3340
    {0x115, "Code 49"},
3341
    {0x116, "Code One"},
3342
    {0x117, "Colorcode"},
3343
    {0x118, "Data Matrix"},
3344
    {0x119, "MaxiCode"},
3345
    {0x11A, "MicroPDF"},
3346
    {0x11B, "PDF-417"},
3347
    {0x11C, "PosiCode"},
3348
    {0x11D, "QR Code"},
3349
    {0x11E, "SuperCode"},
3350
    {0x11F, "UltraCode"},
3351
    {0x120, "USD-5 (Slug Code)"},
3352
    {0x121, "VeriCode"},
3353
    {0, NULL}
3354
};
3355
static const value_string usb_hid_weighing_devices_usage_page_vals[] = {
3356
    {0x00, "Undefined"},
3357
    {0x01, "Weighing Device"},
3358
    {0x20, "Scale Device"},
3359
    {0x21, "Scale Class I Metric"},
3360
    {0x22, "Scale Class I Metric"},
3361
    {0x23, "Scale Class II Metric"},
3362
    {0x24, "Scale Class III Metric"},
3363
    {0x25, "Scale Class IIIL Metric"},
3364
    {0x26, "Scale Class IV Metric"},
3365
    {0x27, "Scale Class III English"},
3366
    {0x28, "Scale Class IIIL English"},
3367
    {0x29, "Scale Class IV English"},
3368
    {0x2A, "Scale Class Generic"},
3369
    {0x30, "Scale Attribute Report"},
3370
    {0x31, "Scale Control Report"},
3371
    {0x32, "Scale Data Report"},
3372
    {0x33, "Scale Status Report"},
3373
    {0x34, "Scale Weight Limit Report"},
3374
    {0x35, "Scale Statistics Report"},
3375
    {0x40, "Data Weight"},
3376
    {0x41, "Data Scaling"},
3377
    {0x50, "Weight Unit"},
3378
    {0x51, "Weight Unit Milligram"},
3379
    {0x52, "Weight Unit Gram"},
3380
    {0x53, "Weight Unit Kilogram"},
3381
    {0x54, "Weight Unit Carats"},
3382
    {0x55, "Weight Unit Taels"},
3383
    {0x56, "Weight Unit Grains"},
3384
    {0x57, "Weight Unit Pennyweights"},
3385
    {0x58, "Weight Unit Metric Ton"},
3386
    {0x59, "Weight Unit Avoir Ton"},
3387
    {0x5A, "Weight Unit Troy Ounce"},
3388
    {0x5B, "Weight Unit Ounce"},
3389
    {0x5C, "Weight Unit Pound"},
3390
    {0x60, "Calibration Count"},
3391
    {0x61, "Re-Zero Count"},
3392
    {0x70, "Scale Status"},
3393
    {0x71, "Scale Status Fault"},
3394
    {0x72, "Scale Status Stable at Center of Zero"},
3395
    {0x73, "Scale Status In Motion"},
3396
    {0x74, "Scale Status Weight Stable"},
3397
    {0x75, "Scale Status Under Zero"},
3398
    {0x76, "Scale Status Over Weight Limit"},
3399
    {0x77, "Scale Status Requires Calibration"},
3400
    {0x78, "Scale Status Requires Re- zeroing"},
3401
    {0x80, "Zero Scale"},
3402
    {0x81, "Enforced Zero Return"},
3403
    {0, NULL}
3404
};
3405
static const value_string usb_hid_magnetic_stripe_reader_usage_page_vals[] = {
3406
    {0x00, "Undefined"},
3407
    {0x01, "MSR Device Read-Only"},
3408
    {0x11, "Track 1 Length"},
3409
    {0x12, "Track 2 Length"},
3410
    {0x13, "Track 3 Length"},
3411
    {0x14, "Track JIS Length"},
3412
    {0x20, "Track Data"},
3413
    {0x21, "Track 1 Data"},
3414
    {0x22, "Track 2 Data"},
3415
    {0x23, "Track 3 Data"},
3416
    {0x24, "Track JIS Data"},
3417
    {0, NULL}
3418
};
3419
static const value_string usb_hid_camera_control_usage_page_vals[] = {
3420
    {0x00, "Undefined"},
3421
    {0x20, "Camera Auto-focus"},
3422
    {0x21, "Camera Shutter"},
3423
    {0, NULL}
3424
};
3425
static const value_string usb_hid_arcade_usage_page_vals[] = {
3426
    {0x00, "Undefined"},
3427
    {0x01, "General Purpose IO Card"},
3428
    {0x02, "Coin Door"},
3429
    {0x03, "Watchdog Timer"},
3430
    {0x30, "General Purpose Analog Input State"},
3431
    {0x31, "General Purpose Digital Input State"},
3432
    {0x32, "General Purpose Optical Input State"},
3433
    {0x33, "General Purpose Digital Output State"},
3434
    {0x34, "Number of Coin Doors"},
3435
    {0x35, "Coin Drawer Drop Count"},
3436
    {0x36, "Coin Drawer Start"},
3437
    {0x37, "Coin Drawer Service"},
3438
    {0x38, "Coin Drawer Tilt"},
3439
    {0x39, "Coin Door Test"},
3440
    {0x3F, "[Undefined]"},
3441
    {0x40, "Coin Door Lockout"},
3442
    {0x41, "Watchdog Timeout"},
3443
    {0x42, "Watchdog Action"},
3444
    {0x43, "Watchdog Reboot"},
3445
    {0x44, "Watchdog Restart"},
3446
    {0x45, "Alarm Input"},
3447
    {0x46, "Coin Door Counter"},
3448
    {0x47, "I/O Direction Mapping"},
3449
    {0x48, "Set I/O Direction"},
3450
    {0x49, "Extended Optical Input State"},
3451
    {0x4A, "Pin Pad Input State"},
3452
    {0x4B, "Pin Pad Status"},
3453
    {0x4C, "Pin Pad Output"},
3454
    {0x4D, "Pin Pad Command"},
3455
    {0, NULL}
3456
};
3457
static const value_string usb_hid_fido_alliance_usage_page_vals[] = {
3458
    {0x00, "Undefined"},
3459
    {0x01, "U2F Authenticator Device"},
3460
    {0x20, "Input Report Data"},
3461
    {0x21, "Output Report Data"},
3462
    {0, NULL}
3463
};
3464
3465
static const value_string keycode_vals[] = {
3466
    {0x00, "<ACTION KEY UP>"},
3467
    {0x01, "ErrorRollOver"},
3468
    {0x02, "POSTFail"},
3469
    {0x03, "ErrorUndefined"},
3470
3471
    {0x04, "a"},
3472
    {0x05, "b"},
3473
    {0x06, "c"},
3474
    {0x07, "d"},
3475
    {0x08, "e"},
3476
    {0x09, "f"},
3477
    {0x0A, "g"},
3478
    {0x0B, "h"},
3479
    {0x0C, "i"},
3480
    {0x0D, "j"},
3481
    {0x0E, "k"},
3482
    {0x0F, "l"},
3483
    {0x10, "m"},
3484
    {0x11, "n"},
3485
    {0x12, "o"},
3486
    {0x13, "p"},
3487
    {0x14, "q"},
3488
    {0x15, "r"},
3489
    {0x16, "s"},
3490
    {0x17, "t"},
3491
    {0x18, "u"},
3492
    {0x19, "v"},
3493
    {0x1A, "w"},
3494
    {0x1B, "x"},
3495
    {0x1C, "y"},
3496
    {0x1D, "z"},
3497
3498
    {0x1E, "1"},
3499
    {0x1F, "2"},
3500
    {0x20, "3"},
3501
    {0x21, "4"},
3502
    {0x22, "5"},
3503
    {0x23, "6"},
3504
    {0x24, "7"},
3505
    {0x25, "8"},
3506
    {0x26, "9"},
3507
    {0x27, "0"},
3508
3509
    {0x28, "ENTER"},
3510
    {0x29, "Escape"},
3511
    {0x2A, "Backspace"},
3512
    {0x2B, "Tab"},
3513
    {0x2C, "Spacebar"},
3514
3515
    {0x2D, "-"},
3516
    {0x2E, "="},
3517
    {0x2F, "["},
3518
    {0x30, "]"},
3519
    {0x31, "\\"},
3520
    {0x32, "NonUS #/~"},
3521
    {0x33, ";"},
3522
    {0x34, "'"},
3523
    {0x35, "`"},
3524
    {0x36, ","},
3525
    {0x37, "."},
3526
    {0x38, "/"},
3527
    {0x39, "CapsLock"},
3528
    {0x3A, "F1"},
3529
    {0x3B, "F2"},
3530
    {0x3C, "F3"},
3531
    {0x3D, "F4"},
3532
    {0x3E, "F5"},
3533
    {0x3F, "F6"},
3534
    {0x40, "F7"},
3535
    {0x41, "F8"},
3536
    {0x42, "F9"},
3537
    {0x43, "F10"},
3538
    {0x44, "F11"},
3539
    {0x45, "F12"},
3540
    {0x46, "PrintScreen"},
3541
    {0x47, "ScrollLock"},
3542
    {0x48, "Pause"},
3543
    {0x49, "Insert"},
3544
    {0x4A, "Home"},
3545
    {0x4B, "PageUp"},
3546
    {0x4C, "DeleteForward"},
3547
    {0x4D, "End"},
3548
    {0x4E, "PageDown"},
3549
    {0x4F, "RightArrow"},
3550
    {0x50, "LeftArrow"},
3551
    {0x51, "DownArrow"},
3552
    {0x52, "UpArrow"},
3553
    {0x53, "NumLock"},
3554
3555
    /* Keypad */
3556
    {0x54, "Keypad /"},
3557
    {0x55, "Keypad *"},
3558
    {0x56, "Keypad -"},
3559
    {0x57, "Keypad +"},
3560
    {0x58, "Keypad ENTER"},
3561
    {0x59, "Keypad 1"},
3562
    {0x5A, "Keypad 2"},
3563
    {0x5B, "Keypad 3"},
3564
    {0x5C, "Keypad 4"},
3565
    {0x5D, "Keypad 5"},
3566
    {0x5E, "Keypad 6"},
3567
    {0x5F, "Keypad 7"},
3568
    {0x60, "Keypad 8"},
3569
    {0x61, "Keypad 9"},
3570
    {0x62, "Keypad 0"},
3571
    {0x63, "Keypad ."},
3572
3573
    /* non PC AT */
3574
    {0x64, "NonUS \\/|"},
3575
    {0x65, "Application"},
3576
    {0x66, "Power"},
3577
    {0x67, "Keypad ="},
3578
    {0x68, "F13"},
3579
    {0x69, "F14"},
3580
    {0x6A, "F15"},
3581
    {0x6B, "F16"},
3582
    {0x6C, "F17"},
3583
    {0x6D, "F18"},
3584
    {0x6E, "F19"},
3585
    {0x6F, "F20"},
3586
3587
    {0x70, "F21"},
3588
    {0x71, "F22"},
3589
    {0x72, "F23"},
3590
    {0x73, "F24"},
3591
    {0x74, "Execute"},
3592
    {0x75, "Help"},
3593
    {0x76, "Menu"},
3594
    {0x77, "Select"},
3595
    {0x78, "Stop"},
3596
    {0x79, "Again"},
3597
    {0x7A, "Undo"},
3598
    {0x7B, "Cut"},
3599
    {0x7C, "Copy"},
3600
    {0x7D, "Paste"},
3601
    {0x7E, "Find"},
3602
    {0x7F, "Mute"},
3603
3604
    {0x80, "VolumeUp"},
3605
    {0x81, "VolumeDown"},
3606
    {0x82, "Locking CapsLock"},
3607
    {0x83, "Locking NumLock"},
3608
    {0x84, "Locking ScrollLock"},
3609
    {0x85, "Keypad Comma"},
3610
    {0x86, "Keypad EqualSign"},
3611
    {0x87, "International1"},
3612
    {0x88, "International2"},
3613
    {0x89, "International3"},
3614
    {0x8A, "International4"},
3615
    {0x8B, "International5"},
3616
    {0x8C, "International6"},
3617
    {0x8D, "International7"},
3618
    {0x8E, "International8"},
3619
    {0x8F, "International9"},
3620
3621
    {0x90, "LANG1"},
3622
    {0x91, "LANG2"},
3623
    {0x92, "LANG3"},
3624
    {0x93, "LANG4"},
3625
    {0x94, "LANG5"},
3626
    {0x95, "LANG6"},
3627
    {0x96, "LANG7"},
3628
    {0x97, "LANG8"},
3629
    {0x98, "LANG9"},
3630
    {0x99, "AlternateErase"},
3631
    {0x9A, "SysReq/Attention"},
3632
    {0x9B, "Cancel"},
3633
    {0x9C, "Clear"},
3634
    {0x9D, "Prior"},
3635
    {0x9E, "Return"},
3636
    {0x9F, "Separator"},
3637
3638
    {0xA0, "Out"},
3639
    {0xA1, "Oper"},
3640
    {0xA2, "Clear/Again"},
3641
    {0xA3, "CrSel/Props"},
3642
    {0xA4, "ExSel"},
3643
    /* 0xA5..0xAF - reserved */
3644
    {0xB0, "Keypad 00"},
3645
    {0xB1, "Keypad 000"},
3646
    {0xB2, "ThousandsSeparator"},
3647
    {0xB3, "DecimalSeparator"},
3648
    {0xB4, "CurrencyUnit"},
3649
    {0xB5, "CurrencySubunit"},
3650
    {0xB6, "Keypad ("},
3651
    {0xB7, "Keypad )"},
3652
    {0xB8, "Keypad {"},
3653
    {0xB9, "Keypad }"},
3654
    {0xBA, "Keypad Tab"},
3655
    {0xBB, "Keypad Backspace"},
3656
    {0xBC, "Keypad A"},
3657
    {0xBD, "Keypad B"},
3658
    {0xBE, "Keypad C"},
3659
    {0xBF, "Keypad D"},
3660
3661
    {0xC0, "Keypad E"},
3662
    {0xC1, "Keypad F"},
3663
    {0xC2, "Keypad XOR"},
3664
    {0xC3, "Keypad ^"},
3665
    {0xC4, "Keypad %"},
3666
    {0xC5, "Keypad <"},
3667
    {0xC6, "Keypad >"},
3668
    {0xC7, "Keypad &"},
3669
    {0xC8, "Keypad &&"},
3670
    {0xC9, "Keypad |"},
3671
    {0xCA, "Keypad ||"},
3672
    {0xCB, "Keypad :"},
3673
    {0xCC, "Keypad #"},
3674
    {0xCD, "Keypad Space"},
3675
    {0xCE, "Keypad @"},
3676
    {0xCF, "Keypad !"},
3677
3678
    {0xD0, "Keypad Memory Store"},
3679
    {0xD1, "Keypad Memory Recall"},
3680
    {0xD2, "Keypad Memory Clear"},
3681
    {0xD3, "Keypad Memory Add"},
3682
    {0xD4, "Keypad Memory Subtract"},
3683
    {0xD5, "Keypad Memory Multiply"},
3684
    {0xD6, "Keypad Memory Divide"},
3685
    {0xD7, "Keypad +/-"},
3686
    {0xD8, "Keypad Clear"},
3687
    {0xD9, "Keypad Clear Entry"},
3688
    {0xDA, "Keypad Binary"},
3689
    {0xDB, "Keypad Octal"},
3690
    {0xDC, "Keypad Decimal"},
3691
    {0xDD, "Keypad Hexadecimal"},
3692
    /* 0xDE..0xDF - reserved,  */
3693
    {0xE0, "LeftControl"},
3694
    {0xE1, "LeftShift"},
3695
    {0xE2, "LeftAlt"},
3696
    {0xE3, "LeftGUI"},
3697
    {0xE4, "RightControl"},
3698
    {0xE5, "RightShift"},
3699
    {0xE6, "RightAlt"},
3700
    {0xE7, "RightGUI"},
3701
3702
    {0, NULL}
3703
};
3704
static value_string_ext keycode_vals_ext = VALUE_STRING_EXT_INIT(keycode_vals);
3705
3706
static uint32_t
3707
hid_unpack_value(uint8_t *data, unsigned int idx, unsigned int size)
3708
0
{
3709
0
    uint32_t value = 0;
3710
3711
0
    for(unsigned int i = 1; i <= size; i++)
3712
0
        value |= data[idx + i] << (8 * (i - 1));
3713
3714
0
    return value;
3715
0
}
3716
3717
static bool
3718
hid_unpack_signed(uint8_t *data, unsigned int idx, unsigned int size, int32_t *value)
3719
0
{
3720
0
    if (size == 1)
3721
0
        *value = (int8_t) hid_unpack_value(data, idx, size);
3722
0
    else if (size == 2)
3723
0
        *value = (int16_t) hid_unpack_value(data, idx, size);
3724
0
    else if (size == 4)
3725
0
        *value = (int32_t) hid_unpack_value(data, idx, size);
3726
0
    else
3727
0
        return true;
3728
3729
0
    return false;
3730
0
}
3731
3732
0
#define MAX_REPORT_DESCRIPTOR_COUNT 100000 // Arbitrary
3733
static bool
3734
parse_report_descriptor(report_descriptor_t *rdesc)
3735
0
{
3736
0
    hid_field_t field;
3737
0
    uint8_t *data = rdesc->desc_body;
3738
0
    unsigned int tag, type, size;
3739
0
    uint8_t prefix;
3740
0
    uint32_t defined = 0, usage_page = 0, usage = 0, usage_min = 0, usage_max = 0;
3741
0
    wmem_allocator_t *scope = wmem_file_scope();
3742
0
    bool first_item = true;
3743
3744
0
    memset(&field, 0, sizeof(field));
3745
0
    field.usages = wmem_array_new(scope, sizeof(uint32_t));
3746
0
    rdesc->fields_in = wmem_array_new(scope, sizeof(hid_field_t));
3747
0
    rdesc->fields_out = wmem_array_new(scope, sizeof(hid_field_t));
3748
3749
0
    int i = 0;
3750
0
    while (i < rdesc->desc_length)
3751
0
    {
3752
0
        prefix = data[i];
3753
0
        tag = (prefix & 0b11110000) >> 4;
3754
0
        type = (prefix & 0b00001100) >> 2;
3755
0
        size = prefix & 0b00000011;
3756
3757
0
        if (size == 3)  /* HID spec: 6.2.2.2 - Short Items */
3758
0
            size = 4;
3759
3760
0
        switch (type)
3761
0
        {
3762
0
            case USBHID_ITEMTYPE_MAIN:
3763
0
                switch (tag)
3764
0
                {
3765
0
                    case USBHID_MAINITEM_TAG_INPUT:
3766
0
                        field.properties = hid_unpack_value(data, i, size);
3767
3768
0
                        if ((defined & HID_REQUIRED_MASK) != HID_REQUIRED_MASK)
3769
0
                            goto err;
3770
3771
                        /* new field */
3772
0
                        wmem_array_append_one(rdesc->fields_in, field);
3773
3774
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3775
0
                        first_item = false;
3776
3777
                        /* only keep the global items */
3778
0
                        defined &= HID_GLOBAL_MASK;
3779
0
                        break;
3780
3781
0
                    case USBHID_MAINITEM_TAG_OUTPUT:
3782
0
                        field.properties = hid_unpack_value(data, i, size);
3783
3784
0
                        if ((defined & HID_REQUIRED_MASK) != HID_REQUIRED_MASK)
3785
0
                            goto err;
3786
3787
                        /* new field */
3788
0
                        wmem_array_append_one(rdesc->fields_out, field);
3789
3790
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3791
0
                        first_item = false;
3792
3793
0
                        defined &= HID_GLOBAL_MASK;
3794
0
                        break;
3795
3796
0
                    case USBHID_MAINITEM_TAG_FEATURE:
3797
                        /*
3798
                        field.properties = hid_unpack_value(data, i, size);
3799
                        TODO
3800
                        */
3801
0
                        break;
3802
3803
0
                    case USBHID_MAINITEM_TAG_COLLECTION:
3804
                        /* clear usages */
3805
0
                        wmem_free(scope, field.usages);
3806
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3807
0
                        break;
3808
3809
0
                    default:
3810
0
                        break;
3811
0
                }
3812
0
                break;
3813
3814
0
            case USBHID_ITEMTYPE_GLOBAL:
3815
0
                switch (tag)
3816
0
                {
3817
0
                    case USBHID_GLOBALITEM_TAG_USAGE_PAGE:
3818
0
                        usage_page = hid_unpack_value(data, i, size);
3819
0
                        if (usage_page > UINT16_MAX)
3820
0
                            goto err;
3821
0
                        defined |= HID_USAGE_PAGE;
3822
0
                        break;
3823
3824
0
                    case USBHID_GLOBALITEM_TAG_LOG_MIN:
3825
0
                        if (hid_unpack_signed(data, i, size, &field.logical_min))
3826
0
                            goto err;
3827
0
                        defined |= HID_LOGICAL_MIN;
3828
0
                        break;
3829
3830
0
                    case USBHID_GLOBALITEM_TAG_LOG_MAX:
3831
0
                        if (hid_unpack_signed(data, i, size, &field.logical_max))
3832
0
                            goto err;
3833
0
                        defined |= HID_LOGICAL_MAX;
3834
0
                        break;
3835
3836
0
                    case USBHID_GLOBALITEM_TAG_REPORT_SIZE:
3837
0
                        field.report_size = hid_unpack_value(data, i, size);
3838
0
                        defined |= HID_REPORT_SIZE;
3839
0
                        break;
3840
3841
0
                    case USBHID_GLOBALITEM_TAG_REPORT_ID:
3842
0
                        if (!first_item && !rdesc->uses_report_id)
3843
0
                            goto err;
3844
3845
0
                        rdesc->uses_report_id = true;
3846
3847
0
                        field.report_id = hid_unpack_value(data, i, size);
3848
0
                        defined |= HID_REPORT_ID;
3849
0
                        break;
3850
3851
0
                    case USBHID_GLOBALITEM_TAG_REPORT_COUNT:
3852
0
                        field.report_count = hid_unpack_value(data, i, size);
3853
0
                        defined |= HID_REPORT_COUNT;
3854
0
                        break;
3855
3856
0
                    case USBHID_GLOBALITEM_TAG_PUSH:
3857
0
                    case USBHID_GLOBALITEM_TAG_POP:
3858
                        /* TODO */
3859
0
                        goto err;
3860
3861
0
                    default:
3862
0
                        break;
3863
0
                }
3864
0
                break;
3865
3866
0
            case USBHID_ITEMTYPE_LOCAL:
3867
0
                switch (tag)
3868
0
                {
3869
0
                    case USBHID_LOCALITEM_TAG_USAGE:
3870
0
                        usage = hid_unpack_value(data, i, size);
3871
3872
                        /* Extended usage (size 4) combines both usage page and id */
3873
0
                        if (size != 4) {
3874
0
                            if (!(defined & HID_USAGE_PAGE))
3875
0
                                goto err;
3876
0
                            usage |= usage_page << 16;
3877
0
                        }
3878
3879
0
                        wmem_array_append_one(field.usages, usage);
3880
0
                        break;
3881
3882
0
                    case USBHID_LOCALITEM_TAG_USAGE_MIN:
3883
0
                        usage_min = hid_unpack_value(data, i, size);
3884
0
                        if (size == 4) {
3885
                            /* Usage max must be extended as well */
3886
0
                            defined |= HID_EXTENDED_USAGE;
3887
0
                        } else {
3888
0
                            if (!(defined & HID_USAGE_PAGE))
3889
0
                                goto err;
3890
0
                            usage_min |= usage_page << 16;
3891
0
                        }
3892
0
                        defined |= HID_USAGE_MIN;
3893
0
                        break;
3894
3895
0
                    case USBHID_LOCALITEM_TAG_USAGE_MAX:
3896
0
                        if (!(defined & HID_USAGE_MIN))
3897
0
                            goto err;
3898
3899
0
                        usage_max = hid_unpack_value(data, i, size);
3900
0
                        if (defined & HID_EXTENDED_USAGE) {
3901
                            /* Fail if max is not extended usage (HID spec 6.2.2.8) */
3902
0
                            if (size != 4)
3903
0
                                goto err;
3904
0
                        } else if (size == 4) {
3905
                            /* Fail because min wasn't extended, but max is */
3906
0
                            goto err;
3907
0
                        } else {
3908
0
                            if (!(defined & HID_USAGE_PAGE))
3909
0
                                goto err;
3910
0
                            usage_max |= usage_page << 16;
3911
0
                        }
3912
3913
                        /* Usage min and max must be on the same page */
3914
0
                        if (USAGE_PAGE(usage_min) != USAGE_PAGE(usage_max))  {
3915
0
                            goto err;
3916
0
                        }
3917
3918
0
                        if (usage_min > usage_max) {
3919
0
                            goto err;
3920
0
                        }
3921
3922
0
                        if (wmem_array_get_count(field.usages) + usage_max - usage_min >= MAX_REPORT_DESCRIPTOR_COUNT) {
3923
0
                            goto err;
3924
0
                        }
3925
3926
                        /* min and max are inclusive */
3927
0
                        wmem_array_grow(field.usages, usage_max - usage_min + 1);
3928
0
                        for (uint32_t j = usage_min; j <= usage_max; j++) {
3929
0
                            wmem_array_append_one(field.usages, j);
3930
0
                        }
3931
3932
0
                        defined &= ~(HID_USAGE_MIN | HID_EXTENDED_USAGE);
3933
0
                        break;
3934
3935
0
                    default: /* TODO */
3936
0
                        goto err;
3937
0
                }
3938
0
                break;
3939
3940
0
            default: /* reserved */
3941
0
                goto err;
3942
0
        }
3943
3944
0
        i += size + 1;
3945
0
    }
3946
3947
0
    return true;
3948
3949
0
err:
3950
0
    for (unsigned int j = 0; j < wmem_array_get_count(rdesc->fields_in); j++)
3951
0
        wmem_free(scope, ((hid_field_t*) wmem_array_index(rdesc->fields_in, j))->usages);
3952
3953
0
    for (unsigned int j = 0; j < wmem_array_get_count(rdesc->fields_out); j++)
3954
0
        wmem_free(scope, ((hid_field_t*) wmem_array_index(rdesc->fields_out, j))->usages);
3955
3956
0
    wmem_free(scope, rdesc->fields_in);
3957
0
    wmem_free(scope, rdesc->fields_out);
3958
0
    return false;
3959
0
}
3960
3961
3962
static bool
3963
is_correct_interface(urb_info_t *urb, report_descriptor_t *report)
3964
0
{
3965
0
    return (urb->bus_id == report->bus_id) &&
3966
0
           (urb->device_address == report->device_address) &&
3967
0
           (urb->conv->interfaceNum == report->interface);
3968
0
}
3969
3970
/* Returns the report descriptor */
3971
static report_descriptor_t _U_ *
3972
get_report_descriptor(packet_info *pinfo _U_, urb_info_t *urb)
3973
0
{
3974
0
    uint32_t bus_id = urb->bus_id;
3975
0
    uint32_t device_address = urb->device_address;
3976
0
    uint32_t interface = urb->conv->interfaceNum;
3977
0
    wmem_tree_key_t key[] = {
3978
0
        {1, &bus_id},
3979
0
        {1, &device_address},
3980
0
        {1, &interface},
3981
0
        {1, &pinfo->num},
3982
0
        {0, NULL}
3983
0
    };
3984
3985
0
    report_descriptor_t *data = NULL;
3986
0
    data = (report_descriptor_t*) wmem_tree_lookup32_array_le(report_descriptors, key);
3987
0
    if (data && is_correct_interface(urb, data))
3988
0
        return data;
3989
3990
0
    return NULL;
3991
0
}
3992
3993
/* Inserts the report descriptor */
3994
static void
3995
insert_report_descriptor(packet_info *pinfo, report_descriptor_t *data)
3996
0
{
3997
0
    uint32_t bus_id = data->bus_id;
3998
0
    uint32_t device_address = data->device_address;
3999
0
    uint32_t interface = data->interface;
4000
0
    wmem_tree_key_t key[] = {
4001
0
        {1, &bus_id},
4002
0
        {1, &device_address},
4003
0
        {1, &interface},
4004
0
        {1, &pinfo->num},
4005
0
        {0, NULL}
4006
0
    };
4007
4008
0
    wmem_tree_insert32_array(report_descriptors, key, data);
4009
0
}
4010
4011
/* Returns usage page string */
4012
static const char*
4013
get_usage_page_string(uint32_t usage_page)
4014
3.52k
{
4015
3.52k
    const char *str;
4016
4017
3.52k
    str = try_val_to_str(usage_page, usb_hid_item_usage_page_vals);
4018
3.52k
    if (!str) {
4019
970
        if ((usage_page & VENDOR_PAGE_HBYTE) == VENDOR_PAGE_HBYTE)
4020
133
            str = "Vendor";
4021
837
        else
4022
837
            str = "Reserved";
4023
970
    }
4024
4025
3.52k
    return str;
4026
3.52k
}
4027
4028
/* Returns usage page item string */
4029
static char*
4030
get_usage_page_item_string(wmem_allocator_t *pool, uint32_t usage_page, uint32_t id)
4031
8.99k
{
4032
8.99k
    const char *str = NULL;
4033
8.99k
    const char *fmt_str = NULL;
4034
4035
8.99k
    switch (usage_page)
4036
8.99k
    {
4037
204
    case GENERIC_DESKTOP_CONTROLS_PAGE:
4038
204
        str = try_val_to_str(id, usb_hid_generic_desktop_controls_usage_page_vals);
4039
204
        break;
4040
336
    case SIMULATION_CONTROLS_PAGE:
4041
336
        str = try_val_to_str(id, usb_hid_simulation_control_usage_page_vals);
4042
336
        break;
4043
111
    case VR_CONTROLS_PAGE:
4044
111
        str = try_val_to_str(id, usb_hid_vr_controls_usage_page_vals);
4045
111
        break;
4046
204
    case SPORT_CONTROLS_PAGE:
4047
204
        str = try_val_to_str(id, usb_hid_sport_controls_usage_page_vals);
4048
204
        break;
4049
632
    case GAME_CONTROLS_PAGE:
4050
632
        str = try_val_to_str(id, usb_hid_game_controls_usage_page_vals);
4051
632
        break;
4052
223
    case GENERIC_DEVICE_CONTROLS_PAGE:
4053
223
        str = try_val_to_str(id, usb_hid_generic_device_controls_usage_page_vals);
4054
223
        break;
4055
191
    case KEYBOARD_KEYPAD_PAGE:
4056
191
        str = try_val_to_str(id, usb_hid_keyboard_keypad_usage_page_vals);
4057
191
        break;
4058
188
    case LED_PAGE:
4059
188
        str = try_val_to_str(id, usb_hid_led_usage_page_vals);
4060
188
        break;
4061
895
    case BUTTON_PAGE:
4062
895
        str = try_val_to_str(id, usb_hid_button_usage_page_vals);
4063
895
        if (!str)
4064
858
            fmt_str = "Button %u";
4065
895
        break;
4066
60
    case ORDINAL_PAGE:
4067
60
        str = try_val_to_str(id, usb_hid_ordinal_usage_page_vals);
4068
60
        break;
4069
9
    case TELEPHONY_PAGE:
4070
9
        str = try_val_to_str(id, usb_hid_telephony_device_usage_page_vals);
4071
9
        break;
4072
242
    case CONSUMER_PAGE:
4073
242
        str = try_val_to_str(id, usb_hid_consumer_usage_page_vals);
4074
242
        if (!str)
4075
208
            fmt_str = "Instance %u";
4076
242
        break;
4077
766
    case DIGITIZER_PAGE:
4078
766
        str = try_val_to_str(id, usb_hid_digitizers_usage_page_vals);
4079
766
        break;
4080
388
    case HAPTICS_PAGE:
4081
388
        str = try_val_to_str(id, usb_hid_haptic_usage_page_vals);
4082
388
        if (id >= 0x2001 && id <= 0x2FFF)
4083
0
            str = "Vendor Waveforms";
4084
388
        break;
4085
51
    case PID_PAGE:
4086
51
        str = try_val_to_str(id, usb_hid_physical_input_device_usage_page_vals);
4087
51
        break;
4088
78
    case UNICODE_PAGE:
4089
78
        fmt_str = "Character U+%04X";
4090
78
        break;
4091
57
    case SOC_PAGE:
4092
57
        str = try_val_to_str(id, usb_hid_soc_usage_page_vals);
4093
57
        break;
4094
48
    case EYE_AND_HEAD_TRACKER_PAGE:
4095
48
        str = try_val_to_str(id, usb_hid_eye_and_head_tracker_usage_page_vals);
4096
48
        break;
4097
1
    case ALPHANUMERIC_DISPLAY_PAGE:
4098
1
        str = try_val_to_str(id, usb_hid_alphanumeric_display_usage_page_vals);
4099
1
        break;
4100
278
    case SENSOR_PAGE:
4101
278
        str = try_val_to_str(id, usb_hid_sensor_usage_page_vals);
4102
278
        if (!str)
4103
267
            str = try_rval_to_str(id, usb_hid_sensor_usage_page_ranges);
4104
278
        break;
4105
85
    case MEDICAL_INSTRUMENTS_PAGE:
4106
85
        str = try_val_to_str(id, usb_hid_medical_instrument_usage_page_vals);
4107
85
        break;
4108
51
    case BRAILLE_DISPLAY_PAGE:
4109
51
        str = try_val_to_str(id, usb_hid_braille_display_usage_page_vals);
4110
51
        break;
4111
97
    case LIGHTING_AND_ILLUMINATION_PAGE:
4112
97
        str = try_val_to_str(id, usb_hid_lighting_and_illumination_usage_page_vals);
4113
97
        break;
4114
30
    case USB_MONITOR_PAGE:
4115
30
        str = try_val_to_str(id, usb_hid_monitor_usage_page_vals);
4116
30
        break;
4117
38
    case USB_ENUMERATED_VALUES_PAGE:
4118
38
        fmt_str = "ENUM_%u";
4119
38
        break;
4120
56
    case VESA_VIRTUAL_CONTROLS_PAGE:
4121
56
        str = try_val_to_str(id, usb_hid_vesa_virtual_control_usage_page_vals);
4122
56
        break;
4123
207
    case POWER_DEVICE_PAGE:
4124
207
        str = try_val_to_str(id, usb_hid_power_device_usage_page_vals);
4125
207
        break;
4126
34
    case BATTERY_SYSTEM_PAGE:
4127
34
        str = try_val_to_str(id, usb_hid_battery_system_usage_page_vals);
4128
34
        break;
4129
0
    case BARCODE_SCANNER_PAGE:
4130
0
        str = try_val_to_str(id, usb_hid_barcode_scanner_usage_page_vals);
4131
0
        break;
4132
27
    case WEIGHING_PAGE:
4133
27
        str = try_val_to_str(id, usb_hid_weighing_devices_usage_page_vals);
4134
27
        break;
4135
2
    case MSR_PAGE:
4136
2
        str = try_val_to_str(id, usb_hid_magnetic_stripe_reader_usage_page_vals);
4137
2
        break;
4138
26
    case CAMERA_CONTROL_PAGE:
4139
26
        str = try_val_to_str(id, usb_hid_camera_control_usage_page_vals);
4140
26
        break;
4141
139
    case ARCADE_PAGE:
4142
139
        str = try_val_to_str(id, usb_hid_arcade_usage_page_vals);
4143
139
        break;
4144
0
    case FIDO_ALLIANCE_PAGE:
4145
0
        str = try_val_to_str(id, usb_hid_fido_alliance_usage_page_vals);
4146
0
        break;
4147
3.23k
    default:
4148
3.23k
        if ((usage_page & VENDOR_PAGE_HBYTE) == VENDOR_PAGE_HBYTE)
4149
460
            str = "Vendor";
4150
3.23k
        break;
4151
8.99k
    }
4152
4153
8.99k
    if (fmt_str) {
4154
1.18k
        return wmem_strdup_printf(pool, fmt_str, id);
4155
1.18k
    }
4156
7.81k
    if (!str) {
4157
6.44k
        str = "Reserved";
4158
6.44k
    }
4159
7.81k
    return wmem_strdup_printf(pool, "%s", str);
4160
8.99k
}
4161
4162
/* Dissector for the data in a HID main report. */
4163
static int
4164
dissect_usb_hid_report_mainitem_data(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag)
4165
35.3k
{
4166
35.3k
    proto_item *ti = proto_tree_get_parent(tree);
4167
35.3k
    uint32_t val = 0;
4168
4169
35.3k
    switch (bTag) {
4170
835
        case USBHID_MAINITEM_TAG_INPUT:
4171
1.68k
        case USBHID_MAINITEM_TAG_OUTPUT:
4172
2.13k
        case USBHID_MAINITEM_TAG_FEATURE:
4173
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit0, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4174
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit1, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4175
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit2, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4176
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit3, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4177
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit4, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4178
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit5, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4179
2.13k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit6, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4180
2.13k
            if (bTag == USBHID_MAINITEM_TAG_INPUT)
4181
777
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit7_input, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4182
1.35k
            else
4183
1.35k
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit7, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4184
2.13k
            if (bSize > 1)
4185
879
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit8, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4186
1.25k
            else
4187
1.25k
                proto_tree_add_boolean_format_value(tree, hf_usb_hid_mainitem_bit8, tvb, offset, 0, false, "Buffered bytes (default, no second byte present)");
4188
4189
2.13k
            val = tvb_get_uint8(tvb, offset);
4190
2.13k
            if (val & (1 << 0))
4191
1.17k
                proto_item_append_text(ti, " (Const,");
4192
959
            else
4193
959
                proto_item_append_text(ti, " (Data,");
4194
2.13k
            if (val & (1 << 1))
4195
927
                proto_item_append_text(ti, "Var,");
4196
1.20k
            else
4197
1.20k
                proto_item_append_text(ti, "Array,");
4198
2.13k
            if (val & (1 << 2))
4199
212
                proto_item_append_text(ti, "Rel");
4200
1.92k
            else
4201
1.92k
                proto_item_append_text(ti, "Abs");
4202
2.13k
            if (val & (1 << 3))
4203
262
                proto_item_append_text(ti, ",Wrap");
4204
2.13k
            if (val & (1 << 4))
4205
1.19k
                proto_item_append_text(ti, ",NonLinear");
4206
2.13k
            if (val & (1 << 5))
4207
679
                proto_item_append_text(ti, ",NoPref");
4208
2.13k
            if (val & (1 << 6))
4209
252
                proto_item_append_text(ti, ",Null");
4210
2.13k
            if ((bTag == USBHID_MAINITEM_TAG_OUTPUT || bTag == USBHID_MAINITEM_TAG_FEATURE) && val & (1 << 7))
4211
1.05k
                proto_item_append_text(ti, ",Volatile");
4212
2.13k
            if (val & (1 << 8))
4213
0
                proto_item_append_text(ti, ",BuffBytes");
4214
2.13k
            proto_item_append_text(ti, ")");
4215
2.13k
            break;
4216
1.78k
        case USBHID_MAINITEM_TAG_COLLECTION:
4217
1.78k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_mainitem_colltype, tvb, offset, 1, ENC_LITTLE_ENDIAN, &val);
4218
1.78k
            proto_item_append_text(ti, " (%s)", rval_to_str_const(val, usb_hid_mainitem_colltype_vals, "Unknown"));
4219
1.78k
            break;
4220
117
        case USBHID_MAINITEM_TAG_ENDCOLLECTION:
4221
            /* No item data */
4222
117
            break;
4223
31.3k
        default:
4224
31.3k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4225
31.3k
            proto_item_append_text(ti, " (Unknown)");
4226
31.3k
            break;
4227
35.3k
    }
4228
35.2k
    offset += bSize;
4229
35.2k
    return offset;
4230
35.3k
}
4231
4232
/* Dissector for the data in a HID main report. */
4233
static int
4234
dissect_usb_hid_report_globalitem_data(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag, struct usb_hid_global_state *global)
4235
17.3k
{
4236
17.3k
    const char *str = NULL;
4237
17.3k
    proto_item *ti = proto_tree_get_parent(tree);
4238
17.3k
    uint32_t val = 0;
4239
17.3k
    int32_t val_sig = 0;
4240
4241
17.3k
    switch (bTag) {
4242
3.53k
        case USBHID_GLOBALITEM_TAG_USAGE_PAGE:
4243
3.53k
            switch (bSize) {
4244
1.58k
                case 1: global->usage_page = tvb_get_uint8(tvb, offset); break;
4245
697
                case 2: global->usage_page = tvb_get_letohs(tvb, offset); break;
4246
0
                case 3: global->usage_page = tvb_get_letoh24(tvb, offset); break;
4247
308
                case 4: global->usage_page = tvb_get_letohl(tvb, offset); break;
4248
950
                default: global->usage_page = 0; break;
4249
3.53k
            }
4250
3.52k
            str = get_usage_page_string(global->usage_page);
4251
3.52k
            proto_tree_add_uint_format_value(tree, hf_usb_hid_globalitem_usage, tvb, offset, bSize, global->usage_page, "%s (0x%04x)", str, global->usage_page);
4252
3.52k
            proto_item_append_text(ti, " (%s)", str);
4253
3.52k
            break;
4254
741
        case USBHID_GLOBALITEM_TAG_LOG_MIN:
4255
741
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_log_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4256
741
            proto_item_append_text(ti, " (%d)", val_sig);
4257
741
            break;
4258
1.79k
        case USBHID_GLOBALITEM_TAG_LOG_MAX:
4259
1.79k
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_log_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4260
1.79k
            proto_item_append_text(ti, " (%d)", val_sig);
4261
1.79k
            break;
4262
1.49k
        case USBHID_GLOBALITEM_TAG_PHY_MIN:
4263
1.49k
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_phy_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4264
1.49k
            proto_item_append_text(ti, " (%d)", val_sig);
4265
1.49k
            break;
4266
1.76k
        case USBHID_GLOBALITEM_TAG_PHY_MAX:
4267
1.76k
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_phy_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4268
1.76k
            proto_item_append_text(ti, " (%d)", val_sig);
4269
1.76k
            break;
4270
945
        case USBHID_GLOBALITEM_TAG_UNIT_EXP:
4271
945
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_unit_exp, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4272
945
            if (val >= 7)
4273
464
                proto_item_append_text(ti, " (%u)", val);
4274
481
            else
4275
481
                proto_item_append_text(ti, " (%d)", -(16 - (int) val));
4276
945
            break;
4277
900
        case USBHID_GLOBALITEM_TAG_UNIT:
4278
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_sys, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4279
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_len, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4280
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_mass, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4281
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_time, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4282
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_temp, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4283
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_current, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4284
900
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_brightness, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4285
900
            proto_item_append_text(ti, " (0x%02x)", tvb_get_uint8(tvb, offset));
4286
900
            break;
4287
927
        case USBHID_GLOBALITEM_TAG_REPORT_SIZE:
4288
927
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_size, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4289
927
            proto_item_append_text(ti, " (%u)", val);
4290
927
            break;
4291
911
        case USBHID_GLOBALITEM_TAG_REPORT_ID:
4292
911
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_id, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4293
911
            proto_item_append_text(ti, " (0x%02x)", val);
4294
911
            break;
4295
988
        case USBHID_GLOBALITEM_TAG_REPORT_COUNT:
4296
988
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_count, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4297
988
            proto_item_append_text(ti, " (%u)", val);
4298
988
            break;
4299
868
        case USBHID_GLOBALITEM_TAG_PUSH:
4300
            // Push and Pop have no data, but the HID spec 6.2.2.7 doesn't prohibit it.
4301
868
            if(bSize > 0) {
4302
375
                proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_push, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4303
375
                proto_item_append_text(ti, " (%u)", val);
4304
375
            }
4305
868
            break;
4306
920
        case USBHID_GLOBALITEM_TAG_POP:
4307
            // Push and Pop have no data, but the HID spec 6.2.2.7 doesn't prohibit it.
4308
920
            if(bSize > 0) {
4309
281
                proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_pop, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4310
281
                proto_item_append_text(ti, " (%u)", val);
4311
281
            }
4312
920
            break;
4313
1.55k
        default:
4314
1.55k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4315
1.55k
            proto_item_append_text(ti, " (Unknown)");
4316
1.55k
            break;
4317
17.3k
    }
4318
17.2k
    offset += bSize;
4319
17.2k
    return offset;
4320
17.3k
}
4321
4322
/* Dissector for the data in a HID main report. */
4323
static int
4324
dissect_usb_hid_report_localitem_data(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag, struct usb_hid_global_state *global)
4325
22.5k
{
4326
22.5k
    uint32_t id = 0xffff;
4327
22.5k
    proto_item *ti = proto_tree_get_parent(tree);
4328
22.5k
    char *str = NULL;
4329
22.5k
    uint32_t val = 0;
4330
4331
22.5k
    switch (bTag) {
4332
9.30k
        case USBHID_LOCALITEM_TAG_USAGE:
4333
9.30k
            if (bSize > 2) {
4334
                /* Full page ID */
4335
309
                proto_tree_add_item(tree, hf_usb_hid_localitem_usage, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4336
9.00k
            } else {
4337
                /* Only lower few bits given, need to combine with last global ID */
4338
9.00k
                if (bSize == 1)
4339
3.79k
                    id = tvb_get_uint8(tvb, offset);
4340
5.20k
                else if (bSize == 2)
4341
1.12k
                    id = tvb_get_letohs(tvb, offset);
4342
9.00k
                str = get_usage_page_item_string(pinfo->pool, global->usage_page, id);
4343
9.00k
                proto_tree_add_uint_format_value(tree, hf_usb_hid_localitem_usage, tvb, offset, bSize, id, "%s (0x%04x)", str, id);
4344
9.00k
                proto_item_append_text(ti, " (%s)", str);
4345
9.00k
            }
4346
9.30k
            break;
4347
1.40k
        case USBHID_LOCALITEM_TAG_USAGE_MIN:
4348
1.40k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_usage_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4349
1.40k
            proto_item_append_text(ti, " (0x%04x)", val);
4350
1.40k
            break;
4351
1.53k
        case USBHID_LOCALITEM_TAG_USAGE_MAX:
4352
1.53k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_usage_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4353
1.53k
            proto_item_append_text(ti, " (0x%04x)", val);
4354
1.53k
            break;
4355
1.29k
        case USBHID_LOCALITEM_TAG_DESIG_INDEX:
4356
1.29k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_index, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4357
1.29k
            proto_item_append_text(ti, " (0x%02x)", val);
4358
1.29k
            break;
4359
1.56k
        case USBHID_LOCALITEM_TAG_DESIG_MIN:
4360
1.56k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4361
1.56k
            proto_item_append_text(ti, " (0x%02x)", val);
4362
1.56k
            break;
4363
1.08k
        case USBHID_LOCALITEM_TAG_DESIG_MAX:
4364
1.08k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4365
1.08k
            proto_item_append_text(ti, " (0x%02x)", val);
4366
1.08k
            break;
4367
949
        case USBHID_LOCALITEM_TAG_STRING_INDEX:
4368
949
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_index, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4369
949
            proto_item_append_text(ti, " (0x%02x)", val);
4370
949
            break;
4371
808
        case USBHID_LOCALITEM_TAG_STRING_MIN:
4372
808
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4373
808
            proto_item_append_text(ti, " (0x%02x)", val);
4374
808
            break;
4375
1.04k
        case USBHID_LOCALITEM_TAG_STRING_MAX:
4376
1.04k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4377
1.04k
            proto_item_append_text(ti, " (0x%02x)", val);
4378
1.04k
            break;
4379
701
        case USBHID_LOCALITEM_TAG_DELIMITER:
4380
701
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_delimiter, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4381
701
            proto_item_append_text(ti, " (0x%02x)", val);
4382
701
            break;
4383
2.85k
        default:
4384
2.85k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4385
2.85k
            proto_item_append_text(ti, " (Unknown)");
4386
2.85k
            break;
4387
22.5k
    }
4388
22.4k
    offset += bSize;
4389
4390
22.4k
    return offset;
4391
22.5k
}
4392
4393
/* Dissector for individual HID report items.  Recursive. */
4394
static int
4395
// NOLINTNEXTLINE(misc-no-recursion)
4396
dissect_usb_hid_report_item(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, urb_info_t *urb, const struct usb_hid_global_state *global)
4397
2.42k
{
4398
2.42k
    proto_item *subitem;
4399
2.42k
    proto_tree *tree, *subtree;
4400
2.42k
    int old_offset;
4401
2.42k
    unsigned int tmp;
4402
2.42k
    unsigned int bSize, bType, bTag;
4403
2.42k
    const value_string *usb_hid_cur_bTag_vals;
4404
2.42k
    int hf_usb_hid_curitem_bTag;
4405
2.42k
    struct usb_hid_global_state cur_global;
4406
2.42k
    memcpy(&cur_global, global, sizeof(struct usb_hid_global_state));
4407
4408
88.2k
    while (tvb_reported_length_remaining(tvb, offset) > 0)
4409
86.2k
    {
4410
86.2k
        old_offset=offset;
4411
4412
86.2k
        tmp = tvb_get_uint8(tvb, offset);
4413
86.2k
        bSize = tmp & USBHID_SIZE_MASK;
4414
86.2k
        if (bSize == 3) bSize++; /* 3 == four bytes */
4415
86.2k
        bType = (tmp & USBHID_TYPE_MASK) >> 2;
4416
86.2k
        bTag = (tmp & USBHID_TAG_MASK) >> 4;
4417
4418
86.2k
        switch (bType) {
4419
35.3k
            case USBHID_ITEMTYPE_MAIN:
4420
35.3k
                hf_usb_hid_curitem_bTag = hf_usb_hid_mainitem_bTag;
4421
35.3k
                usb_hid_cur_bTag_vals = usb_hid_mainitem_bTag_vals;
4422
35.3k
                break;
4423
17.3k
            case USBHID_ITEMTYPE_GLOBAL:
4424
17.3k
                hf_usb_hid_curitem_bTag = hf_usb_hid_globalitem_bTag;
4425
17.3k
                usb_hid_cur_bTag_vals = usb_hid_globalitem_bTag_vals;
4426
17.3k
                break;
4427
22.5k
            case USBHID_ITEMTYPE_LOCAL:
4428
22.5k
                hf_usb_hid_curitem_bTag = hf_usb_hid_localitem_bTag;
4429
22.5k
                usb_hid_cur_bTag_vals = usb_hid_localitem_bTag_vals;
4430
22.5k
                break;
4431
11.0k
            default: /* Only USBHID_ITEMTYPE_LONG, but keep compiler happy */
4432
11.0k
                hf_usb_hid_curitem_bTag = hf_usb_hid_longitem_bTag;
4433
11.0k
                usb_hid_cur_bTag_vals = usb_hid_longitem_bTag_vals;
4434
11.0k
                break;
4435
86.2k
        }
4436
4437
86.2k
        subtree = proto_tree_add_subtree_format(parent_tree, tvb, offset, bSize + 1, ett_usb_hid_item_header, &subitem, "%s", val_to_str(pinfo->pool, bTag, usb_hid_cur_bTag_vals, "Unknown/%u tag"));
4438
4439
86.2k
        tree = proto_tree_add_subtree(subtree, tvb, offset, 1, ett_usb_hid_item_header, NULL, "Header");
4440
86.2k
        proto_tree_add_item(tree, hf_usb_hid_item_bSize, tvb, offset,   1, ENC_LITTLE_ENDIAN);
4441
86.2k
        proto_tree_add_item(tree, hf_usb_hid_item_bType, tvb, offset,   1, ENC_LITTLE_ENDIAN);
4442
86.2k
        proto_tree_add_item(tree, hf_usb_hid_curitem_bTag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4443
86.2k
        offset++;
4444
86.2k
        if ((bType == 3) && (bTag == 16)) {
4445
            /* Long item */
4446
0
            bSize = tvb_get_uint8(tvb, offset);
4447
0
            proto_tree_add_item(subtree, hf_usb_hid_item_bDataSize, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4448
0
            offset++;
4449
0
            proto_tree_add_item(subtree, hf_usb_hid_item_bLongItemTag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4450
0
            offset++;
4451
0
            proto_tree_add_item(subtree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4452
0
            offset += bSize;
4453
86.2k
        } else {
4454
            /* Short item */
4455
86.2k
            switch (bType) {
4456
35.3k
                case USBHID_ITEMTYPE_MAIN:
4457
35.3k
                    offset = dissect_usb_hid_report_mainitem_data(pinfo, subtree, tvb, offset, bSize, bTag);
4458
35.3k
                    break;
4459
17.3k
                case USBHID_ITEMTYPE_GLOBAL:
4460
17.3k
                    offset = dissect_usb_hid_report_globalitem_data(pinfo, subtree, tvb, offset, bSize, bTag, &cur_global);
4461
17.3k
                    break;
4462
22.5k
                case USBHID_ITEMTYPE_LOCAL:
4463
22.5k
                    offset = dissect_usb_hid_report_localitem_data(pinfo, subtree, tvb, offset, bSize, bTag, &cur_global);
4464
22.5k
                    break;
4465
11.0k
                default: /* Only USBHID_ITEMTYPE_LONG, but keep compiler happy */
4466
11.0k
                    proto_tree_add_item(subtree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4467
11.0k
                    offset += bSize;
4468
11.0k
                    break;
4469
86.2k
            }
4470
86.2k
        }
4471
4472
85.9k
        if (bType == USBHID_ITEMTYPE_MAIN) {
4473
35.2k
            if (bTag == USBHID_MAINITEM_TAG_COLLECTION) {
4474
                /* Begin collection, nest following elements under us */
4475
1.77k
                increment_dissection_depth(pinfo);
4476
1.77k
                offset = dissect_usb_hid_report_item(pinfo, subtree, tvb, offset, urb, &cur_global);
4477
1.77k
                decrement_dissection_depth(pinfo);
4478
1.77k
                proto_item_set_len(subitem, offset-old_offset);
4479
33.4k
            } else if (bTag == USBHID_MAINITEM_TAG_ENDCOLLECTION) {
4480
                /* End collection, break out to parent tree item */
4481
117
                break;
4482
117
            }
4483
35.2k
        }
4484
85.9k
    }
4485
2.06k
    return offset;
4486
2.42k
}
4487
4488
/* Dissector for HID "GET DESCRIPTOR" subtype. */
4489
int
4490
dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, urb_info_t *urb)
4491
646
{
4492
646
    proto_item *item;
4493
646
    proto_tree *tree;
4494
646
    int old_offset=offset;
4495
646
    struct usb_hid_global_state initial_global;
4496
4497
646
    memset(&initial_global, 0, sizeof(struct usb_hid_global_state));
4498
4499
646
    item = proto_tree_add_protocol_format(parent_tree, proto_usb_hid, tvb, offset,
4500
646
                                          -1, "HID Report");
4501
646
    tree = proto_item_add_subtree(item, ett_usb_hid_report);
4502
646
    offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, urb, &initial_global);
4503
4504
    /* only insert report descriptor the first time we parse it */
4505
646
    if (!PINFO_FD_VISITED(pinfo) && urb && urb->conv) {
4506
0
        wmem_allocator_t *scope = wmem_file_scope();
4507
0
        report_descriptor_t *data = wmem_new0(scope, report_descriptor_t);
4508
4509
0
        data->bus_id = urb->bus_id;
4510
0
        data->device_address = urb->device_address;
4511
0
        data->interface = urb->conv->interfaceNum;
4512
0
        data->desc_length = offset - old_offset;
4513
0
        data->desc_body = (uint8_t*) tvb_memdup(scope, tvb, old_offset, data->desc_length);
4514
4515
0
        if (parse_report_descriptor(data)) {
4516
0
            insert_report_descriptor(pinfo, data);
4517
0
        } else {
4518
0
            wmem_free(scope, data->desc_body);
4519
0
            wmem_free(scope, data);
4520
0
        }
4521
0
    }
4522
4523
646
    proto_item_set_len(item, offset-old_offset);
4524
4525
646
    return offset;
4526
646
}
4527
4528
/* Dissector for HID GET_REPORT request. See USBHID 1.11, Chapter 7.2.1 Get_Report Request */
4529
static void
4530
dissect_usb_hid_get_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4531
0
{
4532
0
    proto_item *item;
4533
0
    proto_tree *subtree;
4534
4535
0
    if (!is_request)
4536
0
        return;
4537
4538
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4539
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4540
4541
    /* Report Type in the high byte, Report ID in the low byte */
4542
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4543
0
    offset++;
4544
0
    proto_tree_add_item(subtree, hf_usb_hid_report_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4545
0
    offset++;
4546
4547
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4548
0
    offset += 2;
4549
4550
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4551
    /*offset += 2;*/
4552
0
}
4553
4554
/* Dissector for HID SET_REPORT request. See USBHID 1.11, Chapter 7.2.2 Set_Report Request */
4555
static void
4556
dissect_usb_hid_set_report(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4557
0
{
4558
0
    proto_item *item;
4559
0
    proto_tree *subtree;
4560
4561
0
    if (!is_request)
4562
0
        return;
4563
4564
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4565
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4566
4567
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4568
0
    offset++;
4569
0
    proto_tree_add_item(subtree, hf_usb_hid_report_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4570
0
    offset++;
4571
4572
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4573
0
    offset += 2;
4574
4575
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4576
    /*offset += 2;*/
4577
0
}
4578
4579
4580
/* Dissector for HID GET_IDLE request. See USBHID 1.11, Chapter 7.2.3 Get_Idle Request */
4581
static void
4582
dissect_usb_hid_get_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4583
0
{
4584
0
    proto_item *item;
4585
0
    proto_tree *subtree;
4586
4587
0
    if (!is_request)
4588
0
        return;
4589
4590
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4591
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4592
4593
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4594
0
    offset++;
4595
0
    proto_tree_add_item(subtree, hf_usb_hid_zero, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4596
0
    offset++;
4597
4598
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4599
0
    offset += 2;
4600
4601
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4602
    /*offset += 2;*/
4603
0
}
4604
4605
/* Dissector for HID SET_IDLE request. See USBHID 1.11, Chapter 7.2.4 Set_Idle Request */
4606
static void
4607
dissect_usb_hid_set_idle(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4608
0
{
4609
0
    proto_item *item;
4610
0
    proto_tree *subtree;
4611
4612
0
    if (!is_request)
4613
0
        return;
4614
4615
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4616
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4617
4618
    /* Duration in the high byte, Report ID in the low byte */
4619
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4620
0
    offset++;
4621
0
    proto_tree_add_item(subtree, hf_usb_hid_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4622
0
    offset++;
4623
4624
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4625
0
    offset += 2;
4626
4627
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4628
    /*offset += 2;*/
4629
0
}
4630
4631
/* Dissector for HID GET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.5 Get_Protocol Request */
4632
static void
4633
dissect_usb_hid_get_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4634
0
{
4635
0
    if (!is_request)
4636
0
        return;
4637
4638
0
    proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4639
0
    offset += 2;
4640
4641
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4642
0
    offset += 2;
4643
4644
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4645
    /*offset += 2;*/
4646
0
}
4647
4648
/* Dissector for HID SET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.6 Set_Protocol Request */
4649
static void
4650
dissect_usb_hid_set_protocol(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb _U_)
4651
0
{
4652
0
    if (!is_request)
4653
0
        return;
4654
4655
0
    proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4656
0
    offset += 2;
4657
4658
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4659
0
    offset += 2;
4660
4661
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4662
    /*offset += 2;*/
4663
0
}
4664
4665
4666
typedef void (*usb_setup_dissector)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb);
4667
4668
typedef struct _usb_setup_dissector_table_t {
4669
    uint8_t request;
4670
    usb_setup_dissector dissector;
4671
} usb_setup_dissector_table_t;
4672
4673
/* USBHID 1.11, Chapter 7.1 Standard Requests */
4674
#define USB_STD_SETUP_GET_DESCRIPTOR  0x06
4675
4676
4677
/* USBHID 1.11, Chapter 7.2 Class-Specific Requests */
4678
#define USB_HID_SETUP_GET_REPORT      0x01
4679
#define USB_HID_SETUP_GET_IDLE        0x02
4680
#define USB_HID_SETUP_GET_PROTOCOL    0x03
4681
/* 0x04..0x08: Reserved */
4682
#define USB_HID_SETUP_SET_REPORT      0x09
4683
#define USB_HID_SETUP_SET_IDLE        0x0A
4684
#define USB_HID_SETUP_SET_PROTOCOL    0x0B
4685
4686
static const usb_setup_dissector_table_t setup_dissectors[] = {
4687
    { USB_HID_SETUP_GET_REPORT,   dissect_usb_hid_get_report },
4688
    { USB_HID_SETUP_GET_IDLE,     dissect_usb_hid_get_idle },
4689
    { USB_HID_SETUP_GET_PROTOCOL, dissect_usb_hid_get_protocol },
4690
    { USB_HID_SETUP_SET_REPORT,   dissect_usb_hid_set_report },
4691
    { USB_HID_SETUP_SET_IDLE,     dissect_usb_hid_set_idle },
4692
    { USB_HID_SETUP_SET_PROTOCOL, dissect_usb_hid_set_protocol },
4693
    { 0, NULL }
4694
};
4695
4696
static const value_string setup_request_names_vals[] = {
4697
    { USB_STD_SETUP_GET_DESCRIPTOR, "GET_DESCRIPTOR" },
4698
    { USB_HID_SETUP_GET_REPORT,     "GET_REPORT" },
4699
    { USB_HID_SETUP_GET_IDLE,       "GET_IDLE" },
4700
    { USB_HID_SETUP_GET_PROTOCOL,   "GET_PROTOCOL" },
4701
    { USB_HID_SETUP_SET_REPORT,     "SET_REPORT" },
4702
    { USB_HID_SETUP_SET_IDLE,       "SET_IDLE" },
4703
    { USB_HID_SETUP_SET_PROTOCOL,   "SET_PROTOCOL" },
4704
    { 0, NULL }
4705
};
4706
4707
static const value_string usb_hid_report_type_vals[] = {
4708
    { 1, "Input" },
4709
    { 2, "Output" },
4710
    { 3, "Feature" },
4711
    { 0, NULL }
4712
};
4713
4714
static int
4715
dissect_usb_hid_boot_keyboard_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4716
6
{
4717
6
    int       offset = 0;
4718
6
    bool      shortcut_helper = false;
4719
6
    unsigned  modifier;
4720
6
    unsigned  keycode;
4721
4722
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
4723
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
4724
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
4725
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
4726
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
4727
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
4728
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
4729
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
4730
6
    modifier = tvb_get_uint8(tvb, offset);
4731
4732
6
    col_append_str(pinfo->cinfo, COL_INFO, " - ");
4733
6
    if (modifier & 0x80) {
4734
0
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT GUI");
4735
0
        shortcut_helper = true;
4736
0
    }
4737
6
    if (modifier & 0x40) {
4738
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4739
4
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT ALT");
4740
4
        shortcut_helper = true;
4741
4
    }
4742
6
    if (modifier & 0x20) {
4743
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4744
1
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT SHIFT");
4745
1
        shortcut_helper = true;
4746
1
    }
4747
6
    if (modifier & 0x10) {
4748
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4749
2
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT CTRL");
4750
2
        shortcut_helper = true;
4751
2
    }
4752
6
    if (modifier & 0x08) {
4753
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4754
2
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT GUI");
4755
2
        shortcut_helper = true;
4756
2
    }
4757
6
    if (modifier & 0x04) {
4758
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4759
1
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT ALT");
4760
1
        shortcut_helper = true;
4761
1
    }
4762
6
    if (modifier & 0x02) {
4763
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4764
3
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT SHIFT");
4765
3
        shortcut_helper = true;
4766
3
    }
4767
6
    if (modifier & 0x01) {
4768
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4769
2
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT CTRL");
4770
2
        shortcut_helper = true;
4771
2
    }
4772
6
    offset += 1;
4773
4774
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
4775
6
    offset += 1;
4776
4777
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_1, tvb, offset, 1, ENC_BIG_ENDIAN);
4778
6
    keycode = tvb_get_uint8(tvb, offset);
4779
6
    offset += 1;
4780
4781
6
    if (keycode) {
4782
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4783
3
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4784
3
        shortcut_helper = true;
4785
3
    }
4786
4787
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_2, tvb, offset, 1, ENC_BIG_ENDIAN);
4788
6
    keycode = tvb_get_uint8(tvb, offset);
4789
6
    offset += 1;
4790
4791
6
    if (keycode) {
4792
5
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4793
5
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4794
5
        shortcut_helper = true;
4795
5
    }
4796
4797
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_3, tvb, offset, 1, ENC_BIG_ENDIAN);
4798
6
    keycode = tvb_get_uint8(tvb, offset);
4799
6
    offset += 1;
4800
4801
6
    if (keycode) {
4802
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4803
4
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4804
4
        shortcut_helper = true;
4805
4
    }
4806
4807
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_4, tvb, offset, 1, ENC_BIG_ENDIAN);
4808
6
    keycode = tvb_get_uint8(tvb, offset);
4809
6
    offset += 1;
4810
4811
6
    if (keycode) {
4812
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4813
4
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4814
4
        shortcut_helper = true;
4815
4
    }
4816
4817
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_5, tvb, offset, 1, ENC_BIG_ENDIAN);
4818
6
    keycode = tvb_get_uint8(tvb, offset);
4819
6
    offset += 1;
4820
4821
6
    if (keycode) {
4822
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4823
3
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4824
3
        shortcut_helper = true;
4825
3
    }
4826
4827
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_6, tvb, offset, 1, ENC_BIG_ENDIAN);
4828
6
    keycode = tvb_get_uint8(tvb, offset);
4829
6
    offset += 1;
4830
4831
6
    if (keycode) {
4832
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4833
4
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4834
4
        shortcut_helper = true;
4835
4
    }
4836
4837
6
    if (shortcut_helper == false) {
4838
0
        col_append_str(pinfo->cinfo, COL_INFO, "<action key up>");
4839
0
    }
4840
4841
6
    return offset;
4842
6
}
4843
4844
static int
4845
dissect_usb_hid_boot_keyboard_output_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4846
2
{
4847
2
    int       offset = 0;
4848
2
    bool      shortcut_helper = false;
4849
2
    unsigned  leds;
4850
4851
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_constants, tvb, offset, 1, ENC_BIG_ENDIAN);
4852
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_kana, tvb, offset, 1, ENC_BIG_ENDIAN);
4853
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_compose, tvb, offset, 1, ENC_BIG_ENDIAN);
4854
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_scroll_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4855
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_caps_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4856
2
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_num_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4857
2
    leds = tvb_get_uint8(tvb, offset);
4858
4859
2
    col_append_str(pinfo->cinfo, COL_INFO, " - LEDs: ");
4860
2
    if (leds & 0x01) {
4861
0
        col_append_str(pinfo->cinfo, COL_INFO, "NumLock");
4862
0
        shortcut_helper = true;
4863
0
    }
4864
2
    if (leds & 0x02) {
4865
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4866
0
        col_append_str(pinfo->cinfo, COL_INFO, "CapsLock");
4867
0
        shortcut_helper = true;
4868
0
    }
4869
2
    if (leds & 0x04) {
4870
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4871
0
        col_append_str(pinfo->cinfo, COL_INFO, "ScrollLock");
4872
0
        shortcut_helper = true;
4873
0
    }
4874
2
    if (leds & 0x08) {
4875
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4876
0
        col_append_str(pinfo->cinfo, COL_INFO, "Compose");
4877
0
        shortcut_helper = true;
4878
0
    }
4879
2
    if (leds & 0x10) {
4880
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4881
0
        col_append_str(pinfo->cinfo, COL_INFO, "Kana");
4882
0
        shortcut_helper = true;
4883
0
    }
4884
2
    if (leds & 0x20) {
4885
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4886
0
        col_append_str(pinfo->cinfo, COL_INFO, "Constant1");
4887
0
        shortcut_helper = true;
4888
0
    }
4889
2
    if (leds & 0x40) {
4890
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4891
0
        col_append_str(pinfo->cinfo, COL_INFO, "Constant2");
4892
0
        shortcut_helper = true;
4893
0
    }
4894
2
    if (leds & 0x80) {
4895
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4896
0
        col_append_str(pinfo->cinfo, COL_INFO, "Constant3");
4897
        /*shortcut_helper = true;*/
4898
0
    }
4899
2
    if (!leds) {
4900
2
        col_append_str(pinfo->cinfo, COL_INFO, "none");
4901
2
    }
4902
4903
2
    offset += 1;
4904
4905
2
    return offset;
4906
2
}
4907
4908
static int
4909
dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4910
5
{
4911
5
    int       offset = 0;
4912
5
    bool      shortcut_helper = false;
4913
5
    unsigned  buttons;
4914
4915
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_8, tvb, offset, 1, ENC_BIG_ENDIAN);
4916
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_7, tvb, offset, 1, ENC_BIG_ENDIAN);
4917
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_6, tvb, offset, 1, ENC_BIG_ENDIAN);
4918
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_5, tvb, offset, 1, ENC_BIG_ENDIAN);
4919
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_4, tvb, offset, 1, ENC_BIG_ENDIAN);
4920
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_middle, tvb, offset, 1, ENC_BIG_ENDIAN);
4921
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_right, tvb, offset, 1, ENC_BIG_ENDIAN);
4922
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_left, tvb, offset, 1, ENC_BIG_ENDIAN);
4923
5
    buttons = tvb_get_uint8(tvb, offset);
4924
5
    offset += 1;
4925
4926
5
    if (buttons) col_append_str(pinfo->cinfo, COL_INFO, " - ");
4927
5
    if (buttons & 0x01) {
4928
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button LEFT");
4929
2
        shortcut_helper = true;
4930
2
    }
4931
5
    if (buttons & 0x02) {
4932
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4933
1
        col_append_str(pinfo->cinfo, COL_INFO, "Button RIGHT");
4934
1
        shortcut_helper = true;
4935
1
    }
4936
5
    if (buttons & 0x04) {
4937
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4938
1
        col_append_str(pinfo->cinfo, COL_INFO, "Button MIDDLE");
4939
1
    }
4940
5
    if (buttons & 0x08) {
4941
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4942
4
        col_append_str(pinfo->cinfo, COL_INFO, "Button 4");
4943
4
        shortcut_helper = true;
4944
4
    }
4945
5
    if (buttons & 0x10) {
4946
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4947
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 5");
4948
2
        shortcut_helper = true;
4949
2
    }
4950
5
    if (buttons & 0x20) {
4951
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4952
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 6");
4953
2
        shortcut_helper = true;
4954
2
    }
4955
5
    if (buttons & 0x40) {
4956
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4957
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 7");
4958
2
        shortcut_helper = true;
4959
2
    }
4960
5
    if (buttons & 0x80) {
4961
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4962
4
        col_append_str(pinfo->cinfo, COL_INFO, "Button 8");
4963
        /* Not necessary, this is the last case where it is used
4964
         * shortcut_helper = true;
4965
         */
4966
4
    }
4967
4968
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_x_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4969
5
    offset += 1;
4970
4971
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_y_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4972
5
    offset += 1;
4973
4974
    /* not really in HID Specification */
4975
5
    if (tvb_reported_length_remaining(tvb, offset)) {
4976
5
        proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_horizontal_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
4977
5
        offset += 1;
4978
5
    }
4979
4980
    /* not really in HID Specification */
4981
5
    if (tvb_reported_length_remaining(tvb, offset)) {
4982
5
        proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_vertical_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
4983
5
        offset += 1;
4984
5
    }
4985
4986
5
    if (tvb_reported_length_remaining(tvb, offset)) {
4987
5
        proto_tree_add_item(tree, hf_usbhid_data, tvb, offset, -1, ENC_NA);
4988
5
        offset += tvb_captured_length_remaining(tvb, offset);
4989
5
    }
4990
4991
5
    return offset;
4992
5
}
4993
4994
4995
/* dissect a "standard" control message that's sent to an interface */
4996
static int
4997
dissect_usb_hid_control_std_intf(tvbuff_t *tvb, packet_info *pinfo,
4998
        proto_tree *tree, urb_info_t *urb)
4999
0
{
5000
0
    int               offset = 0;
5001
0
    usb_trans_info_t *usb_trans_info;
5002
0
    uint8_t           req;
5003
5004
0
    usb_trans_info = urb->usb_trans_info;
5005
5006
    /* XXX - can we do some plausibility checks here? */
5007
5008
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBHID");
5009
5010
    /* we can't use urb->is_request since urb
5011
       was replaced with the interface conversation */
5012
0
    if (usb_trans_info->request_in == pinfo->num) {
5013
        /* the tvb that we see here is the setup packet
5014
           without the request type byte */
5015
5016
0
        req = tvb_get_uint8(tvb, offset);
5017
0
        if (req != USB_SETUP_GET_DESCRIPTOR)
5018
0
            return offset;
5019
0
        proto_tree_add_item(tree, hf_usb_hid_request, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5020
0
        col_clear(pinfo->cinfo, COL_INFO);
5021
0
        col_append_str(pinfo->cinfo, COL_INFO, "GET DESCRIPTOR Request");
5022
0
        offset += 1;
5023
5024
0
        proto_tree_add_item(tree, hf_usb_hid_bDescriptorIndex, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5025
0
        usb_trans_info->u.get_descriptor.usb_index = tvb_get_uint8(tvb, offset);
5026
0
        offset += 1;
5027
5028
0
        proto_tree_add_item(tree, hf_usb_hid_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5029
0
        usb_trans_info->u.get_descriptor.type = tvb_get_uint8(tvb, offset);
5030
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
5031
0
                val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type,
5032
0
                    &hid_descriptor_type_vals_ext, "Unknown type %u"));
5033
0
        offset += 1;
5034
5035
0
        proto_tree_add_item(tree, hf_usb_hid_wInterfaceNumber, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5036
0
        offset += 2;
5037
5038
0
        proto_tree_add_item(tree, hf_usb_hid_wDescriptorLength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5039
0
        offset += 2;
5040
0
    }
5041
0
    else {
5042
0
        col_clear(pinfo->cinfo, COL_INFO);
5043
0
        col_append_str(pinfo->cinfo, COL_INFO, "GET DESCRIPTOR Response");
5044
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
5045
0
                val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type,
5046
0
                    &hid_descriptor_type_vals_ext, "Unknown type %u"));
5047
0
        if (usb_trans_info->u.get_descriptor.type == USB_DT_HID_REPORT)
5048
0
            offset = dissect_usb_hid_get_report_descriptor(pinfo, tree, tvb, offset, urb);
5049
0
    }
5050
5051
0
    return offset;
5052
0
}
5053
5054
/* dissect a class-specific control message that's sent to an interface */
5055
static int
5056
dissect_usb_hid_control_class_intf(tvbuff_t *tvb, packet_info *pinfo,
5057
        proto_tree *tree, urb_info_t *urb)
5058
0
{
5059
0
    usb_trans_info_t *usb_trans_info;
5060
0
    bool is_request;
5061
0
    unsigned offset = 0;
5062
0
    usb_setup_dissector dissector = NULL;
5063
0
    const usb_setup_dissector_table_t *tmp;
5064
5065
0
    usb_trans_info = urb->usb_trans_info;
5066
5067
0
    is_request = (pinfo->srcport==NO_ENDPOINT);
5068
5069
    /* Check valid values for bmRequestType. See Chapter 7.2 in USBHID 1.11 */
5070
0
    for (tmp = setup_dissectors; tmp->dissector; tmp++) {
5071
0
        if (tmp->request == usb_trans_info->setup.request) {
5072
0
            dissector = tmp->dissector;
5073
0
            break;
5074
0
        }
5075
0
    }
5076
    /* No, we could not find any class specific dissector for this request
5077
     * return 0 and let USB try any of the standard requests.
5078
     */
5079
0
    if (!dissector)
5080
0
        return 0;
5081
5082
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBHID");
5083
5084
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
5085
0
                 val_to_str(pinfo->pool, usb_trans_info->setup.request, setup_request_names_vals, "Unknown type %x"),
5086
0
                 is_request ? "Request" : "Response");
5087
5088
0
    if (is_request) {
5089
0
        proto_tree_add_item(tree, hf_usb_hid_request, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5090
0
        offset += 1;
5091
0
    }
5092
5093
0
    dissector(pinfo, tree, tvb, offset, is_request, urb);
5094
0
    return tvb_captured_length(tvb);
5095
0
}
5096
5097
/* unpack a HID logical report field */
5098
static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, uint32_t size, int32_t min, int32_t *val)
5099
0
{
5100
0
    if (size > 32)
5101
0
        return -1;
5102
5103
0
    *val = tvb_get_bits32(tvb, bit_offset, size, ENC_LITTLE_ENDIAN);
5104
5105
0
    if (min < 0)
5106
0
        *val = ws_sign_ext32(*val, size);
5107
5108
0
    return 0;
5109
0
}
5110
5111
static int
5112
dissect_usb_hid_int_dynamic_value_variable(tvbuff_t *tvb, proto_tree *tree, hid_field_t *field,
5113
        int bit_offset, int hf)
5114
0
{
5115
0
    int32_t val = 0;
5116
5117
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5118
0
        return -1;
5119
5120
0
    proto_tree_add_int_bits_format_value(tree, hf, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN, "%d", val);
5121
0
    return 0;
5122
0
}
5123
5124
/* dissect the Generic Desktop Controls (0x0001) usage page */
5125
static int
5126
dissect_usb_hid_generic_desktop_controls_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5127
        proto_tree *tree, hid_field_t *field, unsigned usage, int bit_offset)
5128
0
{
5129
0
    int ret = 0;
5130
5131
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == GENERIC_DESKTOP_CONTROLS_PAGE);
5132
0
    usage = USAGE_ID(usage);
5133
0
    switch (usage)
5134
0
    {
5135
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_X:
5136
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_x);
5137
0
            break;
5138
5139
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_Y:
5140
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_y);
5141
0
            break;
5142
5143
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_Z:
5144
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_z);
5145
0
            break;
5146
5147
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RX:
5148
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_rx);
5149
0
            break;
5150
5151
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RY:
5152
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_ry);
5153
0
            break;
5154
5155
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RZ:
5156
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_rz);
5157
0
            break;
5158
5159
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_SLIDER:
5160
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_slider);
5161
0
            break;
5162
5163
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VX:
5164
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vx);
5165
0
            break;
5166
5167
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VY:
5168
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vy);
5169
0
            break;
5170
5171
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VZ:
5172
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vz);
5173
0
            break;
5174
5175
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRX:
5176
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbrx);
5177
0
            break;
5178
5179
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRY:
5180
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbry);
5181
0
            break;
5182
5183
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRZ:
5184
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbrz);
5185
0
            break;
5186
5187
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VNO:
5188
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vno);
5189
0
            break;
5190
5191
0
        default:
5192
0
            ret = -1;
5193
0
            break;
5194
0
    }
5195
5196
0
    return ret;
5197
0
}
5198
5199
/* dissect the Keyboard/Keypad (0x0007) usage page */
5200
static int
5201
dissect_usb_hid_keyboard_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5202
        proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset)
5203
0
{
5204
0
    int32_t val = 0;
5205
5206
    /* the data is a boolean state for the usage (eg. KEY_SHIFT = 1, KEY_CONTROL = 0) */
5207
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5208
0
        return -1;
5209
5210
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == KEYBOARD_KEYPAD_PAGE);
5211
0
    usage = USAGE_ID(usage);
5212
5213
0
    proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_key, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN,
5214
0
        "%s (0x%02x): %s", val_to_str_ext_const(usage, &keycode_vals_ext, "Unknown"), usage, val ? "DOWN" : "UP");
5215
0
    return 0;
5216
0
}
5217
5218
/* dissect the Button (0x0009) usage page */
5219
static int
5220
dissect_usb_hid_button_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5221
        proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset)
5222
0
{
5223
0
    int32_t val = 0;
5224
0
    proto_item *ti;
5225
5226
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == BUTTON_PAGE);
5227
0
    usage = USAGE_ID(usage);
5228
5229
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5230
0
        return -1;
5231
5232
0
    ti = proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_button, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN, "%u", usage);
5233
5234
0
    if (usage == 0)
5235
0
        proto_item_append_text(ti, " (No button pressed)");
5236
0
    else if (usage == 1)
5237
0
        proto_item_append_text(ti, " (primary/trigger)");
5238
0
    else if (usage == 2)
5239
0
        proto_item_append_text(ti, " (secondary)");
5240
0
    else if (usage == 3)
5241
0
        proto_item_append_text(ti, " (tertiary)");
5242
5243
0
    proto_item_append_text(ti, ": %s", val ? "DOWN" : "UP");
5244
0
    return 0;
5245
0
}
5246
5247
static void
5248
dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hid_field_t* field,
5249
                     uint32_t usage, int bit_offset)
5250
0
{
5251
0
    int ret = 0;
5252
5253
    /* vendor data (0xff00 - 0xffff) */
5254
0
    if ((USAGE_PAGE(usage) & 0xff00) == 0xff00) {
5255
        /* TODO: should this field be e.g FT_UINT64 ? */
5256
0
        proto_tree_add_bits_item(tree, hf_usbhid_vendor_data, tvb, bit_offset, field->report_size, ENC_LITTLE_ENDIAN);
5257
0
        return;
5258
0
    }
5259
5260
0
    switch (USAGE_PAGE(usage))
5261
0
    {
5262
0
    case GENERIC_DESKTOP_CONTROLS_PAGE:
5263
0
        ret = dissect_usb_hid_generic_desktop_controls_page(tvb, pinfo, tree, field, usage, bit_offset);
5264
0
        break;
5265
5266
0
    case KEYBOARD_KEYPAD_PAGE:
5267
0
        ret = dissect_usb_hid_keyboard_page(tvb, pinfo, tree, field, usage, bit_offset);
5268
0
        break;
5269
5270
0
    case BUTTON_PAGE:
5271
0
        ret = dissect_usb_hid_button_page(tvb, pinfo, tree, field, usage, bit_offset);
5272
0
        break;
5273
5274
0
    default:
5275
0
        ret = -1;
5276
0
        break;
5277
0
    }
5278
5279
0
    if (ret) {
5280
0
        uint32_t val = 0;
5281
0
        proto_item *ti =
5282
0
            proto_tree_add_uint_bits_format_value(tree, hf_usb_hid_localitem_usage, tvb, bit_offset, field->report_size,
5283
0
                                                  usage, ENC_LITTLE_ENDIAN, "%s", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(usage), USAGE_ID(usage)));
5284
0
        if (0 == hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, (int32_t*)&val))
5285
0
            proto_item_append_text(ti, ": %d", val);
5286
0
    }
5287
0
}
5288
5289
static bool hid_get_usage_from_array(hid_field_t *field, int32_t idx, uint32_t *out)
5290
0
{
5291
0
    if ((idx >= field->logical_min) && (idx <= field->logical_max)) {
5292
0
        idx -= field->logical_min;
5293
0
        if ((uint32_t)idx < wmem_array_get_count(field->usages)) {
5294
0
            *out = (*((uint32_t*) wmem_array_index(field->usages, idx)));
5295
0
            return true;
5296
0
        }
5297
0
    }
5298
0
    return false;
5299
0
}
5300
5301
static int
5302
dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_field_t *field, int bit_offset)
5303
0
{
5304
0
    int start_offset = bit_offset;
5305
5306
0
    if ((field->properties & HID_MAIN_TYPE) == HID_MAIN_ARRAY) {
5307
0
        proto_item *array_ti;
5308
0
        proto_tree *array_tree;
5309
5310
0
        array_ti = proto_tree_add_bits_item(tree, hf_usbhid_array, tvb, bit_offset,
5311
0
            field->report_size * field->report_count, ENC_LITTLE_ENDIAN);
5312
0
        array_tree = proto_item_add_subtree(array_ti, ett_usb_hid_array);
5313
5314
0
        for(unsigned int j = 0; j < field->report_count; j++) {
5315
0
            uint32_t val = 0;
5316
0
            bool in_range;
5317
0
            if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, (int32_t*)&val)) {
5318
0
                in_range = false;
5319
0
            } else {
5320
0
                in_range = hid_get_usage_from_array(field, val, &val);
5321
0
            }
5322
0
            if (in_range) {
5323
0
                proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
5324
0
                    val, ENC_LITTLE_ENDIAN, "%s (0x%04x, 0x%04x)", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(val), USAGE_ID(val)),
5325
0
                    USAGE_PAGE(val), USAGE_ID(val));
5326
0
            } else {
5327
0
                proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
5328
0
                    val, ENC_LITTLE_ENDIAN, "No controls asserted");
5329
0
            }
5330
0
            bit_offset += field->report_size;
5331
0
        }
5332
0
    } else {
5333
0
        unsigned int i;
5334
0
        unsigned int count = wmem_array_get_count(field->usages);
5335
0
        if (count > field->report_count) {
5336
0
            count = field->report_count;
5337
0
        }
5338
0
        for(i = 0; i < count; i++) {
5339
0
            uint32_t usage = *((uint32_t*) wmem_array_index(field->usages, i));
5340
0
            dissect_hid_variable(tvb, pinfo, tree, field, usage, bit_offset);
5341
0
            bit_offset += field->report_size;
5342
0
        }
5343
0
        if (field->report_count > count) {
5344
0
            int remaining_bits = (field->report_count - count) * field->report_size;
5345
0
            proto_tree_add_bits_item(tree, hf_usbhid_padding, tvb, bit_offset, remaining_bits, ENC_LITTLE_ENDIAN);
5346
0
            bit_offset += remaining_bits;
5347
0
        }
5348
0
    }
5349
5350
0
    return bit_offset - start_offset;
5351
0
}
5352
5353
/* Dissect USB HID data/reports */
5354
static int
5355
dissect_usb_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
5356
0
{
5357
0
    unsigned offset = 0, hid_bit_offset;
5358
0
    proto_item *hid_ti;
5359
0
    proto_tree *hid_tree;
5360
0
    wmem_array_t *fields;
5361
0
    urb_info_t *usb_data = (urb_info_t*) data;
5362
0
    report_descriptor_t *rdesc = get_report_descriptor(pinfo, usb_data);
5363
0
    unsigned remaining = tvb_reported_length_remaining(tvb, offset);
5364
5365
0
    if (remaining) {
5366
0
        hid_ti = proto_tree_add_item(tree, hf_usbhid_data, tvb, offset, -1, ENC_NA);
5367
0
        hid_tree = proto_item_add_subtree(hid_ti, ett_usb_hid_data);
5368
0
        hid_bit_offset = offset * 8;
5369
0
        offset += remaining;
5370
0
        uint8_t report_id = tvb_get_bits8(tvb, hid_bit_offset, 8);
5371
5372
0
        if (rdesc) {
5373
0
            if (rdesc->uses_report_id) {
5374
0
                proto_tree_add_item(hid_tree, hf_usbhid_report_id, tvb, hid_bit_offset / 8, 1, ENC_NA);
5375
0
                hid_bit_offset += 8;
5376
0
            }
5377
5378
0
            if (usb_data->direction == P2P_DIR_RECV)
5379
0
                fields = rdesc->fields_in;
5380
0
            else
5381
0
                fields = rdesc->fields_out;
5382
5383
0
            for(unsigned int i = 0; i < wmem_array_get_count(fields); i++) {
5384
0
                hid_field_t *field = (hid_field_t*) wmem_array_index(fields, i);
5385
0
                unsigned int data_size = field->report_size * field->report_count;
5386
5387
                /* skip items with invalid report IDs */
5388
0
                if (rdesc->uses_report_id && field->report_id != report_id)
5389
0
                    continue;
5390
5391
                /* skip items with a report size of 0 (no data and won't
5392
                 * advance offset) */
5393
0
                if (field->report_size == 0) {
5394
0
                    continue;
5395
0
                }
5396
5397
                /* if the item has no usages, it is padding - HID spec 6.2.2.9 */
5398
0
                if (wmem_array_get_count(field->usages) == 0) {
5399
0
                    proto_tree_add_bits_item(hid_tree, hf_usbhid_padding, tvb, hid_bit_offset, data_size, ENC_LITTLE_ENDIAN);
5400
0
                    hid_bit_offset += data_size;
5401
0
                    continue;
5402
0
                }
5403
5404
0
                hid_bit_offset += dissect_hid_field(tvb, pinfo, hid_tree, field, hid_bit_offset);
5405
0
            }
5406
0
        }
5407
0
    }
5408
5409
0
    return offset;
5410
0
}
5411
5412
/* Dissector for HID class-specific control request as defined in
5413
 * USBHID 1.11, Chapter 7.2.
5414
 * returns the number of bytes consumed */
5415
static int
5416
dissect_usb_hid_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
5417
0
{
5418
0
    urb_info_t *urb;
5419
0
    usb_trans_info_t *usb_trans_info;
5420
0
    uint8_t type, recip;
5421
5422
0
    urb = (urb_info_t *)data;
5423
0
    if (!urb)
5424
0
        return 0;
5425
0
    usb_trans_info = urb->usb_trans_info;
5426
0
    if (!usb_trans_info)
5427
0
        return 0;
5428
5429
0
    type = USB_TYPE(usb_trans_info->setup.requesttype);
5430
0
    recip = USB_RECIPIENT(usb_trans_info->setup.requesttype);
5431
5432
0
    if (recip == RQT_SETUP_RECIPIENT_INTERFACE) {
5433
0
        if (type == RQT_SETUP_TYPE_STANDARD)
5434
0
            return dissect_usb_hid_control_std_intf(tvb, pinfo, tree, urb);
5435
0
        else if (type == RQT_SETUP_TYPE_CLASS)
5436
0
            return dissect_usb_hid_control_class_intf(tvb, pinfo, tree, urb);
5437
0
    }
5438
5439
0
    return dissect_usb_hid_data(tvb, pinfo, tree, data);
5440
0
}
5441
5442
/* dissect a descriptor that is specific to the HID class */
5443
static int
5444
dissect_usb_hid_class_descriptors(tvbuff_t *tvb, packet_info *pinfo _U_,
5445
        proto_tree *tree, void *data _U_)
5446
0
{
5447
0
    uint8_t     type;
5448
0
    int         offset = 0;
5449
0
    proto_item *ti;
5450
0
    proto_tree *desc_tree;
5451
0
    uint8_t     num_desc;
5452
0
    unsigned    i;
5453
5454
0
    type = tvb_get_uint8(tvb, 1);
5455
5456
    /* for now, we only handle the HID descriptor here */
5457
0
    if (type != USB_DT_HID)
5458
0
        return 0;
5459
5460
0
    desc_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_usb_hid_descriptor, &ti, "HID DESCRIPTOR");
5461
5462
0
    dissect_usb_descriptor_header(desc_tree, tvb, offset, &hid_descriptor_type_vals_ext);
5463
0
    offset += 2;
5464
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bcdHID, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5465
0
    offset += 2;
5466
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bCountryCode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5467
0
    offset++;
5468
0
    num_desc = tvb_get_uint8(tvb, offset);
5469
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bNumDescriptors, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5470
0
    offset++;
5471
0
    for (i=0;i<num_desc;i++) {
5472
0
        proto_tree_add_item(desc_tree, hf_usb_hid_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5473
0
        offset++;
5474
0
        proto_tree_add_item(desc_tree, hf_usb_hid_wDescriptorLength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5475
0
        offset += 2;
5476
0
    }
5477
5478
0
    proto_item_set_len(ti, offset);
5479
0
    return offset;
5480
0
}
5481
5482
5483
void
5484
proto_register_usb_hid(void)
5485
15
{
5486
15
    static hf_register_info hf[] = {
5487
15
        { &hf_usb_hid_item_bSize,
5488
15
            { "bSize", "usbhid.item.bSize", FT_UINT8, BASE_DEC,
5489
15
                VALS(usb_hid_item_bSize_vals), USBHID_SIZE_MASK, NULL, HFILL }},
5490
5491
15
        { &hf_usb_hid_item_bType,
5492
15
            { "bType", "usbhid.item.bType", FT_UINT8, BASE_DEC,
5493
15
                VALS(usb_hid_item_bType_vals), USBHID_TYPE_MASK, NULL, HFILL }},
5494
5495
15
        { &hf_usb_hid_mainitem_bTag,
5496
15
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5497
15
                VALS(usb_hid_mainitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5498
5499
15
        { &hf_usb_hid_globalitem_bTag,
5500
15
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5501
15
                VALS(usb_hid_globalitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5502
5503
15
        { &hf_usb_hid_localitem_bTag,
5504
15
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5505
15
                VALS(usb_hid_localitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5506
5507
15
        { &hf_usb_hid_longitem_bTag,
5508
15
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5509
15
                VALS(usb_hid_longitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5510
5511
15
        { &hf_usb_hid_item_bDataSize,
5512
15
            { "bDataSize", "usbhid.item.bDataSize", FT_UINT8, BASE_DEC,
5513
15
                NULL, 0, NULL, HFILL }},
5514
5515
15
        { &hf_usb_hid_item_bLongItemTag,
5516
15
            { "bTag", "usbhid.item.bLongItemTag", FT_UINT8, BASE_HEX,
5517
15
                NULL, 0, NULL, HFILL }},
5518
5519
        /* Main-report item data */
5520
5521
15
        { &hf_usb_hid_mainitem_bit0,
5522
15
            { "Data/constant", "usbhid.item.main.readonly", FT_BOOLEAN, 9,
5523
15
                TFS(&tfs_mainitem_bit0), 1<<0, NULL, HFILL }},
5524
5525
15
        { &hf_usb_hid_mainitem_bit1,
5526
15
            { "Data type", "usbhid.item.main.variable", FT_BOOLEAN, 9,
5527
15
                TFS(&tfs_mainitem_bit1), 1<<1, NULL, HFILL }},
5528
5529
15
        { &hf_usb_hid_mainitem_bit2,
5530
15
            { "Coordinates", "usbhid.item.main.relative", FT_BOOLEAN, 9,
5531
15
                TFS(&tfs_mainitem_bit2), 1<<2, NULL, HFILL }},
5532
5533
15
        { &hf_usb_hid_mainitem_bit3,
5534
15
            { "Min/max wraparound", "usbhid.item.main.wrap", FT_BOOLEAN, 9,
5535
15
                TFS(&tfs_mainitem_bit3), 1<<3, NULL, HFILL }},
5536
5537
15
        { &hf_usb_hid_mainitem_bit4,
5538
15
            { "Physical relationship to data", "usbhid.item.main.nonlinear", FT_BOOLEAN, 9,
5539
15
                TFS(&tfs_mainitem_bit4), 1<<4, NULL, HFILL }},
5540
5541
15
        { &hf_usb_hid_mainitem_bit5,
5542
15
            { "Preferred state", "usbhid.item.main.no_preferred_state", FT_BOOLEAN, 9,
5543
15
                TFS(&tfs_mainitem_bit5), 1<<5, NULL, HFILL }},
5544
5545
15
        { &hf_usb_hid_mainitem_bit6,
5546
15
            { "Has null position", "usbhid.item.main.nullstate", FT_BOOLEAN, 9,
5547
15
                TFS(&tfs_mainitem_bit6), 1<<6, NULL, HFILL }},
5548
5549
15
        { &hf_usb_hid_mainitem_bit7,
5550
15
            { "(Non)-volatile", "usbhid.item.main.volatile", FT_BOOLEAN, 9,
5551
15
                TFS(&tfs_mainitem_bit7), 1<<7, NULL, HFILL }},
5552
5553
15
        { &hf_usb_hid_mainitem_bit7_input,
5554
15
            { "[Reserved]", "usbhid.item.main.reserved", FT_BOOLEAN, 9,
5555
15
                NULL, 1<<7, NULL, HFILL }},
5556
5557
15
        { &hf_usb_hid_mainitem_bit8,
5558
15
            { "Bits or bytes", "usbhid.item.main.buffered_bytes", FT_BOOLEAN, 9,
5559
15
                TFS(&tfs_mainitem_bit8), 1<<8, NULL, HFILL }},
5560
5561
15
        { &hf_usb_hid_mainitem_colltype,
5562
15
            { "Collection type", "usbhid.item.main.colltype", FT_UINT8, BASE_RANGE_STRING|BASE_HEX,
5563
15
                RVALS(usb_hid_mainitem_colltype_vals), 0, NULL, HFILL }},
5564
5565
        /* Global-report item data */
5566
5567
15
        { &hf_usb_hid_globalitem_usage,
5568
15
            { "Usage page", "usbhid.item.global.usage", FT_UINT16, BASE_RANGE_STRING|BASE_HEX,
5569
15
                NULL, 0, NULL, HFILL }},
5570
5571
15
        { &hf_usb_hid_globalitem_log_min,
5572
15
            { "Logical minimum", "usbhid.item.global.log_min", FT_INT32, BASE_DEC,
5573
15
                NULL, 0, NULL, HFILL }},
5574
5575
15
        { &hf_usb_hid_globalitem_log_max,
5576
15
            { "Logical maximum", "usbhid.item.global.log_max", FT_INT32, BASE_DEC,
5577
15
                NULL, 0, NULL, HFILL }},
5578
5579
15
        { &hf_usb_hid_globalitem_phy_min,
5580
15
            { "Physical minimum", "usbhid.item.global.phy_min", FT_INT32, BASE_DEC,
5581
15
                NULL, 0, NULL, HFILL }},
5582
5583
15
        { &hf_usb_hid_globalitem_phy_max,
5584
15
            { "Physical maximum", "usbhid.item.global.phy_max", FT_INT32, BASE_DEC,
5585
15
                NULL, 0, NULL, HFILL }},
5586
5587
15
        { &hf_usb_hid_globalitem_unit_exp,
5588
15
            { "Unit exponent", "usbhid.item.global.unit_exp", FT_UINT8, BASE_DEC,
5589
15
                NULL, 0, NULL, HFILL }},
5590
5591
15
        { &hf_usb_hid_globalitem_unit_sys,
5592
15
            { "System", "usbhid.item.global.unit.system", FT_UINT32, BASE_HEX,
5593
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0000000F, NULL, HFILL }},
5594
5595
15
        { &hf_usb_hid_globalitem_unit_len,
5596
15
            { "Length", "usbhid.item.global.unit.length", FT_UINT32, BASE_HEX,
5597
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x000000F0, NULL, HFILL }},
5598
5599
15
        { &hf_usb_hid_globalitem_unit_mass,
5600
15
            { "Mass", "usbhid.item.global.unit.mass", FT_UINT32, BASE_HEX,
5601
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x00000F00, NULL, HFILL }},
5602
5603
15
        { &hf_usb_hid_globalitem_unit_time,
5604
15
            { "Time", "usbhid.item.global.unit.time", FT_UINT32, BASE_HEX,
5605
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0000F000, NULL, HFILL }},
5606
5607
15
        { &hf_usb_hid_globalitem_unit_temp,
5608
15
            { "Temperature", "usbhid.item.global.unit.temperature", FT_UINT32, BASE_HEX,
5609
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x000F0000, NULL, HFILL }},
5610
5611
15
        { &hf_usb_hid_globalitem_unit_current,
5612
15
            { "Current", "usbhid.item.global.unit.current", FT_UINT32, BASE_HEX,
5613
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x00F00000, NULL, HFILL }},
5614
5615
15
        { &hf_usb_hid_globalitem_unit_brightness,
5616
15
            { "Luminous intensity", "usbhid.item.global.unit.brightness", FT_UINT32, BASE_HEX,
5617
15
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0F000000, NULL, HFILL }},
5618
5619
15
        { &hf_usb_hid_globalitem_report_size,
5620
15
            { "Report size", "usbhid.item.global.report_size", FT_UINT8, BASE_DEC,
5621
15
                NULL, 0, NULL, HFILL }},
5622
5623
15
        { &hf_usb_hid_globalitem_report_id,
5624
15
            { "Report ID", "usbhid.item.global.report_id", FT_UINT8, BASE_HEX,
5625
15
                NULL, 0, NULL, HFILL }},
5626
5627
15
        { &hf_usb_hid_globalitem_report_count,
5628
15
            { "Report count", "usbhid.item.global.report_count", FT_UINT8, BASE_DEC,
5629
15
                NULL, 0, NULL, HFILL }},
5630
5631
15
        { &hf_usb_hid_globalitem_push,
5632
15
            { "Push", "usbhid.item.global.push", FT_UINT8, BASE_HEX,
5633
15
                NULL, 0, NULL, HFILL }},
5634
5635
15
        { &hf_usb_hid_globalitem_pop,
5636
15
            { "Pop", "usbhid.item.global.pop", FT_UINT8, BASE_HEX,
5637
15
                NULL, 0, NULL, HFILL }},
5638
5639
        /* Local-report item data */
5640
5641
15
        { &hf_usb_hid_localitem_usage,
5642
15
            { "Usage", "usbhid.item.local.usage", FT_UINT16, BASE_HEX,
5643
15
                NULL, 0, NULL, HFILL }},
5644
5645
15
        { &hf_usb_hid_localitem_usage_min,
5646
15
            { "Usage minimum", "usbhid.item.local.usage_min", FT_UINT16, BASE_HEX,
5647
15
                NULL, 0, NULL, HFILL }},
5648
5649
15
        { &hf_usb_hid_localitem_usage_max,
5650
15
            { "Usage maximum", "usbhid.item.local.usage_max", FT_UINT16, BASE_HEX,
5651
15
                NULL, 0, NULL, HFILL }},
5652
5653
15
        { &hf_usb_hid_localitem_desig_index,
5654
15
            { "Designator index", "usbhid.item.local.desig_index", FT_UINT8, BASE_HEX,
5655
15
                NULL, 0, NULL, HFILL }},
5656
5657
15
        { &hf_usb_hid_localitem_desig_min,
5658
15
            { "Designator minimum", "usbhid.item.local.desig_min", FT_UINT8, BASE_HEX,
5659
15
                NULL, 0, NULL, HFILL }},
5660
5661
15
        { &hf_usb_hid_localitem_desig_max,
5662
15
            { "Designator maximum", "usbhid.item.local.desig_max", FT_UINT8, BASE_HEX,
5663
15
                NULL, 0, NULL, HFILL }},
5664
5665
15
        { &hf_usb_hid_localitem_string_index,
5666
15
            { "String index", "usbhid.item.local.string_index", FT_UINT8, BASE_HEX,
5667
15
                NULL, 0, NULL, HFILL }},
5668
5669
15
        { &hf_usb_hid_localitem_string_min,
5670
15
            { "String minimum", "usbhid.item.local.string_min", FT_UINT8, BASE_HEX,
5671
15
                NULL, 0, NULL, HFILL }},
5672
5673
15
        { &hf_usb_hid_localitem_string_max,
5674
15
            { "String maximum", "usbhid.item.local.string_max", FT_UINT8, BASE_HEX,
5675
15
                NULL, 0, NULL, HFILL }},
5676
5677
15
        { &hf_usb_hid_localitem_delimiter,
5678
15
            { "Delimiter", "usbhid.item.local.delimiter", FT_UINT8, BASE_HEX,
5679
15
                NULL, 0, NULL, HFILL }},
5680
5681
5682
15
        { &hf_usb_hid_item_unk_data,
5683
15
            { "Item data", "usbhid.item.data", FT_BYTES, BASE_NONE,
5684
15
                NULL, 0, NULL, HFILL }},
5685
5686
        /* USB HID specific requests */
5687
15
        { &hf_usb_hid_request,
5688
15
            { "bRequest", "usbhid.setup.bRequest", FT_UINT8, BASE_HEX,
5689
15
                VALS(setup_request_names_vals), 0x0, NULL, HFILL }},
5690
5691
15
        { &hf_usb_hid_value,
5692
15
            { "wValue", "usbhid.setup.wValue", FT_UINT16, BASE_HEX,
5693
15
                NULL, 0x0, NULL, HFILL }},
5694
5695
15
        { &hf_usb_hid_index,
5696
15
            { "wIndex", "usbhid.setup.wIndex", FT_UINT16, BASE_DEC,
5697
15
                NULL, 0x0, NULL, HFILL }},
5698
5699
15
        { &hf_usb_hid_length,
5700
15
            { "wLength", "usbhid.setup.wLength", FT_UINT16, BASE_DEC,
5701
15
                NULL, 0x0, NULL, HFILL }},
5702
5703
15
        { &hf_usb_hid_report_type,
5704
15
            { "ReportType", "usbhid.setup.ReportType", FT_UINT8, BASE_DEC,
5705
15
                VALS(usb_hid_report_type_vals), 0x0, NULL, HFILL }},
5706
5707
15
        { &hf_usb_hid_report_id,
5708
15
            { "ReportID", "usbhid.setup.ReportID", FT_UINT8, BASE_DEC,
5709
15
                NULL, 0x0, NULL, HFILL }},
5710
5711
15
        { &hf_usb_hid_duration,
5712
15
            { "Duration", "usbhid.setup.Duration", FT_UINT8, BASE_DEC,
5713
15
                NULL, 0x0, NULL, HFILL }},
5714
5715
15
        { &hf_usb_hid_zero,
5716
15
            { "(zero)", "usbhid.setup.zero", FT_UINT8, BASE_DEC,
5717
15
                NULL, 0x0, NULL, HFILL }},
5718
5719
        /* components of the HID descriptor */
5720
15
        { &hf_usb_hid_bcdHID,
5721
15
            { "bcdHID", "usbhid.descriptor.hid.bcdHID", FT_UINT16, BASE_HEX,
5722
15
                NULL, 0x0, NULL, HFILL }},
5723
5724
15
        { &hf_usb_hid_bCountryCode,
5725
15
            { "bCountryCode", "usbhid.descriptor.hid.bCountryCode", FT_UINT8, BASE_HEX,
5726
15
                VALS(hid_country_code_vals), 0x0, NULL, HFILL }},
5727
5728
15
        { &hf_usb_hid_bNumDescriptors,
5729
15
            { "bNumDescriptors", "usbhid.descriptor.hid.bNumDescriptors", FT_UINT8, BASE_DEC,
5730
15
                NULL, 0x0, NULL, HFILL }},
5731
5732
15
        { &hf_usb_hid_bDescriptorIndex,
5733
15
            { "bDescriptorIndex", "usbhid.descriptor.hid.bDescriptorIndex", FT_UINT8, BASE_HEX,
5734
15
                NULL, 0x0, NULL, HFILL }},
5735
5736
15
        { &hf_usb_hid_bDescriptorType,
5737
15
            { "bDescriptorType", "usbhid.descriptor.hid.bDescriptorType", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5738
15
                &hid_descriptor_type_vals_ext, 0x00, NULL, HFILL }},
5739
5740
15
        { &hf_usb_hid_wInterfaceNumber,
5741
15
            { "wInterfaceNumber", "usbhid.descriptor.hid.wInterfaceNumber", FT_UINT16, BASE_DEC,
5742
15
                NULL, 0x0, NULL, HFILL }},
5743
5744
15
        { &hf_usb_hid_wDescriptorLength,
5745
15
            { "wDescriptorLength", "usbhid.descriptor.hid.wDescriptorLength", FT_UINT16, BASE_DEC,
5746
15
                NULL, 0x0, NULL, HFILL }},
5747
5748
15
        { &hf_usbhid_boot_report_keyboard_reserved,
5749
15
            { "Reserved", "usbhid.boot_report.keyboard.reserved", FT_UINT8, BASE_HEX,
5750
15
                NULL, 0x00, NULL, HFILL }},
5751
5752
15
        { &hf_usbhid_boot_report_keyboard_keycode_1,
5753
15
            { "Keycode 1", "usbhid.boot_report.keyboard.keycode_1", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5754
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5755
5756
15
        { &hf_usbhid_boot_report_keyboard_keycode_2,
5757
15
            { "Keycode 2", "usbhid.boot_report.keyboard.keycode_2", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5758
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5759
5760
15
        { &hf_usbhid_boot_report_keyboard_keycode_3,
5761
15
            { "Keycode 3", "usbhid.boot_report.keyboard.keycode_3", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5762
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5763
5764
15
        { &hf_usbhid_boot_report_keyboard_keycode_4,
5765
15
            { "Keycode 4", "usbhid.boot_report.keyboard.keycode_4", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5766
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5767
5768
15
        { &hf_usbhid_boot_report_keyboard_keycode_5,
5769
15
            { "Keycode 5", "usbhid.boot_report.keyboard.keycode_5", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5770
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5771
5772
15
        { &hf_usbhid_boot_report_keyboard_keycode_6,
5773
15
            { "Keycode 6", "usbhid.boot_report.keyboard.keycode_6", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5774
15
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5775
5776
15
        { &hf_usbhid_boot_report_keyboard_modifier_right_gui,
5777
15
            { "Modifier: RIGHT GUI", "usbhid.boot_report.keyboard.modifier.right_gui", FT_BOOLEAN, 8,
5778
15
                NULL, 0x80, NULL, HFILL }},
5779
5780
15
        { &hf_usbhid_boot_report_keyboard_modifier_right_alt,
5781
15
            { "Modifier: RIGHT ALT", "usbhid.boot_report.keyboard.modifier.right_alt", FT_BOOLEAN, 8,
5782
15
                NULL, 0x40, NULL, HFILL }},
5783
5784
15
        { &hf_usbhid_boot_report_keyboard_modifier_right_shift,
5785
15
            { "Modifier: RIGHT SHIFT", "usbhid.boot_report.keyboard.modifier.right_shift", FT_BOOLEAN, 8,
5786
15
                NULL, 0x20, NULL, HFILL }},
5787
5788
15
        { &hf_usbhid_boot_report_keyboard_modifier_right_ctrl,
5789
15
            { "Modifier: RIGHT CTRL", "usbhid.boot_report.keyboard.modifier.right_ctrl", FT_BOOLEAN, 8,
5790
15
                NULL, 0x10,NULL, HFILL }},
5791
5792
15
        { &hf_usbhid_boot_report_keyboard_modifier_left_gui,
5793
15
            { "Modifier: LEFT GUI", "usbhid.boot_report.keyboard.modifier.left_gui", FT_BOOLEAN, 8,
5794
15
                NULL, 0x08, NULL, HFILL }},
5795
5796
15
        { &hf_usbhid_boot_report_keyboard_modifier_left_alt,
5797
15
            { "Modifier: LEFT ALT", "usbhid.boot_report.keyboard.modifier.left_alt", FT_BOOLEAN, 8,
5798
15
                NULL, 0x04, NULL, HFILL }
5799
15
        },
5800
5801
15
        { &hf_usbhid_boot_report_keyboard_modifier_left_shift,
5802
15
            { "Modifier: LEFT SHIFT", "usbhid.boot_report.keyboard.modifier.left_shift", FT_BOOLEAN, 8,
5803
15
                NULL, 0x02, NULL, HFILL }},
5804
5805
15
        { &hf_usbhid_boot_report_keyboard_modifier_left_ctrl,
5806
15
            { "Modifier: LEFT CTRL", "usbhid.boot_report.keyboard.modifier.left_ctrl", FT_BOOLEAN, 8,
5807
15
                NULL, 0x01, NULL, HFILL }},
5808
5809
15
        { &hf_usbhid_boot_report_keyboard_leds_constants,
5810
15
            { "Constants", "usbhid.boot_report.keyboard.leds.constants", FT_UINT8, BASE_HEX,
5811
15
                NULL, 0xE0, NULL, HFILL }},
5812
5813
15
        { &hf_usbhid_boot_report_keyboard_leds_kana,
5814
15
            { "KANA", "usbhid.boot_report.keyboard.leds.kana", FT_BOOLEAN, 8,
5815
15
                NULL, 0x10, NULL, HFILL }},
5816
5817
15
        { &hf_usbhid_boot_report_keyboard_leds_compose,
5818
15
            { "COMPOSE", "usbhid.boot_report.keyboard.leds.compose", FT_BOOLEAN, 8,
5819
15
                NULL, 0x08, NULL, HFILL }},
5820
5821
15
        { &hf_usbhid_boot_report_keyboard_leds_scroll_lock,
5822
15
            { "SCROLL LOCK", "usbhid.boot_report.keyboard.leds.scroll_lock", FT_BOOLEAN, 8,
5823
15
                NULL, 0x04, NULL, HFILL }},
5824
5825
15
        { &hf_usbhid_boot_report_keyboard_leds_caps_lock,
5826
15
            { "CAPS LOCK", "usbhid.boot_report.keyboard.leds.caps_lock", FT_BOOLEAN, 8,
5827
15
                NULL, 0x02,NULL, HFILL }},
5828
5829
15
        { &hf_usbhid_boot_report_keyboard_leds_num_lock,
5830
15
            { "NUM LOCK",  "usbhid.boot_report.keyboard.leds.num_lock", FT_BOOLEAN, 8,
5831
15
                NULL, 0x01, NULL, HFILL }},
5832
5833
15
        { &hf_usbhid_boot_report_mouse_button_8,
5834
15
            { "Button 8",  "usbhid.boot_report.mouse.button.8", FT_BOOLEAN, 8,
5835
15
                NULL, 0x80, NULL, HFILL }},
5836
5837
15
        { &hf_usbhid_boot_report_mouse_button_7,
5838
15
            { "Button 7",  "usbhid.boot_report.mouse.button.7", FT_BOOLEAN, 8,
5839
15
                NULL, 0x40, NULL, HFILL }},
5840
5841
15
        { &hf_usbhid_boot_report_mouse_button_6,
5842
15
            { "Button 6",  "usbhid.boot_report.mouse.button.6", FT_BOOLEAN, 8,
5843
15
                NULL, 0x20, NULL, HFILL }},
5844
5845
15
        { &hf_usbhid_boot_report_mouse_button_5,
5846
15
            { "Button 5",  "usbhid.boot_report.mouse.button.5", FT_BOOLEAN, 8,
5847
15
                NULL, 0x10, NULL, HFILL }},
5848
5849
15
        { &hf_usbhid_boot_report_mouse_button_4,
5850
15
            { "Button 4",  "usbhid.boot_report.mouse.button.4", FT_BOOLEAN, 8,
5851
15
                NULL, 0x08, NULL, HFILL }},
5852
5853
15
        { &hf_usbhid_boot_report_mouse_button_middle,
5854
15
            { "Button Middle", "usbhid.boot_report.mouse.button.middle", FT_BOOLEAN, 8,
5855
15
                NULL, 0x04, NULL, HFILL }},
5856
5857
15
        { &hf_usbhid_boot_report_mouse_button_right,
5858
15
            { "Button Right",  "usbhid.boot_report.mouse.button.right", FT_BOOLEAN, 8,
5859
15
                NULL, 0x02, NULL, HFILL }},
5860
5861
15
        { &hf_usbhid_boot_report_mouse_button_left,
5862
15
            { "Button Left",   "usbhid.boot_report.mouse.button.left", FT_BOOLEAN, 8,
5863
15
                NULL, 0x01, NULL, HFILL }},
5864
5865
15
        { &hf_usbhid_boot_report_mouse_x_displacement,
5866
15
            { "X Displacement", "usbhid.boot_report.mouse.x_displacement", FT_INT8, BASE_DEC,
5867
15
                NULL, 0x00, NULL, HFILL }},
5868
5869
15
        { &hf_usbhid_boot_report_mouse_y_displacement,
5870
15
            { "Y Displacement", "usbhid.boot_report.mouse.y_displacement", FT_INT8, BASE_DEC,
5871
15
                NULL, 0x00, NULL, HFILL }},
5872
5873
15
        { &hf_usbhid_boot_report_mouse_horizontal_scroll_wheel,
5874
15
            { "Horizontal Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.horizontal", FT_INT8, BASE_DEC,
5875
15
                NULL, 0x00, NULL, HFILL }},
5876
5877
15
        { &hf_usbhid_boot_report_mouse_vertical_scroll_wheel,
5878
15
            { "Vertical Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.vertical", FT_INT8, BASE_DEC,
5879
15
                NULL, 0x00, NULL, HFILL }},
5880
5881
15
        { &hf_usbhid_data,
5882
15
            { "HID Data", "usbhid.data", FT_BYTES, BASE_NONE,
5883
15
                NULL, 0x00, NULL, HFILL }},
5884
5885
15
        { &hf_usbhid_unknown_data,
5886
15
            { "Unknown", "usbhid.data.unknown", FT_BYTES, BASE_NONE,
5887
15
                NULL, 0x00, NULL, HFILL }},
5888
5889
15
        { &hf_usbhid_vendor_data,
5890
15
            { "Vendor Data", "usbhid.data.vendor", FT_BYTES, BASE_NONE,
5891
15
                NULL, 0x00, NULL, HFILL }},
5892
5893
15
        { &hf_usbhid_report_id,
5894
15
            { "Report ID", "usbhid.data.report_id", FT_UINT8, BASE_HEX,
5895
15
                NULL, 0x00, NULL, HFILL }},
5896
5897
15
        { &hf_usbhid_padding,
5898
15
            { "Padding", "usbhid.data.padding", FT_BYTES, BASE_NONE,
5899
15
                NULL, 0x00, NULL, HFILL }},
5900
5901
15
        { &hf_usbhid_axis_x,
5902
15
            { "X Axis", "usbhid.data.axis.x", FT_INT32, BASE_DEC,
5903
15
                NULL, 0x00, NULL, HFILL }},
5904
5905
15
        { &hf_usbhid_axis_y,
5906
15
            { "Y Axis", "usbhid.data.axis.y", FT_INT32, BASE_DEC,
5907
15
                NULL, 0x00, NULL, HFILL }},
5908
5909
15
        { &hf_usbhid_axis_z,
5910
15
            { "Z Axis", "usbhid.data.axis.z", FT_INT32, BASE_DEC,
5911
15
                NULL, 0x00, NULL, HFILL }},
5912
5913
15
        { &hf_usbhid_axis_rx,
5914
15
            { "Rx Axis", "usbhid.data.axis.rx", FT_INT32, BASE_DEC,
5915
15
                NULL, 0x00, NULL, HFILL }},
5916
5917
15
        { &hf_usbhid_axis_ry,
5918
15
            { "Ry Axis", "usbhid.data.axis.ry", FT_INT32, BASE_DEC,
5919
15
                NULL, 0x00, NULL, HFILL }},
5920
5921
15
        { &hf_usbhid_axis_rz,
5922
15
            { "Rz Axis", "usbhid.data.axis.rz", FT_INT32, BASE_DEC,
5923
15
                NULL, 0x00, NULL, HFILL }},
5924
5925
15
        { &hf_usbhid_axis_slider,
5926
15
            { "Slider Axis", "usbhid.data.axis.slider", FT_INT32, BASE_DEC,
5927
15
                NULL, 0x00, NULL, HFILL }},
5928
5929
15
        { &hf_usbhid_axis_vx,
5930
15
            { "Vx Axis", "usbhid.data.axis.vx", FT_INT32, BASE_DEC,
5931
15
                NULL, 0x00, NULL, HFILL }},
5932
5933
15
        { &hf_usbhid_axis_vy,
5934
15
            { "Vy Axis", "usbhid.data.axis.vy", FT_INT32, BASE_DEC,
5935
15
                NULL, 0x00, NULL, HFILL }},
5936
5937
15
        { &hf_usbhid_axis_vz,
5938
15
            { "Vz Axis", "usbhid.data.axis.vz", FT_INT32, BASE_DEC,
5939
15
                NULL, 0x00, NULL, HFILL }},
5940
5941
15
        { &hf_usbhid_axis_vbrx,
5942
15
            { "Vbrx Axis", "usbhid.data.axis.vbrx", FT_INT32, BASE_DEC,
5943
15
                NULL, 0x00, NULL, HFILL }},
5944
5945
15
        { &hf_usbhid_axis_vbry,
5946
15
            { "Vbry Axis", "usbhid.data.axis.vbry", FT_INT32, BASE_DEC,
5947
15
                NULL, 0x00, NULL, HFILL }},
5948
5949
15
        { &hf_usbhid_axis_vbrz,
5950
15
            { "Vbrz Axis", "usbhid.data.axis.vbrz", FT_INT32, BASE_DEC,
5951
15
                NULL, 0x00, NULL, HFILL }},
5952
5953
15
        { &hf_usbhid_axis_vno,
5954
15
            { "Vno Axis", "usbhid.data.axis.vno", FT_INT32, BASE_DEC,
5955
15
                NULL, 0x00, NULL, HFILL }},
5956
5957
15
        { &hf_usbhid_button,
5958
15
            { "Button", "usbhid.data.button", FT_BOOLEAN, BASE_NONE,
5959
15
                NULL, 0x00, NULL, HFILL }},
5960
5961
15
        { &hf_usbhid_key,
5962
15
            { "Key", "usbhid.data.key.variable", FT_BOOLEAN, BASE_NONE,
5963
15
                NULL, 0x00, NULL, HFILL }},
5964
5965
15
        { &hf_usbhid_array,
5966
15
            { "Array", "usbhid.data.array", FT_BYTES, BASE_NONE,
5967
15
                NULL, 0x00, NULL, HFILL }},
5968
5969
15
        { &hf_usbhid_array_usage,
5970
15
            { "Usage", "usbhid.data.array.usage", FT_BOOLEAN, BASE_NONE,
5971
15
            NULL, 0x00, NULL, HFILL }},
5972
15
    };
5973
5974
15
    static int *usb_hid_ett[] = {
5975
15
        &ett_usb_hid_report,
5976
15
        &ett_usb_hid_item_header,
5977
15
        &ett_usb_hid_wValue,
5978
15
        &ett_usb_hid_descriptor,
5979
15
        &ett_usb_hid_data,
5980
15
        &ett_usb_hid_unknown_data,
5981
15
        &ett_usb_hid_array
5982
15
    };
5983
5984
15
    report_descriptors = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
5985
5986
15
    proto_usb_hid = proto_register_protocol("USB HID", "USBHID", "usbhid");
5987
15
    proto_register_field_array(proto_usb_hid, hf, array_length(hf));
5988
15
    proto_register_subtree_array(usb_hid_ett, array_length(usb_hid_ett));
5989
5990
    /*usb_hid_boot_keyboard_input_report_handle  =*/ register_dissector("usbhid.boot_report.keyboard.input",  dissect_usb_hid_boot_keyboard_input_report,  proto_usb_hid);
5991
15
    /*usb_hid_boot_keyboard_output_report_handle =*/ register_dissector("usbhid.boot_report.keyboard.output", dissect_usb_hid_boot_keyboard_output_report, proto_usb_hid);
5992
15
    /*usb_hid_boot_mouse_input_report_handle     =*/ register_dissector("usbhid.boot_report.mouse.input",     dissect_usb_hid_boot_mouse_input_report,     proto_usb_hid);
5993
15
    usb_hid_control_handle                         = register_dissector("usbhid.control", dissect_usb_hid_control, proto_usb_hid);
5994
15
    usb_hid_interrupt_handle                       = register_dissector("usbhid.data", dissect_usb_hid_data, proto_usb_hid);
5995
15
    usb_hid_descr_handle                           = register_dissector("usbhid.class_descriptors", dissect_usb_hid_class_descriptors, proto_usb_hid);
5996
15
}
5997
5998
void
5999
proto_reg_handoff_usb_hid(void)
6000
15
{
6001
15
    dissector_add_uint("usb.control", IF_CLASS_HID, usb_hid_control_handle);
6002
15
    dissector_add_for_decode_as("usb.device", usb_hid_control_handle);
6003
15
    dissector_add_uint("usb.interrupt", IF_CLASS_HID, usb_hid_interrupt_handle);
6004
15
    dissector_add_uint("usb.descriptor", IF_CLASS_HID, usb_hid_descr_handle);
6005
15
}
6006
6007
/*
6008
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
6009
 *
6010
 * Local variables:
6011
 * c-basic-offset: 4
6012
 * tab-width: 8
6013
 * indent-tabs-mode: nil
6014
 * End:
6015
 *
6016
 * vi: set shiftwidth=4 tabstop=8 expandtab:
6017
 * :indentSize=4:tabSize=8:noTabs=true:
6018
 */