Coverage Report

Created: 2026-01-02 06:13

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
77.4k
#define USBHID_SIZE_MASK  0x03
306
77.4k
#define USBHID_TYPE_MASK  0x0C
307
77.5k
#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
138k
#define USBHID_ITEMTYPE_MAIN    0
318
34.4k
#define USBHID_ITEMTYPE_GLOBAL  1
319
36.6k
#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
3.03k
#define USBHID_MAINITEM_TAG_INPUT           8
330
5.91k
#define USBHID_MAINITEM_TAG_OUTPUT          9
331
3.35k
#define USBHID_MAINITEM_TAG_FEATURE        11
332
31.7k
#define USBHID_MAINITEM_TAG_COLLECTION     10
333
28.9k
#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.86k
#define USBHID_GLOBALITEM_TAG_USAGE_PAGE    0
343
1.10k
#define USBHID_GLOBALITEM_TAG_LOG_MIN       1
344
2.11k
#define USBHID_GLOBALITEM_TAG_LOG_MAX       2
345
709
#define USBHID_GLOBALITEM_TAG_PHY_MIN       3
346
998
#define USBHID_GLOBALITEM_TAG_PHY_MAX       4
347
1.12k
#define USBHID_GLOBALITEM_TAG_UNIT_EXP      5
348
676
#define USBHID_GLOBALITEM_TAG_UNIT          6
349
1.21k
#define USBHID_GLOBALITEM_TAG_REPORT_SIZE   7
350
779
#define USBHID_GLOBALITEM_TAG_REPORT_ID     8
351
770
#define USBHID_GLOBALITEM_TAG_REPORT_COUNT  9
352
1.13k
#define USBHID_GLOBALITEM_TAG_PUSH         10
353
1.10k
#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
7.29k
#define USBHID_LOCALITEM_TAG_USAGE          0
374
717
#define USBHID_LOCALITEM_TAG_USAGE_MIN      1
375
1.44k
#define USBHID_LOCALITEM_TAG_USAGE_MAX      2
376
844
#define USBHID_LOCALITEM_TAG_DESIG_INDEX    3
377
1.61k
#define USBHID_LOCALITEM_TAG_DESIG_MIN      4
378
660
#define USBHID_LOCALITEM_TAG_DESIG_MAX      5
379
/* No 6 in spec */
380
772
#define USBHID_LOCALITEM_TAG_STRING_INDEX   7
381
942
#define USBHID_LOCALITEM_TAG_STRING_MIN     8
382
475
#define USBHID_LOCALITEM_TAG_STRING_MAX     9
383
995
#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
411
#define GENERIC_DESKTOP_CONTROLS_PAGE   0x01
441
293
#define SIMULATION_CONTROLS_PAGE        0x02
442
34
#define VR_CONTROLS_PAGE                0x03
443
115
#define SPORT_CONTROLS_PAGE             0x04
444
186
#define GAME_CONTROLS_PAGE              0x05
445
74
#define GENERIC_DEVICE_CONTROLS_PAGE    0x06
446
122
#define KEYBOARD_KEYPAD_PAGE            0x07
447
278
#define LED_PAGE                        0x08
448
540
#define BUTTON_PAGE                     0x09
449
336
#define ORDINAL_PAGE                    0x0A
450
380
#define TELEPHONY_PAGE                  0x0B
451
17
#define CONSUMER_PAGE                   0x0C
452
414
#define DIGITIZER_PAGE                  0x0D
453
58
#define HAPTICS_PAGE                    0x0E
454
74
#define PID_PAGE                        0x0F
455
84
#define UNICODE_PAGE                    0x10
456
27
#define SOC_PAGE                        0x11
457
12
#define EYE_AND_HEAD_TRACKER_PAGE       0x12
458
5
#define ALPHANUMERIC_DISPLAY_PAGE       0x14
459
82
#define SENSOR_PAGE                     0x20
460
89
#define MEDICAL_INSTRUMENTS_PAGE        0x40
461
179
#define BRAILLE_DISPLAY_PAGE            0x41
462
34
#define LIGHTING_AND_ILLUMINATION_PAGE  0x59
463
60
#define USB_MONITOR_PAGE                0x80
464
89
#define USB_ENUMERATED_VALUES_PAGE      0x81
465
20
#define VESA_VIRTUAL_CONTROLS_PAGE      0x82
466
61
#define POWER_DEVICE_PAGE               0x84
467
181
#define BATTERY_SYSTEM_PAGE             0x85
468
1
#define BARCODE_SCANNER_PAGE            0x8C
469
88
#define WEIGHING_PAGE                   0x8D
470
10
#define MSR_PAGE                        0x8E
471
#define RESERVED_POS_PAGE               0x8F
472
0
#define CAMERA_CONTROL_PAGE             0x90
473
101
#define ARCADE_PAGE                     0x91
474
#define GAMING_DEVICE_PAGE              0x92
475
0
#define FIDO_ALLIANCE_PAGE              0xF1D0
476
6.85k
#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
static bool
3733
parse_report_descriptor(report_descriptor_t *rdesc)
3734
0
{
3735
0
    hid_field_t field;
3736
0
    uint8_t *data = rdesc->desc_body;
3737
0
    unsigned int tag, type, size;
3738
0
    uint8_t prefix;
3739
0
    uint32_t defined = 0, usage_page = 0, usage = 0, usage_min = 0, usage_max = 0;
3740
0
    wmem_allocator_t *scope = wmem_file_scope();
3741
0
    bool first_item = true;
3742
3743
0
    memset(&field, 0, sizeof(field));
3744
0
    field.usages = wmem_array_new(scope, sizeof(uint32_t));
3745
0
    rdesc->fields_in = wmem_array_new(scope, sizeof(hid_field_t));
3746
0
    rdesc->fields_out = wmem_array_new(scope, sizeof(hid_field_t));
3747
3748
0
    int i = 0;
3749
0
    while (i < rdesc->desc_length)
3750
0
    {
3751
0
        prefix = data[i];
3752
0
        tag = (prefix & 0b11110000) >> 4;
3753
0
        type = (prefix & 0b00001100) >> 2;
3754
0
        size = prefix & 0b00000011;
3755
3756
0
        if (size == 3)  /* HID spec: 6.2.2.2 - Short Items */
3757
0
            size = 4;
3758
3759
0
        switch (type)
3760
0
        {
3761
0
            case USBHID_ITEMTYPE_MAIN:
3762
0
                switch (tag)
3763
0
                {
3764
0
                    case USBHID_MAINITEM_TAG_INPUT:
3765
0
                        field.properties = hid_unpack_value(data, i, size);
3766
3767
0
                        if ((defined & HID_REQUIRED_MASK) != HID_REQUIRED_MASK)
3768
0
                            goto err;
3769
3770
                        /* new field */
3771
0
                        wmem_array_append_one(rdesc->fields_in, field);
3772
3773
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3774
0
                        first_item = false;
3775
3776
                        /* only keep the global items */
3777
0
                        defined &= HID_GLOBAL_MASK;
3778
0
                        break;
3779
3780
0
                    case USBHID_MAINITEM_TAG_OUTPUT:
3781
0
                        field.properties = hid_unpack_value(data, i, size);
3782
3783
0
                        if ((defined & HID_REQUIRED_MASK) != HID_REQUIRED_MASK)
3784
0
                            goto err;
3785
3786
                        /* new field */
3787
0
                        wmem_array_append_one(rdesc->fields_out, field);
3788
3789
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3790
0
                        first_item = false;
3791
3792
0
                        defined &= HID_GLOBAL_MASK;
3793
0
                        break;
3794
3795
0
                    case USBHID_MAINITEM_TAG_FEATURE:
3796
                        /*
3797
                        field.properties = hid_unpack_value(data, i, size);
3798
                        TODO
3799
                        */
3800
0
                        break;
3801
3802
0
                    case USBHID_MAINITEM_TAG_COLLECTION:
3803
                        /* clear usages */
3804
0
                        wmem_free(scope, field.usages);
3805
0
                        field.usages = wmem_array_new(scope, sizeof(uint32_t));
3806
0
                        break;
3807
3808
0
                    default:
3809
0
                        break;
3810
0
                }
3811
0
                break;
3812
3813
0
            case USBHID_ITEMTYPE_GLOBAL:
3814
0
                switch (tag)
3815
0
                {
3816
0
                    case USBHID_GLOBALITEM_TAG_USAGE_PAGE:
3817
0
                        usage_page = hid_unpack_value(data, i, size);
3818
0
                        if (usage_page > UINT16_MAX)
3819
0
                            goto err;
3820
0
                        defined |= HID_USAGE_PAGE;
3821
0
                        break;
3822
3823
0
                    case USBHID_GLOBALITEM_TAG_LOG_MIN:
3824
0
                        if (hid_unpack_signed(data, i, size, &field.logical_min))
3825
0
                            goto err;
3826
0
                        defined |= HID_LOGICAL_MIN;
3827
0
                        break;
3828
3829
0
                    case USBHID_GLOBALITEM_TAG_LOG_MAX:
3830
0
                        if (hid_unpack_signed(data, i, size, &field.logical_max))
3831
0
                            goto err;
3832
0
                        defined |= HID_LOGICAL_MAX;
3833
0
                        break;
3834
3835
0
                    case USBHID_GLOBALITEM_TAG_REPORT_SIZE:
3836
0
                        field.report_size = hid_unpack_value(data, i, size);
3837
0
                        defined |= HID_REPORT_SIZE;
3838
0
                        break;
3839
3840
0
                    case USBHID_GLOBALITEM_TAG_REPORT_ID:
3841
0
                        if (!first_item && !rdesc->uses_report_id)
3842
0
                            goto err;
3843
3844
0
                        rdesc->uses_report_id = true;
3845
3846
0
                        field.report_id = hid_unpack_value(data, i, size);
3847
0
                        defined |= HID_REPORT_ID;
3848
0
                        break;
3849
3850
0
                    case USBHID_GLOBALITEM_TAG_REPORT_COUNT:
3851
0
                        field.report_count = hid_unpack_value(data, i, size);
3852
0
                        defined |= HID_REPORT_COUNT;
3853
0
                        break;
3854
3855
0
                    case USBHID_GLOBALITEM_TAG_PUSH:
3856
0
                    case USBHID_GLOBALITEM_TAG_POP:
3857
                        /* TODO */
3858
0
                        goto err;
3859
3860
0
                    default:
3861
0
                        break;
3862
0
                }
3863
0
                break;
3864
3865
0
            case USBHID_ITEMTYPE_LOCAL:
3866
0
                switch (tag)
3867
0
                {
3868
0
                    case USBHID_LOCALITEM_TAG_USAGE:
3869
0
                        usage = hid_unpack_value(data, i, size);
3870
3871
                        /* Extended usage (size 4) combines both usage page and id */
3872
0
                        if (size != 4) {
3873
0
                            if (!(defined & HID_USAGE_PAGE))
3874
0
                                goto err;
3875
0
                            usage |= usage_page << 16;
3876
0
                        }
3877
3878
0
                        wmem_array_append_one(field.usages, usage);
3879
0
                        break;
3880
3881
0
                    case USBHID_LOCALITEM_TAG_USAGE_MIN:
3882
0
                        usage_min = hid_unpack_value(data, i, size);
3883
0
                        if (size == 4) {
3884
                            /* Usage max must be extended as well */
3885
0
                            defined |= HID_EXTENDED_USAGE;
3886
0
                        } else {
3887
0
                            if (!(defined & HID_USAGE_PAGE))
3888
0
                                goto err;
3889
0
                            usage_min |= usage_page << 16;
3890
0
                        }
3891
0
                        defined |= HID_USAGE_MIN;
3892
0
                        break;
3893
3894
0
                    case USBHID_LOCALITEM_TAG_USAGE_MAX:
3895
0
                        if (!(defined & HID_USAGE_MIN))
3896
0
                            goto err;
3897
3898
0
                        usage_max = hid_unpack_value(data, i, size);
3899
0
                        if (defined & HID_EXTENDED_USAGE) {
3900
                            /* Fail if max is not extended usage (HID spec 6.2.2.8) */
3901
0
                            if (size != 4)
3902
0
                                goto err;
3903
0
                        } else if (size == 4) {
3904
                            /* Fail because min wasn't extended, but max is */
3905
0
                            goto err;
3906
0
                        } else {
3907
0
                            if (!(defined & HID_USAGE_PAGE))
3908
0
                                goto err;
3909
0
                            usage_max |= usage_page << 16;
3910
0
                        }
3911
3912
                        /* Usage min and max must be on the same page */
3913
0
                        if (USAGE_PAGE(usage_min) != USAGE_PAGE(usage_max)) {
3914
0
                            goto err;
3915
0
                        }
3916
3917
0
                        if (usage_min > usage_max) {
3918
0
                            goto err;
3919
0
                        }
3920
3921
                        /* min and max are inclusive */
3922
0
                        wmem_array_grow(field.usages, usage_max - usage_min + 1);
3923
0
                        for (uint32_t j = usage_min; j <= usage_max; j++) {
3924
0
                            wmem_array_append_one(field.usages, j);
3925
0
                        }
3926
3927
0
                        defined &= ~(HID_USAGE_MIN | HID_EXTENDED_USAGE);
3928
0
                        break;
3929
3930
0
                    default: /* TODO */
3931
0
                        goto err;
3932
0
                }
3933
0
                break;
3934
3935
0
            default: /* reserved */
3936
0
                goto err;
3937
0
        }
3938
3939
0
        i += size + 1;
3940
0
    }
3941
3942
0
    return true;
3943
3944
0
err:
3945
0
    for (unsigned int j = 0; j < wmem_array_get_count(rdesc->fields_in); j++)
3946
0
        wmem_free(scope, ((hid_field_t*) wmem_array_index(rdesc->fields_in, j))->usages);
3947
3948
0
    for (unsigned int j = 0; j < wmem_array_get_count(rdesc->fields_out); j++)
3949
0
        wmem_free(scope, ((hid_field_t*) wmem_array_index(rdesc->fields_out, j))->usages);
3950
3951
0
    wmem_free(scope, rdesc->fields_in);
3952
0
    wmem_free(scope, rdesc->fields_out);
3953
0
    return false;
3954
0
}
3955
3956
3957
static bool
3958
is_correct_interface(urb_info_t *urb, report_descriptor_t *report)
3959
0
{
3960
0
    return (urb->bus_id == report->bus_id) &&
3961
0
           (urb->device_address == report->device_address) &&
3962
0
           (urb->conv->interfaceNum == report->interface);
3963
0
}
3964
3965
/* Returns the report descriptor */
3966
static report_descriptor_t _U_ *
3967
get_report_descriptor(packet_info *pinfo _U_, urb_info_t *urb)
3968
0
{
3969
0
    uint32_t bus_id = urb->bus_id;
3970
0
    uint32_t device_address = urb->device_address;
3971
0
    uint32_t interface = urb->conv->interfaceNum;
3972
0
    wmem_tree_key_t key[] = {
3973
0
        {1, &bus_id},
3974
0
        {1, &device_address},
3975
0
        {1, &interface},
3976
0
        {1, &pinfo->num},
3977
0
        {0, NULL}
3978
0
    };
3979
3980
0
    report_descriptor_t *data = NULL;
3981
0
    data = (report_descriptor_t*) wmem_tree_lookup32_array_le(report_descriptors, key);
3982
0
    if (data && is_correct_interface(urb, data))
3983
0
        return data;
3984
3985
0
    return NULL;
3986
0
}
3987
3988
/* Inserts the report descriptor */
3989
static void
3990
insert_report_descriptor(packet_info *pinfo, report_descriptor_t *data)
3991
0
{
3992
0
    uint32_t bus_id = data->bus_id;
3993
0
    uint32_t device_address = data->device_address;
3994
0
    uint32_t interface = data->interface;
3995
0
    wmem_tree_key_t key[] = {
3996
0
        {1, &bus_id},
3997
0
        {1, &device_address},
3998
0
        {1, &interface},
3999
0
        {1, &pinfo->num},
4000
0
        {0, NULL}
4001
0
    };
4002
4003
0
    wmem_tree_insert32_array(report_descriptors, key, data);
4004
0
}
4005
4006
/* Returns usage page string */
4007
static const char*
4008
get_usage_page_string(uint32_t usage_page)
4009
3.85k
{
4010
3.85k
    const char *str;
4011
4012
3.85k
    str = try_val_to_str(usage_page, usb_hid_item_usage_page_vals);
4013
3.85k
    if (!str) {
4014
907
        if ((usage_page & VENDOR_PAGE_HBYTE) == VENDOR_PAGE_HBYTE)
4015
54
            str = "Vendor";
4016
853
        else
4017
853
            str = "Reserved";
4018
907
    }
4019
4020
3.85k
    return str;
4021
3.85k
}
4022
4023
/* Returns usage page item string */
4024
static char*
4025
get_usage_page_item_string(wmem_allocator_t *pool, uint32_t usage_page, uint32_t id)
4026
6.97k
{
4027
6.97k
    const char *str = NULL;
4028
6.97k
    const char *fmt_str = NULL;
4029
4030
6.97k
    switch (usage_page)
4031
6.97k
    {
4032
411
    case GENERIC_DESKTOP_CONTROLS_PAGE:
4033
411
        str = try_val_to_str(id, usb_hid_generic_desktop_controls_usage_page_vals);
4034
411
        break;
4035
293
    case SIMULATION_CONTROLS_PAGE:
4036
293
        str = try_val_to_str(id, usb_hid_simulation_control_usage_page_vals);
4037
293
        break;
4038
34
    case VR_CONTROLS_PAGE:
4039
34
        str = try_val_to_str(id, usb_hid_vr_controls_usage_page_vals);
4040
34
        break;
4041
115
    case SPORT_CONTROLS_PAGE:
4042
115
        str = try_val_to_str(id, usb_hid_sport_controls_usage_page_vals);
4043
115
        break;
4044
186
    case GAME_CONTROLS_PAGE:
4045
186
        str = try_val_to_str(id, usb_hid_game_controls_usage_page_vals);
4046
186
        break;
4047
74
    case GENERIC_DEVICE_CONTROLS_PAGE:
4048
74
        str = try_val_to_str(id, usb_hid_generic_device_controls_usage_page_vals);
4049
74
        break;
4050
122
    case KEYBOARD_KEYPAD_PAGE:
4051
122
        str = try_val_to_str(id, usb_hid_keyboard_keypad_usage_page_vals);
4052
122
        break;
4053
278
    case LED_PAGE:
4054
278
        str = try_val_to_str(id, usb_hid_led_usage_page_vals);
4055
278
        break;
4056
540
    case BUTTON_PAGE:
4057
540
        str = try_val_to_str(id, usb_hid_button_usage_page_vals);
4058
540
        if (!str)
4059
500
            fmt_str = "Button %u";
4060
540
        break;
4061
336
    case ORDINAL_PAGE:
4062
336
        str = try_val_to_str(id, usb_hid_ordinal_usage_page_vals);
4063
336
        break;
4064
380
    case TELEPHONY_PAGE:
4065
380
        str = try_val_to_str(id, usb_hid_telephony_device_usage_page_vals);
4066
380
        break;
4067
17
    case CONSUMER_PAGE:
4068
17
        str = try_val_to_str(id, usb_hid_consumer_usage_page_vals);
4069
17
        if (!str)
4070
9
            fmt_str = "Instance %u";
4071
17
        break;
4072
414
    case DIGITIZER_PAGE:
4073
414
        str = try_val_to_str(id, usb_hid_digitizers_usage_page_vals);
4074
414
        break;
4075
58
    case HAPTICS_PAGE:
4076
58
        str = try_val_to_str(id, usb_hid_haptic_usage_page_vals);
4077
58
        if (id >= 0x2001 && id <= 0x2FFF)
4078
0
            str = "Vendor Waveforms";
4079
58
        break;
4080
74
    case PID_PAGE:
4081
74
        str = try_val_to_str(id, usb_hid_physical_input_device_usage_page_vals);
4082
74
        break;
4083
84
    case UNICODE_PAGE:
4084
84
        fmt_str = "Character U+%04X";
4085
84
        break;
4086
27
    case SOC_PAGE:
4087
27
        str = try_val_to_str(id, usb_hid_soc_usage_page_vals);
4088
27
        break;
4089
12
    case EYE_AND_HEAD_TRACKER_PAGE:
4090
12
        str = try_val_to_str(id, usb_hid_eye_and_head_tracker_usage_page_vals);
4091
12
        break;
4092
5
    case ALPHANUMERIC_DISPLAY_PAGE:
4093
5
        str = try_val_to_str(id, usb_hid_alphanumeric_display_usage_page_vals);
4094
5
        break;
4095
82
    case SENSOR_PAGE:
4096
82
        str = try_val_to_str(id, usb_hid_sensor_usage_page_vals);
4097
82
        if (!str)
4098
73
            str = try_rval_to_str(id, usb_hid_sensor_usage_page_ranges);
4099
82
        break;
4100
89
    case MEDICAL_INSTRUMENTS_PAGE:
4101
89
        str = try_val_to_str(id, usb_hid_medical_instrument_usage_page_vals);
4102
89
        break;
4103
179
    case BRAILLE_DISPLAY_PAGE:
4104
179
        str = try_val_to_str(id, usb_hid_braille_display_usage_page_vals);
4105
179
        break;
4106
34
    case LIGHTING_AND_ILLUMINATION_PAGE:
4107
34
        str = try_val_to_str(id, usb_hid_lighting_and_illumination_usage_page_vals);
4108
34
        break;
4109
60
    case USB_MONITOR_PAGE:
4110
60
        str = try_val_to_str(id, usb_hid_monitor_usage_page_vals);
4111
60
        break;
4112
89
    case USB_ENUMERATED_VALUES_PAGE:
4113
89
        fmt_str = "ENUM_%u";
4114
89
        break;
4115
20
    case VESA_VIRTUAL_CONTROLS_PAGE:
4116
20
        str = try_val_to_str(id, usb_hid_vesa_virtual_control_usage_page_vals);
4117
20
        break;
4118
61
    case POWER_DEVICE_PAGE:
4119
61
        str = try_val_to_str(id, usb_hid_power_device_usage_page_vals);
4120
61
        break;
4121
181
    case BATTERY_SYSTEM_PAGE:
4122
181
        str = try_val_to_str(id, usb_hid_battery_system_usage_page_vals);
4123
181
        break;
4124
1
    case BARCODE_SCANNER_PAGE:
4125
1
        str = try_val_to_str(id, usb_hid_barcode_scanner_usage_page_vals);
4126
1
        break;
4127
88
    case WEIGHING_PAGE:
4128
88
        str = try_val_to_str(id, usb_hid_weighing_devices_usage_page_vals);
4129
88
        break;
4130
10
    case MSR_PAGE:
4131
10
        str = try_val_to_str(id, usb_hid_magnetic_stripe_reader_usage_page_vals);
4132
10
        break;
4133
0
    case CAMERA_CONTROL_PAGE:
4134
0
        str = try_val_to_str(id, usb_hid_camera_control_usage_page_vals);
4135
0
        break;
4136
101
    case ARCADE_PAGE:
4137
101
        str = try_val_to_str(id, usb_hid_arcade_usage_page_vals);
4138
101
        break;
4139
0
    case FIDO_ALLIANCE_PAGE:
4140
0
        str = try_val_to_str(id, usb_hid_fido_alliance_usage_page_vals);
4141
0
        break;
4142
2.52k
    default:
4143
2.52k
        if ((usage_page & VENDOR_PAGE_HBYTE) == VENDOR_PAGE_HBYTE)
4144
122
            str = "Vendor";
4145
2.52k
        break;
4146
6.97k
    }
4147
4148
6.97k
    if (fmt_str) {
4149
682
        return wmem_strdup_printf(pool, fmt_str, id);
4150
682
    }
4151
6.29k
    if (!str) {
4152
5.52k
        str = "Reserved";
4153
5.52k
    }
4154
6.29k
    return wmem_strdup_printf(pool, "%s", str);
4155
6.97k
}
4156
4157
/* Dissector for the data in a HID main report. */
4158
static int
4159
dissect_usb_hid_report_mainitem_data(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, unsigned int bSize, unsigned int bTag)
4160
30.4k
{
4161
30.4k
    proto_item *ti = proto_tree_get_parent(tree);
4162
30.4k
    uint32_t val = 0;
4163
4164
30.4k
    switch (bTag) {
4165
940
        case USBHID_MAINITEM_TAG_INPUT:
4166
1.73k
        case USBHID_MAINITEM_TAG_OUTPUT:
4167
2.09k
        case USBHID_MAINITEM_TAG_FEATURE:
4168
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit0, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4169
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit1, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4170
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit2, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4171
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit3, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4172
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit4, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4173
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit5, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4174
2.09k
            proto_tree_add_item(tree, hf_usb_hid_mainitem_bit6, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4175
2.09k
            if (bTag == USBHID_MAINITEM_TAG_INPUT)
4176
903
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit7_input, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4177
1.19k
            else
4178
1.19k
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit7, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4179
2.09k
            if (bSize > 1)
4180
856
                proto_tree_add_item(tree, hf_usb_hid_mainitem_bit8, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4181
1.23k
            else
4182
1.23k
                proto_tree_add_boolean_format_value(tree, hf_usb_hid_mainitem_bit8, tvb, offset, 0, false, "Buffered bytes (default, no second byte present)");
4183
4184
2.09k
            val = tvb_get_uint8(tvb, offset);
4185
2.09k
            if (val & (1 << 0))
4186
1.32k
                proto_item_append_text(ti, " (Const,");
4187
767
            else
4188
767
                proto_item_append_text(ti, " (Data,");
4189
2.09k
            if (val & (1 << 1))
4190
877
                proto_item_append_text(ti, "Var,");
4191
1.21k
            else
4192
1.21k
                proto_item_append_text(ti, "Array,");
4193
2.09k
            if (val & (1 << 2))
4194
336
                proto_item_append_text(ti, "Rel");
4195
1.75k
            else
4196
1.75k
                proto_item_append_text(ti, "Abs");
4197
2.09k
            if (val & (1 << 3))
4198
325
                proto_item_append_text(ti, ",Wrap");
4199
2.09k
            if (val & (1 << 4))
4200
1.04k
                proto_item_append_text(ti, ",NonLinear");
4201
2.09k
            if (val & (1 << 5))
4202
544
                proto_item_append_text(ti, ",NoPref");
4203
2.09k
            if (val & (1 << 6))
4204
264
                proto_item_append_text(ti, ",Null");
4205
2.09k
            if ((bTag == USBHID_MAINITEM_TAG_OUTPUT || bTag == USBHID_MAINITEM_TAG_FEATURE) && val & (1 << 7))
4206
904
                proto_item_append_text(ti, ",Volatile");
4207
2.09k
            if (val & (1 << 8))
4208
0
                proto_item_append_text(ti, ",BuffBytes");
4209
2.09k
            proto_item_append_text(ti, ")");
4210
2.09k
            break;
4211
1.47k
        case USBHID_MAINITEM_TAG_COLLECTION:
4212
1.47k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_mainitem_colltype, tvb, offset, 1, ENC_LITTLE_ENDIAN, &val);
4213
1.47k
            proto_item_append_text(ti, " (%s)", rval_to_str_const(val, usb_hid_mainitem_colltype_vals, "Unknown"));
4214
1.47k
            break;
4215
86
        case USBHID_MAINITEM_TAG_ENDCOLLECTION:
4216
            /* No item data */
4217
86
            break;
4218
26.7k
        default:
4219
26.7k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4220
26.7k
            proto_item_append_text(ti, " (Unknown)");
4221
26.7k
            break;
4222
30.4k
    }
4223
30.2k
    offset += bSize;
4224
30.2k
    return offset;
4225
30.4k
}
4226
4227
/* Dissector for the data in a HID main report. */
4228
static int
4229
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)
4230
17.2k
{
4231
17.2k
    const char *str = NULL;
4232
17.2k
    proto_item *ti = proto_tree_get_parent(tree);
4233
17.2k
    uint32_t val = 0;
4234
17.2k
    int32_t val_sig = 0;
4235
4236
17.2k
    switch (bTag) {
4237
3.86k
        case USBHID_GLOBALITEM_TAG_USAGE_PAGE:
4238
3.86k
            switch (bSize) {
4239
1.49k
                case 1: global->usage_page = tvb_get_uint8(tvb, offset); break;
4240
579
                case 2: global->usage_page = tvb_get_letohs(tvb, offset); break;
4241
0
                case 3: global->usage_page = tvb_get_letoh24(tvb, offset); break;
4242
327
                case 4: global->usage_page = tvb_get_letohl(tvb, offset); break;
4243
1.46k
                default: global->usage_page = 0; break;
4244
3.86k
            }
4245
3.85k
            str = get_usage_page_string(global->usage_page);
4246
3.85k
            proto_tree_add_uint_format(tree, hf_usb_hid_globalitem_usage, tvb, offset, bSize, global->usage_page, "Usage Page: %s (0x%02x)", str, global->usage_page);
4247
3.85k
            proto_item_append_text(ti, " (%s)", str);
4248
3.85k
            break;
4249
1.10k
        case USBHID_GLOBALITEM_TAG_LOG_MIN:
4250
1.10k
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_log_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4251
1.10k
            proto_item_append_text(ti, " (%d)", val_sig);
4252
1.10k
            break;
4253
2.11k
        case USBHID_GLOBALITEM_TAG_LOG_MAX:
4254
2.11k
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_log_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4255
2.11k
            proto_item_append_text(ti, " (%d)", val_sig);
4256
2.11k
            break;
4257
709
        case USBHID_GLOBALITEM_TAG_PHY_MIN:
4258
709
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_phy_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4259
709
            proto_item_append_text(ti, " (%d)", val_sig);
4260
709
            break;
4261
998
        case USBHID_GLOBALITEM_TAG_PHY_MAX:
4262
998
            proto_tree_add_item_ret_int(tree, hf_usb_hid_globalitem_phy_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val_sig);
4263
998
            proto_item_append_text(ti, " (%d)", val_sig);
4264
998
            break;
4265
1.12k
        case USBHID_GLOBALITEM_TAG_UNIT_EXP:
4266
1.12k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_unit_exp, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4267
1.12k
            if (val >= 7)
4268
535
                proto_item_append_text(ti, " (%u)", val);
4269
593
            else
4270
593
                proto_item_append_text(ti, " (%d)", -(16 - (int) val));
4271
1.12k
            break;
4272
676
        case USBHID_GLOBALITEM_TAG_UNIT:
4273
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_sys, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4274
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_len, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4275
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_mass, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4276
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_time, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4277
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_temp, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4278
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_current, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4279
676
            proto_tree_add_item(tree, hf_usb_hid_globalitem_unit_brightness, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4280
676
            proto_item_append_text(ti, " (0x%02x)", tvb_get_uint8(tvb, offset));
4281
676
            break;
4282
1.21k
        case USBHID_GLOBALITEM_TAG_REPORT_SIZE:
4283
1.21k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_size, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4284
1.21k
            proto_item_append_text(ti, " (%u)", val);
4285
1.21k
            break;
4286
779
        case USBHID_GLOBALITEM_TAG_REPORT_ID:
4287
779
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_id, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4288
779
            proto_item_append_text(ti, " (0x%02x)", val);
4289
779
            break;
4290
770
        case USBHID_GLOBALITEM_TAG_REPORT_COUNT:
4291
770
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_report_count, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4292
770
            proto_item_append_text(ti, " (%u)", val);
4293
770
            break;
4294
1.13k
        case USBHID_GLOBALITEM_TAG_PUSH:
4295
            // Push and Pop have no data, but the HID spec 6.2.2.7 doesn't prohibit it.
4296
1.13k
            if(bSize > 0) {
4297
396
                proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_push, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4298
396
                proto_item_append_text(ti, " (%u)", val);
4299
396
            }
4300
1.13k
            break;
4301
1.10k
        case USBHID_GLOBALITEM_TAG_POP:
4302
            // Push and Pop have no data, but the HID spec 6.2.2.7 doesn't prohibit it.
4303
1.10k
            if(bSize > 0) {
4304
453
                proto_tree_add_item_ret_uint(tree, hf_usb_hid_globalitem_pop, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4305
453
                proto_item_append_text(ti, " (%u)", val);
4306
453
            }
4307
1.10k
            break;
4308
1.62k
        default:
4309
1.62k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4310
1.62k
            proto_item_append_text(ti, " (Unknown)");
4311
1.62k
            break;
4312
17.2k
    }
4313
17.1k
    offset += bSize;
4314
17.1k
    return offset;
4315
17.2k
}
4316
4317
/* Dissector for the data in a HID main report. */
4318
static int
4319
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)
4320
18.3k
{
4321
18.3k
    uint32_t id = 0xffff;
4322
18.3k
    proto_item *ti = proto_tree_get_parent(tree);
4323
18.3k
    char *str = NULL;
4324
18.3k
    uint32_t val = 0;
4325
4326
18.3k
    switch (bTag) {
4327
7.29k
        case USBHID_LOCALITEM_TAG_USAGE:
4328
7.29k
            if (bSize > 2) {
4329
                /* Full page ID */
4330
311
                proto_tree_add_item(tree, hf_usb_hid_localitem_usage, tvb, offset, bSize, ENC_LITTLE_ENDIAN);
4331
6.98k
            } else {
4332
                /* Only lower few bits given, need to combine with last global ID */
4333
6.98k
                if (bSize == 1)
4334
1.78k
                    id = tvb_get_uint8(tvb, offset);
4335
5.20k
                else if (bSize == 2)
4336
894
                    id = tvb_get_ntohs(tvb, offset);
4337
6.98k
                str = get_usage_page_item_string(pinfo->pool, global->usage_page, id);
4338
6.98k
                proto_tree_add_uint_format(tree, hf_usb_hid_localitem_usage, tvb, offset, bSize, id, "Usage: %s (0x%02x)", str, id);
4339
6.98k
                proto_item_append_text(ti, " (%s)", str);
4340
6.98k
            }
4341
7.29k
            break;
4342
717
        case USBHID_LOCALITEM_TAG_USAGE_MIN:
4343
717
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_usage_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4344
717
            proto_item_append_text(ti, " (0x%02x)", val);
4345
717
            break;
4346
1.44k
        case USBHID_LOCALITEM_TAG_USAGE_MAX:
4347
1.44k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_usage_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4348
1.44k
            proto_item_append_text(ti, " (0x%02x)", val);
4349
1.44k
            break;
4350
844
        case USBHID_LOCALITEM_TAG_DESIG_INDEX:
4351
844
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_index, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4352
844
            proto_item_append_text(ti, " (0x%02x)", val);
4353
844
            break;
4354
1.61k
        case USBHID_LOCALITEM_TAG_DESIG_MIN:
4355
1.61k
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4356
1.61k
            proto_item_append_text(ti, " (0x%02x)", val);
4357
1.61k
            break;
4358
660
        case USBHID_LOCALITEM_TAG_DESIG_MAX:
4359
660
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_desig_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4360
660
            proto_item_append_text(ti, " (0x%02x)", val);
4361
660
            break;
4362
772
        case USBHID_LOCALITEM_TAG_STRING_INDEX:
4363
772
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_index, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4364
772
            proto_item_append_text(ti, " (0x%02x)", val);
4365
772
            break;
4366
942
        case USBHID_LOCALITEM_TAG_STRING_MIN:
4367
942
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_min, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4368
942
            proto_item_append_text(ti, " (0x%02x)", val);
4369
942
            break;
4370
475
        case USBHID_LOCALITEM_TAG_STRING_MAX:
4371
475
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_string_max, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4372
475
            proto_item_append_text(ti, " (0x%02x)", val);
4373
475
            break;
4374
995
        case USBHID_LOCALITEM_TAG_DELIMITER:
4375
995
            proto_tree_add_item_ret_uint(tree, hf_usb_hid_localitem_delimiter, tvb, offset, bSize, ENC_LITTLE_ENDIAN, &val);
4376
995
            proto_item_append_text(ti, " (0x%02x)", val);
4377
995
            break;
4378
2.58k
        default:
4379
2.58k
            proto_tree_add_item(tree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4380
2.58k
            proto_item_append_text(ti, " (Unknown)");
4381
2.58k
            break;
4382
18.3k
    }
4383
18.3k
    offset += bSize;
4384
4385
18.3k
    return offset;
4386
18.3k
}
4387
4388
/* Dissector for individual HID report items.  Recursive. */
4389
static int
4390
// NOLINTNEXTLINE(misc-no-recursion)
4391
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)
4392
2.08k
{
4393
2.08k
    proto_item *subitem;
4394
2.08k
    proto_tree *tree, *subtree;
4395
2.08k
    int old_offset;
4396
2.08k
    unsigned int tmp;
4397
2.08k
    unsigned int bSize, bType, bTag;
4398
2.08k
    const value_string *usb_hid_cur_bTag_vals;
4399
2.08k
    int hf_usb_hid_curitem_bTag;
4400
2.08k
    struct usb_hid_global_state cur_global;
4401
2.08k
    memcpy(&cur_global, global, sizeof(struct usb_hid_global_state));
4402
4403
79.1k
    while (tvb_reported_length_remaining(tvb, offset) > 0)
4404
77.4k
    {
4405
77.4k
        old_offset=offset;
4406
4407
77.4k
        tmp = tvb_get_uint8(tvb, offset);
4408
77.4k
        bSize = tmp & USBHID_SIZE_MASK;
4409
77.4k
        if (bSize == 3) bSize++; /* 3 == four bytes */
4410
77.4k
        bType = (tmp & USBHID_TYPE_MASK) >> 2;
4411
77.4k
        bTag = (tmp & USBHID_TAG_MASK) >> 4;
4412
4413
77.4k
        switch (bType) {
4414
30.4k
            case USBHID_ITEMTYPE_MAIN:
4415
30.4k
                hf_usb_hid_curitem_bTag = hf_usb_hid_mainitem_bTag;
4416
30.4k
                usb_hid_cur_bTag_vals = usb_hid_mainitem_bTag_vals;
4417
30.4k
                break;
4418
17.2k
            case USBHID_ITEMTYPE_GLOBAL:
4419
17.2k
                hf_usb_hid_curitem_bTag = hf_usb_hid_globalitem_bTag;
4420
17.2k
                usb_hid_cur_bTag_vals = usb_hid_globalitem_bTag_vals;
4421
17.2k
                break;
4422
18.3k
            case USBHID_ITEMTYPE_LOCAL:
4423
18.3k
                hf_usb_hid_curitem_bTag = hf_usb_hid_localitem_bTag;
4424
18.3k
                usb_hid_cur_bTag_vals = usb_hid_localitem_bTag_vals;
4425
18.3k
                break;
4426
11.4k
            default: /* Only USBHID_ITEMTYPE_LONG, but keep compiler happy */
4427
11.4k
                hf_usb_hid_curitem_bTag = hf_usb_hid_longitem_bTag;
4428
11.4k
                usb_hid_cur_bTag_vals = usb_hid_longitem_bTag_vals;
4429
11.4k
                break;
4430
77.4k
        }
4431
4432
77.4k
        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"));
4433
4434
77.4k
        tree = proto_tree_add_subtree(subtree, tvb, offset, 1, ett_usb_hid_item_header, NULL, "Header");
4435
77.4k
        proto_tree_add_item(tree, hf_usb_hid_item_bSize, tvb, offset,   1, ENC_LITTLE_ENDIAN);
4436
77.4k
        proto_tree_add_item(tree, hf_usb_hid_item_bType, tvb, offset,   1, ENC_LITTLE_ENDIAN);
4437
77.4k
        proto_tree_add_item(tree, hf_usb_hid_curitem_bTag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4438
77.4k
        offset++;
4439
77.4k
        if ((bType == 3) && (bTag == 16)) {
4440
            /* Long item */
4441
0
            bSize = tvb_get_uint8(tvb, offset);
4442
0
            proto_tree_add_item(subtree, hf_usb_hid_item_bDataSize, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4443
0
            offset++;
4444
0
            proto_tree_add_item(subtree, hf_usb_hid_item_bLongItemTag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4445
0
            offset++;
4446
0
            proto_tree_add_item(subtree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4447
0
            offset += bSize;
4448
77.4k
        } else {
4449
            /* Short item */
4450
77.4k
            switch (bType) {
4451
30.4k
                case USBHID_ITEMTYPE_MAIN:
4452
30.4k
                    offset = dissect_usb_hid_report_mainitem_data(pinfo, subtree, tvb, offset, bSize, bTag);
4453
30.4k
                    break;
4454
17.2k
                case USBHID_ITEMTYPE_GLOBAL:
4455
17.2k
                    offset = dissect_usb_hid_report_globalitem_data(pinfo, subtree, tvb, offset, bSize, bTag, &cur_global);
4456
17.2k
                    break;
4457
18.3k
                case USBHID_ITEMTYPE_LOCAL:
4458
18.3k
                    offset = dissect_usb_hid_report_localitem_data(pinfo, subtree, tvb, offset, bSize, bTag, &cur_global);
4459
18.3k
                    break;
4460
11.4k
                default: /* Only USBHID_ITEMTYPE_LONG, but keep compiler happy */
4461
11.4k
                    proto_tree_add_item(subtree, hf_usb_hid_item_unk_data, tvb, offset, bSize, ENC_NA);
4462
11.4k
                    offset += bSize;
4463
11.4k
                    break;
4464
77.4k
            }
4465
77.4k
        }
4466
4467
77.1k
        if (bType == USBHID_ITEMTYPE_MAIN) {
4468
30.2k
            if (bTag == USBHID_MAINITEM_TAG_COLLECTION) {
4469
                /* Begin collection, nest following elements under us */
4470
1.47k
                increment_dissection_depth(pinfo);
4471
1.47k
                offset = dissect_usb_hid_report_item(pinfo, subtree, tvb, offset, urb, &cur_global);
4472
1.47k
                decrement_dissection_depth(pinfo);
4473
1.47k
                proto_item_set_len(subitem, offset-old_offset);
4474
28.8k
            } else if (bTag == USBHID_MAINITEM_TAG_ENDCOLLECTION) {
4475
                /* End collection, break out to parent tree item */
4476
86
                break;
4477
86
            }
4478
30.2k
        }
4479
77.1k
    }
4480
1.74k
    return offset;
4481
2.08k
}
4482
4483
/* Dissector for HID "GET DESCRIPTOR" subtype. */
4484
int
4485
dissect_usb_hid_get_report_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, tvbuff_t *tvb, int offset, urb_info_t *urb)
4486
613
{
4487
613
    proto_item *item;
4488
613
    proto_tree *tree;
4489
613
    int old_offset=offset;
4490
613
    struct usb_hid_global_state initial_global;
4491
4492
613
    memset(&initial_global, 0, sizeof(struct usb_hid_global_state));
4493
4494
613
    item = proto_tree_add_protocol_format(parent_tree, proto_usb_hid, tvb, offset,
4495
613
                                          -1, "HID Report");
4496
613
    tree = proto_item_add_subtree(item, ett_usb_hid_report);
4497
613
    offset = dissect_usb_hid_report_item(pinfo, tree, tvb, offset, urb, &initial_global);
4498
4499
    /* only insert report descriptor the first time we parse it */
4500
613
    if (!PINFO_FD_VISITED(pinfo) && urb && urb->conv) {
4501
0
        wmem_allocator_t *scope = wmem_file_scope();
4502
0
        report_descriptor_t *data = wmem_new0(scope, report_descriptor_t);
4503
4504
0
        data->bus_id = urb->bus_id;
4505
0
        data->device_address = urb->device_address;
4506
0
        data->interface = urb->conv->interfaceNum;
4507
0
        data->desc_length = offset - old_offset;
4508
0
        data->desc_body = (uint8_t*) tvb_memdup(scope, tvb, old_offset, data->desc_length);
4509
4510
0
        if (parse_report_descriptor(data)) {
4511
0
            insert_report_descriptor(pinfo, data);
4512
0
        } else {
4513
0
            wmem_free(scope, data->desc_body);
4514
0
            wmem_free(scope, data);
4515
0
        }
4516
0
    }
4517
4518
613
    proto_item_set_len(item, offset-old_offset);
4519
4520
613
    return offset;
4521
613
}
4522
4523
/* Dissector for HID GET_REPORT request. See USBHID 1.11, Chapter 7.2.1 Get_Report Request */
4524
static void
4525
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_)
4526
0
{
4527
0
    proto_item *item;
4528
0
    proto_tree *subtree;
4529
4530
0
    if (!is_request)
4531
0
        return;
4532
4533
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4534
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4535
4536
    /* Report Type in the high byte, Report ID in the low byte */
4537
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4538
0
    offset++;
4539
0
    proto_tree_add_item(subtree, hf_usb_hid_report_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4540
0
    offset++;
4541
4542
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4543
0
    offset += 2;
4544
4545
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4546
    /*offset += 2;*/
4547
0
}
4548
4549
/* Dissector for HID SET_REPORT request. See USBHID 1.11, Chapter 7.2.2 Set_Report Request */
4550
static void
4551
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_)
4552
0
{
4553
0
    proto_item *item;
4554
0
    proto_tree *subtree;
4555
4556
0
    if (!is_request)
4557
0
        return;
4558
4559
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4560
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4561
4562
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4563
0
    offset++;
4564
0
    proto_tree_add_item(subtree, hf_usb_hid_report_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4565
0
    offset++;
4566
4567
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4568
0
    offset += 2;
4569
4570
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4571
    /*offset += 2;*/
4572
0
}
4573
4574
4575
/* Dissector for HID GET_IDLE request. See USBHID 1.11, Chapter 7.2.3 Get_Idle Request */
4576
static void
4577
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_)
4578
0
{
4579
0
    proto_item *item;
4580
0
    proto_tree *subtree;
4581
4582
0
    if (!is_request)
4583
0
        return;
4584
4585
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4586
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4587
4588
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4589
0
    offset++;
4590
0
    proto_tree_add_item(subtree, hf_usb_hid_zero, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4591
0
    offset++;
4592
4593
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4594
0
    offset += 2;
4595
4596
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4597
    /*offset += 2;*/
4598
0
}
4599
4600
/* Dissector for HID SET_IDLE request. See USBHID 1.11, Chapter 7.2.4 Set_Idle Request */
4601
static void
4602
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_)
4603
0
{
4604
0
    proto_item *item;
4605
0
    proto_tree *subtree;
4606
4607
0
    if (!is_request)
4608
0
        return;
4609
4610
0
    item = proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4611
0
    subtree = proto_item_add_subtree(item, ett_usb_hid_wValue);
4612
4613
    /* Duration in the high byte, Report ID in the low byte */
4614
0
    proto_tree_add_item(subtree, hf_usb_hid_report_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4615
0
    offset++;
4616
0
    proto_tree_add_item(subtree, hf_usb_hid_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4617
0
    offset++;
4618
4619
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4620
0
    offset += 2;
4621
4622
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4623
    /*offset += 2;*/
4624
0
}
4625
4626
/* Dissector for HID GET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.5 Get_Protocol Request */
4627
static void
4628
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_)
4629
0
{
4630
0
    if (!is_request)
4631
0
        return;
4632
4633
0
    proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4634
0
    offset += 2;
4635
4636
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4637
0
    offset += 2;
4638
4639
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4640
    /*offset += 2;*/
4641
0
}
4642
4643
/* Dissector for HID SET_PROTOCOL request. See USBHID 1.11, Chapter 7.2.6 Set_Protocol Request */
4644
static void
4645
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_)
4646
0
{
4647
0
    if (!is_request)
4648
0
        return;
4649
4650
0
    proto_tree_add_item(tree, hf_usb_hid_value, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4651
0
    offset += 2;
4652
4653
0
    proto_tree_add_item(tree, hf_usb_hid_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4654
0
    offset += 2;
4655
4656
0
    proto_tree_add_item(tree, hf_usb_hid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4657
    /*offset += 2;*/
4658
0
}
4659
4660
4661
typedef void (*usb_setup_dissector)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, bool is_request, urb_info_t *urb);
4662
4663
typedef struct _usb_setup_dissector_table_t {
4664
    uint8_t request;
4665
    usb_setup_dissector dissector;
4666
} usb_setup_dissector_table_t;
4667
4668
/* USBHID 1.11, Chapter 7.1 Standard Requests */
4669
#define USB_STD_SETUP_GET_DESCRIPTOR  0x06
4670
4671
4672
/* USBHID 1.11, Chapter 7.2 Class-Specific Requests */
4673
#define USB_HID_SETUP_GET_REPORT      0x01
4674
#define USB_HID_SETUP_GET_IDLE        0x02
4675
#define USB_HID_SETUP_GET_PROTOCOL    0x03
4676
/* 0x04..0x08: Reserved */
4677
#define USB_HID_SETUP_SET_REPORT      0x09
4678
#define USB_HID_SETUP_SET_IDLE        0x0A
4679
#define USB_HID_SETUP_SET_PROTOCOL    0x0B
4680
4681
static const usb_setup_dissector_table_t setup_dissectors[] = {
4682
    { USB_HID_SETUP_GET_REPORT,   dissect_usb_hid_get_report },
4683
    { USB_HID_SETUP_GET_IDLE,     dissect_usb_hid_get_idle },
4684
    { USB_HID_SETUP_GET_PROTOCOL, dissect_usb_hid_get_protocol },
4685
    { USB_HID_SETUP_SET_REPORT,   dissect_usb_hid_set_report },
4686
    { USB_HID_SETUP_SET_IDLE,     dissect_usb_hid_set_idle },
4687
    { USB_HID_SETUP_SET_PROTOCOL, dissect_usb_hid_set_protocol },
4688
    { 0, NULL }
4689
};
4690
4691
static const value_string setup_request_names_vals[] = {
4692
    { USB_STD_SETUP_GET_DESCRIPTOR, "GET_DESCRIPTOR" },
4693
    { USB_HID_SETUP_GET_REPORT,     "GET_REPORT" },
4694
    { USB_HID_SETUP_GET_IDLE,       "GET_IDLE" },
4695
    { USB_HID_SETUP_GET_PROTOCOL,   "GET_PROTOCOL" },
4696
    { USB_HID_SETUP_SET_REPORT,     "SET_REPORT" },
4697
    { USB_HID_SETUP_SET_IDLE,       "SET_IDLE" },
4698
    { USB_HID_SETUP_SET_PROTOCOL,   "SET_PROTOCOL" },
4699
    { 0, NULL }
4700
};
4701
4702
static const value_string usb_hid_report_type_vals[] = {
4703
    { 1, "Input" },
4704
    { 2, "Output" },
4705
    { 3, "Feature" },
4706
    { 0, NULL }
4707
};
4708
4709
static int
4710
dissect_usb_hid_boot_keyboard_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4711
5
{
4712
5
    int       offset = 0;
4713
5
    bool      shortcut_helper = false;
4714
5
    unsigned  modifier;
4715
5
    unsigned  keycode;
4716
4717
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
4718
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
4719
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
4720
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_right_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
4721
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_gui, tvb, offset, 1, ENC_BIG_ENDIAN);
4722
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_alt, tvb, offset, 1, ENC_BIG_ENDIAN);
4723
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_shift, tvb, offset, 1, ENC_BIG_ENDIAN);
4724
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_modifier_left_ctrl, tvb, offset, 1, ENC_BIG_ENDIAN);
4725
5
    modifier = tvb_get_uint8(tvb, offset);
4726
4727
5
    col_append_str(pinfo->cinfo, COL_INFO, " - ");
4728
5
    if (modifier & 0x80) {
4729
0
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT GUI");
4730
0
        shortcut_helper = true;
4731
0
    }
4732
5
    if (modifier & 0x40) {
4733
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4734
1
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT ALT");
4735
1
        shortcut_helper = true;
4736
1
    }
4737
5
    if (modifier & 0x20) {
4738
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4739
2
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT SHIFT");
4740
2
        shortcut_helper = true;
4741
2
    }
4742
5
    if (modifier & 0x10) {
4743
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4744
1
        col_append_str(pinfo->cinfo, COL_INFO, "RIGHT CTRL");
4745
1
        shortcut_helper = true;
4746
1
    }
4747
5
    if (modifier & 0x08) {
4748
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4749
1
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT GUI");
4750
1
        shortcut_helper = true;
4751
1
    }
4752
5
    if (modifier & 0x04) {
4753
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4754
2
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT ALT");
4755
2
        shortcut_helper = true;
4756
2
    }
4757
5
    if (modifier & 0x02) {
4758
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4759
1
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT SHIFT");
4760
1
        shortcut_helper = true;
4761
1
    }
4762
5
    if (modifier & 0x01) {
4763
0
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4764
0
        col_append_str(pinfo->cinfo, COL_INFO, "LEFT CTRL");
4765
0
        shortcut_helper = true;
4766
0
    }
4767
5
    offset += 1;
4768
4769
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
4770
5
    offset += 1;
4771
4772
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_1, tvb, offset, 1, ENC_BIG_ENDIAN);
4773
5
    keycode = tvb_get_uint8(tvb, offset);
4774
5
    offset += 1;
4775
4776
5
    if (keycode) {
4777
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4778
2
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4779
2
        shortcut_helper = true;
4780
2
    }
4781
4782
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_2, tvb, offset, 1, ENC_BIG_ENDIAN);
4783
5
    keycode = tvb_get_uint8(tvb, offset);
4784
5
    offset += 1;
4785
4786
5
    if (keycode) {
4787
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4788
2
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4789
2
        shortcut_helper = true;
4790
2
    }
4791
4792
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_3, tvb, offset, 1, ENC_BIG_ENDIAN);
4793
5
    keycode = tvb_get_uint8(tvb, offset);
4794
5
    offset += 1;
4795
4796
5
    if (keycode) {
4797
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4798
1
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4799
1
        shortcut_helper = true;
4800
1
    }
4801
4802
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_4, tvb, offset, 1, ENC_BIG_ENDIAN);
4803
5
    keycode = tvb_get_uint8(tvb, offset);
4804
5
    offset += 1;
4805
4806
5
    if (keycode) {
4807
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4808
1
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4809
1
        shortcut_helper = true;
4810
1
    }
4811
4812
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_5, tvb, offset, 1, ENC_BIG_ENDIAN);
4813
5
    keycode = tvb_get_uint8(tvb, offset);
4814
5
    offset += 1;
4815
4816
5
    if (keycode) {
4817
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4818
3
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4819
3
        shortcut_helper = true;
4820
3
    }
4821
4822
5
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_keycode_6, tvb, offset, 1, ENC_BIG_ENDIAN);
4823
5
    keycode = tvb_get_uint8(tvb, offset);
4824
5
    offset += 1;
4825
4826
5
    if (keycode) {
4827
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4828
3
        col_append_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(keycode, &keycode_vals_ext, "Unknown"));
4829
3
        shortcut_helper = true;
4830
3
    }
4831
4832
5
    if (shortcut_helper == false) {
4833
1
        col_append_str(pinfo->cinfo, COL_INFO, "<action key up>");
4834
1
    }
4835
4836
5
    return offset;
4837
5
}
4838
4839
static int
4840
dissect_usb_hid_boot_keyboard_output_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4841
6
{
4842
6
    int       offset = 0;
4843
6
    bool      shortcut_helper = false;
4844
6
    unsigned  leds;
4845
4846
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_constants, tvb, offset, 1, ENC_BIG_ENDIAN);
4847
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_kana, tvb, offset, 1, ENC_BIG_ENDIAN);
4848
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_compose, tvb, offset, 1, ENC_BIG_ENDIAN);
4849
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_scroll_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4850
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_caps_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4851
6
    proto_tree_add_item(tree, hf_usbhid_boot_report_keyboard_leds_num_lock, tvb, offset, 1, ENC_BIG_ENDIAN);
4852
6
    leds = tvb_get_uint8(tvb, offset);
4853
4854
6
    col_append_str(pinfo->cinfo, COL_INFO, " - LEDs: ");
4855
6
    if (leds & 0x01) {
4856
6
        col_append_str(pinfo->cinfo, COL_INFO, "NumLock");
4857
6
        shortcut_helper = true;
4858
6
    }
4859
6
    if (leds & 0x02) {
4860
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4861
4
        col_append_str(pinfo->cinfo, COL_INFO, "CapsLock");
4862
4
        shortcut_helper = true;
4863
4
    }
4864
6
    if (leds & 0x04) {
4865
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4866
4
        col_append_str(pinfo->cinfo, COL_INFO, "ScrollLock");
4867
4
        shortcut_helper = true;
4868
4
    }
4869
6
    if (leds & 0x08) {
4870
4
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4871
4
        col_append_str(pinfo->cinfo, COL_INFO, "Compose");
4872
4
        shortcut_helper = true;
4873
4
    }
4874
6
    if (leds & 0x10) {
4875
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4876
3
        col_append_str(pinfo->cinfo, COL_INFO, "Kana");
4877
3
        shortcut_helper = true;
4878
3
    }
4879
6
    if (leds & 0x20) {
4880
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4881
3
        col_append_str(pinfo->cinfo, COL_INFO, "Constant1");
4882
3
        shortcut_helper = true;
4883
3
    }
4884
6
    if (leds & 0x40) {
4885
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4886
1
        col_append_str(pinfo->cinfo, COL_INFO, "Constant2");
4887
1
        shortcut_helper = true;
4888
1
    }
4889
6
    if (leds & 0x80) {
4890
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, ", ");
4891
3
        col_append_str(pinfo->cinfo, COL_INFO, "Constant3");
4892
        /*shortcut_helper = true;*/
4893
3
    }
4894
6
    if (!leds) {
4895
0
        col_append_str(pinfo->cinfo, COL_INFO, "none");
4896
0
    }
4897
4898
6
    offset += 1;
4899
4900
6
    return offset;
4901
6
}
4902
4903
static int
4904
dissect_usb_hid_boot_mouse_input_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4905
3
{
4906
3
    int       offset = 0;
4907
3
    bool      shortcut_helper = false;
4908
3
    unsigned  buttons;
4909
4910
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_8, tvb, offset, 1, ENC_BIG_ENDIAN);
4911
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_7, tvb, offset, 1, ENC_BIG_ENDIAN);
4912
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_6, tvb, offset, 1, ENC_BIG_ENDIAN);
4913
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_5, tvb, offset, 1, ENC_BIG_ENDIAN);
4914
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_4, tvb, offset, 1, ENC_BIG_ENDIAN);
4915
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_middle, tvb, offset, 1, ENC_BIG_ENDIAN);
4916
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_right, tvb, offset, 1, ENC_BIG_ENDIAN);
4917
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_button_left, tvb, offset, 1, ENC_BIG_ENDIAN);
4918
3
    buttons = tvb_get_uint8(tvb, offset);
4919
3
    offset += 1;
4920
4921
3
    if (buttons) col_append_str(pinfo->cinfo, COL_INFO, " - ");
4922
3
    if (buttons & 0x01) {
4923
1
        col_append_str(pinfo->cinfo, COL_INFO, "Button LEFT");
4924
1
        shortcut_helper = true;
4925
1
    }
4926
3
    if (buttons & 0x02) {
4927
3
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4928
3
        col_append_str(pinfo->cinfo, COL_INFO, "Button RIGHT");
4929
3
        shortcut_helper = true;
4930
3
    }
4931
3
    if (buttons & 0x04) {
4932
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4933
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button MIDDLE");
4934
2
    }
4935
3
    if (buttons & 0x08) {
4936
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4937
1
        col_append_str(pinfo->cinfo, COL_INFO, "Button 4");
4938
1
        shortcut_helper = true;
4939
1
    }
4940
3
    if (buttons & 0x10) {
4941
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4942
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 5");
4943
2
        shortcut_helper = true;
4944
2
    }
4945
3
    if (buttons & 0x20) {
4946
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4947
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 6");
4948
2
        shortcut_helper = true;
4949
2
    }
4950
3
    if (buttons & 0x40) {
4951
2
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4952
2
        col_append_str(pinfo->cinfo, COL_INFO, "Button 7");
4953
2
        shortcut_helper = true;
4954
2
    }
4955
3
    if (buttons & 0x80) {
4956
1
        if (shortcut_helper) col_append_str(pinfo->cinfo, COL_INFO, " + ");
4957
1
        col_append_str(pinfo->cinfo, COL_INFO, "Button 8");
4958
        /* Not necessary, this is the last case where it is used
4959
         * shortcut_helper = true;
4960
         */
4961
1
    }
4962
4963
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_x_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4964
3
    offset += 1;
4965
4966
3
    proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_y_displacement, tvb, offset, 1, ENC_LITTLE_ENDIAN);
4967
3
    offset += 1;
4968
4969
    /* not really in HID Specification */
4970
3
    if (tvb_reported_length_remaining(tvb, offset)) {
4971
3
        proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_horizontal_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
4972
3
        offset += 1;
4973
3
    }
4974
4975
    /* not really in HID Specification */
4976
3
    if (tvb_reported_length_remaining(tvb, offset)) {
4977
3
        proto_tree_add_item(tree, hf_usbhid_boot_report_mouse_vertical_scroll_wheel, tvb, offset, 1, ENC_BIG_ENDIAN);
4978
3
        offset += 1;
4979
3
    }
4980
4981
3
    if (tvb_reported_length_remaining(tvb, offset)) {
4982
3
        proto_tree_add_item(tree, hf_usbhid_data, tvb, offset, -1, ENC_NA);
4983
3
        offset += tvb_captured_length_remaining(tvb, offset);
4984
3
    }
4985
4986
3
    return offset;
4987
3
}
4988
4989
4990
/* dissect a "standard" control message that's sent to an interface */
4991
static int
4992
dissect_usb_hid_control_std_intf(tvbuff_t *tvb, packet_info *pinfo,
4993
        proto_tree *tree, urb_info_t *urb)
4994
0
{
4995
0
    int               offset = 0;
4996
0
    usb_trans_info_t *usb_trans_info;
4997
0
    uint8_t           req;
4998
4999
0
    usb_trans_info = urb->usb_trans_info;
5000
5001
    /* XXX - can we do some plausibility checks here? */
5002
5003
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBHID");
5004
5005
    /* we can't use urb->is_request since urb
5006
       was replaced with the interface conversation */
5007
0
    if (usb_trans_info->request_in == pinfo->num) {
5008
        /* the tvb that we see here is the setup packet
5009
           without the request type byte */
5010
5011
0
        req = tvb_get_uint8(tvb, offset);
5012
0
        if (req != USB_SETUP_GET_DESCRIPTOR)
5013
0
            return offset;
5014
0
        proto_tree_add_item(tree, hf_usb_hid_request, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5015
0
        col_clear(pinfo->cinfo, COL_INFO);
5016
0
        col_append_str(pinfo->cinfo, COL_INFO, "GET DESCRIPTOR Request");
5017
0
        offset += 1;
5018
5019
0
        proto_tree_add_item(tree, hf_usb_hid_bDescriptorIndex, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5020
0
        usb_trans_info->u.get_descriptor.usb_index = tvb_get_uint8(tvb, offset);
5021
0
        offset += 1;
5022
5023
0
        proto_tree_add_item(tree, hf_usb_hid_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5024
0
        usb_trans_info->u.get_descriptor.type = tvb_get_uint8(tvb, offset);
5025
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
5026
0
                val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type,
5027
0
                    &hid_descriptor_type_vals_ext, "Unknown type %u"));
5028
0
        offset += 1;
5029
5030
0
        proto_tree_add_item(tree, hf_usb_hid_wInterfaceNumber, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5031
0
        offset += 2;
5032
5033
0
        proto_tree_add_item(tree, hf_usb_hid_wDescriptorLength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5034
0
        offset += 2;
5035
0
    }
5036
0
    else {
5037
0
        col_clear(pinfo->cinfo, COL_INFO);
5038
0
        col_append_str(pinfo->cinfo, COL_INFO, "GET DESCRIPTOR Response");
5039
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
5040
0
                val_to_str_ext(pinfo->pool, usb_trans_info->u.get_descriptor.type,
5041
0
                    &hid_descriptor_type_vals_ext, "Unknown type %u"));
5042
0
        if (usb_trans_info->u.get_descriptor.type == USB_DT_HID_REPORT)
5043
0
            offset = dissect_usb_hid_get_report_descriptor(pinfo, tree, tvb, offset, urb);
5044
0
    }
5045
5046
0
    return offset;
5047
0
}
5048
5049
/* dissect a class-specific control message that's sent to an interface */
5050
static int
5051
dissect_usb_hid_control_class_intf(tvbuff_t *tvb, packet_info *pinfo,
5052
        proto_tree *tree, urb_info_t *urb)
5053
0
{
5054
0
    usb_trans_info_t *usb_trans_info;
5055
0
    bool is_request;
5056
0
    int offset = 0;
5057
0
    usb_setup_dissector dissector = NULL;
5058
0
    const usb_setup_dissector_table_t *tmp;
5059
5060
0
    usb_trans_info = urb->usb_trans_info;
5061
5062
0
    is_request = (pinfo->srcport==NO_ENDPOINT);
5063
5064
    /* Check valid values for bmRequestType. See Chapter 7.2 in USBHID 1.11 */
5065
0
    for (tmp = setup_dissectors; tmp->dissector; tmp++) {
5066
0
        if (tmp->request == usb_trans_info->setup.request) {
5067
0
            dissector = tmp->dissector;
5068
0
            break;
5069
0
        }
5070
0
    }
5071
    /* No, we could not find any class specific dissector for this request
5072
     * return 0 and let USB try any of the standard requests.
5073
     */
5074
0
    if (!dissector)
5075
0
        return 0;
5076
5077
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBHID");
5078
5079
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
5080
0
                 val_to_str(pinfo->pool, usb_trans_info->setup.request, setup_request_names_vals, "Unknown type %x"),
5081
0
                 is_request ? "Request" : "Response");
5082
5083
0
    if (is_request) {
5084
0
        proto_tree_add_item(tree, hf_usb_hid_request, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5085
0
        offset += 1;
5086
0
    }
5087
5088
0
    dissector(pinfo, tree, tvb, offset, is_request, urb);
5089
0
    return tvb_captured_length(tvb);
5090
0
}
5091
5092
/* unpack a HID logical report field */
5093
static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, uint32_t size, int32_t min, int32_t *val)
5094
0
{
5095
0
    if (size > 32)
5096
0
        return -1;
5097
5098
0
    *val = tvb_get_bits32(tvb, bit_offset, size, ENC_LITTLE_ENDIAN);
5099
5100
0
    if (min < 0)
5101
0
        *val = ws_sign_ext32(*val, size);
5102
5103
0
    return 0;
5104
0
}
5105
5106
static int
5107
dissect_usb_hid_int_dynamic_value_variable(tvbuff_t *tvb, proto_tree *tree, hid_field_t *field,
5108
        int bit_offset, int hf)
5109
0
{
5110
0
    int32_t val = 0;
5111
5112
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5113
0
        return -1;
5114
5115
0
    proto_tree_add_int_bits_format_value(tree, hf, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN, "%d", val);
5116
0
    return 0;
5117
0
}
5118
5119
/* dissect the Generic Desktop Controls (0x0001) usage page */
5120
static int
5121
dissect_usb_hid_generic_desktop_controls_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5122
        proto_tree *tree, hid_field_t *field, unsigned usage, int bit_offset)
5123
0
{
5124
0
    int ret = 0;
5125
5126
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == GENERIC_DESKTOP_CONTROLS_PAGE);
5127
0
    usage = USAGE_ID(usage);
5128
0
    switch (usage)
5129
0
    {
5130
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_X:
5131
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_x);
5132
0
            break;
5133
5134
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_Y:
5135
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_y);
5136
0
            break;
5137
5138
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_Z:
5139
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_z);
5140
0
            break;
5141
5142
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RX:
5143
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_rx);
5144
0
            break;
5145
5146
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RY:
5147
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_ry);
5148
0
            break;
5149
5150
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_RZ:
5151
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_rz);
5152
0
            break;
5153
5154
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_SLIDER:
5155
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_slider);
5156
0
            break;
5157
5158
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VX:
5159
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vx);
5160
0
            break;
5161
5162
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VY:
5163
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vy);
5164
0
            break;
5165
5166
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VZ:
5167
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vz);
5168
0
            break;
5169
5170
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRX:
5171
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbrx);
5172
0
            break;
5173
5174
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRY:
5175
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbry);
5176
0
            break;
5177
5178
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VBRZ:
5179
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vbrz);
5180
0
            break;
5181
5182
0
        case USBHID_GENERIC_DESKTOP_CONTROLS_VNO:
5183
0
            ret = dissect_usb_hid_int_dynamic_value_variable(tvb, tree, field, bit_offset, hf_usbhid_axis_vno);
5184
0
            break;
5185
5186
0
        default:
5187
0
            ret = -1;
5188
0
            break;
5189
0
    }
5190
5191
0
    return ret;
5192
0
}
5193
5194
/* dissect the Keyboard/Keypad (0x0007) usage page */
5195
static int
5196
dissect_usb_hid_keyboard_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5197
        proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset)
5198
0
{
5199
0
    int32_t val = 0;
5200
5201
    /* the data is a boolean state for the usage (eg. KEY_SHIFT = 1, KEY_CONTROL = 0) */
5202
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5203
0
        return -1;
5204
5205
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == KEYBOARD_KEYPAD_PAGE);
5206
0
    usage = USAGE_ID(usage);
5207
5208
0
    proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_key, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN,
5209
0
        "%s (0x%02x): %s", val_to_str_ext_const(usage, &keycode_vals_ext, "Unknown"), usage, val ? "DOWN" : "UP");
5210
0
    return 0;
5211
0
}
5212
5213
/* dissect the Button (0x0009) usage page */
5214
static int
5215
dissect_usb_hid_button_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
5216
        proto_tree *tree, hid_field_t *field, uint32_t usage, int bit_offset)
5217
0
{
5218
0
    int32_t val = 0;
5219
0
    proto_item *ti;
5220
5221
0
    DISSECTOR_ASSERT(USAGE_PAGE(usage) == BUTTON_PAGE);
5222
0
    usage = USAGE_ID(usage);
5223
5224
0
    if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
5225
0
        return -1;
5226
5227
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);
5228
5229
0
    if (usage == 0)
5230
0
        proto_item_append_text(ti, " (No button pressed)");
5231
0
    else if (usage == 1)
5232
0
        proto_item_append_text(ti, " (primary/trigger)");
5233
0
    else if (usage == 2)
5234
0
        proto_item_append_text(ti, " (secondary)");
5235
0
    else if (usage == 3)
5236
0
        proto_item_append_text(ti, " (tertiary)");
5237
5238
0
    proto_item_append_text(ti, ": %s", val ? "DOWN" : "UP");
5239
0
    return 0;
5240
0
}
5241
5242
static void
5243
dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hid_field_t* field,
5244
                     uint32_t usage, int bit_offset)
5245
0
{
5246
0
    int ret = 0;
5247
5248
    /* vendor data (0xff00 - 0xffff) */
5249
0
    if ((USAGE_PAGE(usage) & 0xff00) == 0xff00) {
5250
0
        proto_tree_add_bits_item(tree, hf_usbhid_vendor_data, tvb, bit_offset, field->report_size, ENC_NA);
5251
0
        return;
5252
0
    }
5253
5254
0
    switch (USAGE_PAGE(usage))
5255
0
    {
5256
0
    case GENERIC_DESKTOP_CONTROLS_PAGE:
5257
0
        ret = dissect_usb_hid_generic_desktop_controls_page(tvb, pinfo, tree, field, usage, bit_offset);
5258
0
        break;
5259
5260
0
    case KEYBOARD_KEYPAD_PAGE:
5261
0
        ret = dissect_usb_hid_keyboard_page(tvb, pinfo, tree, field, usage, bit_offset);
5262
0
        break;
5263
5264
0
    case BUTTON_PAGE:
5265
0
        ret = dissect_usb_hid_button_page(tvb, pinfo, tree, field, usage, bit_offset);
5266
0
        break;
5267
5268
0
    default:
5269
0
        ret = -1;
5270
0
        break;
5271
0
    }
5272
5273
0
    if (ret) {
5274
0
        uint32_t val = 0;
5275
0
        proto_item *ti =
5276
0
            proto_tree_add_uint_bits_format_value(tree, hf_usb_hid_localitem_usage, tvb, bit_offset, field->report_size,
5277
0
                                                  usage, ENC_LITTLE_ENDIAN, "%s", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(usage), USAGE_ID(usage)));
5278
0
        if (0 == hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, (int32_t*)&val))
5279
0
            proto_item_append_text(ti, ": %d", val);
5280
0
    }
5281
0
}
5282
5283
static bool hid_get_usage_from_array(hid_field_t *field, int32_t idx, uint32_t *out)
5284
0
{
5285
0
    if ((idx >= field->logical_min) && (idx <= field->logical_max)) {
5286
0
        idx -= field->logical_min;
5287
0
        if ((uint32_t)idx < wmem_array_get_count(field->usages)) {
5288
0
            *out = (*((uint32_t*) wmem_array_index(field->usages, idx)));
5289
0
            return true;
5290
0
        }
5291
0
    }
5292
0
    return false;
5293
0
}
5294
5295
static int
5296
dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_field_t *field, int bit_offset)
5297
0
{
5298
0
    int start_offset = bit_offset;
5299
5300
0
    if ((field->properties & HID_MAIN_TYPE) == HID_MAIN_ARRAY) {
5301
0
        proto_item *array_ti;
5302
0
        proto_tree *array_tree;
5303
5304
0
        array_ti = proto_tree_add_bits_item(tree, hf_usbhid_array, tvb, bit_offset,
5305
0
            field->report_size * field->report_count, ENC_NA);
5306
0
        array_tree = proto_item_add_subtree(array_ti, ett_usb_hid_array);
5307
5308
0
        for(unsigned int j = 0; j < field->report_count; j++) {
5309
0
            uint32_t val = 0;
5310
0
            bool in_range;
5311
0
            if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, (int32_t*)&val)) {
5312
0
                in_range = false;
5313
0
            } else {
5314
0
                in_range = hid_get_usage_from_array(field, val, &val);
5315
0
            }
5316
0
            if (in_range) {
5317
0
                proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
5318
0
                    val, ENC_LITTLE_ENDIAN, "%s (0x%04x, 0x%04x)", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(val), USAGE_ID(val)),
5319
0
                    USAGE_PAGE(val), USAGE_ID(val));
5320
0
            } else {
5321
0
                proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
5322
0
                    val, ENC_LITTLE_ENDIAN, "No controls asserted");
5323
0
            }
5324
0
            bit_offset += field->report_size;
5325
0
        }
5326
0
    } else {
5327
0
        unsigned int i;
5328
0
        unsigned int count = wmem_array_get_count(field->usages);
5329
0
        if (count > field->report_count) {
5330
0
            count = field->report_count;
5331
0
        }
5332
0
        for(i = 0; i < count; i++) {
5333
0
            uint32_t usage = *((uint32_t*) wmem_array_index(field->usages, i));
5334
0
            dissect_hid_variable(tvb, pinfo, tree, field, usage, bit_offset);
5335
0
            bit_offset += field->report_size;
5336
0
        }
5337
0
        if (field->report_count > count) {
5338
0
            int remaining_bits = (field->report_count - count) * field->report_size;
5339
0
            proto_tree_add_bits_item(tree, hf_usbhid_padding, tvb, bit_offset, remaining_bits, ENC_NA);
5340
0
            bit_offset += remaining_bits;
5341
0
        }
5342
0
    }
5343
5344
0
    return bit_offset - start_offset;
5345
0
}
5346
5347
/* Dissect USB HID data/reports */
5348
static int
5349
dissect_usb_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
5350
0
{
5351
0
    unsigned offset = 0, hid_bit_offset;
5352
0
    proto_item *hid_ti;
5353
0
    proto_tree *hid_tree;
5354
0
    wmem_array_t *fields;
5355
0
    urb_info_t *usb_data = (urb_info_t*) data;
5356
0
    report_descriptor_t *rdesc = get_report_descriptor(pinfo, usb_data);
5357
0
    unsigned remaining = tvb_reported_length_remaining(tvb, offset);
5358
5359
0
    if (remaining) {
5360
0
        hid_ti = proto_tree_add_item(tree, hf_usbhid_data, tvb, offset, -1, ENC_NA);
5361
0
        hid_tree = proto_item_add_subtree(hid_ti, ett_usb_hid_data);
5362
0
        hid_bit_offset = offset * 8;
5363
0
        offset += remaining;
5364
0
        uint8_t report_id = tvb_get_bits8(tvb, hid_bit_offset, 8);
5365
5366
0
        if (rdesc) {
5367
0
            if (rdesc->uses_report_id) {
5368
0
                proto_tree_add_item(hid_tree, hf_usbhid_report_id, tvb, hid_bit_offset / 8, 1, ENC_NA);
5369
0
                hid_bit_offset += 8;
5370
0
            }
5371
5372
0
            if (usb_data->direction == P2P_DIR_RECV)
5373
0
                fields = rdesc->fields_in;
5374
0
            else
5375
0
                fields = rdesc->fields_out;
5376
5377
0
            for(unsigned int i = 0; i < wmem_array_get_count(fields); i++) {
5378
0
                hid_field_t *field = (hid_field_t*) wmem_array_index(fields, i);
5379
0
                unsigned int data_size = field->report_size * field->report_count;
5380
5381
                /* skip items with invalid report IDs */
5382
0
                if (rdesc->uses_report_id && field->report_id != report_id)
5383
0
                    continue;
5384
5385
                /* if the item has no usages, it is padding - HID spec 6.2.2.9 */
5386
0
                if (wmem_array_get_count(field->usages) == 0) {
5387
0
                    proto_tree_add_bits_item(hid_tree, hf_usbhid_padding, tvb, hid_bit_offset, data_size, ENC_NA);
5388
0
                    hid_bit_offset += data_size;
5389
0
                    continue;
5390
0
                }
5391
5392
0
                hid_bit_offset += dissect_hid_field(tvb, pinfo, hid_tree, field, hid_bit_offset);
5393
0
            }
5394
0
        }
5395
0
    }
5396
5397
0
    return offset;
5398
0
}
5399
5400
/* Dissector for HID class-specific control request as defined in
5401
 * USBHID 1.11, Chapter 7.2.
5402
 * returns the number of bytes consumed */
5403
static int
5404
dissect_usb_hid_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
5405
0
{
5406
0
    urb_info_t *urb;
5407
0
    usb_trans_info_t *usb_trans_info;
5408
0
    uint8_t type, recip;
5409
5410
0
    urb = (urb_info_t *)data;
5411
0
    if (!urb)
5412
0
        return 0;
5413
0
    usb_trans_info = urb->usb_trans_info;
5414
0
    if (!usb_trans_info)
5415
0
        return 0;
5416
5417
0
    type = USB_TYPE(usb_trans_info->setup.requesttype);
5418
0
    recip = USB_RECIPIENT(usb_trans_info->setup.requesttype);
5419
5420
0
    if (recip == RQT_SETUP_RECIPIENT_INTERFACE) {
5421
0
        if (type == RQT_SETUP_TYPE_STANDARD)
5422
0
            return dissect_usb_hid_control_std_intf(tvb, pinfo, tree, urb);
5423
0
        else if (type == RQT_SETUP_TYPE_CLASS)
5424
0
            return dissect_usb_hid_control_class_intf(tvb, pinfo, tree, urb);
5425
0
    }
5426
5427
0
    return dissect_usb_hid_data(tvb, pinfo, tree, data);
5428
0
}
5429
5430
/* dissect a descriptor that is specific to the HID class */
5431
static int
5432
dissect_usb_hid_class_descriptors(tvbuff_t *tvb, packet_info *pinfo _U_,
5433
        proto_tree *tree, void *data _U_)
5434
0
{
5435
0
    uint8_t     type;
5436
0
    int         offset = 0;
5437
0
    proto_item *ti;
5438
0
    proto_tree *desc_tree;
5439
0
    uint8_t     num_desc;
5440
0
    unsigned    i;
5441
5442
0
    type = tvb_get_uint8(tvb, 1);
5443
5444
    /* for now, we only handle the HID descriptor here */
5445
0
    if (type != USB_DT_HID)
5446
0
        return 0;
5447
5448
0
    desc_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_usb_hid_descriptor, &ti, "HID DESCRIPTOR");
5449
5450
0
    dissect_usb_descriptor_header(desc_tree, tvb, offset, &hid_descriptor_type_vals_ext);
5451
0
    offset += 2;
5452
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bcdHID, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5453
0
    offset += 2;
5454
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bCountryCode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5455
0
    offset++;
5456
0
    num_desc = tvb_get_uint8(tvb, offset);
5457
0
    proto_tree_add_item(desc_tree, hf_usb_hid_bNumDescriptors, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5458
0
    offset++;
5459
0
    for (i=0;i<num_desc;i++) {
5460
0
        proto_tree_add_item(desc_tree, hf_usb_hid_bDescriptorType, tvb, offset, 1, ENC_LITTLE_ENDIAN);
5461
0
        offset++;
5462
0
        proto_tree_add_item(desc_tree, hf_usb_hid_wDescriptorLength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
5463
0
        offset += 2;
5464
0
    }
5465
5466
0
    proto_item_set_len(ti, offset);
5467
0
    return offset;
5468
0
}
5469
5470
5471
void
5472
proto_register_usb_hid(void)
5473
14
{
5474
14
    static hf_register_info hf[] = {
5475
14
        { &hf_usb_hid_item_bSize,
5476
14
            { "bSize", "usbhid.item.bSize", FT_UINT8, BASE_DEC,
5477
14
                VALS(usb_hid_item_bSize_vals), USBHID_SIZE_MASK, NULL, HFILL }},
5478
5479
14
        { &hf_usb_hid_item_bType,
5480
14
            { "bType", "usbhid.item.bType", FT_UINT8, BASE_DEC,
5481
14
                VALS(usb_hid_item_bType_vals), USBHID_TYPE_MASK, NULL, HFILL }},
5482
5483
14
        { &hf_usb_hid_mainitem_bTag,
5484
14
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5485
14
                VALS(usb_hid_mainitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5486
5487
14
        { &hf_usb_hid_globalitem_bTag,
5488
14
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5489
14
                VALS(usb_hid_globalitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5490
5491
14
        { &hf_usb_hid_localitem_bTag,
5492
14
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5493
14
                VALS(usb_hid_localitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5494
5495
14
        { &hf_usb_hid_longitem_bTag,
5496
14
            { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX,
5497
14
                VALS(usb_hid_longitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }},
5498
5499
14
        { &hf_usb_hid_item_bDataSize,
5500
14
            { "bDataSize", "usbhid.item.bDataSize", FT_UINT8, BASE_DEC,
5501
14
                NULL, 0, NULL, HFILL }},
5502
5503
14
        { &hf_usb_hid_item_bLongItemTag,
5504
14
            { "bTag", "usbhid.item.bLongItemTag", FT_UINT8, BASE_HEX,
5505
14
                NULL, 0, NULL, HFILL }},
5506
5507
        /* Main-report item data */
5508
5509
14
        { &hf_usb_hid_mainitem_bit0,
5510
14
            { "Data/constant", "usbhid.item.main.readonly", FT_BOOLEAN, 9,
5511
14
                TFS(&tfs_mainitem_bit0), 1<<0, NULL, HFILL }},
5512
5513
14
        { &hf_usb_hid_mainitem_bit1,
5514
14
            { "Data type", "usbhid.item.main.variable", FT_BOOLEAN, 9,
5515
14
                TFS(&tfs_mainitem_bit1), 1<<1, NULL, HFILL }},
5516
5517
14
        { &hf_usb_hid_mainitem_bit2,
5518
14
            { "Coordinates", "usbhid.item.main.relative", FT_BOOLEAN, 9,
5519
14
                TFS(&tfs_mainitem_bit2), 1<<2, NULL, HFILL }},
5520
5521
14
        { &hf_usb_hid_mainitem_bit3,
5522
14
            { "Min/max wraparound", "usbhid.item.main.wrap", FT_BOOLEAN, 9,
5523
14
                TFS(&tfs_mainitem_bit3), 1<<3, NULL, HFILL }},
5524
5525
14
        { &hf_usb_hid_mainitem_bit4,
5526
14
            { "Physical relationship to data", "usbhid.item.main.nonlinear", FT_BOOLEAN, 9,
5527
14
                TFS(&tfs_mainitem_bit4), 1<<4, NULL, HFILL }},
5528
5529
14
        { &hf_usb_hid_mainitem_bit5,
5530
14
            { "Preferred state", "usbhid.item.main.no_preferred_state", FT_BOOLEAN, 9,
5531
14
                TFS(&tfs_mainitem_bit5), 1<<5, NULL, HFILL }},
5532
5533
14
        { &hf_usb_hid_mainitem_bit6,
5534
14
            { "Has null position", "usbhid.item.main.nullstate", FT_BOOLEAN, 9,
5535
14
                TFS(&tfs_mainitem_bit6), 1<<6, NULL, HFILL }},
5536
5537
14
        { &hf_usb_hid_mainitem_bit7,
5538
14
            { "(Non)-volatile", "usbhid.item.main.volatile", FT_BOOLEAN, 9,
5539
14
                TFS(&tfs_mainitem_bit7), 1<<7, NULL, HFILL }},
5540
5541
14
        { &hf_usb_hid_mainitem_bit7_input,
5542
14
            { "[Reserved]", "usbhid.item.main.reserved", FT_BOOLEAN, 9,
5543
14
                NULL, 1<<7, NULL, HFILL }},
5544
5545
14
        { &hf_usb_hid_mainitem_bit8,
5546
14
            { "Bits or bytes", "usbhid.item.main.buffered_bytes", FT_BOOLEAN, 9,
5547
14
                TFS(&tfs_mainitem_bit8), 1<<8, NULL, HFILL }},
5548
5549
14
        { &hf_usb_hid_mainitem_colltype,
5550
14
            { "Collection type", "usbhid.item.main.colltype", FT_UINT8, BASE_RANGE_STRING|BASE_HEX,
5551
14
                RVALS(usb_hid_mainitem_colltype_vals), 0, NULL, HFILL }},
5552
5553
        /* Global-report item data */
5554
5555
14
        { &hf_usb_hid_globalitem_usage,
5556
14
            { "Usage page", "usbhid.item.global.usage", FT_UINT8, BASE_RANGE_STRING|BASE_HEX,
5557
14
                NULL, 0, NULL, HFILL }},
5558
5559
14
        { &hf_usb_hid_globalitem_log_min,
5560
14
            { "Logical minimum", "usbhid.item.global.log_min", FT_INT32, BASE_DEC,
5561
14
                NULL, 0, NULL, HFILL }},
5562
5563
14
        { &hf_usb_hid_globalitem_log_max,
5564
14
            { "Logical maximum", "usbhid.item.global.log_max", FT_INT32, BASE_DEC,
5565
14
                NULL, 0, NULL, HFILL }},
5566
5567
14
        { &hf_usb_hid_globalitem_phy_min,
5568
14
            { "Physical minimum", "usbhid.item.global.phy_min", FT_INT32, BASE_DEC,
5569
14
                NULL, 0, NULL, HFILL }},
5570
5571
14
        { &hf_usb_hid_globalitem_phy_max,
5572
14
            { "Physical maximum", "usbhid.item.global.phy_max", FT_INT32, BASE_DEC,
5573
14
                NULL, 0, NULL, HFILL }},
5574
5575
14
        { &hf_usb_hid_globalitem_unit_exp,
5576
14
            { "Unit exponent", "usbhid.item.global.unit_exp", FT_UINT8, BASE_DEC,
5577
14
                NULL, 0, NULL, HFILL }},
5578
5579
14
        { &hf_usb_hid_globalitem_unit_sys,
5580
14
            { "System", "usbhid.item.global.unit.system", FT_UINT32, BASE_HEX,
5581
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0000000F, NULL, HFILL }},
5582
5583
14
        { &hf_usb_hid_globalitem_unit_len,
5584
14
            { "Length", "usbhid.item.global.unit.length", FT_UINT32, BASE_HEX,
5585
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x000000F0, NULL, HFILL }},
5586
5587
14
        { &hf_usb_hid_globalitem_unit_mass,
5588
14
            { "Mass", "usbhid.item.global.unit.mass", FT_UINT32, BASE_HEX,
5589
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x00000F00, NULL, HFILL }},
5590
5591
14
        { &hf_usb_hid_globalitem_unit_time,
5592
14
            { "Time", "usbhid.item.global.unit.time", FT_UINT32, BASE_HEX,
5593
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0000F000, NULL, HFILL }},
5594
5595
14
        { &hf_usb_hid_globalitem_unit_temp,
5596
14
            { "Temperature", "usbhid.item.global.unit.temperature", FT_UINT32, BASE_HEX,
5597
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x000F0000, NULL, HFILL }},
5598
5599
14
        { &hf_usb_hid_globalitem_unit_current,
5600
14
            { "Current", "usbhid.item.global.unit.current", FT_UINT32, BASE_HEX,
5601
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x00F00000, NULL, HFILL }},
5602
5603
14
        { &hf_usb_hid_globalitem_unit_brightness,
5604
14
            { "Luminous intensity", "usbhid.item.global.unit.brightness", FT_UINT32, BASE_HEX,
5605
14
                VALS(usb_hid_globalitem_unit_exp_vals), 0x0F000000, NULL, HFILL }},
5606
5607
14
        { &hf_usb_hid_globalitem_report_size,
5608
14
            { "Report size", "usbhid.item.global.report_size", FT_UINT8, BASE_DEC,
5609
14
                NULL, 0, NULL, HFILL }},
5610
5611
14
        { &hf_usb_hid_globalitem_report_id,
5612
14
            { "Report ID", "usbhid.item.global.report_id", FT_UINT8, BASE_HEX,
5613
14
                NULL, 0, NULL, HFILL }},
5614
5615
14
        { &hf_usb_hid_globalitem_report_count,
5616
14
            { "Report count", "usbhid.item.global.report_count", FT_UINT8, BASE_DEC,
5617
14
                NULL, 0, NULL, HFILL }},
5618
5619
14
        { &hf_usb_hid_globalitem_push,
5620
14
            { "Push", "usbhid.item.global.push", FT_UINT8, BASE_HEX,
5621
14
                NULL, 0, NULL, HFILL }},
5622
5623
14
        { &hf_usb_hid_globalitem_pop,
5624
14
            { "Pop", "usbhid.item.global.pop", FT_UINT8, BASE_HEX,
5625
14
                NULL, 0, NULL, HFILL }},
5626
5627
        /* Local-report item data */
5628
5629
14
        { &hf_usb_hid_localitem_usage,
5630
14
            { "Usage", "usbhid.item.local.usage", FT_UINT8, BASE_RANGE_STRING|BASE_HEX,
5631
14
                NULL, 0, NULL, HFILL }},
5632
5633
14
        { &hf_usb_hid_localitem_usage_min,
5634
14
            { "Usage minimum", "usbhid.item.local.usage_min", FT_UINT8, BASE_HEX,
5635
14
                NULL, 0, NULL, HFILL }},
5636
5637
14
        { &hf_usb_hid_localitem_usage_max,
5638
14
            { "Usage maximum", "usbhid.item.local.usage_max", FT_UINT8, BASE_HEX,
5639
14
                NULL, 0, NULL, HFILL }},
5640
5641
14
        { &hf_usb_hid_localitem_desig_index,
5642
14
            { "Designator index", "usbhid.item.local.desig_index", FT_UINT8, BASE_HEX,
5643
14
                NULL, 0, NULL, HFILL }},
5644
5645
14
        { &hf_usb_hid_localitem_desig_min,
5646
14
            { "Designator minimum", "usbhid.item.local.desig_min", FT_UINT8, BASE_HEX,
5647
14
                NULL, 0, NULL, HFILL }},
5648
5649
14
        { &hf_usb_hid_localitem_desig_max,
5650
14
            { "Designator maximum", "usbhid.item.local.desig_max", FT_UINT8, BASE_HEX,
5651
14
                NULL, 0, NULL, HFILL }},
5652
5653
14
        { &hf_usb_hid_localitem_string_index,
5654
14
            { "String index", "usbhid.item.local.string_index", FT_UINT8, BASE_HEX,
5655
14
                NULL, 0, NULL, HFILL }},
5656
5657
14
        { &hf_usb_hid_localitem_string_min,
5658
14
            { "String minimum", "usbhid.item.local.string_min", FT_UINT8, BASE_HEX,
5659
14
                NULL, 0, NULL, HFILL }},
5660
5661
14
        { &hf_usb_hid_localitem_string_max,
5662
14
            { "String maximum", "usbhid.item.local.string_max", FT_UINT8, BASE_HEX,
5663
14
                NULL, 0, NULL, HFILL }},
5664
5665
14
        { &hf_usb_hid_localitem_delimiter,
5666
14
            { "Delimiter", "usbhid.item.local.delimiter", FT_UINT8, BASE_HEX,
5667
14
                NULL, 0, NULL, HFILL }},
5668
5669
5670
14
        { &hf_usb_hid_item_unk_data,
5671
14
            { "Item data", "usbhid.item.data", FT_BYTES, BASE_NONE,
5672
14
                NULL, 0, NULL, HFILL }},
5673
5674
        /* USB HID specific requests */
5675
14
        { &hf_usb_hid_request,
5676
14
            { "bRequest", "usbhid.setup.bRequest", FT_UINT8, BASE_HEX,
5677
14
                VALS(setup_request_names_vals), 0x0, NULL, HFILL }},
5678
5679
14
        { &hf_usb_hid_value,
5680
14
            { "wValue", "usbhid.setup.wValue", FT_UINT16, BASE_HEX,
5681
14
                NULL, 0x0, NULL, HFILL }},
5682
5683
14
        { &hf_usb_hid_index,
5684
14
            { "wIndex", "usbhid.setup.wIndex", FT_UINT16, BASE_DEC,
5685
14
                NULL, 0x0, NULL, HFILL }},
5686
5687
14
        { &hf_usb_hid_length,
5688
14
            { "wLength", "usbhid.setup.wLength", FT_UINT16, BASE_DEC,
5689
14
                NULL, 0x0, NULL, HFILL }},
5690
5691
14
        { &hf_usb_hid_report_type,
5692
14
            { "ReportType", "usbhid.setup.ReportType", FT_UINT8, BASE_DEC,
5693
14
                VALS(usb_hid_report_type_vals), 0x0, NULL, HFILL }},
5694
5695
14
        { &hf_usb_hid_report_id,
5696
14
            { "ReportID", "usbhid.setup.ReportID", FT_UINT8, BASE_DEC,
5697
14
                NULL, 0x0, NULL, HFILL }},
5698
5699
14
        { &hf_usb_hid_duration,
5700
14
            { "Duration", "usbhid.setup.Duration", FT_UINT8, BASE_DEC,
5701
14
                NULL, 0x0, NULL, HFILL }},
5702
5703
14
        { &hf_usb_hid_zero,
5704
14
            { "(zero)", "usbhid.setup.zero", FT_UINT8, BASE_DEC,
5705
14
                NULL, 0x0, NULL, HFILL }},
5706
5707
        /* components of the HID descriptor */
5708
14
        { &hf_usb_hid_bcdHID,
5709
14
            { "bcdHID", "usbhid.descriptor.hid.bcdHID", FT_UINT16, BASE_HEX,
5710
14
                NULL, 0x0, NULL, HFILL }},
5711
5712
14
        { &hf_usb_hid_bCountryCode,
5713
14
            { "bCountryCode", "usbhid.descriptor.hid.bCountryCode", FT_UINT8, BASE_HEX,
5714
14
                VALS(hid_country_code_vals), 0x0, NULL, HFILL }},
5715
5716
14
        { &hf_usb_hid_bNumDescriptors,
5717
14
            { "bNumDescriptors", "usbhid.descriptor.hid.bNumDescriptors", FT_UINT8, BASE_DEC,
5718
14
                NULL, 0x0, NULL, HFILL }},
5719
5720
14
        { &hf_usb_hid_bDescriptorIndex,
5721
14
            { "bDescriptorIndex", "usbhid.descriptor.hid.bDescriptorIndex", FT_UINT8, BASE_HEX,
5722
14
                NULL, 0x0, NULL, HFILL }},
5723
5724
14
        { &hf_usb_hid_bDescriptorType,
5725
14
            { "bDescriptorType", "usbhid.descriptor.hid.bDescriptorType", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5726
14
                &hid_descriptor_type_vals_ext, 0x00, NULL, HFILL }},
5727
5728
14
        { &hf_usb_hid_wInterfaceNumber,
5729
14
            { "wInterfaceNumber", "usbhid.descriptor.hid.wInterfaceNumber", FT_UINT16, BASE_DEC,
5730
14
                NULL, 0x0, NULL, HFILL }},
5731
5732
14
        { &hf_usb_hid_wDescriptorLength,
5733
14
            { "wDescriptorLength", "usbhid.descriptor.hid.wDescriptorLength", FT_UINT16, BASE_DEC,
5734
14
                NULL, 0x0, NULL, HFILL }},
5735
5736
14
        { &hf_usbhid_boot_report_keyboard_reserved,
5737
14
            { "Reserved", "usbhid.boot_report.keyboard.reserved", FT_UINT8, BASE_HEX,
5738
14
                NULL, 0x00, NULL, HFILL }},
5739
5740
14
        { &hf_usbhid_boot_report_keyboard_keycode_1,
5741
14
            { "Keycode 1", "usbhid.boot_report.keyboard.keycode_1", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5742
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5743
5744
14
        { &hf_usbhid_boot_report_keyboard_keycode_2,
5745
14
            { "Keycode 2", "usbhid.boot_report.keyboard.keycode_2", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5746
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5747
5748
14
        { &hf_usbhid_boot_report_keyboard_keycode_3,
5749
14
            { "Keycode 3", "usbhid.boot_report.keyboard.keycode_3", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5750
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5751
5752
14
        { &hf_usbhid_boot_report_keyboard_keycode_4,
5753
14
            { "Keycode 4", "usbhid.boot_report.keyboard.keycode_4", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5754
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5755
5756
14
        { &hf_usbhid_boot_report_keyboard_keycode_5,
5757
14
            { "Keycode 5", "usbhid.boot_report.keyboard.keycode_5", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5758
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5759
5760
14
        { &hf_usbhid_boot_report_keyboard_keycode_6,
5761
14
            { "Keycode 6", "usbhid.boot_report.keyboard.keycode_6", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
5762
14
                &keycode_vals_ext, 0x00, NULL, HFILL }},
5763
5764
14
        { &hf_usbhid_boot_report_keyboard_modifier_right_gui,
5765
14
            { "Modifier: RIGHT GUI", "usbhid.boot_report.keyboard.modifier.right_gui", FT_BOOLEAN, 8,
5766
14
                NULL, 0x80, NULL, HFILL }},
5767
5768
14
        { &hf_usbhid_boot_report_keyboard_modifier_right_alt,
5769
14
            { "Modifier: RIGHT ALT", "usbhid.boot_report.keyboard.modifier.right_alt", FT_BOOLEAN, 8,
5770
14
                NULL, 0x40, NULL, HFILL }},
5771
5772
14
        { &hf_usbhid_boot_report_keyboard_modifier_right_shift,
5773
14
            { "Modifier: RIGHT SHIFT", "usbhid.boot_report.keyboard.modifier.right_shift", FT_BOOLEAN, 8,
5774
14
                NULL, 0x20, NULL, HFILL }},
5775
5776
14
        { &hf_usbhid_boot_report_keyboard_modifier_right_ctrl,
5777
14
            { "Modifier: RIGHT CTRL", "usbhid.boot_report.keyboard.modifier.right_ctrl", FT_BOOLEAN, 8,
5778
14
                NULL, 0x10,NULL, HFILL }},
5779
5780
14
        { &hf_usbhid_boot_report_keyboard_modifier_left_gui,
5781
14
            { "Modifier: LEFT GUI", "usbhid.boot_report.keyboard.modifier.left_gui", FT_BOOLEAN, 8,
5782
14
                NULL, 0x08, NULL, HFILL }},
5783
5784
14
        { &hf_usbhid_boot_report_keyboard_modifier_left_alt,
5785
14
            { "Modifier: LEFT ALT", "usbhid.boot_report.keyboard.modifier.left_alt", FT_BOOLEAN, 8,
5786
14
                NULL, 0x04, NULL, HFILL }
5787
14
        },
5788
5789
14
        { &hf_usbhid_boot_report_keyboard_modifier_left_shift,
5790
14
            { "Modifier: LEFT SHIFT", "usbhid.boot_report.keyboard.modifier.left_shift", FT_BOOLEAN, 8,
5791
14
                NULL, 0x02, NULL, HFILL }},
5792
5793
14
        { &hf_usbhid_boot_report_keyboard_modifier_left_ctrl,
5794
14
            { "Modifier: LEFT CTRL", "usbhid.boot_report.keyboard.modifier.left_ctrl", FT_BOOLEAN, 8,
5795
14
                NULL, 0x01, NULL, HFILL }},
5796
5797
14
        { &hf_usbhid_boot_report_keyboard_leds_constants,
5798
14
            { "Constants", "usbhid.boot_report.keyboard.leds.constants", FT_UINT8, BASE_HEX,
5799
14
                NULL, 0xE0, NULL, HFILL }},
5800
5801
14
        { &hf_usbhid_boot_report_keyboard_leds_kana,
5802
14
            { "KANA", "usbhid.boot_report.keyboard.leds.kana", FT_BOOLEAN, 8,
5803
14
                NULL, 0x10, NULL, HFILL }},
5804
5805
14
        { &hf_usbhid_boot_report_keyboard_leds_compose,
5806
14
            { "COMPOSE", "usbhid.boot_report.keyboard.leds.compose", FT_BOOLEAN, 8,
5807
14
                NULL, 0x08, NULL, HFILL }},
5808
5809
14
        { &hf_usbhid_boot_report_keyboard_leds_scroll_lock,
5810
14
            { "SCROLL LOCK", "usbhid.boot_report.keyboard.leds.scroll_lock", FT_BOOLEAN, 8,
5811
14
                NULL, 0x04, NULL, HFILL }},
5812
5813
14
        { &hf_usbhid_boot_report_keyboard_leds_caps_lock,
5814
14
            { "CAPS LOCK", "usbhid.boot_report.keyboard.leds.caps_lock", FT_BOOLEAN, 8,
5815
14
                NULL, 0x02,NULL, HFILL }},
5816
5817
14
        { &hf_usbhid_boot_report_keyboard_leds_num_lock,
5818
14
            { "NUM LOCK",  "usbhid.boot_report.keyboard.leds.num_lock", FT_BOOLEAN, 8,
5819
14
                NULL, 0x01, NULL, HFILL }},
5820
5821
14
        { &hf_usbhid_boot_report_mouse_button_8,
5822
14
            { "Button 8",  "usbhid.boot_report.mouse.button.8", FT_BOOLEAN, 8,
5823
14
                NULL, 0x80, NULL, HFILL }},
5824
5825
14
        { &hf_usbhid_boot_report_mouse_button_7,
5826
14
            { "Button 7",  "usbhid.boot_report.mouse.button.7", FT_BOOLEAN, 8,
5827
14
                NULL, 0x40, NULL, HFILL }},
5828
5829
14
        { &hf_usbhid_boot_report_mouse_button_6,
5830
14
            { "Button 6",  "usbhid.boot_report.mouse.button.6", FT_BOOLEAN, 8,
5831
14
                NULL, 0x20, NULL, HFILL }},
5832
5833
14
        { &hf_usbhid_boot_report_mouse_button_5,
5834
14
            { "Button 5",  "usbhid.boot_report.mouse.button.5", FT_BOOLEAN, 8,
5835
14
                NULL, 0x10, NULL, HFILL }},
5836
5837
14
        { &hf_usbhid_boot_report_mouse_button_4,
5838
14
            { "Button 4",  "usbhid.boot_report.mouse.button.4", FT_BOOLEAN, 8,
5839
14
                NULL, 0x08, NULL, HFILL }},
5840
5841
14
        { &hf_usbhid_boot_report_mouse_button_middle,
5842
14
            { "Button Middle", "usbhid.boot_report.mouse.button.middle", FT_BOOLEAN, 8,
5843
14
                NULL, 0x04, NULL, HFILL }},
5844
5845
14
        { &hf_usbhid_boot_report_mouse_button_right,
5846
14
            { "Button Right",  "usbhid.boot_report.mouse.button.right", FT_BOOLEAN, 8,
5847
14
                NULL, 0x02, NULL, HFILL }},
5848
5849
14
        { &hf_usbhid_boot_report_mouse_button_left,
5850
14
            { "Button Left",   "usbhid.boot_report.mouse.button.left", FT_BOOLEAN, 8,
5851
14
                NULL, 0x01, NULL, HFILL }},
5852
5853
14
        { &hf_usbhid_boot_report_mouse_x_displacement,
5854
14
            { "X Displacement", "usbhid.boot_report.mouse.x_displacement", FT_INT8, BASE_DEC,
5855
14
                NULL, 0x00, NULL, HFILL }},
5856
5857
14
        { &hf_usbhid_boot_report_mouse_y_displacement,
5858
14
            { "Y Displacement", "usbhid.boot_report.mouse.y_displacement", FT_INT8, BASE_DEC,
5859
14
                NULL, 0x00, NULL, HFILL }},
5860
5861
14
        { &hf_usbhid_boot_report_mouse_horizontal_scroll_wheel,
5862
14
            { "Horizontal Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.horizontal", FT_INT8, BASE_DEC,
5863
14
                NULL, 0x00, NULL, HFILL }},
5864
5865
14
        { &hf_usbhid_boot_report_mouse_vertical_scroll_wheel,
5866
14
            { "Vertical Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.vertical", FT_INT8, BASE_DEC,
5867
14
                NULL, 0x00, NULL, HFILL }},
5868
5869
14
        { &hf_usbhid_data,
5870
14
            { "HID Data", "usbhid.data", FT_BYTES, BASE_NONE,
5871
14
                NULL, 0x00, NULL, HFILL }},
5872
5873
14
        { &hf_usbhid_unknown_data,
5874
14
            { "Unknown", "usbhid.data.unknown", FT_BYTES, BASE_NONE,
5875
14
                NULL, 0x00, NULL, HFILL }},
5876
5877
14
        { &hf_usbhid_vendor_data,
5878
14
            { "Vendor Data", "usbhid.data.vendor", FT_BYTES, BASE_NONE,
5879
14
                NULL, 0x00, NULL, HFILL }},
5880
5881
14
        { &hf_usbhid_report_id,
5882
14
            { "Report ID", "usbhid.data.report_id", FT_UINT8, BASE_HEX,
5883
14
                NULL, 0x00, NULL, HFILL }},
5884
5885
14
        { &hf_usbhid_padding,
5886
14
            { "Padding", "usbhid.data.padding", FT_BYTES, BASE_NONE,
5887
14
                NULL, 0x00, NULL, HFILL }},
5888
5889
14
        { &hf_usbhid_axis_x,
5890
14
            { "X Axis", "usbhid.data.axis.x", FT_INT32, BASE_DEC,
5891
14
                NULL, 0x00, NULL, HFILL }},
5892
5893
14
        { &hf_usbhid_axis_y,
5894
14
            { "Y Axis", "usbhid.data.axis.y", FT_INT32, BASE_DEC,
5895
14
                NULL, 0x00, NULL, HFILL }},
5896
5897
14
        { &hf_usbhid_axis_z,
5898
14
            { "Z Axis", "usbhid.data.axis.z", FT_INT32, BASE_DEC,
5899
14
                NULL, 0x00, NULL, HFILL }},
5900
5901
14
        { &hf_usbhid_axis_rx,
5902
14
            { "Rx Axis", "usbhid.data.axis.rx", FT_INT32, BASE_DEC,
5903
14
                NULL, 0x00, NULL, HFILL }},
5904
5905
14
        { &hf_usbhid_axis_ry,
5906
14
            { "Ry Axis", "usbhid.data.axis.ry", FT_INT32, BASE_DEC,
5907
14
                NULL, 0x00, NULL, HFILL }},
5908
5909
14
        { &hf_usbhid_axis_rz,
5910
14
            { "Rz Axis", "usbhid.data.axis.rz", FT_INT32, BASE_DEC,
5911
14
                NULL, 0x00, NULL, HFILL }},
5912
5913
14
        { &hf_usbhid_axis_slider,
5914
14
            { "Slider Axis", "usbhid.data.axis.slider", FT_INT32, BASE_DEC,
5915
14
                NULL, 0x00, NULL, HFILL }},
5916
5917
14
        { &hf_usbhid_axis_vx,
5918
14
            { "Vx Axis", "usbhid.data.axis.vx", FT_INT32, BASE_DEC,
5919
14
                NULL, 0x00, NULL, HFILL }},
5920
5921
14
        { &hf_usbhid_axis_vy,
5922
14
            { "Vy Axis", "usbhid.data.axis.vy", FT_INT32, BASE_DEC,
5923
14
                NULL, 0x00, NULL, HFILL }},
5924
5925
14
        { &hf_usbhid_axis_vz,
5926
14
            { "Vz Axis", "usbhid.data.axis.vz", FT_INT32, BASE_DEC,
5927
14
                NULL, 0x00, NULL, HFILL }},
5928
5929
14
        { &hf_usbhid_axis_vbrx,
5930
14
            { "Vbrx Axis", "usbhid.data.axis.vbrx", FT_INT32, BASE_DEC,
5931
14
                NULL, 0x00, NULL, HFILL }},
5932
5933
14
        { &hf_usbhid_axis_vbry,
5934
14
            { "Vbry Axis", "usbhid.data.axis.vbry", FT_INT32, BASE_DEC,
5935
14
                NULL, 0x00, NULL, HFILL }},
5936
5937
14
        { &hf_usbhid_axis_vbrz,
5938
14
            { "Vbrz Axis", "usbhid.data.axis.vbrz", FT_INT32, BASE_DEC,
5939
14
                NULL, 0x00, NULL, HFILL }},
5940
5941
14
        { &hf_usbhid_axis_vno,
5942
14
            { "Vno Axis", "usbhid.data.axis.vno", FT_INT32, BASE_DEC,
5943
14
                NULL, 0x00, NULL, HFILL }},
5944
5945
14
        { &hf_usbhid_button,
5946
14
            { "Button", "usbhid.data.button", FT_BOOLEAN, BASE_NONE,
5947
14
                NULL, 0x00, NULL, HFILL }},
5948
5949
14
        { &hf_usbhid_key,
5950
14
            { "Key", "usbhid.data.key.variable", FT_BOOLEAN, BASE_NONE,
5951
14
                NULL, 0x00, NULL, HFILL }},
5952
5953
14
        { &hf_usbhid_array,
5954
14
            { "Array", "usbhid.data.array", FT_BYTES, BASE_NONE,
5955
14
                NULL, 0x00, NULL, HFILL }},
5956
5957
14
        { &hf_usbhid_array_usage,
5958
14
            { "Usage", "usbhid.data.array.usage", FT_BOOLEAN, BASE_NONE,
5959
14
            NULL, 0x00, NULL, HFILL }},
5960
14
    };
5961
5962
14
    static int *usb_hid_ett[] = {
5963
14
        &ett_usb_hid_report,
5964
14
        &ett_usb_hid_item_header,
5965
14
        &ett_usb_hid_wValue,
5966
14
        &ett_usb_hid_descriptor,
5967
14
        &ett_usb_hid_data,
5968
14
        &ett_usb_hid_unknown_data,
5969
14
        &ett_usb_hid_array
5970
14
    };
5971
5972
14
    report_descriptors = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
5973
5974
14
    proto_usb_hid = proto_register_protocol("USB HID", "USBHID", "usbhid");
5975
14
    proto_register_field_array(proto_usb_hid, hf, array_length(hf));
5976
14
    proto_register_subtree_array(usb_hid_ett, array_length(usb_hid_ett));
5977
5978
    /*usb_hid_boot_keyboard_input_report_handle  =*/ register_dissector("usbhid.boot_report.keyboard.input",  dissect_usb_hid_boot_keyboard_input_report,  proto_usb_hid);
5979
14
    /*usb_hid_boot_keyboard_output_report_handle =*/ register_dissector("usbhid.boot_report.keyboard.output", dissect_usb_hid_boot_keyboard_output_report, proto_usb_hid);
5980
14
    /*usb_hid_boot_mouse_input_report_handle     =*/ register_dissector("usbhid.boot_report.mouse.input",     dissect_usb_hid_boot_mouse_input_report,     proto_usb_hid);
5981
14
    usb_hid_control_handle                         = register_dissector("usbhid.control", dissect_usb_hid_control, proto_usb_hid);
5982
14
    usb_hid_interrupt_handle                       = register_dissector("usbhid.data", dissect_usb_hid_data, proto_usb_hid);
5983
14
    usb_hid_descr_handle                           = register_dissector("usbhid.class_descriptors", dissect_usb_hid_class_descriptors, proto_usb_hid);
5984
14
}
5985
5986
void
5987
proto_reg_handoff_usb_hid(void)
5988
14
{
5989
14
    dissector_add_uint("usb.control", IF_CLASS_HID, usb_hid_control_handle);
5990
14
    dissector_add_for_decode_as("usb.device", usb_hid_control_handle);
5991
14
    dissector_add_uint("usb.interrupt", IF_CLASS_HID, usb_hid_interrupt_handle);
5992
14
    dissector_add_uint("usb.descriptor", IF_CLASS_HID, usb_hid_descr_handle);
5993
14
}
5994
5995
/*
5996
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
5997
 *
5998
 * Local variables:
5999
 * c-basic-offset: 4
6000
 * tab-width: 8
6001
 * indent-tabs-mode: nil
6002
 * End:
6003
 *
6004
 * vi: set shiftwidth=4 tabstop=8 expandtab:
6005
 * :indentSize=4:tabSize=8:noTabs=true:
6006
 */