31 Locator::getLogger()->warn(
"{} - {}({:x},{})", s, mach_error_string(err), err, err & 0xFFFFFF);
72 IOHIDDeviceInterface** m_Interface;
73 IOHIDQueueInterface** m_Queue;
75 std::string m_sDescription;
77 static void AddLogicalDevice(
const void* value,
void* context);
78 static void AddElement(
const void* value,
void* context);
84 virtual bool AddLogicalDevice(
int usagePage,
int usage) = 0;
88 virtual void AddElement(
int usagePage,
90 IOHIDElementCookie cookie,
91 const CFDictionaryRef properties) = 0;
95 virtual void Open() = 0;
98 virtual bool InitDevice(
int vid,
int pid) {
return true; }
102 inline void AddElementToQueue(IOHIDElementCookie cookie)
104 IOReturn ret = CALL(m_Queue, addElement, cookie, 0);
105 if (ret != KERN_SUCCESS)
106 Locator::getLogger()->warn(
"Failed to add HID element with cookie %p to queue: {}",
107 static_cast<UInt32
>(cookie),ret);
111 inline IOReturn SetReport(IOHIDReportType type,
117 return CALL(m_Interface,
133 bool Open(io_object_t device);
134 void StartQueue(CFRunLoopRef loopRef,
135 IOHIDCallbackFunction callback,
138 inline const std::string& GetDescription()
const {
return m_sDescription; }
145 virtual void GetButtonPresses(
146 std::vector<DeviceInput>& vPresses,
147 IOHIDElementCookie cookie,
149 const std::chrono::time_point<std::chrono::steady_clock>& now)
const = 0;
157 virtual int AssignIDs(InputDevice startID) {
return 0; }
160 virtual void GetDevicesAndDescriptions(
161 std::vector<InputDeviceInfo>& vDevices)
const = 0;