Skip to content

Switch 2 Pro Controller over USB on Windows: ship libusb for SDL - #633

Merged
featureJosh merged 2 commits into
mainfrom
claude/github-issue-522-f60783
Nov 13, 2026
Merged

featureJosh merged 2 commits into
mainfrom
claude/github-issue-522-f60783

Conversation

@featureJosh

Copy link
Copy Markdown
Collaborator

What it changes

On Windows a Switch 2 Pro Controller (057e:2069) plugged in by USB cable was not picked up. SDL 3.4.18 has the driver (SDL_hidapi_switch2.c), but on Windows it reaches the controller only through libusb, and our SDL build never found libusb, so that path was compiled out.

  • runtime/cmake/gfx_deps.cmake pins the official libusb 1.0.30 Windows binary release (URL + SHA256, cached in NXRT_DEPS_DIR like the other deps), unpacks libusb.h, the x64 import library and libusb-1.0.dll, and points SDL's FindLibUSB at them. Windows x64 only; Linux and macOS are unchanged.
  • SDL loads libusb-1.0.dll by name at run time (SDL_HIDAPI_LIBUSB_SHARED), so pkp_rt.dll's imports are unchanged and the game still starts without the DLL. Configure fails if SDL would link libusb directly instead.
  • nxrt_bundle_libusb() copies the DLL next to pkp_rt.dll, the dev pkp.exe and the gfx demo. make-release.ps1 ships it next to pkp.exe (ahead of any other libusb-1.0.dll on PATH) with its licence as licenses/LICENSE.libusb.LGPL-2.1.txt. Notices, README pin table and BUNDLED_TOOLS.txt list it.
  • The release archive is a .7z that CMake's bundled libarchive cannot read (the ARM64 builds inside use the ARM64 filter), so it is unpacked with the system tar.exe (bsdtar, Windows 10 1803 and later).
  • By default SDL only sends a short list of devices (the Switch 2 controllers, the GameCube adapter) through libusb, so other controllers are not affected. Under Proton the Windows libusb cannot reach USB devices and SDL just skips it.

Owner rule 3 override: .github/workflows/release.yml gains one line, build/rtdll/libusb-1.0.dll in the win-rt artifact, so make-release.ps1 can find the DLL. Approved by featureJosh for this change. It is its own commit.

Based on the change and hardware test in the issue by ondona.

Fixes #522

For players

  • CHANGELOG.md ## Unreleased has an entry
  • Needs Set up again / Finish update: Update only; pkp_rt.dll and the new libusb-1.0.dll come with the package, the game code is not lifted again
  • Rebuilds shaders: no

Pros

  • USB Switch 2 Pro Controllers work on Windows with Switch prompts, rumble and gyro, with no driver install.
  • No new import in pkp_rt.dll; one pinned, unmodified upstream binary.

Cons

  • One more third-party DLL (LGPL-2.1) in the package.
  • The Windows build now needs the system tar.exe able to read the libusb .7z.

🤖 Generated with Claude Code

featureJosh and others added 2 commits November 13, 2026 11:31
SDL 3.4.18 drives the Switch 2 Pro Controller (057e:2069), but on Windows
it reaches it only through libusb, which our SDL build never found, so the
controller was not opened over USB.

gfx_deps.cmake now pins the official libusb 1.0.30 Windows binary release
(URL + SHA256), unpacks libusb.h, the import library and the DLL with the
system bsdtar (CMake's own extractor cannot read the archive), and points
SDL's FindLibUSB at them. SDL loads libusb-1.0.dll by name at run time
(SDL_HIDAPI_LIBUSB_SHARED), so pkp_rt.dll does not import it; configure
fails if SDL would link it directly instead. nxrt_bundle_libusb() copies
the DLL next to pkp_rt.dll, pkp.exe and the gfx demo, and make-release.ps1
ships it next to pkp.exe with its LGPL-2.1 licence.

Co-Authored-By: Claude <noreply@anthropic.com>
make-release.ps1 takes libusb-1.0.dll from the runtime build folder, so
the windows-runtime job uploads it with pkp_rt.dll and pkp_rt.lib.

Co-Authored-By: Claude <noreply@anthropic.com>
@featureJosh
featureJosh merged commit 33963cc into main Nov 13, 2026
1 check passed
@featureJosh
featureJosh deleted the claude/github-issue-522-f60783 branch November 13, 2026 16:33
@featureJosh featureJosh mentioned this pull request Nov 13, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch 2 Pro Controller over USB: turn on SDL's HIDAPI libusb backend

1 participant