Files
nanakura dc26878386
CI / Lint (push) Canceled after 0s
CI / Build Test (stage-web) (push) Canceled after 0s
CI / Build Test (ui-loading-screens) (push) Canceled after 0s
CI / Build Test (ui-transitions) (push) Canceled after 0s
CI / Unit Test (push) Canceled after 0s
CI / Type Check (push) Canceled after 0s
CI / Check Provenance (push) Canceled after 0s
Sync Labels / sync-labels (push) Successful in 1m43s
chore: prune unused apps and services for the moeka fork
- Remove stage-tamagotchi, stage-pocket, server, and engine workspaces with their workflows, addons, and docs
- Switch the toolchain from pnpm to bun, replace lockfiles with bun.lock
- Rewrite remaining product references to Moeka
2026-09-14 16:40:49 +07:00
..

@proj-airi/input-gamepad

This package reads controllers through the browser Gamepad API. It accepts controllers that expose the W3C standard mapping.

The package converts browser button indices to physical names. For example, button 0 becomes faceBottom. The printed label can be ×, A, or B.

Use the package

import { StandardGamepadMonitor } from '@proj-airi/input-gamepad'

const monitor = new StandardGamepadMonitor({ deadzone: 0.12 })
const stopListening = monitor.onSnapshot((snapshot) => {
  if (!snapshot)
    return

  console.info(snapshot.leftStick, snapshot.buttons.faceBottom)
})

monitor.start()

// Run these operations when the feature closes.
stopListening()
monitor.stop()

When to use it

Use this package directly in framework-independent browser code. It supports buttons, sticks, and analog triggers.

In Vue code, own the polling lifecycle in a composable: create the controller with createGamepadMonitor(), stop it when the component unmounts, and expose the state you need as readonly refs.

Do not use this package for motion sensors, touchpads, lights, or adaptive triggers. Use a device-specific adapter for these features.

The package ignores controllers without the standard mapping. This rule prevents device-specific button indices from entering application code.