FlightGear next
FGHIDEventInput.cxx File Reference
#include "config.h"
#include "FGHIDEventInput.hxx"
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <Main/fg_props.hxx>
#include <hidapi/hidapi.h>
#include <hidapi/hidparse.h>
#include <simgear/structure/exception.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/misc/strutils.hxx>
#include <simgear/io/lowlevel.hxx>

Go to the source code of this file.

Classes

class  FGHIDEventInput::FGHIDEventInputPrivate
 

Namespaces

namespace  HID
 

Enumerations

enum class  HID::UsagePage {
  HID::Undefined = 0x00 , HID::GenericDesktop = 0x01 , HID::Simulation = 0x02 , HID::VR = 0x03 ,
  HID::Sport =0x04 , HID::Game =0x05 , HID::GenericDevice = 0x06 , HID::Keyboard = 0x07 ,
  HID::LEDs = 0x08 , HID::Button = 0x09 , HID::Ordinal = 0x0A , HID::Telephony = 0x0B ,
  HID::Consumer = 0x0C , HID::Digitizer = 0x0D , HID::PID = 0x0F , HID::Unicode = 0x10 ,
  HID::AlphanumericDisplay = 0x14 , HID::MedicalInstruments = 0x40 , HID::BarCodeScanner = 0x8C , HID::MagneticStripeReadingDevice = 0x8E ,
  HID::CameraControl = 0x90 , HID::Arcade = 0x91 , HID::VendorDefinedStart = 0xFF00
}
 
enum  HID::SimulationUsage {
  HID::SC_FlightSimulationDevice = 0x01 , HID::SC_AutomobileSimulationDevice = 0x02 , HID::SC_TankSimulationDevice = 0x03 , HID::SC_SpaceShipSimulationDevice = 0x04 ,
  HID::SC_SubmarineSimulationDevice = 0x05 , HID::SC_SailingSimulationDevice = 0x06 , HID::SC_MotorcycleSimulationDevice = 0x07 , HID::SC_SportsSimulationDevice = 0x08 ,
  HID::SC_AirplaneSimulationDevice = 0x09 , HID::SC_HelicopterSimulationDevice = 0x0A , HID::SC_MagicCarpetSimulationDevice = 0x0B , HID::SC_BycicleSimulationDevice = 0x0C ,
  HID::SC_FlightControlStick = 0x20 , HID::SC_FlightStick = 0x21 , HID::SC_CyclicControl = 0x22 , HID::SC_CyclicTrim = 0x23 ,
  HID::SC_FlightYoke = 0x24 , HID::SC_TrackControl = 0x25 , HID::SC_Aileron = 0xB0 , HID::SC_AileronTrim = 0xB1 ,
  HID::SC_AntiTorqueControl = 0xB2 , HID::SC_AutopilotEnable = 0xB3 , HID::SC_ChaffRelease = 0xB4 , HID::SC_CollectiveControl = 0xB5 ,
  HID::SC_DiveBrake = 0xB6 , HID::SC_ElectronicCountermeasures = 0xB7 , HID::SC_Elevator = 0xB8 , HID::SC_ElevatorTrim = 0xB9 ,
  HID::SC_Rudder = 0xBA , HID::SC_Throttle = 0xBB , HID::SC_FlightCommunications = 0xBC , HID::SC_FlareRelease = 0xBD ,
  HID::SC_LandingGear = 0xBE , HID::SC_ToeBrake = 0xBF , HID::SC_Trigger = 0xC0 , HID::SC_WeaponsArm = 0xC1 ,
  HID::SC_WeaponsSelect = 0xC2 , HID::SC_WingFlaps = 0xC3 , HID::SC_Accelerator = 0xC4 , HID::SC_Brake = 0xC5 ,
  HID::SC_Clutch = 0xC6 , HID::SC_Shifter = 0xC7 , HID::SC_Steering = 0xC8 , HID::SC_TurretDirection = 0xC9 ,
  HID::SC_BarrelElevation = 0xCA , HID::SC_DivePlane = 0xCB , HID::SC_Ballast = 0xCC , HID::SC_BicycleCrank = 0xCD ,
  HID::SC_HandleBars = 0xCE , HID::SC_FrontBrake = 0xCF , HID::SC_RearBrake = 0xD0
}
 
enum  HID::GenericDesktopUsage {
  HID::GD_Undefined = 0x00 , HID::GD_Pointer = 0x01 , HID::GD_Mouse = 0x02 , HID::GD_Reserved03 = 0x03 ,
  HID::GD_Joystick = 0x04 , HID::GD_GamePad = 0x05 , HID::GD_Keyboard = 0x06 , HID::GD_Keypad = 0x07 ,
  HID::GD_MultiAxisController = 0x08 , HID::GD_TabletPCSysCtrls = 0x09 , HID::GD_WaterCoolingDevice = 0x0A , HID::GD_ComputerChassisDevice = 0x0B ,
  HID::GD_WirelessRadioControls = 0x0C , HID::GD_PortableDeviceControl = 0x0D , HID::GD_SystemMultiAxisController = 0x0E , HID::GD_SpatialController = 0x0F ,
  HID::GD_AssistiveControl = 0x10 , HID::GD_DeviceDock = 0x11 , HID::GD_DockableDevice = 0x12 , HID::GD_CallStateManagementControl = 0x13 ,
  HID::GD_Reserved14 = 0x14 , HID::GD_Reserved15 = 0x15 , HID::GD_Reserved16 = 0x16 , HID::GD_Reserved17 = 0x17 ,
  HID::GD_Reserved18 = 0x18 , HID::GD_Reserved19 = 0x19 , HID::GD_Reserved1A = 0x1A , HID::GD_Reserved1B = 0x1B ,
  HID::GD_Reserved1C = 0x1C , HID::GD_Reserved1D = 0x1D , HID::GD_Reserved1E = 0x1E , HID::GD_Reserved1F = 0x1F ,
  HID::GD_Reserved20 = 0x20 , HID::GD_Reserved21 = 0x21 , HID::GD_Reserved22 = 0x22 , HID::GD_Reserved23 = 0x23 ,
  HID::GD_Reserved24 = 0x24 , HID::GD_Reserved25 = 0x25 , HID::GD_Reserved26 = 0x26 , HID::GD_Reserved27 = 0x27 ,
  HID::GD_Reserved28 = 0x28 , HID::GD_Reserved29 = 0x29 , HID::GD_Reserved2A = 0x2A , HID::GD_Reserved2B = 0x2B ,
  HID::GD_Reserved2C = 0x2C , HID::GD_Reserved2D = 0x2D , HID::GD_Reserved2E = 0x2E , HID::GD_Reserved2F = 0x2F ,
  HID::GD_X = 0x30 , HID::GD_Y = 0x31 , HID::GD_Z = 0x32 , HID::GD_Rx = 0x33 ,
  HID::GD_Ry = 0x34 , HID::GD_Rz = 0x35 , HID::GD_Slider = 0x36 , HID::GD_Dial = 0x37 ,
  HID::GD_Wheel = 0x38 , HID::GD_Hatswitch = 0x39 , HID::GD_CountedBuffer = 0x3A , HID::GD_ByteCount = 0x3B ,
  HID::GD_MotionWakeUp = 0x3C , HID::GD_Start = 0x3D , HID::GD_Select = 0x3E , HID::GD_Reserved3F = 0x3F ,
  HID::GD_Vx = 0x40 , HID::GD_Vy = 0x41 , HID::GD_Vz = 0x42 , HID::GD_Vbrx = 0x43 ,
  HID::GD_Vbry = 0x44 , HID::GD_Vbrz = 0x45 , HID::GD_Vno = 0x46 , HID::GD_FeatureNotification = 0x47 ,
  HID::GD_ResolutionMultiplier = 0x48 , HID::GD_Qx = 0x49 , HID::GD_Qy = 0x4A , HID::GD_Qz = 0x4B ,
  HID::GD_Qw = 0x4C , HID::GD_SystemControl = 0x80 , HID::GD_SystemPowerDown = 0x81 , HID::GD_SystemSleep = 0x82 ,
  HID::GD_SystemWakeUp = 0x83 , HID::GD_SystemContextMenu = 0x84 , HID::GD_SystemMainMenu = 0x85 , HID::GD_SystemAppMenu = 0x86 ,
  HID::GD_SystemMenuHelp = 0x87 , HID::GD_SystemMenuExit = 0x88 , HID::GD_SystemMenuSelect = 0x89 , HID::GD_SystemMenuRight = 0x8A ,
  HID::GD_SystemMenuLeft = 0x8B , HID::GD_SystemMenuUp = 0x8C , HID::GD_SystemMenuDown = 0x8D , HID::GD_SystemColdRestart = 0x8E ,
  HID::GD_SystemWarmRestart = 0x8F , HID::GD_DpadUp = 0x90 , HID::GD_DpadDown = 0x91 , HID::GD_DpadRight = 0x92 ,
  HID::GD_DpadLeft = 0x93 , HID::GD_IndexTrigger = 0x94 , HID::GD_PalmTrigger = 0x95 , HID::GD_Thumbstick = 0x96 ,
  HID::GD_SystemFunctionShift = 0x97 , HID::GD_SystemFunctionShiftLock = 0x98 , HID::GD_SystemFunctionShiftLockIndicator = 0x99 , HID::GD_SystemDismissNotification = 0x9A ,
  HID::GD_SystemDoNotDisturb = 0x9B , HID::GD_SystemDock = 0xA0 , HID::GD_SystemUndock = 0xA1 , HID::GD_SystemSetup = 0xA2 ,
  HID::GD_SystemBreak = 0xA3 , HID::GD_SystemDebuggerBreak = 0xA4 , HID::GD_ApplicationBreak = 0xA5 , HID::GD_ApplicationDebuggerBreak = 0xA6 ,
  HID::GD_SystemSpeakerMute = 0xA7 , HID::GD_SystemHibernate = 0xA8 , HID::GD_SystemMicrophoneMute = 0xA9 , HID::GD_SystemDisplayInvert = 0xB0 ,
  HID::GD_SystemDisplayInternal = 0xB1 , HID::GD_SystemDisplayExternal = 0xB2 , HID::GD_SystemDisplayBoth = 0xB3 , HID::GD_SystemDisplayDual = 0xB4 ,
  HID::GD_SystemDisplayToggleIntExtMode = 0xB5 , HID::GD_SystemDisplaySwapPrimarySecondary = 0xB6 , HID::GD_SystemDisplayToggleLCDAutoscale = 0xB7 , HID::GD_SensorZone = 0xC0 ,
  HID::GD_RPM = 0xC1 , HID::GD_CoolantLevel = 0xC2 , HID::GD_CoolantCriticalLevel = 0xC3 , HID::GD_CoolantPump = 0xC4 ,
  HID::GD_ChassisEnclosure = 0xC5 , HID::GD_WirelessRadioButton = 0xC6 , HID::GD_WirelessRadioLED = 0xC7 , HID::GD_WirelessRadioSliderSwitch = 0xC8 ,
  HID::GD_SystemDisplayRotationLockButton = 0xC9 , HID::GD_SystemDisplayRotationLockSliderSwitch = 0xCA , HID::GD_ControlEnable = 0xCB , HID::GD_DockableDeviceUniqueID = 0xD0 ,
  HID::GD_DockableDeviceVendorID = 0xD1 , HID::GD_DockableDevicePrimaryUsagePage = 0xD2 , HID::GD_DockableDevicePrimaryUsageID = 0xD3 , HID::GD_DockableDeviceDockingState = 0xD4 ,
  HID::GD_DockableDeviceDisplayOcclusion = 0xD5 , HID::GD_DockableDeviceObjectType = 0xD6 , HID::GD_CallActiveLED = 0xE0 , HID::GD_CallMuteToggle = 0xE1 ,
  HID::GD_CallMuteLED = 0xE2
}
 
enum  HID::LEDUsage {
  HID::LED_Undefined = 0 , HID::LED_NumLock = 0x01 , HID::LED_CapsLock = 0x02 , HID::LED_ScrollLock = 0x03 ,
  HID::LED_Compose = 0x04 , HID::LED_Kana = 0x05 , HID::LED_Power = 0x06 , HID::LED_Shift = 0x07 ,
  HID::LED_DoNotDisturb = 0x08 , HID::LED_Mute = 0x09 , HID::LED_ToneEnable = 0x0A , HID::LED_HighCutFilter = 0x0B ,
  HID::LED_LowCutFilter = 0x0C , HID::LED_EqualizerEnable = 0x0D , HID::LED_SoundFieldOn = 0x0E , HID::LED_SurroundOn = 0x0F ,
  HID::LED_Repeat = 0x10 , HID::LED_Stereo = 0x11 , HID::LED_SampligRateDetect = 0x12 , HID::LED_Spinning = 0x013 ,
  HID::LED_CAV = 0x14 , HID::LED_CLV = 0x15 , HID::LED_RecordingFormatDetect = 0x16 , HID::LED_OffHook = 0x17 ,
  HID::LED_Ring = 0x18 , HID::LED_MessageWaiting = 0x19 , HID::LED_DataMode = 0x1A , HID::LED_BatteryOperation = 0x1B ,
  HID::LED_BatteryOk = 0x1C , HID::LED_BatteryLow = 0x1D , HID::LED_Speaker = 0x1E , HID::LED_HeadSet = 0x1F ,
  HID::LED_Hold = 0x20 , HID::LED_Microphone = 0x21 , HID::LED_Coverage = 0x22 , HID::LED_NightMode = 0x23 ,
  HID::LED_SendCalls = 0x24 , HID::LED_CallPickup = 0x25 , HID::LED_Conference = 0x26 , HID::LED_StandBy = 0x27 ,
  HID::LED_CameraOn = 0x28 , HID::LED_CameraOff = 0x29 , HID::LED_OnLine = 0x2A , HID::LED_OffLine = 0x2B ,
  HID::LED_Busy = 0x2C , HID::LED_Ready = 0x2D , HID::LED_PaperOut = 0x2E , HID::LED_PaperJam = 0x2F ,
  HID::LED_Remote = 0x30 , HID::LED_Forward = 0x31 , HID::LED_Reverse = 0x32 , HID::LED_Stop = 0x33 ,
  HID::LED_Rewind = 0x34 , HID::LED_FastForward = 0x35 , HID::LED_Play = 0x36 , HID::LED_Pause = 0x37 ,
  HID::LED_Record = 0x38 , HID::LED_Error = 0x39 , HID::LED_UsageSelectedIndicator = 0x3A , HID::LED_UsageInUseIndicator = 0x3B ,
  HID::LED_UsageMultiModeIndicator = 0x3C , HID::LED_IndicatorOn = 0x3D , HID::LED_IndicatorFlash = 0x3E , HID::LED_IndicatorSlowBlink = 0x3F ,
  HID::LED_IndicatorFastBlink = 0x40 , HID::LED_IndicatorOff = 0x41 , HID::LED_FlashOnTime = 0x42 , HID::LED_SlowBlinkOnTime = 0x43 ,
  HID::LED_SlowBlinkOffTime = 0x44 , HID::LED_FastBlinkOnTime = 0x45 , HID::LED_FastBlinkOfftime = 0x46 , HID::LED_UsageIndicatorColor = 0x47 ,
  HID::LED_IndicatorRed = 0x48 , HID::LED_IndicatorGreen = 0x49 , HID::LED_IndicatorAmber = 0x4A , HID::LED_GenericIndicator = 0x4B ,
  HID::LED_SystemSuspend = 0x4C , HID::LED_ExternalPowerConnected = 0x4D
}
 
enum  HID::AlphanumericDisplayUsage {
  HID::AD_AlphanumericDisplay = 0x01 , HID::AD_BitmappedDisplay = 0x02 , HID::AD_DisplayControlReport = 0x24 , HID::AD_ClearDisplay = 0x25 ,
  HID::AD_CharacterReport = 0x2B , HID::AD_DisplayData = 0x2C , HID::AD_DisplayStatus = 0x2D , HID::AD_Rows = 0x35 ,
  HID::AD_Columns = 0x36 , HID::AD_7SegmentDirectMap = 0x43 , HID::AD_14SegmentDirectMap = 0x45 , HID::AD_DisplayBrightness = 0x46 ,
  HID::AD_DisplayContrast = 0x47
}
 
enum  HID::VRUsage {
  HID::VR_Undefined = 0x00 , HID::VR_Belt = 0x01 , HID::VR_BodySuit = 0x02 , HID::VR_Flexor = 0x03 ,
  HID::VR_Glove = 0x04 , HID::VR_HeadTracker = 0x05 , HID::VR_HeadMountedDisplay = 0x06 , HID::VR_HandTracker = 0x07 ,
  HID::VR_Oculometer = 0x08 , HID::VR_Vest = 0x09 , HID::VR_AnimatronicDevice = 0x0A , HID::VR_StereoEnable = 0x20 ,
  HID::VR_DisplayEnable = 0x21
}
 
enum class  HID::ReportType { HID::Invalid = 0 , HID::In = 0x08 , HID::Out = 0x09 , HID::Feature = 0x0B }
 

Functions

std::string HID::nameForUsage (uint32_t usagePage, uint32_t usage)
 
bool HID::shouldPrefixWithAbs (uint32_t usagePage, uint32_t usage)
 
ReportType HID::reportTypeFromString (const std::string &s)
 
int extractBits (uint8_t *bytes, size_t lengthInBytes, size_t bitOffset, size_t bitSize)
 
int signExtend (int inValue, size_t bitSize)
 
void writeBits (uint8_t *bytes, size_t bitOffset, size_t bitSize, int value)
 

Variables

const char * hexTable = "0123456789ABCDEF"
 
SGSubsystemMgr::Registrant< FGHIDEventInputregistrantFGHIDEventInput
 

Function Documentation

◆ extractBits()

int extractBits ( uint8_t * bytes,
size_t lengthInBytes,
size_t bitOffset,
size_t bitSize )

Definition at line 1422 of file FGHIDEventInput.cxx.

◆ signExtend()

int signExtend ( int inValue,
size_t bitSize )

Definition at line 1443 of file FGHIDEventInput.cxx.

◆ writeBits()

void writeBits ( uint8_t * bytes,
size_t bitOffset,
size_t bitSize,
int value )

Definition at line 1449 of file FGHIDEventInput.cxx.

Variable Documentation

◆ hexTable

const char* hexTable = "0123456789ABCDEF"

Definition at line 39 of file FGHIDEventInput.cxx.

◆ registrantFGHIDEventInput

SGSubsystemMgr::Registrant<FGHIDEventInput> registrantFGHIDEventInput

Definition at line 1516 of file FGHIDEventInput.cxx.