diff --git a/Makefile.common b/Makefile.common index 754df9eb2d..0e4846db3f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,4 +1,5 @@ HAVE_LIBRETRODB = 1 +#HAVE_LIBUSB = 1 ifeq ($(HAVE_LIBRETRODB), 1) DEFINES += -DHAVE_LIBRETRODB @@ -393,6 +394,7 @@ ifeq ($(HAVE_UDEV), 1) endif ifeq ($(HAVE_LIBUSB), 1) + DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o LIBS += -lusb-1.0 JOYCONFIG_LIBS += -lusb-1.0 diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 787d1f3cf2..51b3ae30dc 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -29,6 +29,9 @@ struct libusb_adapter struct libusb_device *device; libusb_device_handle *handle; + uint8_t manufacturer_name[255]; + uint8_t name[255]; + sthread_t *thread; struct libusb_adapter *next; }; @@ -60,7 +63,6 @@ static int add_adapter(struct libusb_device *dev) fprintf(stderr, "Allocation of adapter failed.\n"); return -1; } - rc = libusb_get_device_descriptor(dev, &desc); if (rc != LIBUSB_SUCCESS) @@ -80,6 +82,23 @@ static int add_adapter(struct libusb_device *dev) goto error; } + if (desc.iManufacturer) + { + libusb_get_string_descriptor_ascii(adapter->handle, + desc.iManufacturer, adapter->manufacturer_name, + sizeof(adapter->manufacturer_name)); + fprintf(stderr, "Adapter Manufacturer name: %s\n", + adapter->manufacturer_name); + } + + if (desc.iProduct) + { + libusb_get_string_descriptor_ascii(adapter->handle, + desc.iProduct, adapter->name, + sizeof(adapter->name)); + fprintf(stderr, "Adapter name: %s\n", adapter->name); + } + if (libusb_kernel_driver_active(adapter->handle, 0) == 1 && libusb_detach_kernel_driver(adapter->handle, 0)) {