FN_INTERNAL int fnusb_num_devices(freenect_context *ctx) { libusb_device **devs; // pointer to pointer of device, used to retrieve a list of devices ssize_t count = libusb_get_device_list (ctx->usb.ctx, &devs); if (count < 0) return (count >= INT_MIN) ? (int)count : -1; int number_found = 0, i = 0; struct libusb_device_descriptor desc; for (i = 0; i < count; ++i) { int r = libusb_get_device_descriptor (devs[i], &desc); if (r < 0) { FN_WARNING("Failed to query USB device descriptor.\n"); continue; } if (desc.idVendor == VID_MICROSOFT) { if (desc.idProduct == PID_NUI_CAMERA || desc.idProduct == PID_K4W_CAMERA) { number_found++; } else if (desc.idProduct == PID_KV2_CAMERA) { FN_NOTICE("Skipping Kinect v2 device (needs https://github.com/libfreenect2).\n"); } } } libusb_free_device_list (devs, 1); return number_found; }
FREENECTAPI int freenect_shutdown(freenect_context *ctx) { while (ctx->first) { FN_NOTICE("Device %p open during shutdown, closing...\n", ctx->first); freenect_close_device(ctx->first); } fnusb_shutdown(&ctx->usb); free(ctx); return 0; }