| 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | // SPDX-FileCopyrightText: 2025 James Turner <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <cstdint> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace HID { |
| 10 | // clang-format off |
| 11 | enum class UsagePage |
| 12 | { |
| 13 | Undefined = 0x00, |
| 14 | GenericDesktop = 0x01, |
| 15 | Simulation = 0x02, |
| 16 | VR = 0x03, |
| 17 | Sport =0x04, |
| 18 | Game =0x05, |
| 19 | GenericDevice = 0x06, |
| 20 | Keyboard = 0x07, |
| 21 | LEDs = 0x08, |
| 22 | Button = 0x09, |
| 23 | Ordinal = 0x0A, |
| 24 | Telephony = 0x0B, |
| 25 | Consumer = 0x0C, |
| 26 | Digitizer = 0x0D, |
| 27 | // reserved 0x0E |
| 28 | PID = 0x0F, |
| 29 | Unicode = 0x10, |
| 30 | AlphanumericDisplay = 0x14, |
| 31 | MedicalInstruments = 0x40, |
| 32 | BarCodeScanner = 0x8C, |
| 33 | MagneticStripeReadingDevice = 0x8E, |
| 34 | CameraControl = 0x90, |
| 35 | Arcade = 0x91, |
| 36 | VendorDefinedStart = 0xFF00 |
| 37 | }; |
| 38 | |
| 39 | enum SimulationUsage |
| 40 | { |
| 41 | SC_FlightSimulationDevice = 0x01, |
| 42 | SC_AutomobileSimulationDevice = 0x02, |
| 43 | SC_TankSimulationDevice = 0x03, |
| 44 | SC_SpaceShipSimulationDevice = 0x04, |
| 45 | SC_SubmarineSimulationDevice = 0x05, |
| 46 | SC_SailingSimulationDevice = 0x06, |
| 47 | SC_MotorcycleSimulationDevice = 0x07, |
| 48 | SC_SportsSimulationDevice = 0x08, |
| 49 | SC_AirplaneSimulationDevice = 0x09, |
| 50 | SC_HelicopterSimulationDevice = 0x0A, |
| 51 | SC_MagicCarpetSimulationDevice = 0x0B, |
| 52 | SC_BycicleSimulationDevice = 0x0C, |
| 53 | SC_FlightControlStick = 0x20, |
| 54 | SC_FlightStick = 0x21, |
| 55 | SC_CyclicControl = 0x22, |
| 56 | SC_CyclicTrim = 0x23, |
| 57 | SC_FlightYoke = 0x24, |
| 58 | SC_TrackControl = 0x25, |
| 59 | SC_Aileron = 0xB0, |
| 60 | SC_AileronTrim = 0xB1, |
| 61 | SC_AntiTorqueControl = 0xB2, |
| 62 | SC_AutopilotEnable = 0xB3, |
| 63 | SC_ChaffRelease = 0xB4, |
| 64 | SC_CollectiveControl = 0xB5, |
| 65 | SC_DiveBrake = 0xB6, |
| 66 | SC_ElectronicCountermeasures = 0xB7, |
| 67 | SC_Elevator = 0xB8, |
| 68 | SC_ElevatorTrim = 0xB9, |
| 69 | SC_Rudder = 0xBA, |
| 70 | SC_Throttle = 0xBB, |
| 71 | SC_FlightCommunications = 0xBC, |
| 72 | SC_FlareRelease = 0xBD, |
| 73 | SC_LandingGear = 0xBE, |
| 74 | SC_ToeBrake = 0xBF, |
| 75 | SC_Trigger = 0xC0, |
| 76 | SC_WeaponsArm = 0xC1, |
| 77 | SC_WeaponsSelect = 0xC2, |
| 78 | SC_WingFlaps = 0xC3, |
| 79 | SC_Accelerator = 0xC4, |
| 80 | SC_Brake = 0xC5, |
| 81 | SC_Clutch = 0xC6, |
| 82 | SC_Shifter = 0xC7, |
| 83 | SC_Steering = 0xC8, |
| 84 | SC_TurretDirection = 0xC9, |
| 85 | SC_BarrelElevation = 0xCA, |
| 86 | SC_DivePlane = 0xCB, |
| 87 | SC_Ballast = 0xCC, |
| 88 | SC_BicycleCrank = 0xCD, |
| 89 | SC_HandleBars= 0xCE, |
| 90 | SC_FrontBrake = 0xCF, |
| 91 | SC_RearBrake = 0xD0 |
| 92 | |
| 93 | }; |
| 94 | |
| 95 | |
| 96 | enum GenericDesktopUsage |
| 97 | { |
| 98 | // generic desktop section |
| 99 | GD_Undefined= 0x00, |
| 100 | GD_Pointer = 0x01, |
| 101 | GD_Mouse = 0x02, |
| 102 | GD_Reserved03 = 0x03, |
| 103 | GD_Joystick = 0x04, |
| 104 | GD_GamePad = 0x05, |
| 105 | GD_Keyboard = 0x06, |
| 106 | GD_Keypad = 0x07, |
| 107 | GD_MultiAxisController = 0x08, |
| 108 | GD_TabletPCSysCtrls = 0x09, |
| 109 | GD_WaterCoolingDevice = 0x0A, |
| 110 | GD_ComputerChassisDevice = 0x0B, |
| 111 | GD_WirelessRadioControls = 0x0C, |
| 112 | GD_PortableDeviceControl = 0x0D, |
| 113 | GD_SystemMultiAxisController = 0x0E, |
| 114 | GD_SpatialController = 0x0F, |
| 115 | GD_AssistiveControl = 0x10, |
| 116 | GD_DeviceDock = 0x11, |
| 117 | GD_DockableDevice = 0x12, |
| 118 | GD_CallStateManagementControl = 0x13, |
| 119 | GD_Reserved14 = 0x14, |
| 120 | GD_Reserved15 = 0x15, |
| 121 | GD_Reserved16 = 0x16, |
| 122 | GD_Reserved17 = 0x17, |
| 123 | GD_Reserved18 = 0x18, |
| 124 | GD_Reserved19 = 0x19, |
| 125 | GD_Reserved1A = 0x1A, |
| 126 | GD_Reserved1B = 0x1B, |
| 127 | GD_Reserved1C = 0x1C, |
| 128 | GD_Reserved1D = 0x1D, |
| 129 | GD_Reserved1E = 0x1E, |
| 130 | GD_Reserved1F = 0x1F, |
| 131 | GD_Reserved20 = 0x20, |
| 132 | GD_Reserved21 = 0x21, |
| 133 | GD_Reserved22 = 0x22, |
| 134 | GD_Reserved23 = 0x23, |
| 135 | GD_Reserved24 = 0x24, |
| 136 | GD_Reserved25 = 0x25, |
| 137 | GD_Reserved26 = 0x26, |
| 138 | GD_Reserved27 = 0x27, |
| 139 | GD_Reserved28 = 0x28, |
| 140 | GD_Reserved29 = 0x29, |
| 141 | GD_Reserved2A = 0x2A, |
| 142 | GD_Reserved2B = 0x2B, |
| 143 | GD_Reserved2C = 0x2C, |
| 144 | GD_Reserved2D = 0x2D, |
| 145 | GD_Reserved2E = 0x2E, |
| 146 | GD_Reserved2F = 0x2F, |
| 147 | GD_X = 0x30, |
| 148 | GD_Y = 0x31, |
| 149 | GD_Z = 0x32, |
| 150 | GD_Rx = 0x33, |
| 151 | GD_Ry = 0x34, |
| 152 | GD_Rz = 0x35, |
| 153 | GD_Slider = 0x36, |
| 154 | GD_Dial = 0x37, |
| 155 | GD_Wheel = 0x38, |
| 156 | GD_Hatswitch = 0x39, |
| 157 | GD_CountedBuffer= 0x3A, |
| 158 | GD_ByteCount = 0x3B, |
| 159 | GD_MotionWakeUp = 0x3C, |
| 160 | GD_Start = 0x3D, |
| 161 | GD_Select = 0x3E, |
| 162 | GD_Reserved3F = 0x3F, |
| 163 | GD_Vx = 0x40, |
| 164 | GD_Vy = 0x41, |
| 165 | GD_Vz = 0x42, |
| 166 | GD_Vbrx = 0x43, |
| 167 | GD_Vbry = 0x44, |
| 168 | GD_Vbrz = 0x45, |
| 169 | GD_Vno = 0x46, |
| 170 | GD_FeatureNotification = 0x47, |
| 171 | GD_ResolutionMultiplier = 0x48, |
| 172 | GD_Qx = 0x49, |
| 173 | GD_Qy = 0x4A, |
| 174 | GD_Qz = 0x4B, |
| 175 | GD_Qw = 0x4C, |
| 176 | GD_SystemControl = 0x80, |
| 177 | GD_SystemPowerDown = 0x81, |
| 178 | GD_SystemSleep = 0x82, |
| 179 | GD_SystemWakeUp = 0x83, |
| 180 | GD_SystemContextMenu = 0x84, |
| 181 | GD_SystemMainMenu = 0x85, |
| 182 | GD_SystemAppMenu = 0x86, |
| 183 | GD_SystemMenuHelp = 0x87, |
| 184 | GD_SystemMenuExit = 0x88, |
| 185 | GD_SystemMenuSelect = 0x89, |
| 186 | GD_SystemMenuRight = 0x8A, |
| 187 | GD_SystemMenuLeft = 0x8B, |
| 188 | GD_SystemMenuUp= 0x8C, |
| 189 | GD_SystemMenuDown = 0x8D, |
| 190 | GD_SystemColdRestart = 0x8E, |
| 191 | GD_SystemWarmRestart = 0x8F, |
| 192 | GD_DpadUp = 0x90, |
| 193 | GD_DpadDown = 0x91, |
| 194 | GD_DpadRight = 0x92, |
| 195 | GD_DpadLeft = 0x93, |
| 196 | GD_IndexTrigger = 0x94, |
| 197 | GD_PalmTrigger = 0x95, |
| 198 | GD_Thumbstick = 0x96, |
| 199 | GD_SystemFunctionShift = 0x97, |
| 200 | GD_SystemFunctionShiftLock = 0x98, |
| 201 | GD_SystemFunctionShiftLockIndicator = 0x99, |
| 202 | GD_SystemDismissNotification = 0x9A, |
| 203 | GD_SystemDoNotDisturb = 0x9B, |
| 204 | GD_SystemDock = 0xA0, |
| 205 | GD_SystemUndock = 0xA1, |
| 206 | GD_SystemSetup = 0xA2, |
| 207 | GD_SystemBreak = 0xA3, |
| 208 | GD_SystemDebuggerBreak = 0xA4, |
| 209 | GD_ApplicationBreak = 0xA5, |
| 210 | GD_ApplicationDebuggerBreak = 0xA6, |
| 211 | GD_SystemSpeakerMute = 0xA7, |
| 212 | GD_SystemHibernate = 0xA8, |
| 213 | GD_SystemMicrophoneMute = 0xA9, |
| 214 | GD_SystemDisplayInvert = 0xB0, |
| 215 | GD_SystemDisplayInternal = 0xB1, |
| 216 | GD_SystemDisplayExternal = 0xB2, |
| 217 | GD_SystemDisplayBoth = 0xB3, |
| 218 | GD_SystemDisplayDual = 0xB4, |
| 219 | GD_SystemDisplayToggleIntExtMode = 0xB5, |
| 220 | GD_SystemDisplaySwapPrimarySecondary = 0xB6, |
| 221 | GD_SystemDisplayToggleLCDAutoscale = 0xB7, |
| 222 | GD_SensorZone = 0xC0, |
| 223 | GD_RPM= 0xC1, |
| 224 | GD_CoolantLevel = 0xC2, |
| 225 | GD_CoolantCriticalLevel = 0xC3, |
| 226 | GD_CoolantPump = 0xC4, |
| 227 | GD_ChassisEnclosure = 0xC5, |
| 228 | GD_WirelessRadioButton = 0xC6, |
| 229 | GD_WirelessRadioLED = 0xC7, |
| 230 | GD_WirelessRadioSliderSwitch = 0xC8, |
| 231 | GD_SystemDisplayRotationLockButton = 0xC9, |
| 232 | GD_SystemDisplayRotationLockSliderSwitch = 0xCA, |
| 233 | GD_ControlEnable = 0xCB, |
| 234 | GD_DockableDeviceUniqueID = 0xD0, |
| 235 | GD_DockableDeviceVendorID = 0xD1, |
| 236 | GD_DockableDevicePrimaryUsagePage = 0xD2, |
| 237 | GD_DockableDevicePrimaryUsageID = 0xD3, |
| 238 | GD_DockableDeviceDockingState = 0xD4, |
| 239 | GD_DockableDeviceDisplayOcclusion = 0xD5, |
| 240 | GD_DockableDeviceObjectType = 0xD6, |
| 241 | GD_CallActiveLED = 0xE0, |
| 242 | GD_CallMuteToggle = 0xE1, |
| 243 | GD_CallMuteLED = 0xE2 |
| 244 | }; |
| 245 | |
| 246 | enum LEDUsage |
| 247 | { |
| 248 | LED_Undefined = 0, |
| 249 | LED_NumLock = 0x01, |
| 250 | LED_CapsLock = 0x02, |
| 251 | LED_ScrollLock = 0x03, |
| 252 | LED_Compose = 0x04, |
| 253 | LED_Kana = 0x05, |
| 254 | LED_Power = 0x06, |
| 255 | LED_Shift = 0x07, |
| 256 | LED_DoNotDisturb = 0x08, |
| 257 | LED_Mute = 0x09, |
| 258 | LED_ToneEnable = 0x0A, |
| 259 | LED_HighCutFilter = 0x0B, |
| 260 | LED_LowCutFilter = 0x0C, |
| 261 | LED_EqualizerEnable = 0x0D, |
| 262 | LED_SoundFieldOn = 0x0E, |
| 263 | LED_SurroundOn = 0x0F, |
| 264 | LED_Repeat = 0x10, |
| 265 | LED_Stereo = 0x11, |
| 266 | LED_SampligRateDetect = 0x12, |
| 267 | LED_Spinning = 0x013, |
| 268 | LED_CAV = 0x14, |
| 269 | LED_CLV = 0x15, |
| 270 | LED_RecordingFormatDetect = 0x16, |
| 271 | LED_OffHook = 0x17, |
| 272 | LED_Ring = 0x18, |
| 273 | LED_MessageWaiting= 0x19, |
| 274 | LED_DataMode = 0x1A, |
| 275 | LED_BatteryOperation = 0x1B, |
| 276 | LED_BatteryOk = 0x1C, |
| 277 | LED_BatteryLow = 0x1D, |
| 278 | LED_Speaker = 0x1E, |
| 279 | LED_HeadSet = 0x1F, |
| 280 | LED_Hold = 0x20, |
| 281 | LED_Microphone = 0x21, |
| 282 | LED_Coverage = 0x22, |
| 283 | LED_NightMode = 0x23, |
| 284 | LED_SendCalls = 0x24, |
| 285 | LED_CallPickup = 0x25, |
| 286 | LED_Conference = 0x26, |
| 287 | LED_StandBy = 0x27, |
| 288 | LED_CameraOn = 0x28, |
| 289 | LED_CameraOff = 0x29, |
| 290 | LED_OnLine = 0x2A, |
| 291 | LED_OffLine = 0x2B, |
| 292 | LED_Busy = 0x2C, |
| 293 | LED_Ready = 0x2D, |
| 294 | LED_PaperOut = 0x2E, |
| 295 | LED_PaperJam = 0x2F, |
| 296 | LED_Remote = 0x30, |
| 297 | LED_Forward = 0x31, |
| 298 | LED_Reverse = 0x32, |
| 299 | LED_Stop = 0x33, |
| 300 | LED_Rewind = 0x34, |
| 301 | LED_FastForward = 0x35, |
| 302 | LED_Play = 0x36, |
| 303 | LED_Pause = 0x37, |
| 304 | LED_Record = 0x38, |
| 305 | LED_Error = 0x39, |
| 306 | LED_UsageSelectedIndicator = 0x3A, |
| 307 | LED_UsageInUseIndicator = 0x3B, |
| 308 | LED_UsageMultiModeIndicator = 0x3C, |
| 309 | LED_IndicatorOn = 0x3D, |
| 310 | LED_IndicatorFlash= 0x3E, |
| 311 | LED_IndicatorSlowBlink = 0x3F, |
| 312 | LED_IndicatorFastBlink = 0x40, |
| 313 | LED_IndicatorOff = 0x41, |
| 314 | LED_FlashOnTime = 0x42, |
| 315 | LED_SlowBlinkOnTime = 0x43, |
| 316 | LED_SlowBlinkOffTime = 0x44, |
| 317 | LED_FastBlinkOnTime = 0x45, |
| 318 | LED_FastBlinkOfftime = 0x46, |
| 319 | LED_UsageIndicatorColor = 0x47, |
| 320 | LED_IndicatorRed = 0x48, |
| 321 | LED_IndicatorGreen = 0x49, |
| 322 | LED_IndicatorAmber = 0x4A, |
| 323 | LED_GenericIndicator = 0x4B, |
| 324 | LED_SystemSuspend = 0x4C, |
| 325 | LED_ExternalPowerConnected = 0x4D |
| 326 | }; |
| 327 | |
| 328 | enum AlphanumericDisplayUsage |
| 329 | { |
| 330 | AD_AlphanumericDisplay = 0x01, |
| 331 | AD_BitmappedDisplay = 0x02, |
| 332 | AD_DisplayControlReport = 0x24, |
| 333 | AD_ClearDisplay = 0x25, |
| 334 | AD_CharacterReport = 0x2B, |
| 335 | AD_DisplayData = 0x2C, |
| 336 | AD_DisplayStatus = 0x2D, |
| 337 | AD_Rows = 0x35, |
| 338 | AD_Columns = 0x36, |
| 339 | AD_7SegmentDirectMap = 0x43, |
| 340 | AD_14SegmentDirectMap = 0x45, |
| 341 | AD_DisplayBrightness = 0x46, |
| 342 | AD_DisplayContrast = 0x47 |
| 343 | }; |
| 344 | |
| 345 | enum VRUsage |
| 346 | { |
| 347 | VR_Undefined = 0x00, |
| 348 | VR_Belt = 0x01, |
| 349 | VR_BodySuit = 0x02, |
| 350 | VR_Flexor = 0x03, |
| 351 | VR_Glove = 0x04, |
| 352 | VR_HeadTracker = 0x05, |
| 353 | VR_HeadMountedDisplay = 0x06, |
| 354 | VR_HandTracker = 0x07, |
| 355 | VR_Oculometer = 0x08, |
| 356 | VR_Vest = 0x09, |
| 357 | VR_AnimatronicDevice = 0x0A, |
| 358 | VR_StereoEnable = 0x20, |
| 359 | VR_DisplayEnable = 0x21 |
| 360 | }; |
| 361 | |
| 362 | enum class ReportType |
| 363 | { |
| 364 | Invalid = 0, |
| 365 | In = 0x08, |
| 366 | Out = 0x09, |
| 367 | Feature = 0x0B |
| 368 | }; |
| 369 | |
| 370 | // clang-format on |
| 371 | |
| 372 | /** |
| 373 | * @brief return the usage string for a page+code. |
| 374 | * These values need to be stable and also consistent with event-input on Linux, which |
| 375 | * is not always easy. |
| 376 | * |
| 377 | * @param usagePage |
| 378 | * @param usage |
| 379 | */ |
| 380 | std::string nameForUsage(uint32_t usagePage, uint32_t usage); |
| 381 | |
| 382 | } // namespace HID |