From 1d87cbc79dd771ab0b5451a66144b474162a153b Mon Sep 17 00:00:00 2001 From: Le-Syl21 Date: Fri, 8 May 2026 23:13:12 +0200 Subject: [PATCH] Windows: opt into the libusb UsbDk backend at init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror libfreenect2's behaviour (libfreenect2.cpp): on Windows, after libusb_init, call libusb_set_option(LIBUSB_OPTION_USE_USBDK). Without this opt-in, libusb on Windows uses the WinUSB backend, which can only reach devices that already have a libusb-compatible driver attached (WinUSB / libusbK / libusb-win32). On Kinect v1 hardware whose sub-devices are bound to the Microsoft Kinect SDK driver — or to no driver at all — libusb_open returns LIBUSB_ERROR_NOT_SUPPORTED (-12), forcing users to run Zadig and replace each sub-device's driver with libusbK before the device can be opened. libfreenect2 already addresses this with a one-line opt-in. Extending the same opt-in to libfreenect lets a Windows user install UsbDk's filter driver (a single signed MSI from Daynix) and have the Kinect work, without per-device Zadig steps and without giving up the Microsoft Kinect SDK driver if they want to keep it. The call is wrapped in (void) to swallow the return value, matching libfreenect2's pattern, since LIBUSB_OPTION_USE_USBDK only fails on non-Windows platforms (where this code is compiled out anyway). No behaviour change on Linux or macOS. --- src/usb_libusb10.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/usb_libusb10.c b/src/usb_libusb10.c index 5ae4429c..89a26370 100644 --- a/src/usb_libusb10.c +++ b/src/usb_libusb10.c @@ -258,6 +258,15 @@ FN_INTERNAL int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx) if (!usb_ctx) { res = libusb_init(&ctx->ctx); if (res >= 0) { +#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__) + // Mirrors libfreenect2 (libfreenect2.cpp): on Windows, ask + // libusb to use the UsbDk backend so the Kinect can be + // reached without forcing the user to replace the device's + // driver via Zadig+libusbK. With UsbDk installed, libusb can + // attach to the device even when another driver (e.g. the + // Microsoft Kinect SDK driver) currently owns it. + (void)libusb_set_option(ctx->ctx, LIBUSB_OPTION_USE_USBDK); +#endif ctx->should_free_ctx = 1; return 0; } else {