Skip to content

fix: report controller vendor and product in the gamepad id - #18

Merged
bbbreaddd merged 2 commits into
bbbreaddd:mainfrom
AbdullahTrees:pr/gamepad-vendor-id
Nov 15, 2026
Merged

bbbreaddd merged 2 commits into
bbbreaddd:mainfrom
AbdullahTrees:pr/gamepad-vendor-id

Conversation

@AbdullahTrees

Copy link
Copy Markdown
Contributor

Problem

Browsers identify a standard-mapped controller with its vendor and product in
the Gamepad id, for example:

Xbox 360 Controller (XInput STANDARD GAMEPAD Vendor: 045e Product: 028e)
Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 09cc)

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 Gamepad id the way Chromium does —
    "<name> (STANDARD GAMEPAD Vendor: %04x Product: %04x)" — using
    SDL_GameControllerGetVendor() and SDL_GameControllerGetProduct().
  • The controller name, mapping: "standard", button/axis layout and all
    input behaviour are unchanged.

One commit (37b51a4) on upstream main 25b9932. Branch pr/gamepad-vendor-id. One file,
8 insertions, 1 deletion.

Evidence

  • Anbernic RG40XX-H (muOS 2502.0), release runtime: before the change,
    navigator.getGamepads() reported
    {"id":"Deeplay-keys","mapping":"standard","buttons":17,"axes":4} — no
    vendor or product, so OMORI's determineVendorRect (which searches the id
    for 054c, 045e, xbox, switch) always chose its Xbox fallback.
  • With the change, the same probe reports
    Deeplay-keys (STANDARD GAMEPAD Vendor: 0001 Product: 0001); MV is polling
    it (Input._lastGamepad = 0, one gamepad state). The generic pad still
    resolves 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.
  • Built for arm64 against SDL 2.28.5 (SDL_GameControllerGetVendor/Product
    are available in the SDK); test/scene-encoders and the full JS suite are
    unaffected because the change is native-only.

Tests

No unit harness covers Platform::gamepads(); verification is the device
probe 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

AbdullahTrees and others added 2 commits November 8, 2026 16:05
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.
@bbbreaddd
bbbreaddd merged commit 0350793 into bbbreaddd:main Nov 15, 2026
2 checks passed
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.

2 participants