diff options
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/core.c | 8 | ||||
-rw-r--r-- | libusb/libusb.h | 14 | ||||
-rw-r--r-- | libusb/libusbi.h | 9 | ||||
-rw-r--r-- | libusb/os/darwin_usb.c | 1 | ||||
-rw-r--r-- | libusb/os/linux_usbfs.c | 1 | ||||
-rw-r--r-- | libusb/os/openbsd_usb.c | 1 | ||||
-rw-r--r-- | libusb/os/wince_usb.c | 1 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 1 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
9 files changed, 33 insertions, 5 deletions
diff --git a/libusb/core.c b/libusb/core.c index b3df73a..e2da1ea 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1740,15 +1740,21 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx) /** \ingroup misc * Check at runtime if the loaded library has a given capability. + * This call should be performed after \ref libusb_init(), to ensure the + * backend has updated its capability set. * * \param capability the \ref libusb_capability to check for - * \returns 1 if the running library has the capability, 0 otherwise + * \returns nonzero if the running library has the capability, 0 otherwise */ int API_EXPORTED libusb_has_capability(uint32_t capability) { switch (capability) { case LIBUSB_CAP_HAS_CAPABILITY: return 1; + case LIBUSB_CAP_HAS_HID_ACCESS: + return (usbi_backend->caps && USBI_CAP_HAS_HID_ACCESS); + case LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER: + return (usbi_backend->caps && USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER); } return 0; } diff --git a/libusb/libusb.h b/libusb/libusb.h index d7e84c0..3613864 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -136,7 +136,7 @@ typedef unsigned __int32 uint32_t; * Internally, LIBUSBX_API_VERSION is defined as follows: * (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental) */ -#define LIBUSBX_API_VERSION 0x010000FF +#define LIBUSBX_API_VERSION 0x01000101 #ifdef __cplusplus extern "C" { @@ -994,7 +994,17 @@ struct libusb_transfer { */ enum libusb_capability { /** The libusb_has_capability() API is available. */ - LIBUSB_CAP_HAS_CAPABILITY = 0, + LIBUSB_CAP_HAS_CAPABILITY = 0x0000, + /** Hotplug support is available. */ + LIBUSB_CAP_HAS_HOTPLUG = 0x0001, + /** The library can access HID devices without requiring user intervention. + * Note that before being able to actually access an HID device, you may + * still have to call additional libusbx functions such as + * \ref libusb_detach_kernel_driver(). */ + LIBUSB_CAP_HAS_HID_ACCESS = 0x0100, + /** The library supports detaching of the default USB driver, using + * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */ + LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101 }; /** \ingroup lib diff --git a/libusb/libusbi.h b/libusb/libusbi.h index eed549e..ed95d43 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -52,8 +52,12 @@ #define USB_MAXINTERFACES 32 #define USB_MAXCONFIG 8 +/* Backend specific capabilities */ +#define USBI_CAP_HAS_HID_ACCESS 0x00010000 +#define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER 0x00020000 + /* The following is used to silence warnings for unused variables */ -#define UNUSED(var) (void)(var) +#define UNUSED(var) do { (void)(var); } while(0) struct list_head { struct list_head *prev, *next; @@ -446,6 +450,9 @@ struct usbi_os_backend { /* A human-readable name for your backend, e.g. "Linux usbfs" */ const char *name; + /* Binary mask for backend specific capabilities */ + uint32_t caps; + /* Perform initialization of your backend. You might use this function * to determine specific capabilities of the system, allocate required * data structures for later, etc. diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 08bd7f0..30ee3ff 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1782,6 +1782,7 @@ static int darwin_clock_gettime(int clk_id, struct timespec *tp) { const struct usbi_os_backend darwin_backend = { .name = "Darwin", + .caps = 0, .init = darwin_init, .exit = darwin_exit, .get_device_list = darwin_get_device_list, diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 99bbd07..95e5339 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -2527,6 +2527,7 @@ static clockid_t op_get_timerfd_clockid(void) const struct usbi_os_backend linux_usbfs_backend = { .name = "Linux usbfs", + .caps = USBI_CAP_HAS_HID_ACCESS|USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER, .init = op_init, .exit = NULL, .get_device_list = op_get_device_list, diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c index 88e2c7a..353385b 100644 --- a/libusb/os/openbsd_usb.c +++ b/libusb/os/openbsd_usb.c @@ -89,6 +89,7 @@ static int _access_endpoint(struct libusb_transfer *); const struct usbi_os_backend openbsd_backend = { "Synchronous OpenBSD backend", + 0, NULL, /* init() */ NULL, /* exit() */ obsd_get_device_list, diff --git a/libusb/os/wince_usb.c b/libusb/os/wince_usb.c index 354c0e6..e4f7c7b 100644 --- a/libusb/os/wince_usb.c +++ b/libusb/os/wince_usb.c @@ -973,6 +973,7 @@ static int wince_clock_gettime(int clk_id, struct timespec *tp) const struct usbi_os_backend wince_backend = { "Windows CE", + 0, wince_init, wince_exit, diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 1eb81b4..7c2428d 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -2262,6 +2262,7 @@ static int windows_clock_gettime(int clk_id, struct timespec *tp) // NB: MSVC6 does not support named initializers. const struct usbi_os_backend windows_backend = { "Windows", + USBI_CAP_HAS_HID_ACCESS, windows_init, windows_exit, diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 5a977a3..26d7735 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10633 +#define LIBUSB_NANO 10634 |