Vuo  2.1.2
VuoHidUsage.c
Go to the documentation of this file.
1 
10 #include "VuoHid.h"
11 
12 #include <string.h>
13 
14 
15 #ifdef VUO_COMPILER
17  "title" : "VuoHidDevices"
18  });
19 #endif
20 
21 
38 char *VuoHid_getUsageText(uint32_t usagePage, uint32_t usage)
39 {
40  char *text = 0;
41 
42  if (usagePage == 0x01) // Generic Desktop
43  {
44  char *lookup[] = {
45  0, "Pointer", "Mouse", 0, "Joystick", "Game Pad", "Keyboard", "Keypad",
46  "Multi-axis Controller", "Tablet PC System Controls", "Water Cooling Device", "Computer Chassis Device", "Wireless Radio Controls", "Portable Device Control", 0, 0,
47  0, 0, 0, 0, 0, 0, 0, 0,
48  0, 0, 0, 0, 0, 0, 0, 0,
49  0, 0, 0, 0, 0, 0, 0, 0,
50  0, 0, 0, 0, 0, 0, 0, 0,
51  "X", "Y", "Z", "Rx", "Ry", "Rz", "Slider", "Dial",
52  "Wheel", "Hat switch", "Counted Buffer", "Byte Count", "Motion Wakeup", "Start", "Select", 0,
53  "Vx", "Vy", "Vz", "Vbrx", "Vbry", "Vbrz", "Vno", "Feature Notification",
54  "Resolution Multiplier", 0, 0, 0, 0, 0, 0, 0,
55  0, 0, 0, 0, 0, 0, 0, 0,
56  0, 0, 0, 0, 0, 0, 0, 0,
57  0, 0, 0, 0, 0, 0, 0, 0,
58  0, 0, 0, 0, 0, 0, 0, 0,
59  0, 0, 0, 0, 0, 0, 0, 0,
60  0, 0, 0, 0, 0, 0, 0, 0,
61  "System Control", "System Power Down", "System Sleep", "System Wake Up", "System Context Menu", "System Main Menu", "System App Menu", "System Menu Help",
62  "System Menu Exit", "System Menu Select", "System Menu Right", "System Menu Left", "System Menu Up", "System Menu Down", "System Cold Restart", "System Warm Restart",
63  "D-pad Up", "D-pad Down", "D-pad Right", "D-pad Left", 0, 0, 0, 0,
64  0, 0, 0, 0, 0, 0, 0, 0,
65  "System Dock", "System Undock", "System Setup", "System Break", "System Debugger Break", "Application Break", "Application Debugger Break", "System Speaker Mute",
66  "System Hibernate", 0, 0, 0, 0, 0, 0, 0,
67  "System Display Invert", "System Display Internal", "System Display External", "System Display Both", "System Display Dual", "System Display Toggle Int/Ext", "System Display Swap Primary/Secondary", "System Display LCD Autoscale",
68  0, 0, 0, 0, 0, 0, 0, 0,
69  "Sensor Zone", "RPM", "Coolant Level", "Coolant Critical Level", "Coolant Pump", "Chassis Enclosure", "Wireless Radio Button", "Wireless Radio LED",
70  "Wireless Radio Slider Switch", "System Display Rotation Lock Button", "System Display Rotation Lock Slider Switch", "Control Enable", 0, 0, 0, 0,
71  };
72  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
73 
74  if (usage == 0xffffffff)
75  text = strdup("Keycodes");
76  }
77 
78  else if (usagePage == 0x02) // Simulation Controls
79  {
80  char *lookup[] = {
81  0, "Flight Simulation Device", "Automobile Simulation Device", "Tank Simulation Device", "Spaceship Simulation Device", "Submarine Simulation Device", "Sailing Simulation Device", "Motorcycle Simulation Device",
82  "Sports Simulation Device", "Airplane Simulation Device", "Helicopter Simulation Device", "Magic Carpet Simulation Device", "Bicycle Simulation Device", 0, 0, 0,
83  0, 0, 0, 0, 0, 0, 0, 0,
84  "Flight Control Stick", "Flight Stick", "Cyclic Control", "Cyclic Trim", "Flight Yoke", "Track Control", 0, 0,
85  0, 0, 0, 0, 0, 0, 0, 0,
86  0, 0, 0, 0, 0, 0, 0, 0,
87  0, 0, 0, 0, 0, 0, 0, 0,
88  0, 0, 0, 0, 0, 0, 0, 0,
89  0, 0, 0, 0, 0, 0, 0, 0,
90  0, 0, 0, 0, 0, 0, 0, 0,
91  0, 0, 0, 0, 0, 0, 0, 0,
92  0, 0, 0, 0, 0, 0, 0, 0,
93  0, 0, 0, 0, 0, 0, 0, 0,
94  0, 0, 0, 0, 0, 0, 0, 0,
95  0, 0, 0, 0, 0, 0, 0, 0,
96  0, 0, 0, 0, 0, 0, 0, 0,
97  0, 0, 0, 0, 0, 0, 0, 0,
98  0, 0, 0, 0, 0, 0, 0, 0,
99  0, 0, 0, 0, 0, 0, 0, 0,
100  0, 0, 0, 0, 0, 0, 0, 0,
101  0, 0, 0, 0, 0, 0, 0, 0,
102  "Aileron", "Aileron Trim", "Anti-Torque Control", "Autopilot Enable", "Chaff Release", "Collective Control", "Dive Brake", "Electronic Countermeasures",
103  "Elevator", "Elevator Trim", "Rudder", "Throttle", "Flight Communications", "Flare Release", "Landing Gear", "Toe Brake",
104  "Trigger", "Weapons Arm", "Weapons Select", "Wing Flaps", "Accelerator", "Brake", "Clutch", "Shifter",
105  "Steering", "Turret Direction", "Barrel Elevation", "Dive Plane", "Ballast", "Bicycle Crank", "Handle Bars", "Front Brake",
106  "Rear Brake", 0, 0, 0, 0, 0, 0, 0,
107  };
108  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
109  }
110 
111  else if (usagePage == 0x03) // VR Controls
112  {
113  char *lookup[] = {
114  0, "Belt", "Body Suit", "Flexor", "Glove", "Head Tracker", "Head Mounted Display", "Hand Tracker",
115  "Oculometer", "Vest", "Animatronic Device", 0, 0, 0, 0, 0,
116  0, 0, 0, 0, 0, 0, 0, 0,
117  0, 0, 0, 0, 0, 0, 0, 0,
118  "Stereo Enable", "Display Enable", 0, 0, 0, 0, 0, 0,
119  };
120  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
121  }
122 
123  else if (usagePage == 0x04) // Sport Controls
124  {
125  char *lookup[] = {
126  0, "Baseball Bat", "Golf Club", "Rowing Machine", "Treadmill", 0, 0, 0,
127  0, 0, 0, 0, 0, 0, 0, 0,
128  0, 0, 0, 0, 0, 0, 0, 0,
129  0, 0, 0, 0, 0, 0, 0, 0,
130  0, 0, 0, 0, 0, 0, 0, 0,
131  0, 0, 0, 0, 0, 0, 0, 0,
132  "Oar", "Slope", "Rate", "Stick Speed", "Stick Face Angle", "Stick Heel/Toe", "Stick Follow Through", "Stick Tempo",
133  "Stick Type", "Stick Height", 0, 0, 0, 0, 0, 0,
134  0, 0, 0, 0, 0, 0, 0, 0,
135  0, 0, 0, 0, 0, 0, 0, 0,
136  "Putter", "1 Iron", "2 Iron", "3 Iron", "4 Iron", "5 Iron", "6 Iron", "7 Iron",
137  "8 Iron", "9 Iron", "10 Iron", "11 Iron", "Sand Wedge", "Loft Wedge", "Power Wedge", "1 Wood",
138  "3 Wood", "5 Wood", "7 Wood", "9 Wood", 0, 0, 0, 0,
139  };
140  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
141  }
142 
143  else if (usagePage == 0x05) // Game Controls
144  {
145  char *lookup[] = {
146  0, "3D Game Controller", "Pinball Device", "Gun Device", 0, 0, 0, 0,
147  0, 0, 0, 0, 0, 0, 0, 0,
148  0, 0, 0, 0, 0, 0, 0, 0,
149  0, 0, 0, 0, 0, 0, 0, 0,
150  "Point of View", "Turn Right/Left", "Pitch Forward/Backward", "Roll Right/Left", "Move Right/Left", "Move Forward/Backward", "Move Up/Down", "Lean Right/Left",
151  "Lean Forward/Backward", "Height of POV", "Flipper", "Secondary Flipper", "Bump", "New Game", "Shoot Ball", "Player",
152  "Gun Bolt", "Gun Clip", "Gun Selector", "Gun Single Shot", "Gun Burst", "Gun Automatic", "Gun Safety", "Gamepad Fire/Jump",
153  "Gamepad Trigger", 0, 0, 0, 0, 0, 0, 0,
154  };
155  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
156  }
157 
158  else if (usagePage == 0x06) // Generic Device Controls
159  {
160  char *lookup[] = {
161  0, "Background Controls", 0, 0, 0, 0, 0, 0,
162  0, 0, 0, 0, 0, 0, 0, 0,
163  0, 0, 0, 0, 0, 0, 0, 0,
164  0, 0, 0, 0, 0, 0, 0, 0,
165  "Battery Strength", "Wireless Channel", "Wireless ID", "Discover Wireless Control", "Security Code Character Entered", "Security Code Character Erased", "Security Code Cleared", "Sequence ID",
166  "Sequence ID Reset", "RF Signal Strength", 0, 0, 0, 0, 0, 0,
167  };
168  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
169  }
170 
171  else if (usagePage == 0x07) // Keyboard/Keypad
172  {
173  char *lookup[] = {
174  0, "Keyboard ErrorRollOver", "Keyboard POSTFail", "Keyboard ErrorUndefined", "Keyboard a and A", "Keyboard b and B", "Keyboard c and C", "Keyboard d and D",
175  "Keyboard e and E", "Keyboard f and F", "Keyboard g and G", "Keyboard h and H", "Keyboard i and I", "Keyboard j and J", "Keyboard k and K", "Keyboard l and L",
176  "Keyboard m and M", "Keyboard n and N", "Keyboard o and O", "Keyboard p and P", "Keyboard q and Q", "Keyboard r and R", "Keyboard s and S", "Keyboard t and T",
177  "Keyboard u and U", "Keyboard v and V", "Keyboard w and W", "Keyboard x and X", "Keyboard y and Y", "Keyboard z and Z", "Keyboard 1 and !", "Keyboard 2 and @",
178  "Keyboard 3 and #", "Keyboard 4 and $", "Keyboard 5 and %", "Keyboard 6 and ^", "Keyboard 7 and &", "Keyboard 8 and *", "Keyboard 9 and (", "Keyboard 0 and )",
179  "Keyboard Return (ENTER)", "Keyboard ESCAPE", "Keyboard DELETE (Backspace)", "Keyboard Tab", "Keyboard Spacebar", "Keyboard - and _", "Keyboard = and +", "Keyboard [ and {",
180  "Keyboard ] and }", "Keyboard \\ and |", "Keyboard Non-US # and ~", "Keyboard ; and :", "Keyboard ‘ and “", "Keyboard Grave Accent and Tilde", "Keyboard , and <", "Keyboard . and >",
181  "Keyboard / and ?", "Keyboard Caps Lock", "Keyboard F1", "Keyboard F2", "Keyboard F3", "Keyboard F4", "Keyboard F5", "Keyboard F6",
182  "Keyboard F7", "Keyboard F8", "Keyboard F9", "Keyboard F10", "Keyboard F11", "Keyboard F12", "Keyboard PrintScreen", "Keyboard Scroll Lock",
183  "Keyboard Pause", "Keyboard Insert", "Keyboard Home", "Keyboard PageUp", "Keyboard Delete Forward", "Keyboard End", "Keyboard PageDown", "Keyboard RightArrow",
184  "Keyboard LeftArrow", "Keyboard DownArrow", "Keyboard UpArrow", "Keypad Num Lock and Clear", "Keypad /", "Keypad *", "Keypad -", "Keypad +",
185  "Keypad ENTER", "Keypad 1 and End", "Keypad 2 and Down Arrow", "Keypad 3 and PageDn", "Keypad 4 and Left Arrow", "Keypad 5", "Keypad 6 and Right Arrow", "Keypad 7 and Home",
186  "Keypad 8 and Up Arrow", "Keypad 9 and PageUp", "Keypad 0 and Insert", "Keypad . and Delete", "Keyboard Non-US \\ and |", "Keyboard Application", "Keyboard Power", "Keypad =",
187  "Keyboard F13", "Keyboard F14", "Keyboard F15", "Keyboard F16", "Keyboard F17", "Keyboard F18", "Keyboard F19", "Keyboard F20",
188  "Keyboard F21", "Keyboard F22", "Keyboard F23", "Keyboard F24", "Keyboard Execute", "Keyboard Help", "Keyboard Menu", "Keyboard Select",
189  "Keyboard Stop", "Keyboard Again", "Keyboard Undo", "Keyboard Cut", "Keyboard Copy", "Keyboard Paste", "Keyboard Find", "Keyboard Mute",
190  "Keyboard Volume Up", "Keyboard Volume Down", "Keyboard Locking Caps Lock", "Keyboard Locking Num Lock", "Keyboard Locking Scroll Lock", "Keypad Comma", "Keypad Equal Sign", "Keyboard International1",
191  "Keyboard International2", "Keyboard International3", "Keyboard International4", "Keyboard International5", "Keyboard International6", "Keyboard International7", "Keyboard International8", "Keyboard International9",
192  "Keyboard LANG1", "Keyboard LANG2", "Keyboard LANG3", "Keyboard LANG4", "Keyboard LANG5", "Keyboard LANG6", "Keyboard LANG7", "Keyboard LANG8",
193  "Keyboard LANG9", "Keyboard Alternate Erase", "Keyboard SysReq/Attention", "Keyboard Cancel", "Keyboard Clear", "Keyboard Prior", "Keyboard Return", "Keyboard Separator",
194  "Keyboard Out", "Keyboard Oper", "Keyboard Clear/Again", "Keyboard CrSel/Props", "Keyboard ExSel", 0, 0, 0,
195  0, 0, 0, 0, 0, 0, 0, 0,
196  "Keypad 00", "Keypad 000", "Thousands Separator", "Decimal Separator", "Currency Unit", "Currency Sub-unit", "Keypad (", "Keypad )",
197  "Keypad {", "Keypad }", "Keypad Tab", "Keypad Backspace", "Keypad A", "Keypad B", "Keypad C", "Keypad D",
198  "Keypad E", "Keypad F", "Keypad XOR", "Keypad ^", "Keypad %", "Keypad <", "Keypad >", "Keypad &",
199  "Keypad &&", "Keypad |", "Keypad ||", "Keypad :", "Keypad #", "Keypad Space", "Keypad @", "Keypad !",
200  "Keypad Memory Store", "Keypad Memory Recall", "Keypad Memory Clear", "Keypad Memory Add", "Keypad Memory Subtract", "Keypad Memory Multiply", "Keypad Memory Divide", "Keypad +/-",
201  "Keypad Clear", "Keypad Clear Entry", "Keypad Binary", "Keypad Octal", "Keypad Decimal", "Keypad Hexadecimal", 0, 0,
202  "Keyboard LeftControl", "Keyboard LeftShift", "Keyboard LeftAlt", "Keyboard Left GUI", "Keyboard RightControl", "Keyboard RightShift", "Keyboard RightAlt", "Keyboard Right GUI",
203  };
204  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
205 
206  if (usage == 0xffffffff)
207  text = strdup("Keycodes");
208  }
209 
210  else if (usagePage == 0x08) // LED
211  {
212  char *lookup[] = {
213  0, "Num Lock", "Caps Lock", "Scroll Lock", "Compose", "Kana", "Power", "Shift",
214  "Do Not Disturb", "Mute", "Tone Enable", "High Cut Filter", "Low Cut Filter", "Equalizer Enable", "Sound Field On", "Surround On",
215  "Repeat", "Stereo", "Sampling Rate Detect", "Spinning", "CAV", "CLV", "Recording Format Detect", "Off-Hook",
216  "Ring", "Message Waiting", "Data Mode", "Battery Operation", "Battery OK", "Battery Low", "Speaker", "Head Set",
217  "Hold", "Microphone", "Coverage", "Night Mode", "Send Calls", "Call Pickup", "Conference", "Stand-by",
218  "Camera On", "Camera Off", "On-Line", "Off-Line", "Busy", "Ready", "Paper-Out", "Paper-Jam",
219  "Remote", "Forward", "Reverse", "Stop", "Rewind", "Fast Forward", "Play", "Pause",
220  "Record", "Error", "Usage Selected Indicator", "Usage In Use Indicator", "Usage Multi Mode Indicator", "Indicator On", "Indicator Flash", "Indicator Slow Blink",
221  "Indicator Fast Blink", "Indicator Off", "Flash On Time", "Slow Blink On Time", "Slow Blink Off Time", "Fast Blink On Time", "Fast Blink Off Time", "Usage Indicator Color",
222  "Indicator Red", "Indicator Green", "Indicator Amber", "Generic Indicator", "System Suspend", "External Power Connected", "Indicator Blue", "Indicator Orange",
223  "Good Status", "Warning Status", "RGB LED", "Red LED Channel", "Greed LED Channel", "Blue LED Channel", "LED Intensity", 0,
224  0, 0, 0, 0, 0, 0, 0, 0,
225  "Player Indicator", "Player 1", "Player 2", "Player 3", "Player 4", "Player 5", "Player 6", "Player 7",
226  "Player 8", 0, 0, 0, 0, 0, 0, 0,
227  };
228  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
229  }
230 
231  else if (usagePage == 0x09) // Button
232  {
233  if (usage > 0 && usage <= 0xffff)
234  asprintf(&text, "Button %d", usage);
235  }
236 
237  else if (usagePage == 0x0a) // Ordinal
238  {
239  if (usage > 0 && usage <= 0xffff)
240  asprintf(&text, "Instance %d", usage);
241  }
242 
243  else if (usagePage == 0x0b) // Telephony Device
244  {
245  char *lookup[] = {
246  0, "Phone", "Answering Machine", "Message Controls", "Handset", "Headset", "Telephony Key Pad", "Programmable Button",
247  0, 0, 0, 0, 0, 0, 0, 0,
248  0, 0, 0, 0, 0, 0, 0, 0,
249  0, 0, 0, 0, 0, 0, 0, 0,
250  "Hook Switch", "Flash", "Feature", "Hold", "Redial", "Transfer", "Drop", "Park",
251  "Forward Calls", "Alternate Function", "Line", "Speaker Phone", "Conference", "Ring Enable", "Ring Select", "Phone Mute",
252  "Caller ID", "Send", 0, 0, 0, 0, 0, 0,
253  0, 0, 0, 0, 0, 0, 0, 0,
254  0, 0, 0, 0, 0, 0, 0, 0,
255  0, 0, 0, 0, 0, 0, 0, 0,
256  "Speed Dial", "Store Number", "Recall Number", "Phone Directory", 0, 0, 0, 0,
257  0, 0, 0, 0, 0, 0, 0, 0,
258  0, 0, 0, 0, 0, 0, 0, 0,
259  0, 0, 0, 0, 0, 0, 0, 0,
260  "Voice Mail", "Screen Calls", "Do Not Disturb", "Message", "Answer On/Off", 0, 0, 0,
261  0, 0, 0, 0, 0, 0, 0, 0,
262  0, 0, 0, 0, 0, 0, 0, 0,
263  0, 0, 0, 0, 0, 0, 0, 0,
264  "Inside Dial Tone", "Outside Dial Tone", "Inside Ring Tone", "Outside Ring Tone", "Priority Ring Tone", "Inside Ringback", "Priority Ringback", "Line Busy Tone",
265  "Reorder Tone", "Call Waiting Tone", "Confirmation Tone", "Confirmation Tone", "Tones Off", "Outside Ringback", "Ringer", 0,
266  0, 0, 0, 0, 0, 0, 0, 0,
267  0, 0, 0, 0, 0, 0, 0, 0,
268  "Phone Key 0", "Phone Key 1", "Phone Key 2", "Phone Key 3", "Phone Key 4", "Phone Key 5", "Phone Key 6", "Phone Key 7",
269  "Phone Key 8", "Phone Key 9", "Phone Key Star", "Phone Key Pound", "Phone Key A", "Phone Key B", "Phone Key C", "Phone Key D",
270  "Phone Call History Key", "Phone Caller ID Key", "Phone Settings Key", 0, 0, 0, 0, 0,
271  0, 0, 0, 0, 0, 0, 0, 0,
272  0, 0, 0, 0, 0, 0, 0, 0,
273  0, 0, 0, 0, 0, 0, 0, 0,
274  0, 0, 0, 0, 0, 0, 0, 0,
275  0, 0, 0, 0, 0, 0, 0, 0,
276  "Host Control", "Host Available", "Host Call Active", "Activate Handset Audio", "Ring Type", "Re-dialable Phone Number", 0, 0,
277  "Stop Ring Tone", "PSTN Ring Tone", "Host Ring Tone", "Alert Sound Error", "Alert Sound Confirm", "Alert Sound Notification", "Silent Ring", 0,
278  0, 0, 0, 0, 0, 0, 0, 0,
279  "Email Message Waiting", "Voicemail Message Waiting", "Host Hold", 0, 0, 0, 0, 0,
280  "Incoming Call History Count", "Outgoing Call History Count", "Incoming Call History", "Outgoing Call History", "Phone Locale", 0, 0, 0,
281  0, 0, 0, 0, 0, 0, 0, 0,
282  0, 0, 0, 0, 0, 0, 0, 0,
283  0, 0, 0, 0, 0, 0, 0, 0,
284  0, 0, 0, 0, 0, 0, 0, 0,
285  0, 0, 0, 0, 0, 0, 0, 0,
286  "Phone Time Second", "Phone Time Minute", "Phone Time Hour", "Phone Date Day", "Phone Date Month", "Phone Date Year", "Handset Nickname", "Address Book ID",
287  "Call Duration", "Dual Mode Phone", 0, 0, 0, 0, 0, 0,
288  };
289  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
290  }
291 
292  else if (usagePage == 0x0c) // Consumer
293  {
294  char *lookup[] = {
295  0, "Consumer Control", "Numeric Key Pad", "Programmable Buttons", "Microphone", "Headphone", "Graphic Equalizer", 0,
296  0, 0, 0, 0, 0, 0, 0, 0,
297  0, 0, 0, 0, 0, 0, 0, 0,
298  0, 0, 0, 0, 0, 0, 0, 0,
299  "+10", "+100", "AM/PM", 0, 0, 0, 0, 0,
300  0, 0, 0, 0, 0, 0, 0, 0,
301  "Power", "Reset", "Sleep", "Sleep After", "Sleep Mode", "Illumination", "Function Buttons", 0,
302  0, 0, 0, 0, 0, 0, 0, 0,
303  "Menu", "Menu Pick", "Menu Up", "Menu Down", "Menu Left", "Menu Right", "Menu Escape", "Menu Value Increase",
304  "Menu Value Decrease", 0, 0, 0, 0, 0, 0, 0,
305  0, 0, 0, 0, 0, 0, 0, 0,
306  0, 0, 0, 0, 0, 0, 0, 0,
307  "Data On Screen", "Closed Caption", "Closed Caption Select", "VCR/TV", "Broadcast Mode", "Snapshot", "Still", "Picture-in-Picture Toggle",
308  "Picture-in-Picture Swap", "Red Menu Button", "Green Menu Button", "Blue Menu Button", "Yellow Menu Button", "Aspect", "3D Mode Select", "Display Brightness Increment",
309  "Display Brightness Decrement", "Display Brightness", "Display Backlight Toggle", "Display Set Brightness to Minimum", "Display Set Brightness to Maximum", "Display Set Auto Brightness", 0, 0,
310  0, 0, 0, 0, 0, 0, 0, 0,
311  0, "Assign Selection", "Mode Step", "Recall Last", "Enter Channel", "Order Movie", "Channel", 0,
312  "Media Select Computer", "Media Select TV", "Media Select WWW", "Media Select DVD", "Media Select Telephone", "Media Select Program Guide", "Media Select Video Phone", "Media Select Games",
313  "Media Select Messages", "Media Select CD", "Media Select VCR", "Media Select Tuner", "Quit", "Help", "Media Select Tape", "Media Select Cable",
314  "Media Select Satellite", "Media Select Security", "Media Select Home", "Media Select Call", "Channel Increment", "Channel Decrement", "Media Select SAP", 0,
315  "VCR Plus", "Once", "Daily", "Weekly", "Monthly", 0, 0, 0,
316  0, 0, 0, 0, 0, 0, 0, 0,
317  "Play", "Pause", "Record", "Fast Forward", "Rewind", "Scan Next Track", "Scan Previous Track", "Stop",
318  "Eject", "Random Play", "Select Disc", "Enter Disc", "Repeat", "Tracking", "Track Normal", "Slow Tracking",
319  "Frame Forward", "Frame Back", "Mark", "Clear Mark", "Repeat From Mark", "Return To Mark", "Search Mark Forward", "Search Mark Backwards",
320  "Counter Reset", "Show Counter", "Tracking Increment", "Tracking Decrement", "Stop/Eject", "Play/Pause", "Play/Skip", "Voice Command",
321  0, 0, 0, 0, 0, 0, 0, 0,
322  0, 0, 0, 0, 0, 0, 0, 0,
323  "Volume", "Balance", "Mute", "Bass", "Treble", "Bass Boost", "Surround Mode", "Loudness",
324  "MPX", "Volume Increment", "Volume Decrement", 0, 0, 0, 0, 0,
325  "Speed Select", "Playback Speed", "Standard Play", "Long Play", "Extended Play", "Slow", 0, 0,
326  0, 0, 0, 0, 0, 0, 0, 0,
327  "Fan Enable", "Fan Speed", "Light Enable", "Light Illumination Level", "Climate Control Enable", "Room Temperature", "Security Enable", "Fire Alarm",
328  "Police Alarm", "Proximity", "Motion", "Duress Alarm", "Holdup Alarm", "Medical Alarm", 0, 0,
329  0, 0, 0, 0, 0, 0, 0, 0,
330  0, 0, 0, 0, 0, 0, 0, 0,
331  0, 0, 0, 0, 0, 0, 0, 0,
332  0, 0, 0, 0, 0, 0, 0, 0,
333  0, 0, 0, 0, 0, 0, 0, 0,
334  0, 0, 0, 0, 0, 0, 0, 0,
335  0, 0, 0, 0, 0, 0, 0, 0,
336  0, 0, 0, 0, 0, 0, 0, 0,
337  "Balance Right", "Balance Left", "Bass Increment", "Bass Decrement", "Treble Increment", "Treble Decrement", 0, 0,
338  0, 0, 0, 0, 0, 0, 0, 0,
339  "Speaker System", "Channel Left", "Channel Right", "Channel Center", "Channel Front", "Channel Center Front", "Channel Side", "Channel Surround",
340  "Channel Low Frequency Enhancement", "Channel Top", "Channel Unknown", 0, 0, 0, 0, 0,
341  "Sub-channel", "Sub-channel Increment", "Sub-channel Decrement", "Alternate Audio Increment", "Alternate Audio Decrement", 0, 0, 0,
342  0, 0, 0, 0, 0, 0, 0, 0,
343  "Application Launch Buttons", "AL Launch Button Configuration Tool", "AL Programmable Button Configuration", "AL Consumer Control Configuration", "AL Word Processor", "AL Text Editor", "AL Spreadsheet", "AL Graphics Editor",
344  "AL Presentation App", "AL Database App", "AL Email Reader", "AL Newsreader", "AL Voicemail", "AL Contacts/Address Book", "AL Calendar/Schedule", "AL Task/Project Manager",
345  "AL Log/Journal/Timecard", "AL Checkbook/Finance", "AL Calculator", "AL A/V Capture/Playback", "AL Local Machine Browser", "AL LAN/WAN Browser", "AL Internet Browser", "AL Remote Networking/ISP Connect",
346  "AL Network Conference", "AL Network Chat", "AL Telephony/Dialer", "AL Logon", "AL Logoff", "AL Logon/Logoff", "AL Terminal Lock/Screensaver", "AL Control Panel",
347  "AL Command Line Processor/Run", "AL Process/Task Manager", "AL Select Task/Application", "AL Next Task/Application", "AL Previous Task/Application", "AL Preemptive Halt Task/Application", "AL Integrated Help Center", "AL Documents",
348  "AL Thesaurus", "AL Dictionary", "AL Desktop", "AL Spell Check", "AL Grammar Check", "AL Wireless Status", "AL Keyboard Layout", "AL Virus Protection",
349  "AL Encryption", "AL Screen Saver", "AL Alarms", "AL Clock", "AL File Browser", "AL Power Status", "AL Image Browser", "AL Audio Browser",
350  "AL Movie Browser", "AL Digital Rights Manager", "AL Digital Wallet", 0, "AL Instant Messaging", "AL OEM Features/Tips/Tutorial Browser", "AL OEM Help", "AL Online Community",
351  "AL Entertainment Content Browser", "AL Online Shopping Browser", "AL SmartCard Information/Help", "AL Market Monitor/Finance Browser", "AL Customized Corporate News Browser", "AL Online Activity Browser", "AL Research/Search Browser", "AL Audio Player",
352  "AL Message Status", "AL Contact Sync", 0, 0, 0, 0, 0, 0,
353  0, 0, 0, 0, 0, 0, 0, 0,
354  0, 0, 0, 0, 0, 0, 0, 0,
355  0, 0, 0, 0, 0, 0, 0, 0,
356  0, 0, 0, 0, 0, 0, 0, 0,
357  0, 0, 0, 0, 0, 0, 0, 0,
358  0, 0, 0, 0, 0, 0, 0, 0,
359  "Generic GUI Application Controls", "AC New", "AC Open", "AC Close", "AC Exit", "AC Maximize", "AC Minimize", "AC Save",
360  "AC Print", "AC Properties", "AC Undo", "AC Copy", "AC Cut", "AC Paste", "AC Select All", "AC Find",
361  "AC Find and Replace", "AC Search", "AC Go To", "AC Home", "AC Back", "AC Forward", "AC Stop", "AC Refresh",
362  "AC Previous Link", "AC Next Link", "AC Bookmarks", "AC History", "AC Subscriptions", "AC Zoom In", "AC Zoom Out", "AC Zoom",
363  "AC Full Screen View", "AC Normal View", "AC View Toggle", "AC Scroll Up", "AC Scroll Down", "AC Scroll", "AC Pan Left", "AC Pan Right",
364  "AC Pan", "AC New Window", "AC Tile Horizontally", "AC Tile Vertically", "AC Format", "AC Edit", "AC Bold", "AC Italics",
365  "AC Underline", "AC Strikethrough", "AC Subscript", "AC Superscript", "AC All Caps", "AC Rotate", "AC Resize", "AC Flip horizontal",
366  "AC Flip Vertical", "AC Mirror Horizontal", "AC Mirror Vertical", "AC Font Select", "AC Font Color", "AC Font Size", "AC Justify Left", "AC Justify Center H",
367  "AC Justify Right", "AC Justify Block H", "AC Justify Top", "AC Justify Center V", "AC Justify Bottom", "AC Justify Block V", "AC Indent Decrease", "AC Indent Increase",
368  "AC Numbered List", "AC Restart Numbering", "AC Bulleted List", "AC Promote", "AC Demote", "AC Yes", "AC No", "AC Cancel",
369  "AC Catalog", "AC Buy/Checkout", "AC Add to Cart", "AC Expand", "AC Expand All", "AC Collapse", "AC Collapse All", "AC Print Preview",
370  "AC Paste Special", "AC Insert Mode", "AC Delete", "AC Lock", "AC Unlock", "AC Protect", "AC Unprotect", "AC Attach Comment",
371  "AC Delete Comment", "AC View Comment", "AC Select Word", "AC Select Sentence", "AC Select Paragraph", "AC Select Column", "AC Select Row", "AC Select Table",
372  "AC Select Object", "AC Redo/Repeat", "AC Sort", "AC Sort Ascending", "AC Sort Descending", "AC Filter", "AC Set Clock", "AC View Clock",
373  "AC Select Time Zone", "AC Edit Time Zones", "AC Set Alarm", "AC Clear Alarm", "AC Snooze Alarm", "AC Reset Alarm", "AC Synchronize", "AC Send/Receive",
374  "AC Send To", "AC Reply", "AC Reply All", "AC Forward Msg", "AC Send", "AC Attach File", "AC Upload", "AC Download (Save Target As)",
375  "AC Set Borders", "AC Insert Row", "AC Insert Column", "AC Insert File", "AC Insert Picture", "AC Insert Object", "AC Insert Symbol", "AC Save and Close",
376  "AC Rename", "AC Merge", "AC Split", "AC Distribute Horizontally", "AC Distribute Vertically", 0, 0, 0,
377  "AC Soft Key Left", "AC Soft Key Right", 0, 0, 0, 0, 0, 0,
378  0, 0, 0, 0, 0, "AC Next Keyboard Layout Select", 0, 0,
379  "AC Idle Keep Alive", 0, 0, 0, 0, 0, 0, 0,
380  0, 0, 0, 0, 0, 0, 0, 0,
381  "Extended Keyboard Attributes Collection", "Keyboard Form Factor", "Keyboard Key Type", "Keyboard Physical Layout", "Vendor-Specific Keyboard Physical Layout", "Keyboard IETF Language Tag Index", "Implemented Keyboard Input Assist Controls", "Keyboard Input Assist Previous",
382  "Keyboard Input Assist Next", "Keyboard Input Assist Previous Group", "Keyboard Input Assist Next Group", "Keyboard Input Assist Accept", "Keyboard Input Assist Cancel", 0, 0, 0,
383  0, 0, 0, 0, 0, 0, 0, 0,
384  0, 0, 0, 0, 0, 0, 0, 0,
385  0, 0, 0, 0, 0, 0, 0, 0,
386  0, 0, 0, 0, 0, 0, 0, 0,
387  0, 0, 0, 0, 0, 0, 0, 0,
388  0, 0, 0, 0, 0, 0, 0, 0,
389  0, 0, 0, 0, 0, 0, 0, 0,
390  0, 0, 0, 0, 0, 0, 0, 0,
391  0, 0, 0, 0, 0, 0, 0, 0,
392  0, 0, 0, 0, 0, 0, 0, 0,
393  0, 0, 0, 0, 0, 0, 0, 0,
394  0, 0, 0, 0, 0, 0, 0, 0,
395  0, 0, 0, 0, 0, 0, 0, 0,
396  0, 0, 0, 0, 0, 0, 0, 0,
397  0, 0, 0, 0, 0, 0, 0, 0,
398  0, 0, 0, 0, 0, 0, 0, 0,
399  0, 0, 0, 0, 0, 0, 0, 0,
400  0, 0, 0, 0, 0, 0, 0, 0,
401  0, 0, 0, 0, 0, 0, 0, 0,
402  0, 0, 0, 0, 0, 0, 0, 0,
403  0, 0, 0, 0, 0, 0, 0, 0,
404  0, 0, 0, 0, 0, 0, 0, 0,
405  0, 0, 0, 0, 0, 0, 0, 0,
406  0, 0, 0, 0, 0, 0, 0, 0,
407  0, 0, 0, 0, 0, 0, 0, 0,
408  0, 0, 0, 0, 0, 0, 0, 0,
409  0, 0, 0, 0, 0, 0, 0, 0,
410  0, 0, 0, 0, 0, 0, 0, 0,
411  0, 0, 0, 0, 0, 0, 0, 0,
412  0, 0, 0, 0, 0, 0, 0, 0,
413  0, 0, 0, 0, 0, 0, 0, 0,
414  0, 0, 0, 0, 0, 0, 0, 0,
415  0, 0, 0, 0, 0, 0, 0, 0,
416  0, 0, 0, 0, 0, 0, 0, 0,
417  0, 0, 0, 0, 0, 0, 0, 0,
418  0, 0, 0, 0, 0, 0, 0, 0,
419  0, 0, 0, 0, 0, 0, 0, 0,
420  0, 0, 0, 0, 0, 0, 0, 0,
421  0, 0, 0, 0, 0, 0, 0, 0,
422  0, 0, 0, 0, 0, 0, 0, 0,
423  0, 0, 0, 0, 0, 0, 0, 0,
424  0, 0, 0, 0, 0, 0, 0, 0,
425  0, 0, 0, 0, 0, 0, 0, 0,
426  0, 0, 0, 0, 0, 0, 0, 0,
427  0, 0, 0, 0, 0, 0, 0, 0,
428  0, 0, 0, 0, 0, 0, 0, 0,
429  0, 0, 0, 0, 0, 0, 0, 0,
430  0, 0, 0, 0, 0, 0, 0, 0,
431  0, 0, 0, 0, 0, 0, 0, 0,
432  0, 0, 0, 0, 0, 0, 0, 0,
433  0, 0, 0, 0, 0, 0, 0, 0,
434  0, 0, 0, 0, 0, 0, 0, 0,
435  0, 0, 0, 0, 0, 0, 0, 0,
436  0, 0, 0, 0, 0, 0, 0, 0,
437  0, 0, 0, 0, 0, 0, 0, 0,
438  0, 0, 0, 0, 0, 0, 0, 0,
439  0, 0, 0, 0, 0, 0, 0, 0,
440  0, 0, 0, 0, 0, 0, 0, 0,
441  0, 0, 0, 0, 0, 0, 0, 0,
442  0, 0, 0, 0, 0, 0, 0, 0,
443  0, 0, 0, 0, 0, 0, 0, 0,
444  0, 0, 0, 0, 0, 0, 0, 0,
445  0, 0, 0, 0, 0, 0, 0, 0,
446  0, 0, 0, 0, 0, 0, 0, 0,
447  0, 0, 0, 0, 0, 0, 0, 0,
448  0, 0, 0, 0, 0, 0, 0, 0,
449  0, 0, 0, 0, 0, 0, 0, 0,
450  0, 0, 0, 0, 0, 0, 0, 0,
451  0, 0, 0, 0, 0, 0, 0, 0,
452  0, 0, 0, 0, 0, 0, 0, 0,
453  "Contact Edited", "Contact Added", "Contact Record Active", "Contact Index", "Contact Nickname", "Contact First Name", "Contact Last Name", "Contact Full Name",
454  "Contact Phone Number Personal", "Contact Phone Number Business", "Contact Phone Number Mobile", "Contact Phone Number Pager", "Contact Phone Number Fax", "Contact Phone Number Other", "Contact Email Personal", "Contact Email Business",
455  "Contact Email Other", "Contact Email Main", "Contact Speed Dial Number", "Contact Status Flag", "Contact Misc.", 0, 0, 0,
456  };
457  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
458  }
459 
460  else if (usagePage == 0x0d) // Digitizers
461  {
462  char *lookup[] = {
463  0, "Digitizer", "Pen", "Light Pen", "Touch Screen", "Touch Pad", "White Board", "Coordinate Measuring",
464  "3D Digitizer", "Stereo Plotter", "Articulated Arm", "Armature", "Multiple Point Digitizer", "Free Space Wand", "Device configuration", 0,
465  0, 0, 0, 0, 0, 0, 0, 0,
466  0, 0, 0, 0, 0, 0, 0, 0,
467  "Stylus", "Puck", "Finger", "Device settings", 0, 0, 0, 0,
468  0, 0, 0, 0, 0, 0, 0, 0,
469  "Tip Pressure", "Barrel Pressure", "In Range", "Touch", "Untouch", "Tap", "Quality", "Data Valid",
470  "Transducer Index", "Tablet Function Keys", "Program Change Keys", "Battery Strength", "Invert", "X Tilt", "Y Tilt", "Azimuth",
471  "Altitude", "Twist", "Tip Switch", "Secondary Tip Switch", "Barrel Switch", "Eraser", "Tablet Pick", "Touch Valid",
472  "Width", "Height", 0, 0, 0, 0, 0, 0,
473  0, "Contact identifier", "Device mode", "Device identifier", "Contact count", "Contact count maximum", 0, 0,
474  0, 0, "Secondary Barrel Switch", "Transducer Serial Number", "Preferred Color", 0, 0, 0,
475  };
476  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
477  }
478 
479  else if (usagePage == 0x14) // Alphanumeric Display / Auxiliary Display
480  {
481  char *lookup[] = {
482  0, "Alphanumeric Display", "Bitmapped/Auxiliary Display", 0, 0, 0, 0, 0,
483  0, 0, 0, 0, 0, 0, 0, 0,
484  0, 0, 0, 0, 0, 0, 0, 0,
485  0, 0, 0, 0, 0, 0, 0, 0,
486  "Display Attributes Report", "ASCII Character Set", "Data Read Back", "Font Read Back", "Display Control Report", "Clear Display", "Display Enable", "Screen Saver Delay",
487  "Screen Saver Enable", "Vertical Scroll", "Horizontal Scroll", "Character Report", "Display Data", "Display Status", "Stat Not Ready", "Stat Ready",
488  "Err Not a loadable character", "Err Font data cannot be read", "Cursor Position Report", "Row", "Column", "Rows", "Columns", "Cursor Pixel Positioning",
489  "Cursor Mode", "Cursor Enable", "Cursor Blink", "Font Report", "Font Data", "Character Width", "Character Height", "Character Spacing Horizontal",
490  "Character Spacing Vertical", "Unicode Character Set", "Font 7-Segment", "7-Segment Direct Map", "Font 14-Segment", "14-Segment Direct Map", "Display Brightness", "Display Contrast",
491  "Character Attribute", "Attribute Readback", "Attribute Data", "Char Attr Enhance", "Char Attr Underline", "Char Attr Blink", 0, 0,
492  0, 0, 0, 0, 0, 0, 0, 0,
493  0, 0, 0, 0, 0, 0, 0, 0,
494  0, 0, 0, 0, 0, 0, 0, 0,
495  0, 0, 0, 0, 0, 0, 0, 0,
496  0, 0, 0, 0, 0, 0, 0, 0,
497  0, 0, 0, 0, 0, 0, 0, 0,
498  "Bitmap Size X", "Bitmap Size Y", "Max Blit Size", "Bit Depth Format", "Display Orientation", "Palette Report", "Palette Data Size", "Palette Data Offset",
499  "Palette Data", "Blit Report", "Blit Rectangle X1", "Blit Rectangle Y1", "Blit Rectangle X2", "Blit Rectangle Y2", "Blit Data", "Soft Button",
500  "Soft Button ID", "Soft Button Side", "Soft Button Offset 1", "Soft Button Offset 2", "Soft Button Report", 0, 0, 0,
501  0, 0, 0, 0, 0, 0, 0, 0,
502  0, 0, 0, 0, 0, 0, 0, 0,
503  0, 0, 0, 0, 0, 0, 0, 0,
504  0, 0, 0, 0, 0, 0, 0, 0,
505  0, 0, 0, 0, 0, 0, 0, 0,
506  0, 0, "Soft Keys", 0, 0, 0, 0, 0,
507  0, 0, 0, 0, "Display Data Extensions", 0, 0, "Character Mapping",
508  0, 0, 0, 0, 0, 0, 0, 0,
509  0, 0, 0, 0, 0, "Unicode Equivalent", 0, "Character Page Mapping",
510  0, 0, 0, 0, 0, 0, 0, 0,
511  0, 0, 0, 0, 0, 0, 0, "Request Report",
512  };
513  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
514  }
515 
516  else if (usagePage == 0x20) // Sensor
517  {
518  char *lookup[] = {
519  0, "Sensor", 0, 0, 0, 0, 0, 0,
520  0, 0, 0, 0, 0, 0, 0, 0,
521  "Biometric", "Biometric: Human Presence", "Biometric: Human Proximity", "Biometric: Human Touch", 0, 0, 0, 0,
522  0, 0, "Property: Maximum FIFO Events", "Property: Report Latency", 0, 0, 0, 0,
523  "Electrical", "Electrical: Capacitance", "Electrical: Current", "Electrical: Power", "Electrical: Inductance", "Electrical: Resistance", "Electrical: Voltage", "Electrical: Potentiometer",
524  "Electrical: Frequency", "Electrical: Period", 0, 0, 0, 0, 0, 0,
525  "Environmental", "Environmental: Atmospheric Pressure", "Environmental: Humidity", "Environmental: Temperature", "Environmental: Wind Direction", "Environmental: Wind Speed", 0, 0,
526  0, 0, 0, 0, 0, 0, 0, 0,
527  "Light", "Light: Ambient Light", "Light: Consumer Infrared", 0, 0, 0, 0, 0,
528  0, 0, 0, 0, 0, 0, 0, 0,
529  "Location", "Location: Broadcast", "Location: Dead Reckoning", "Location: GPS (Global Positioning System)", "Location: Lookup", "Location: Other", "Location: Static", "Location: Triangulation",
530  0, 0, 0, 0, 0, 0, 0, 0,
531  "Mechanical", "Mechanical: Boolean Switch", "Mechanical: Boolean Switch Array", "Mechanical: Multivalue Switch", "Mechanical: Force", "Mechanical: Pressure", "Mechanical: Strain", "Mechanical: Weight",
532  "Mechanical: Haptic Vibrator", "Mechanical: Hall Effect Switch", 0, 0, 0, 0, 0, 0,
533  "Motion", "Motion: Accelerometer 1D", "Motion: Accelerometer 2D", "Motion: Accelerometer 3D", "Motion: Gyrometer 1D", "Motion: Gyrometer 2D", "Motion: Gyrometer 3D", "Motion: Motion Detector",
534  "Motion: Speedometer", "Motion: Accelerometer", "Motion: Gyrometer", 0, 0, 0, 0, 0,
535  "Orientation", "Orientation: Compass 1D", "Orientation: Compass 2D", "Orientation: Compass 3D", "Orientation: Inclinometer 1D", "Orientation: Inclinometer 2D", "Orientation: Inclinometer 3D", "Orientation: Distance 1D",
536  "Orientation: Distance 2D", "Orientation: Distance 3D", "Orientation: Device Orientation", "Orientation: Compass", "Orientation: Inclinometer", "Orientation: Distance", 0, 0,
537  "Scanner", "Scanner: Barcode", "Scanner: RFID", "Scanner: NFC", 0, 0, 0, 0,
538  0, 0, 0, 0, 0, 0, 0, 0,
539  "Time", "Time: Alarm Timer", "Time: Real Time Clock", 0, 0, 0, 0, 0,
540  0, 0, 0, 0, 0, 0, 0, 0,
541  0, 0, 0, 0, 0, 0, 0, 0,
542  0, 0, 0, 0, 0, 0, 0, 0,
543  0, 0, 0, 0, 0, 0, 0, 0,
544  0, 0, 0, 0, 0, 0, 0, 0,
545  0, 0, 0, 0, 0, 0, 0, 0,
546  0, 0, 0, 0, 0, 0, 0, 0,
547  "Other", "Other: Custom", "Other: Generic", "Other: Generic Enumerator", 0, 0, 0, 0,
548  0, 0, 0, 0, 0, 0, 0, 0,
549  };
550  uint32_t usageWithoutModifier = usage & 0xff;
551  text = usageWithoutModifier < sizeof(lookup)/sizeof(char *) ? (lookup[usageWithoutModifier] ? strdup(lookup[usageWithoutModifier]) : 0) : 0;
552  }
553 
554  else if (usagePage == 0x40) // Medical Instrument
555  {
556  char *lookup[] = {
557  0, "Medical Ultrasound", 0, 0, 0, 0, 0, 0,
558  0, 0, 0, 0, 0, 0, 0, 0,
559  0, 0, 0, 0, 0, 0, 0, 0,
560  0, 0, 0, 0, 0, 0, 0, 0,
561  "VCR/Acquisition", "Freeze/Thaw", "Clip Store", "Update", "Next", "Save", "Print", "Microphone Enable",
562  0, 0, 0, 0, 0, 0, 0, 0,
563  0, 0, 0, 0, 0, 0, 0, 0,
564  0, 0, 0, 0, 0, 0, 0, 0,
565  "Cine", "Transmit Power", "Volume", "Focus", "Depth", 0, 0, 0,
566  0, 0, 0, 0, 0, 0, 0, 0,
567  0, 0, 0, 0, 0, 0, 0, 0,
568  0, 0, 0, 0, 0, 0, 0, 0,
569  "Soft Step - Primary", "Soft Step - Secondary", 0, 0, 0, 0, 0, 0,
570  0, 0, 0, 0, 0, 0, 0, 0,
571  "Depth Gain Compensation", 0, 0, 0, 0, 0, 0, 0,
572  0, 0, 0, 0, 0, 0, 0, 0,
573  "Zoom Select", "Zoom Adjust", "Spectral Doppler Mode Select", "Spectral Doppler Adjust", "Color Doppler Mode Select", "Color Doppler Adjust", "Motion Mode Select", "Motion Mode Adjust",
574  "2-D Mode Select", "2-D Mode Adjust", 0, 0, 0, 0, 0, 0,
575  0, 0, 0, 0, 0, 0, 0, 0,
576  0, 0, 0, 0, 0, 0, 0, 0,
577  "Soft Control Select", "Soft Control Adjust", 0, 0, 0, 0, 0, 0,
578  };
579  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
580  }
581 
582  else if (usagePage == 0x84) // Power Device
583  {
584  char *lookup[] = {
585  0, "iName", "PresentStatus", "ChangedStatus", "UPS", "PowerSupply", 0, 0,
586  0, 0, 0, 0, 0, 0, 0, 0,
587  "BatterySystem", "BatterySystemID", "Battery", "BatteryID", "Charger", "ChargerID", "PowerConverter", "PowerConverterID",
588  "OutletSystem", "OutletSystemID", "Input", "InputID", "Output", "OutputID", "Flow", "FlowID",
589  "Outlet", "OutletID", "Gang", "GangID", "Sink", "SinkID", 0, 0,
590  0, 0, 0, 0, 0, 0, 0, 0,
591  "Voltage", "Current", "Frequency", "ApparentPower", "ActivePower", "PercentLoad", "Temperature", "Humidity",
592  "BadCount", 0, 0, 0, 0, 0, 0, 0,
593  "ConfigVoltage", "ConfigCurrent", "ConfigFrequency", "ConfigApparentPower", "ConfigActivePower", "ConfigPercentLoad", "ConfigTemperature", "ConfigHumidity",
594  0, 0, 0, 0, 0, 0, 0, 0,
595  "SwitchOnControl", "SwitchOffControl", "ToggleControl", "LowVoltageTransfer", "HighVoltageTransfer", "DelayBeforeReboot", "DelayBeforeStartup", "DelayBeforeShutdown",
596  "Test", "ModuleReset", "AudibleAlarmControl", 0, 0, 0, 0, 0,
597  "Present", "Good", "InternalFailure", "VoltageOutOfRange", "FrequencyOutOfRange", "Overload", "OverCharged", "OverTemperature",
598  "ShutdownRequested", "ShutdownImminent", 0, "SwitchOn/Off", "Switchable", "Used", "Boost", "Buck",
599  "Initialized", "Tested", "AwaitingPower", "CommunicationLost", 0, 0, 0, 0,
600  0, 0, 0, 0, 0, 0, 0, 0,
601  0, 0, 0, 0, 0, 0, 0, 0,
602  0, 0, 0, 0, 0, 0, 0, 0,
603  0, 0, 0, 0, 0, 0, 0, 0,
604  0, 0, 0, 0, 0, 0, 0, 0,
605  0, 0, 0, 0, 0, 0, 0, 0,
606  0, 0, 0, 0, 0, 0, 0, 0,
607  0, 0, 0, 0, 0, 0, 0, 0,
608  0, 0, 0, 0, 0, 0, 0, 0,
609  0, 0, 0, 0, 0, 0, 0, 0,
610  0, 0, 0, 0, 0, 0, 0, 0,
611  0, 0, 0, 0, 0, 0, 0, 0,
612  0, 0, 0, 0, 0, 0, 0, 0,
613  0, 0, 0, 0, 0, 0, 0, 0,
614  0, 0, 0, 0, 0, 0, 0, 0,
615  0, 0, 0, 0, 0, "iManufacturer", "iProduct", "iSerialNumber",
616  };
617  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
618  }
619 
620  else if (usagePage == 0x85) // Battery System
621  {
622  char *lookup[] = {
623  0, "SMBBatteryMode", "SMBBatteryStatus", "SMBAlarmWarning", "SMBChargerMode", "SMBChargerStatus", "SMBChargerSpecInfo", "SMBSelectorState",
624  "SMBSelectorPresets", "SMBSelectorInfo", 0, 0, 0, 0, 0, 0,
625  "OptionalMfgFunction1", "OptionalMfgFunction2", "OptionalMfgFunction3", "OptionalMfgFunction4", "OptionalMfgFunction5", "ConnectionToSMBus", "OutputConnection", "ChargerConnection",
626  "BatteryInsertion", "Usenext", "OKToUse", "BatterySupported", "SelectorRevision", "ChargingIndicator", 0, 0,
627  0, 0, 0, 0, 0, 0, 0, 0,
628  "ManufacturerAccess", "RemainingCapacityLimit", "RemainingTimeLimit", "AtRate", "CapacityMode", "BroadcastToCharger", "PrimaryBattery", "ChargeController",
629  0, 0, 0, 0, 0, 0, 0, 0,
630  0, 0, 0, 0, 0, 0, 0, 0,
631  "TerminateCharge", "TerminateDischarge", "BelowRemainingCapacityLimit", "RemainingTimeLimitExpired", "Charging", "Discharging", "FullyCharged", "FullyDischarged",
632  "ConditioningFlag", "AtRateOK", "SMBErrorCode", "NeedReplacement", 0, 0, 0, 0,
633  0, 0, 0, 0, 0, 0, 0, 0,
634  0, 0, 0, 0, 0, 0, 0, 0,
635  "AtRateTimeToFull", "AtRateTimeToEmpty", "AverageCurrent", "Maxerror", "RelativeStateOfCharge", "AbsoluteStateOfCharge", "RemainingCapacity", "FullChargeCapacity",
636  "RunTimeToEmpty", "AverageTimeToEmpty", "AverageTimeToFull", "CycleCount", 0, 0, 0, 0,
637  0, 0, 0, 0, 0, 0, 0, 0,
638  0, 0, 0, 0, 0, 0, 0, 0,
639  "BattPackModelLevel", "InternalChargeController", "PrimaryBatterySupport", "DesignCapacity", "SpecificationInfo", "ManufacturerDate", "SerialNumber", "iManufacturerName",
640  "iDevicename", "iDeviceChemistry", "ManufacturerData", "Rechargeable", "WarningCapacityLimit", "CapacityGranularity1", "CapacityGranularity2", "iOEMInformation",
641  0, 0, 0, 0, 0, 0, 0, 0,
642  0, 0, 0, 0, 0, 0, 0, 0,
643  0, 0, 0, 0, 0, 0, 0, 0,
644  0, 0, 0, 0, 0, 0, 0, 0,
645  0, 0, 0, 0, 0, 0, 0, 0,
646  0, 0, 0, 0, 0, 0, 0, 0,
647  "InhibitCharge", "EnablePolling", "ResetToZero", 0, 0, 0, 0, 0,
648  0, 0, 0, 0, 0, 0, 0, 0,
649  "ACPresent", "BatteryPresent", "PowerFail", "AlarmInhibited", "ThermistorUnderRange", "ThermistorHot", "ThermistorCold", "ThermistorOverRange",
650  "VoltageOutOfRange", "CurrentOutOfRange", "CurrentNotRegulated", "VoltageNotRegulated", "MasterMode", 0, 0, 0,
651  0, 0, 0, 0, 0, 0, 0, 0,
652  0, 0, 0, 0, 0, 0, 0, 0,
653  "ChargerSelectorSupport", "ChargerSpec", "Level2", "Level3", 0, 0, 0, 0,
654  0, 0, 0, 0, 0, 0, 0, 0,
655  };
656  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
657  }
658 
659  else if (usagePage == 0x90) // Camera Control
660  {
661  char *lookup[] = {
662  0, 0, 0, 0, 0, 0, 0, 0,
663  0, 0, 0, 0, 0, 0, 0, 0,
664  0, 0, 0, 0, 0, 0, 0, 0,
665  0, 0, 0, 0, 0, 0, 0, 0,
666  "Camera Auto-focus", "Camera Shutter", 0, 0, 0, 0, 0, 0,
667  };
668  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
669  }
670 
671  else if (usagePage == 0xff) // Fn key on Apple Keyboards
672  {
673  char *lookup[] = {
674  0, 0, 0, "Fn key", 0, 0, 0, 0,
675  };
676  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
677  }
678 
679  else if (usagePage == 0xf1d0) // Fast IDentity Online Alliance
680  {
681  char *lookup[] = {
682  0, "U2F Authenticator Device", 0, 0, 0, 0, 0, 0,
683  0, 0, 0, 0, 0, 0, 0, 0,
684  0, 0, 0, 0, 0, 0, 0, 0,
685  0, 0, 0, 0, 0, 0, 0, 0,
686  "Input Report Data", "Output Report Data", 0, 0, 0, 0, 0, 0,
687  };
688  text = usage < sizeof(lookup)/sizeof(char *) ? (lookup[usage] ? strdup(lookup[usage]) : 0) : 0;
689  }
690 
691  else if (usagePage >= 0xff00 && usagePage <= 0xffff)
692  asprintf(&text, "Vendor-defined (%04x:%04x)", usagePage, usage);
693 
694  if (!text)
695  asprintf(&text, "unknown (%04x:%04x)", usagePage, usage);
696 
697  return text;
698 }