Repository navigation
Switch 2 Pro Controller over USB on Windows: ship libusb for SDL - #633
Merged
Merged
Conversation
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>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.cmakepins the official libusb 1.0.30 Windows binary release (URL + SHA256, cached inNXRT_DEPS_DIRlike the other deps), unpackslibusb.h, the x64 import library andlibusb-1.0.dll, and points SDL'sFindLibUSBat them. Windows x64 only; Linux and macOS are unchanged.libusb-1.0.dllby name at run time (SDL_HIDAPI_LIBUSB_SHARED), sopkp_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 topkp_rt.dll, the devpkp.exeand the gfx demo.make-release.ps1ships it next topkp.exe(ahead of any otherlibusb-1.0.dllon PATH) with its licence aslicenses/LICENSE.libusb.LGPL-2.1.txt. Notices, README pin table andBUNDLED_TOOLS.txtlist it..7zthat CMake's bundled libarchive cannot read (the ARM64 builds inside use the ARM64 filter), so it is unpacked with the systemtar.exe(bsdtar, Windows 10 1803 and later).Owner rule 3 override:
.github/workflows/release.ymlgains one line,build/rtdll/libusb-1.0.dllin thewin-rtartifact, somake-release.ps1can 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## Unreleasedhas an entrypkp_rt.dlland the newlibusb-1.0.dllcome with the package, the game code is not lifted againPros
pkp_rt.dll; one pinned, unmodified upstream binary.Cons
tar.exeable to read the libusb.7z.🤖 Generated with Claude Code