summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-02-10 23:06:54 +0000
committerPete Batard <pbatard@gmail.com>2010-02-10 23:06:54 +0000
commit06f92a48c52f91a6784716fbd0a2c5856c30085f (patch)
tree23fa0917cd5a50385a376aded13edce7ca2bcb28
parent36d76382a06d00c936e881acb60c69cbb91d679f (diff)
downloadlibusb-06f92a48c52f91a6784716fbd0a2c5856c30085f.tar.gz
final fix for composite HID mouse and keyboard detectionr147
introduces the use of multiple driver names in the USB API backends
-rw-r--r--libusb/os/windows_usb.c45
-rw-r--r--libusb/os/windows_usb.h3
2 files changed, 29 insertions, 19 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 425dc1a..d1d9f0d 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -352,6 +352,18 @@ static void windows_assign_endpoints(struct libusb_device *dev, int iface, int a
}
}
+// Lookup for a match in the list of API driver names
+bool is_api_driver(char* driver, uint8_t api)
+{
+ uint8_t i;
+ for (i=0; i<usb_api_backend[api].nb_driver_names; i++) {
+ if (safe_strcmp(driver, usb_api_backend[api].driver_name_list[i]) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
/*
* init: libusb backend init function
*
@@ -1021,8 +1033,6 @@ enum libusb_hid_report_type {
if (dev_interface_details == NULL)
break;
-// usbi_dbg("processing: %s", dev_interface_details->DevicePath);
-
// HID devices (and possibly other classes) have an extra indirection
// for an USB path we can recognize
if (j == HID_DEVICE_INTERFACE_GUID_INDEX) {
@@ -1055,17 +1065,8 @@ enum libusb_hid_report_type {
driver[0] = 0;
}
-// usbi_dbg("driver: %s", driver);
- // Temporary fix for composite mouse and hid keyboards
- // TODO: something better
- if (safe_strcmp(driver, "kbdhid") == 0) {
- strcpy(driver, "HidUsb");
- } else if (safe_strcmp(driver, "mouhid") == 0) {
- strcpy(driver, "HidUsb");
- }
-
for (api=USB_API_WINUSB; api<USB_API_MAX; api++) {
- if ( (safe_strcmp(driver, usb_api_backend[api].driver_name) == 0)
+ if ( (is_api_driver(driver, api))
|| (guid_eq(&class_guid, usb_api_backend[api].class_guid)) ) {
api_type[nb_paths] = api;
if (j == HID_DEVICE_INTERFACE_GUID_INDEX) {
@@ -1258,7 +1259,8 @@ static int set_device_paths(struct libusb_context *ctx, struct discovered_devs *
GUID guid;
DWORD size, reg_type, install_state, port_nr;
int r = LIBUSB_SUCCESS;
- unsigned i, j, k, api;
+ unsigned i, j, k;
+ uint8_t api;
bool found;
// TODO (v1.5): MI_## automated driver installation
@@ -1352,7 +1354,7 @@ static int set_device_paths(struct libusb_context *ctx, struct discovered_devs *
found = true;
for (api = 0; api<USB_API_MAX; api++) {
- if (safe_strcmp(reg_key, usb_api_backend[api].driver_name) == 0) {
+ if (is_api_driver(reg_key, api)) {
priv->apib = &usb_api_backend[api];
switch(api) {
case USB_API_COMPOSITE:
@@ -2099,11 +2101,15 @@ static int unsupported_copy_transfer_data(struct usbi_transfer *itransfer, uint3
PRINT_UNSUPPORTED_API(copy_transfer_data);
}
+const char* composite_driver_names[] = {"usbccgp"};
+const char* winusb_driver_names[] = {"WinUSB"};
+const char* hid_driver_names[] = {"HidUsb", "mouhid", "kbdhid"};
const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
{
USB_API_UNSUPPORTED,
&CLASS_GUID_UNSUPPORTED,
- "_UNSUPPORTED_",
+ NULL,
+ 0,
unsupported_init,
unsupported_exit,
unsupported_open,
@@ -2122,7 +2128,8 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
}, {
USB_API_COMPOSITE,
&CLASS_GUID_COMPOSITE,
- "usbccgp",
+ composite_driver_names,
+ 1,
composite_init,
composite_exit,
composite_open,
@@ -2141,7 +2148,8 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
}, {
USB_API_WINUSB,
&CLASS_GUID_LIBUSB_WINUSB,
- "WinUSB",
+ winusb_driver_names,
+ 1,
winusb_init,
winusb_exit,
winusb_open,
@@ -2160,7 +2168,8 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
}, {
USB_API_HID,
&CLASS_GUID_HID,
- "HidUsb",
+ hid_driver_names,
+ 3,
hid_init,
hid_exit,
hid_open,
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index e3bc4d1..30ec048 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -127,7 +127,8 @@ const GUID CLASS_GUID_COMPOSITE = { 0x36FC9E60, 0xC465, 0x11cF, {0x80, 0x56,
struct windows_usb_api_backend {
const uint8_t id;
const GUID *class_guid; // The Class GUID (for fallback in case the driver name cannot be read)
- const char *driver_name; // Driver name, without .sys, e.g. "usbccgp"
+ const char **driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
+ const uint8_t nb_driver_names;
int (*init)(struct libusb_context *ctx);
int (*exit)(void);
int (*open)(struct libusb_device_handle *dev_handle);