Skip to content

Gamepad Support

Yin.Story supports gamepad input across the editor, story browser, and web-based stories.

Default Mapping

ButtonAction
AConfirm / Select
BBack (when a back event with history = -1 exists)
D-pad / Left StickNavigate focus / Switch options
XAuxiliary action (scene-defined)
YAuxiliary action
StartStart / Menu
SelectSelect
LB / RBLeft/Right bumpers
LT / RTLeft/Right triggers
LS / RSStick press

Auto-Focus

The system automatically manages gamepad focus between event buttons in a scene. Moving the d-pad triggers focus jumps based on layout:

  • Horizontal layout: left/right navigation
  • Vertical layout: up/down navigation
  • Cross-component focus automatically snaps to the nearest element

Background Loop

Gamepad input is polled continuously via requestAnimationFrame and pauses automatically when the page is not visible, reducing resource usage.

Custom Binding

Access gamepad state in scripts:

js
import { gamepad } from '@/assets/gamepad.js'

// Register custom events
gamepad.on('A', () => {
  // A button pressed
})

// Currently hovered element ID
import { gamepadHover } from '@/assets/gamepad.js'