Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_Linux_HIDDevice.cpp
Go to the documentation of this file.
1 /************************************************************************************
2 Filename : OVR_Linux_HIDDevice.cpp
3 Content : Linux HID device implementation.
4 Created : February 26, 2013
5 Authors : Lee Cooper
6 
7 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
8 
9 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
10 you may not use the Oculus VR Rift SDK except in compliance with the License,
11 which is provided at the time of installation or download, or which
12 otherwise accompanies this software in either electronic or hard copy form.
13 
14 You may obtain a copy of the License at
15 
16 http://www.oculusvr.com/licenses/LICENSE-3.1
17 
18 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
23 
24 *************************************************************************************/
25 
26 #include "OVR_Linux_HIDDevice.h"
27 
28 #include <sys/ioctl.h>
29 #include <fcntl.h>
30 #include <errno.h>
31 #include <linux/hidraw.h>
32 #include "OVR_HIDDeviceImpl.h"
33 
34 namespace OVR { namespace Linux {
35 
37 
38 //-------------------------------------------------------------------------------------
39 // **** Linux::DeviceManager
40 //-----------------------------------------------------------------------------
41 HIDDeviceManager::HIDDeviceManager(DeviceManager* manager) : DevManager(manager)
42 {
44  HIDMonitor = NULL;
45  HIDMonHandle = -1;
46 }
47 
48 //-----------------------------------------------------------------------------
50 {
51 }
52 
53 //-----------------------------------------------------------------------------
55 {
56  if (HIDMonitor)
57  {
58  return true;
59  }
60 
61  // Create a udev_monitor handle to watch for device changes (hot-plug detection)
62  HIDMonitor = udev_monitor_new_from_netlink(UdevInstance, "udev");
63  if (HIDMonitor == NULL)
64  {
65  return false;
66  }
67 
68  udev_monitor_filter_add_match_subsystem_devtype(HIDMonitor, "hidraw", NULL); // filter for hidraw only
69 
70  int err = udev_monitor_enable_receiving(HIDMonitor);
71  if (err)
72  {
73  udev_monitor_unref(HIDMonitor);
74  HIDMonitor = NULL;
75  return false;
76  }
77 
78  // Get the file descriptor (fd) for the monitor.
79  HIDMonHandle = udev_monitor_get_fd(HIDMonitor);
80  if (HIDMonHandle < 0)
81  {
82  udev_monitor_unref(HIDMonitor);
83  HIDMonitor = NULL;
84  return false;
85  }
86 
87  // This file handle will be polled along-side with the device hid handles for changes
88  // Add the handle to the polling list
89  if (!DevManager->pThread->AddSelectFd(this, HIDMonHandle))
90  {
91  close(HIDMonHandle);
92  HIDMonHandle = -1;
93 
94  udev_monitor_unref(HIDMonitor);
95  HIDMonitor = NULL;
96  return false;
97  }
98 
99  return true;
100 }
101 
102 //-----------------------------------------------------------------------------
104 {
105  // Get a udev library handle. This handle must stay active during the
106  // duration the lifetime of device monitoring handles
107  UdevInstance = udev_new();
108  if (!UdevInstance)
109  return false;
110 
111  return initializeManager();
112 }
113 
114 //-----------------------------------------------------------------------------
116 {
117  OVR_ASSERT_LOG((UdevInstance), ("Should have called 'Initialize' before 'Shutdown'."));
118 
119  if (HIDMonitor)
120  {
121  DevManager->pThread->RemoveSelectFd(this, HIDMonHandle);
122  close(HIDMonHandle);
123  HIDMonHandle = -1;
124 
125  udev_monitor_unref(HIDMonitor);
126  HIDMonitor = NULL;
127  }
128 
129  udev_unref(UdevInstance); // release the library
130 
131  LogText("OVR::Linux::HIDDeviceManager - shutting down.\n");
132 }
133 
134 //-------------------------------------------------------------------------------
136 {
137  NotificationDevices.PushBack(device);
138  return true;
139 }
140 
141 //-------------------------------------------------------------------------------
143 {
144  for (UPInt i = 0; i < NotificationDevices.GetSize(); i++)
145  {
146  if (NotificationDevices[i] == device)
147  {
148  NotificationDevices.RemoveAt(i);
149  return true;
150  }
151  }
152  return false;
153 }
154 
155 //-----------------------------------------------------------------------------
156 bool HIDDeviceManager::getIntProperty(udev_device* device,
157  const char* propertyName,
158  SInt32* pResult)
159 {
160  const char* str = udev_device_get_sysattr_value(device, propertyName);
161  if (str)
162  {
163  *pResult = strtol(str, NULL, 16);
164  return true;
165  }
166  else
167  {
168  *pResult = 0;
169  return true;
170  }
171 }
172 
173 //-----------------------------------------------------------------------------
174 bool HIDDeviceManager::initVendorProductVersion(udev_device* device, HIDDeviceDesc* pDevDesc)
175 {
176  SInt32 result;
177  if (getIntProperty(device, "idVendor", &result))
178  pDevDesc->VendorId = result;
179  else
180  return false;
181 
182  if (getIntProperty(device, "idProduct", &result))
183  pDevDesc->ProductId = result;
184  else
185  return false;
186 
187  if (getIntProperty(device, "bcdDevice", &result))
188  pDevDesc->VersionNumber = result;
189  else
190  return false;
191 
192  return true;
193 }
194 
195 //-----------------------------------------------------------------------------
196 bool HIDDeviceManager::getStringProperty(udev_device* device,
197  const char* propertyName,
198  OVR::String* pResult)
199 {
200  // Get the attribute in UTF8
201  const char* str = udev_device_get_sysattr_value(device, propertyName);
202  if (str)
203  { // Copy the string into the return value
204  *pResult = String(str);
205  return true;
206  }
207  else
208  {
209  return false;
210  }
211 }
212 
213 //-----------------------------------------------------------------------------
215 {
216 
217  if (!initializeManager())
218  {
219  return false;
220  }
221 
222  // Get a list of hid devices
223  udev_enumerate* devices = udev_enumerate_new(UdevInstance);
224  udev_enumerate_add_match_subsystem(devices, "hidraw");
225  udev_enumerate_scan_devices(devices);
226 
227  udev_list_entry* entry = udev_enumerate_get_list_entry(devices);
228 
229  // Search each device for the matching vid/pid
230  while (entry != NULL)
231  {
232  // Get the device file name
233  const char* sysfs_path = udev_list_entry_get_name(entry);
234  udev_device* hid; // The device's HID udev node.
235  hid = udev_device_new_from_syspath(UdevInstance, sysfs_path);
236  const char* dev_path = udev_device_get_devnode(hid);
237 
238  // Get the USB device
239  hid = udev_device_get_parent_with_subsystem_devtype(hid, "usb", "usb_device");
240  if (hid)
241  {
242  HIDDeviceDesc devDesc;
243 
244  // Check the VID/PID for a match
245  if (dev_path &&
246  initVendorProductVersion(hid, &devDesc) &&
247  enumVisitor->MatchVendorProduct(devDesc.VendorId, devDesc.ProductId))
248  {
249  devDesc.Path = dev_path;
250  getFullDesc(hid, &devDesc);
251 
252  // Look for the device to check if it is already opened.
253  Ptr<DeviceCreateDesc> existingDevice = DevManager->FindHIDDevice(devDesc, true);
254  // if device exists and it is opened then most likely the device open()
255  // will fail; therefore, we just set Enumerated to 'true' and continue.
256  if (existingDevice && existingDevice->pDevice)
257  {
258  existingDevice->Enumerated = true;
259  }
260  else
261  { // open the device temporarily for startup communication
262  int device_handle = open(dev_path, O_RDWR);
263  if (device_handle >= 0)
264  {
265  // Construct minimal device that the visitor callback can get feature reports from
266  Linux::HIDDevice device(this, device_handle);
267  enumVisitor->Visit(device, devDesc);
268 
269  close(device_handle); // close the file handle
270  }
271  }
272  }
273 
274  udev_device_unref(hid);
275  entry = udev_list_entry_get_next(entry);
276  }
277  }
278 
279  // Free the enumerator and udev objects
280  udev_enumerate_unref(devices);
281 
282  return true;
283 }
284 
285 //-----------------------------------------------------------------------------
287 {
288  Ptr<Linux::HIDDevice> device = *new Linux::HIDDevice(this);
289 
290  if (device->HIDInitialize(path))
291  {
292  device->AddRef();
293  return device;
294  }
295 
296  return NULL;
297 }
298 
299 //-----------------------------------------------------------------------------
300 bool HIDDeviceManager::getFullDesc(udev_device* device, HIDDeviceDesc* desc)
301 {
302 
303  if (!initVendorProductVersion(device, desc))
304  {
305  return false;
306  }
307 
308  if (!getStringProperty(device, "serial", &(desc->SerialNumber)))
309  {
310  return false;
311  }
312 
313  getStringProperty(device, "manufacturer", &(desc->Manufacturer));
314  getStringProperty(device, "product", &(desc->Product));
315 
316  return true;
317 }
318 
319 //-----------------------------------------------------------------------------
321 {
322  if (!initializeManager())
323  {
324  return false;
325  }
326 
327  // Search for the udev device from the given pathname so we can
328  // have a handle to query device properties
329 
330  udev_enumerate* devices = udev_enumerate_new(UdevInstance);
331  udev_enumerate_add_match_subsystem(devices, "hidraw");
332  udev_enumerate_scan_devices(devices);
333 
334  udev_list_entry* entry = udev_enumerate_get_list_entry(devices);
335 
336  bool success = false;
337  // Search for the device with the matching path
338  while (entry != NULL)
339  {
340  // Get the device file name
341  const char* sysfs_path = udev_list_entry_get_name(entry);
342  udev_device* hid; // The device's HID udev node.
343  hid = udev_device_new_from_syspath(UdevInstance, sysfs_path);
344  const char* path = udev_device_get_devnode(hid);
345 
346  if (OVR_strcmp(dev_path, path) == 0)
347  { // Found the device so lets collect the device descriptor
348 
349  // Get the USB device
350  hid = udev_device_get_parent_with_subsystem_devtype(hid, "usb", "usb_device");
351  if (hid)
352  {
353  desc->Path = dev_path;
354  success = getFullDesc(hid, desc);
355  }
356 
357  }
358 
359  udev_device_unref(hid);
360  entry = udev_list_entry_get_next(entry);
361  }
362 
363  // Free the enumerator
364  udev_enumerate_unref(devices);
365 
366  return success;
367 }
368 
369 //-----------------------------------------------------------------------------
370 void HIDDeviceManager::OnEvent(int i, int fd)
371 {
372  OVR_UNUSED(i);
373  OVR_UNUSED(fd);
374 
375  // There is a device status change
376  udev_device* hid = udev_monitor_receive_device(HIDMonitor);
377  if (hid)
378  {
379  const char* dev_path = udev_device_get_devnode(hid);
380  const char* action = udev_device_get_action(hid);
381 
382  HIDDeviceDesc device_info;
383  device_info.Path = dev_path;
384 
385  MessageType notify_type;
386  if (OVR_strcmp(action, "add") == 0)
387  {
388  notify_type = Message_DeviceAdded;
389 
390  // Retrieve the device info. This can only be done on a connected
391  // device and is invalid for a disconnected device
392 
393  // Get the USB device
394  hid = udev_device_get_parent_with_subsystem_devtype(hid, "usb", "usb_device");
395  if (!hid)
396  {
397  return;
398  }
399 
400  getFullDesc(hid, &device_info);
401  }
402  else if (OVR_strcmp(action, "remove") == 0)
403  {
404  notify_type = Message_DeviceRemoved;
405  }
406  else
407  {
408  return;
409  }
410 
411  bool error = false;
412  bool deviceFound = false;
413  for (UPInt i = 0; i < NotificationDevices.GetSize(); i++)
414  {
415  if (NotificationDevices[i] &&
416  NotificationDevices[i]->OnDeviceNotification(notify_type, &device_info, &error))
417  {
418  // The notification was for an existing device
419  deviceFound = true;
420  break;
421  }
422  }
423 
424  if (notify_type == Message_DeviceAdded && !deviceFound)
425  {
426  DevManager->DetectHIDDevice(device_info);
427  }
428 
429  udev_device_unref(hid);
430  }
431 }
432 
433 //=============================================================================
434 // Linux::HIDDevice
435 //=============================================================================
437  : InMinimalMode(false), HIDManager(manager)
438 {
439  DeviceHandle = -1;
440 }
441 
442 //-----------------------------------------------------------------------------
443 // This is a minimal constructor used during enumeration for us to pass
444 // a HIDDevice to the visit function (so that it can query feature reports).
445 HIDDevice::HIDDevice(HIDDeviceManager* manager, int device_handle)
446 : InMinimalMode(true), HIDManager(manager), DeviceHandle(device_handle)
447 {
448 }
449 
450 //-----------------------------------------------------------------------------
452 {
453  if (!InMinimalMode)
454  {
455  HIDShutdown();
456  }
457 }
458 
459 //-----------------------------------------------------------------------------
461 {
462  const char* hid_path = path.ToCStr();
463  if (!openDevice(hid_path))
464  {
465  LogText("OVR::Linux::HIDDevice - Failed to open HIDDevice: %s", hid_path);
466  return false;
467  }
468 
469  HIDManager->DevManager->pThread->AddTicksNotifier(this);
471 
472  LogText("OVR::Linux::HIDDevice - Opened '%s'\n"
473  " Manufacturer:'%s' Product:'%s' Serial#:'%s'\n",
474  DevDesc.Path.ToCStr(),
477 
478  return true;
479 }
480 
481 //-----------------------------------------------------------------------------
483 {
484  // Device must have been successfully opened.
485  OVR_ASSERT(DeviceHandle >= 0);
486 
487  int desc_size = 0;
488  hidraw_report_descriptor rpt_desc;
489  memset(&rpt_desc, 0, sizeof(rpt_desc));
490 
491  // get report descriptor size
492  int r = ioctl(DeviceHandle, HIDIOCGRDESCSIZE, &desc_size);
493  if (r < 0)
494  {
495  OVR_ASSERT_LOG(false, ("Failed to get report descriptor size."));
496  return false;
497  }
498 
499  // Get the report descriptor
500  rpt_desc.size = desc_size;
501  r = ioctl(DeviceHandle, HIDIOCGRDESC, &rpt_desc);
502  if (r < 0)
503  {
504  OVR_ASSERT_LOG(false, ("Failed to get report descriptor."));
505  return false;
506  }
507 
508  /*
509  // Get report lengths.
510  SInt32 bufferLength;
511  bool getResult = HIDManager->getIntProperty(Device, CFSTR(kIOHIDMaxInputReportSizeKey), &bufferLength);
512  OVR_ASSERT(getResult);
513  InputReportBufferLength = (UInt16) bufferLength;
514 
515  getResult = HIDManager->getIntProperty(Device, CFSTR(kIOHIDMaxOutputReportSizeKey), &bufferLength);
516  OVR_ASSERT(getResult);
517  OutputReportBufferLength = (UInt16) bufferLength;
518 
519  getResult = HIDManager->getIntProperty(Device, CFSTR(kIOHIDMaxFeatureReportSizeKey), &bufferLength);
520  OVR_ASSERT(getResult);
521  FeatureReportBufferLength = (UInt16) bufferLength;
522 
523 
524  if (ReadBufferSize < InputReportBufferLength)
525  {
526  OVR_ASSERT_LOG(false, ("Input report buffer length is bigger than read buffer."));
527  return false;
528  }
529 
530  // Get device desc.
531  if (!HIDManager->getFullDesc(Device, &DevDesc))
532  {
533  OVR_ASSERT_LOG(false, ("Failed to get device desc while initializing device."));
534  return false;
535  }
536 
537  return true;
538  */
539 
540  // Get report lengths.
541 // TODO: hard-coded for now. Need to interpret these values from the report descriptor
545 
547  {
548  OVR_ASSERT_LOG(false, ("Input report buffer length is bigger than read buffer."));
549  return false;
550  }
551 
552  return true;
553 }
554 
555 //-----------------------------------------------------------------------------
556 bool HIDDevice::openDevice(const char* device_path)
557 {
558  // First fill out the device descriptor
559  if (!HIDManager->GetDescriptorFromPath(device_path, &DevDesc))
560  {
561  return false;
562  }
563 
564  // Now open the device
565  DeviceHandle = open(device_path, O_RDWR);
566  if (DeviceHandle < 0)
567  {
568  OVR_DEBUG_LOG(("Failed 'CreateHIDFile' while opening device, error = 0x%X.", errno));
569  DeviceHandle = -1;
570  return false;
571  }
572 
573  // fill out some values from the feature report descriptor
574  if (!initInfo())
575  {
576  OVR_ASSERT_LOG(false, ("Failed to get HIDDevice info."));
577 
578  close(DeviceHandle);
579  DeviceHandle = -1;
580  return false;
581  }
582 
583  // Add the device to the polling list
584  if (!HIDManager->DevManager->pThread->AddSelectFd(this, DeviceHandle))
585  {
586  OVR_ASSERT_LOG(false, ("Failed to initialize polling for HIDDevice."));
587 
588  close(DeviceHandle);
589  DeviceHandle = -1;
590  return false;
591  }
592 
593  return true;
594 }
595 
596 //-----------------------------------------------------------------------------
598 {
599 
600  HIDManager->DevManager->pThread->RemoveTicksNotifier(this);
602 
603  if (DeviceHandle >= 0) // Device may already have been closed if unplugged.
604  {
605  closeDevice(false);
606  }
607 
608  LogText("OVR::Linux::HIDDevice - HIDShutdown '%s'\n", DevDesc.Path.ToCStr());
609 }
610 
611 //-----------------------------------------------------------------------------
612 void HIDDevice::closeDevice(bool wasUnplugged)
613 {
614  OVR_UNUSED(wasUnplugged);
615  OVR_ASSERT(DeviceHandle >= 0);
616 
617 
618  HIDManager->DevManager->pThread->RemoveSelectFd(this, DeviceHandle);
619 
620  close(DeviceHandle); // close the file handle
621  DeviceHandle = -1;
622 
623  LogText("OVR::Linux::HIDDevice - HID Device Closed '%s'\n", DevDesc.Path.ToCStr());
624 }
625 
626 //-----------------------------------------------------------------------------
628 {
629  LogText("OVR::Linux::HIDDevice - Lost connection to '%s'\n", DevDesc.Path.ToCStr());
630  closeDevice(false);
631 }
632 
633 //-----------------------------------------------------------------------------
635 {
636 
637  if (DeviceHandle < 0)
638  return false;
639 
640  UByte reportID = data[0];
641 
642  if (reportID == 0)
643  {
644  // Not using reports so remove from data packet.
645  data++;
646  length--;
647  }
648 
649  int r = ioctl(DeviceHandle, HIDIOCSFEATURE(length), data);
650  return (r >= 0);
651 }
652 
653 //-----------------------------------------------------------------------------
655 {
656  if (DeviceHandle < 0)
657  return false;
658 
659  int r = ioctl(DeviceHandle, HIDIOCGFEATURE(length), data);
660  return (r >= 0);
661 }
662 
663 //-----------------------------------------------------------------------------
664 double HIDDevice::OnTicks(double tickSeconds)
665 {
666  if (Handler)
667  {
668  return Handler->OnTicks(tickSeconds);
669  }
670 
671  return DeviceManagerThread::Notifier::OnTicks(tickSeconds);
672 }
673 
674 //-----------------------------------------------------------------------------
675 void HIDDevice::OnEvent(int i, int fd)
676 {
677  OVR_UNUSED(i);
678  // We have data to read from the device
679  int bytes = read(fd, ReadBuffer, ReadBufferSize);
680  if (bytes >= 0)
681  {
682 // TODO: I need to handle partial messages and package reconstruction
683  if (Handler)
684  {
686  }
687  }
688  else
689  { // Close the device on read error.
691  }
692 }
693 
694 //-----------------------------------------------------------------------------
696  HIDDeviceDesc* device_info,
697  bool* error)
698 {
699  const char* device_path = device_info->Path.ToCStr();
700 
701  if (messageType == Message_DeviceAdded && DeviceHandle < 0)
702  {
703  // Is this the correct device?
704  if (!(device_info->VendorId == DevDesc.VendorId
705  && device_info->ProductId == DevDesc.ProductId
706  && device_info->SerialNumber == DevDesc.SerialNumber))
707  {
708  return false;
709  }
710 
711  // A closed device has been re-added. Try to reopen.
712  if (!openDevice(device_path))
713  {
714  LogError("OVR::Linux::HIDDevice - Failed to reopen a device '%s' that was re-added.\n",
715  device_path);
716  *error = true;
717  return true;
718  }
719 
720  LogText("OVR::Linux::HIDDevice - Reopened device '%s'\n", device_path);
721 
722  if (Handler)
723  {
725  }
726  }
727  else if (messageType == Message_DeviceRemoved)
728  {
729  // Is this the correct device?
730  // For disconnected device, the device description will be invalid so
731  // checking the path is the only way to match them
732  if (DevDesc.Path.CompareNoCase(device_path) != 0)
733  {
734  return false;
735  }
736 
737  if (DeviceHandle >= 0)
738  {
739  closeDevice(true);
740  }
741 
742  if (Handler)
743  {
745  }
746  }
747  else
748  {
749  OVR_ASSERT(0);
750  }
751 
752  *error = false;
753  return true;
754 }
755 
756 //-----------------------------------------------------------------------------
758 {
759 
760  if (!System::IsInitialized())
761  {
762  // Use custom message, since Log is not yet installed.
764  LogMessage(Log_Debug, "HIDDeviceManager::Create failed - OVR::System not initialized"); );
765  return 0;
766  }
767 
768  Ptr<Linux::HIDDeviceManager> manager = *new Linux::HIDDeviceManager(devManager);
769 
770  if (manager)
771  {
772  if (manager->Initialize())
773  {
774  manager->AddRef();
775  }
776  else
777  {
778  manager.Clear();
779  }
780  }
781 
782  return manager.GetPtr();
783 }
784 
785 } // namespace Linux
786 
787 //-------------------------------------------------------------------------------------
788 // ***** Creation
789 
790 // Creates a new HIDDeviceManager and initializes OVR.
792 {
793 
794  if (!System::IsInitialized())
795  {
796  // Use custom message, since Log is not yet installed.
798  LogMessage(Log_Debug, "HIDDeviceManager::Create failed - OVR::System not initialized"); );
799  return 0;
800  }
801 
802  Ptr<Linux::DeviceManager> deviceManagerLinux = *new Linux::DeviceManager;
803 
804  if (!deviceManagerLinux)
805  {
806  return NULL;
807  }
808 
809  if (!deviceManagerLinux->Initialize(NULL))
810  {
811  return NULL;
812  }
813 
814  deviceManager = deviceManagerLinux;
815 
816  return deviceManagerLinux->GetHIDDeviceManager();
817 }
818 
819 } // namespace OVR
void LogText(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
virtual void OnInputReport(UByte *pData, UInt32 length)
bool getStringProperty(udev_device *device, const char *propertyName, OVR::String *pResult)
bool initVendorProductVersion(udev_device *device, HIDDeviceDesc *pDevDesc)
OVR_FORCE_INLINE void Clear()
Definition: OVR_RefCount.h:496
#define OVR_ASSERT_LOG(c, args)
Definition: OVR_Log.h:198
UByte ReadBuffer[ReadBufferSize]
void OnEvent(int i, int fd)
#define NULL
bool getIntProperty(udev_device *device, const char *key, int32_t *pResult)
static HIDDeviceManager * Create(Ptr< OVR::DeviceManager > &deviceManager)
virtual OVR::HIDDevice * Open(const String &path)
bool GetDescriptorFromPath(const char *dev_path, HIDDeviceDesc *desc)
static const UInt32 MAX_QUEUED_INPUT_REPORTS
OVR_FORCE_INLINE C * GetPtr() const
Definition: OVR_RefCount.h:506
uint32_t UInt32
Definition: OVR_Types.h:253
#define OVR_UNUSED(a)
#define OVR_DEBUG_STATEMENT(s)
Array< HIDDevice * > NotificationDevices
virtual double OnTicks(double tickSeconds)
virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId)
Definition: OVR_HIDDevice.h:64
size_t UPInt
Definition: OVR_Types.h:218
uint8_t UByte
Definition: OVR_Types.h:249
bool RemoveNotificationDevice(HIDDevice *device)
Ptr< DeviceManagerThread > pThread
virtual void Visit(HIDDevice &, const HIDDeviceDesc &)
Definition: OVR_HIDDevice.h:69
const char * ToCStr() const
Definition: OVR_String.h:186
static HIDDeviceManager * CreateInternal(DeviceManager *manager)
Ptr< DeviceCreateDesc > FindHIDDevice(const HIDDeviceDesc &, bool created)
void void LogError(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
bool openDevice(const char *dev_path)
bool OnDeviceNotification(MessageType messageType, HIDDeviceDesc *device_info, bool *error)
bool getFullDesc(udev_device *device, HIDDeviceDesc *desc)
virtual bool GetFeatureReport(UByte *data, UInt32 length)
#define OVR_ASSERT(p)
static bool OVR_CDECL IsInitialized()
Definition: OVR_System.cpp:75
bool HIDInitialize(const String &path)
static Log * GetDefaultLog()
Definition: OVR_Log.cpp:152
int OVR_CDECL OVR_strcmp(const char *dest, const char *src)
Definition: OVR_Std.h:181
double OnTicks(double tickSeconds)
void closeDevice(bool wasUnplugged)
virtual void OnDeviceMessage(HIDDeviceMessageType messageType)
bool AddNotificationDevice(HIDDevice *device)
int32_t SInt32
Definition: OVR_Types.h:252
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
HIDDeviceManager * HIDManager
void DetectHIDDevice(const HIDDeviceDesc &)
#define OVR_DEBUG_LOG(args)
Definition: OVR_Log.h:196
HIDHandler * Handler
static int OVR_STDCALL CompareNoCase(const char *a, const char *b)
Definition: OVR_String.cpp:488
virtual double OnTicks(double tickSeconds)
virtual bool Enumerate(HIDEnumerateVisitor *enumVisitor)
virtual bool SetFeatureReport(UByte *data, UInt32 length)