Troubleshooting
Find the symptom below. Each answer says what causes it and how to fix it. Unless an answer says otherwise, the browser behavior described here was checked in desktop Chromium. Items marked not tested come from browser and vendor documentation, not from our own runs.
First, see what the SDK sees
Section titled “First, see what the SDK sees”Log what the SDK reports about the active controller. Every capability it cannot use carries a reason:
import { createGamepadly } from '@gamepadly/sdk';
const hub = createGamepadly();hub.onCapabilitiesChange(() => { const caps = hub.active.getCapabilities(); console.log(caps.tier, caps.identity.displayName, hub.active.input.getState().mapping); for (const [id, status] of Object.entries(caps.matrix)) { if (status.reason) console.log(id, status.availability, status.reason); }});tier is 'keyboard_mouse' until a controller is detected. To check the controller and browser without your game
involved, open the online controller tester. If the tester does not see the controller,
your game will not either.
The controller is not detected
Section titled “The controller is not detected”- No button has been pressed yet. Browsers report a controller only after the player presses a button on it
while the page is open, so the page cannot learn which controllers you own. Moving a stick or plugging the
controller in is not always enough. Show a “Press any button” hint until
tierchanges. - The tab is in the background. Browsers send controller input only to the visible tab. The game resumes when its tab is shown again.
- The cable only charges. A charge-only USB cable powers the controller but carries no data. Try another cable, or pair the controller over Bluetooth.
- Another program owns the controller (not tested). Remapping tools such as DS4Windows or reWASD can hide the controller from other programs, or show it to them as a virtual Xbox controller. If the browser reports an Xbox 360 controller while you hold a DualSense, a remapper is the likely cause. Close it and reconnect the controller.
A keyboard game ignores the controller
Section titled “A keyboard game ignores the controller”This section applies to games that use the bridge.
- The game listens on an element. By default the bridge dispatches its key events on
document, and from there they bubble up towindow. Events never travel down to elements, so a game that listens on its canvas never sees them. Pass that element askeyTarget. See how your game reads the keyboard. Before 0.7.0 the default target waswindow, whichdocumentlisteners do not hear. - The profile presses other keys. Compare the keys the game reads (
event.code,event.keyorkeyCode) with the keys in your profile. The built-in'platformer'profile presses the arrow keys, Space and Z. A WASD game needs its own profile. - The game checks
event.isTrusted. Events created by a script, the bridge’s included, always haveisTrusted: false, and some games skip such events. Remove the check, or read the controller with an action map instead of the bridge.
The bridge stops pressing keys, and releases any it holds, when no controller is connected. The keyboard always keeps working.
Buttons are wrong or swapped
Section titled “Buttons are wrong or swapped”- The browser reports a non-standard layout. When
getState().mappingis'nonstandard', the browser did not map the controller’s buttons to the standard positions, so they can be misnamed. This happens more often in Firefox, Safari and with some third-party controllers. Connect DualSense and Switch Pro controllers over WebHID, which reads them directly, or supply a layout withgamepadMappings. See Non-standard layouts. - A and B look swapped on Nintendo controllers. This is by design.
southis the bottom face button, which is A on Xbox and B on Nintendo, so the same code works for both. Show the player’s own label withgetButtonLabel('south', caps.identity.brand).
The character drifts, or a press is missed
Section titled “The character drifts, or a press is missed”- The stick is read raw.
getState()returns sticks with no deadzone, so a worn stick that rests at 0.03 moves the character. Read movement through an action map axis, which has a 0.08 deadzone by default, and raise itsdeadzoneif the stick still drifts. When you readgetState()directly, usep1.input.applyDeadzone(value, 0.12). justPressed()is never true. Callactions.update()exactly once per frame, before you read any action. Calling it twice per frame clears the press before the game reads it. Not calling it at all means nothing ever changes.- A press fires twice, or rumble does not stop. Create one hub per page and share it. React StrictMode runs effects twice in development, so create the hub in an effect and dispose of it in the cleanup. See the React recipe.
Space or the arrow keys scroll the page
Section titled “Space or the arrow keys scroll the page”An action map calls preventDefault() for the Space, arrow and Tab keys it binds, unless focus is in a form field.
Your own keyboard handlers have to call it themselves. Key events from the bridge never
scroll the page: browsers do not run a key’s default action for events created by a script.
WebHID: DualSense triggers and Switch Pro HD Rumble
Section titled “WebHID: DualSense triggers and Switch Pro HD Rumble”The connect button throws in Firefox or Safari
Section titled “The connect button throws in Firefox or Safari”These browsers do not have WebHID, and hub.connectWebHID() throws WebHID requires a Chromium browser there.
Show the button only where it can work. Everything else in the SDK keeps working without it:
connectButton.hidden = !('hid' in navigator);The picker does not open
Section titled “The picker does not open”Browsers show the device picker only in response to a click or key press. Call hub.connectWebHID() from the
click handler itself, not on page load and not after an await that takes long. Outside a click the call fails:
depending on the browser it rejects with a SecurityError or resolves false.
It fails inside an iframe
Section titled “It fails inside an iframe”If the game runs in an iframe from another origin, as on game portals and in CodePen or CodeSandbox previews, Chromium blocks WebHID unless the embedding page allows it:
SecurityError: Failed to execute 'requestDevice' on 'HID': Access to the feature "hid" is disallowed by permissions policy.The page that embeds the game has to add allow="hid" to the iframe:
<iframe src="https://game.example.com/" allow="hid"></iframe>Chromium allows the Gamepad API, which carries input and standard rumble, in cross-origin iframes by default, so the game stays playable without the attribute. If you do not control the embedding page, such as a portal like itch.io (not tested), offer WebHID only when the game is opened in its own tab.
The controller is not in the picker
Section titled “The controller is not in the picker”The picker lists only the controllers WebHID can upgrade: DualSense, DualSense Edge and the Switch Pro Controller. DualShock 4, Joy-Con and Xbox controllers are not listed. Xbox controllers do not need WebHID: rumble and trigger motors work through the standard Gamepad API.
Connecting fails after the picker
Section titled “Connecting fails after the picker”connectWebHID() rejects when the browser cannot open the device, for example while another program holds it
(not tested). Catch the error so a failed upgrade never stops the game:
connectButton.addEventListener('click', async () => { try { const connected = await hub.connectWebHID(); // false when the player closes the picker if (!connected) return; } catch (error) { showMessage('Could not connect the controller. Close other controller apps and try again.'); console.warn(error); }});After a page reload, call hub.reconnectAuthorized() to reattach controllers the player already approved, with no
picker.
Haptics
Section titled “Haptics”-
Every call returns
'none'. No controller is detected yet (see above), or the browser exposes no rumble motor for this controller.caps.matrix.dual_motor_rumble.reasonsays which. -
Xbox rumble plays, but not the trigger motors. The call returns
'dual_rumble'instead of'impulse_triggers'. Trigger motors need Chrome or Edge 126 or later. Windows Bluetooth can block them, so connect over USB or the Xbox Wireless Adapter if they stay silent.caps.matrix.impulse_triggers.reasonexplains the current controller. -
Adaptive triggers do not resist. They need a DualSense connected over WebHID. Trigger calls made before the connection do nothing, so apply the effect again when the connection changes:
const p1 = hub.player(0);const applyTriggers = () => p1.triggers.applyPreset('weapon', 'right');applyTriggers();hub.onCapabilitiesChange(applyTriggers);A bridge profile with a
triggersentry does this for you when the bridge is given the hub (player: hub). -
Rumble or trigger resistance stays on after the game ends. Call
hub.dispose()when the game’s view goes away. The SDK also stops rumble and resets the triggers when the page closes.
Tests and server rendering
Section titled “Tests and server rendering”- Server rendering and Node. The SDK can be imported in Node, and
createGamepadly()works there withoutnavigator: it reports'keyboard_mouse'and its haptic calls return'none'. You do not need to guard the import.connectWebHID()throws in Node, so call it only from a click. - A test presses
southand nothing happens. Mock state uses the base button names. Setstate.buttons.crossforsouth,circleforeast,squareforwestandtrianglefornorth. See Test it without a controller.
Optional 4-channel audio
Section titled “Optional 4-channel audio”The DualSense speaker and its 4-channel haptics need Windows and a USB connection. The connect functions return a
typed error such as link_not_running or dualsense_audio_not_found. Each error is explained in
Permissions and failure modes, and the setup is in
Optional Link.
Still stuck
Section titled “Still stuck”Open an issue with:
- the browser and its version, and the operating system;
- the controller and how it is connected (USB, Bluetooth or a wireless adapter);
- what the snippet at the top of this page logged;
- whether the online controller tester sees the controller.
Results from browsers, systems and controllers we have not tested are welcome too: they decide what the compatibility matrix marks as verified.