Skip to content

Commit 43b882b

Browse files
Le-Syl21claude
andcommitted
feat: vendor libusb 1.0.29 + UsbDk runtime integration
* Add `libusb-sys` workspace crate with libusb v1.0.29 vendored as a submodule under `crates/libusb-sys/vendor/libusb`. On Windows it builds libusb statically via `cc-rs` (libusb has no upstream CMakeLists.txt in this version range); on Linux/macOS it probes the system copy via `pkg-config` (≥ 1.0.20). Exposes location via `cargo:include` / `cargo:lib` / `cargo:lib_name` metadata, picked up by direct dependents through `DEP_USB_1.0_*` env vars (note: the literal `.` in the env-var name is preserved by Cargo's `links` translation — only `-` becomes `_`). * Switch `freenect-sys` and `freenect2-sys` to consume libusb-sys as a direct dependency, removing their per-crate vcpkg / pkg-config fallback dance. Each build script now reads `DEP_USB_1.0_*` and feeds the values straight into the bundled libfreenect[2] cmake invocations. * In-tree patch on `freenect-sys`: idempotently inject `libusb_set_option(LIBUSB_OPTION_USE_USBDK)` after `libusb_init` in `vendor/libfreenect/src/usb_libusb10.c`, mirroring what libfreenect2 already does upstream. Open PR OpenKinect/libfreenect#701 — once merged the marker check makes this a no-op. With the patch + the runtime probe (next commit), a Windows user with the UsbDk filter installed can reach the Kinect v1 without going through Zadig. * Wrap `freenect_open_device`'s rc into `OpenFailureCode` with a Display impl that decodes the most common libusb errors (-3/-4/-5/-6/-12) into actionable hints, so error -12 surfaces the UsbDk install instructions directly. * Bundle UsbDk into Windows release ZIPs: a new `tools/windows-release/install-drivers.cmd` (UAC-aware msiexec wrapper) ships next to the plugin binary, alongside `UsbDk_1.0.22_x64.msi` fetched from Daynix's GitHub release at CI time. README updated with the bundled-installer flow in both English and French sections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 61be7e1 commit 43b882b

15 files changed

Lines changed: 1235 additions & 171 deletions

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,38 @@ jobs:
210210

211211
# ---------- Stage + archive ----------
212212

213+
# ---------- Bundle UsbDk MSI for Windows releases ----------
214+
215+
# On Windows, the plugin needs UsbDk's filter driver to reach the
216+
# Kinect. Rather than asking users to download it themselves, we
217+
# ship the signed MSI from Daynix's GitHub releases right next to
218+
# the plugin DLL. The download is over HTTPS from GitHub directly
219+
# (no proxy), the file is signed by Daynix and Windows verifies
220+
# that signature on UAC. The pinned URL targets a specific
221+
# release tag so the bundle doesn't drift.
222+
- name: Fetch UsbDk MSI (Windows only)
223+
if: matrix.os == 'windows-latest'
224+
shell: pwsh
225+
run: |
226+
$url = "https://github.com/daynix/UsbDk/releases/download/v1.00-22/UsbDk_1.0.22_x64.msi"
227+
$out = "${{ github.workspace }}/UsbDk_1.0.22_x64.msi"
228+
Write-Host "Fetching $url"
229+
Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing
230+
# Display the SHA-256 so the release log carries an audit
231+
# trail. We deliberately don't *enforce* a hash here — the
232+
# MSI is signed by Daynix and re-fetched at every release;
233+
# Windows' Authenticode check during UAC install is the
234+
# actual integrity boundary. If you want to harden, lift
235+
# this hash into a Verify-FileHash step pinned per release.
236+
$hash = (Get-FileHash $out -Algorithm SHA256).Hash
237+
Write-Host "UsbDk MSI SHA-256: $hash"
238+
# Sanity: refuse a 0-byte file (404 served as 200 by some mirrors).
239+
$size = (Get-Item $out).Length
240+
if ($size -lt 1000000) {
241+
Write-Error "UsbDk MSI suspiciously small ($size bytes) — refusing"
242+
exit 1
243+
}
244+
213245
- name: Stage artifacts
214246
shell: bash
215247
run: |
@@ -222,6 +254,13 @@ jobs:
222254
cp plugin.cfg "$stage/"
223255
[ -f LICENSE ] && cp LICENSE "$stage/" || true
224256
[ -f README.md ] && cp README.md "$stage/" || true
257+
# Windows: bundle UsbDk MSI + the install helper alongside
258+
# the plugin under drivers/. Linux/macOS skip this.
259+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
260+
mkdir -p "$stage/drivers"
261+
cp UsbDk_1.0.22_x64.msi "$stage/drivers/"
262+
cp tools/windows-release/install-drivers.cmd "$stage/drivers/"
263+
fi
225264
echo "STAGE_DIR=$stage" >> "$GITHUB_ENV"
226265
echo "ARTIFACT_BASENAME=headtracking-${version}-${{ matrix.suffix }}" >> "$GITHUB_ENV"
227266

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "crates/freenect-sys/vendor/libfreenect"]
55
path = crates/freenect-sys/vendor/libfreenect
66
url = https://github.com/OpenKinect/libfreenect
7+
[submodule "crates/libusb-sys/vendor/libusb"]
8+
path = crates/libusb-sys/vendor/libusb
9+
url = https://github.com/libusb/libusb.git

0 commit comments

Comments
 (0)