[haiku-commits] r41992 - haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid

Author: mmlr
Date: 2011-06-07 00:47:22 +0200 (Tue, 07 Jun 2011)
New Revision: 41992
Changeset: https://dev.haiku-os.org/changeset/41992

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp
Log:
Add devices we have explicit quirky device support for to the support
descriptor. This allows us to support devices that aren't strictly HID or only
provide vendor specific interfaces by constructing report descriptors for their
data format.


Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp     
2011-06-06 22:37:29 UTC (rev 41991)
+++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp     
2011-06-06 22:47:22 UTC (rev 41992)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008-2009 Michael Lotz <mmlr@xxxxxxxx>
+ * Copyright 2008-2011 Michael Lotz <mmlr@xxxxxxxx>
  * Distributed under the terms of the MIT license.
  */
 
@@ -11,6 +11,7 @@
 #include "Driver.h"
 #include "HIDDevice.h"
 #include "ProtocolHandler.h"
+#include "QuirkyDevices.h"
 
 #include <lock.h>
 #include <util/AutoLock.h>
@@ -31,6 +32,7 @@
 DeviceList *gDeviceList = NULL;
 static int32 sParentCookie = 0;
 static mutex sDriverLock;
+static usb_support_descriptor *sSupportDescriptors;
 
 
 // #pragma mark - notify hooks
@@ -311,11 +313,31 @@
                &usb_hid_device_removed
        };
 
-       static usb_support_descriptor supportDescriptor = {
+       static usb_support_descriptor genericHIDSupportDescriptor = {
                USB_INTERFACE_CLASS_HID, 0, 0, 0, 0
        };
 
-       gUSBModule->register_driver(DRIVER_NAME, &supportDescriptor, 1, NULL);
+       int32 supportDescriptorCount = 1 + gQuirkyDeviceCount;
+       sSupportDescriptors
+               = new(std::nothrow) 
usb_support_descriptor[supportDescriptorCount];
+       if (sSupportDescriptors != NULL) {
+               sSupportDescriptors[0] = genericHIDSupportDescriptor;
+               for (int32 i = 0; i < gQuirkyDeviceCount; i++) {
+                       sSupportDescriptors[i + 1].dev_class = 0;
+                       sSupportDescriptors[i + 1].dev_subclass = 0;
+                       sSupportDescriptors[i + 1].dev_protocol = 0;
+                       sSupportDescriptors[i + 1].vendor = 
gQuirkyDevices[i].vendor_id;
+                       sSupportDescriptors[i + 1].product = 
gQuirkyDevices[i].product_id;
+               }
+
+               gUSBModule->register_driver(DRIVER_NAME, sSupportDescriptors,
+                       supportDescriptorCount, NULL);
+       } else {
+               // no memory for quirky devices, at least support proper HID
+               gUSBModule->register_driver(DRIVER_NAME, 
&genericHIDSupportDescriptor,
+                       1, NULL);
+       }
+
        gUSBModule->install_notify(DRIVER_NAME, &notifyHooks);
        TRACE("init_driver() OK\n");
        return B_OK;
@@ -328,6 +350,8 @@
        TRACE("uninit_driver()\n");
        gUSBModule->uninstall_notify(DRIVER_NAME);
        put_module(B_USB_MODULE_NAME);
+       delete[] sSupportDescriptors;
+       sSupportDescriptors = NULL;
        delete gDeviceList;
        gDeviceList = NULL;
        mutex_destroy(&sDriverLock);


Other related posts:

  • » [haiku-commits] r41992 - haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid - mmlr