Repository navigation
fix: report controller vendor and product in the gamepad id - #18
Merged
Merged
Conversation
Chromium formats the id of a standard-mapped pad as "<name> (STANDARD GAMEPAD Vendor: xxxx Product: yyyy)", and games read the vendor number from that string to choose controller-specific glyphs. The platform reported only the SDL controller name, so every pad looked like an unrecognized vendor and games fell back to the default glyph set. Append the SDL vendor and product to the id. The controller name, mapping and input behaviour are unchanged.
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.
Problem
Browsers identify a standard-mapped controller with its vendor and product in
the Gamepad
id, for example:Games read the vendor number from that string to choose controller-specific
glyphs (PlayStation, Xbox, Switch). The platform exposed only the SDL
controller name, so every pad looked like an unknown vendor and games fell
back to the default glyph set, unlike the same game under Chromium/NW.js.
Change
src/platform.cpp: build the Gamepadidthe way Chromium does —"<name> (STANDARD GAMEPAD Vendor: %04x Product: %04x)"— usingSDL_GameControllerGetVendor()andSDL_GameControllerGetProduct().mapping: "standard", button/axis layout and allinput behaviour are unchanged.
One commit (
37b51a4) on upstreammain25b9932. Branchpr/gamepad-vendor-id. One file,8 insertions, 1 deletion.
Evidence
navigator.getGamepads()reported{"id":"Deeplay-keys","mapping":"standard","buttons":17,"axes":4}— novendor or product, so OMORI's
determineVendorRect(which searches the idfor
054c,045e,xbox,switch) always chose its Xbox fallback.Deeplay-keys (STANDARD GAMEPAD Vendor: 0001 Product: 0001); MV is pollingit (
Input._lastGamepad = 0, one gamepad state). The generic pad stillresolves to the Xbox fallback because its kernel ids are 0001/0001, while a
recognised Sony/Nintendo pad now carries the vendor number its glyph set
needs.
SDL_GameControllerGetVendor/Productare available in the SDK);
test/scene-encodersand the full JS suite areunaffected because the change is native-only.
Tests
No unit harness covers
Platform::gamepads(); verification is the deviceprobe above. The id format matches Chromium's for standard-mapped pads, and
the append happens only for real controllers (disconnected slots keep an
empty id).
🤖 Generated with Claude Code