{"record":{"id":"bf78beb875c5b2f8","repo":"moeru-ai/airi","slug":"the-gamepad-does-not-use-the-standard-mapping","errorCode":null,"errorMessage":"The gamepad does not use the standard mapping.","messagePattern":"The gamepad does not use the standard mapping\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/input-gamepad/src/standard-gamepad.ts","lineNumber":119,"sourceCode":"export function createStandardGamepadSnapshot(\n  gamepad: Gamepad,\n  options?: StandardGamepadSnapshotOptions,\n): StandardGamepadSnapshot {\n  if (gamepad.mapping !== 'standard')\n    throw new Error('The gamepad does not use the standard mapping.')\n\n  const deadzone = options?.deadzone ?? 0.12\n  if (!Number.isFinite(deadzone) || deadzone < 0 || deadzone >= 1)\n    throw new Error('The gamepad deadzone must be from 0 to less than 1.')\n\n  return {\n    buttons: createButtonStates(gamepad.buttons),\n    family: detectGamepadFamily(gamepad.id),\n    id: gamepad.id,\n    index: gamepad.index,\n    leftStick: applyRadialDeadzone(gamepad.axes[0] ?? 0, gamepad.axes[1] ?? 0, deadzone),\n    rightStick: applyRadialDeadzone(gamepad.axes[2] ?? 0, gamepad.axes[3] ?? 0, deadzone),\n    timestamp: gamepad.timestamp,\n  }\n}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/moeru-ai/airi/blob/9c213115f8bd0fff9e6eabab02b077ac32da21be/packages/input-gamepad/src/standard-gamepad.ts#L101-L137","documentation":"createStandardGamepadSnapshot only knows how to normalize controllers that report the W3C 'standard' mapping; button and axis indexes have guaranteed positions only under that layout. The guard throws when the passed Gamepad reports any other mapping (e.g. a non-standard layout driver or an empty mapping), because applying standard positional indexes to it would produce wrong button/axis data.","triggerScenarios":"Thrown at packages/input-gamepad/src/standard-gamepad.ts:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only pass Gamepad objects whose `mapping` property equals 'standard', or filter with `navigator.getGamepads().filter(g => g?.mapping === 'standard')` first.","If you must support non-standard controllers, extend the package with a mapping-specific snapshot builder instead of forcing the standard one.","In UI code, skip or grey out devices without the standard mapping and surface the reason to the user."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c213115f8bd0fff9e6eabab02b077ac32da21be","analyzedAt":"2026-09-02T04:27:24.639Z","contentChangedAt":"2026-09-02T04:27:24.639Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}