InputService
The global input service — provides access to all PlayerInput instances and raw devices.
Retrieved via useInput() or engine.inject('input').
class InputServicePlayers
player
player(index: number): PlayerInputReturns the PlayerInput for the given zero-based player slot.
| Parameter | Type | Description |
|---|---|---|
index | number | Zero-based player slot index (0–3). |
Throws RangeError if index is out of bounds.
players
get players(): readonly PlayerInput[]All active PlayerInput instances. Length matches the players count passed to InputPlugin.
action
action<T extends ActionType>(ref: ActionRef<T>): ActionState<T>Convenience shorthand for input.player(0).action(ref).
Devices
keyboard
get keyboard(): KeyboardDeviceThe keyboard device instance. See Devices — KeyboardDevice.
mouse
get mouse(): MouseDeviceThe mouse device instance. See Devices — MouseDevice.
gamepad
get gamepad(): GamepadDeviceThe gamepad device instance. See Devices — GamepadDevice.
touch
get touch(): TouchDeviceThe touch device instance. See Devices — TouchDevice.
gyro
get gyro(): GyroDeviceThe gyroscope device instance. See Devices — GyroDevice.
virtualControls
get virtualControls(): VirtualControlsOverlay | undefinedThe virtual controls overlay instance. Present only when configured via InputPlugin({ touch: { virtualJoysticks, virtualButtons } }).
Recording
recorder
get recorder(): InputRecorderThe InputRecorder instance. Use to start/stop recording and export recordings. See Recording & Playback.
playback
get playback(): InputPlaybackThe InputPlayback instance. Use to load, play, seek, and stop recorded sessions.
Motion permission
requestMotionPermission
requestMotionPermission(): Promise<'granted' | 'denied' | 'unavailable'>Requests iOS 13+ motion permission for the gyroscope. Must be called from a user gesture handler (e.g. a button click). Calling from onUpdate() will fail silently on iOS.
On platforms that do not require an explicit permission grant, resolves immediately with 'granted'. If DeviceOrientationEvent is not available, resolves with 'unavailable'.
button.onclick = async () => {
const result = await useInput().requestMotionPermission()
if (result === 'granted') enableGyroAim()
}Accessibility profiles
getAccessibilityProfiles
getAccessibilityProfiles(): string[]Returns the names of all registered accessibility profiles. Profiles are registered via InputPlugin({ accessibilityProfiles: { ... } }). Activate a profile for a player via player.activateAccessibilityProfile(name).
const profiles = useInput().getAccessibilityProfiles()
// ['one-handed-left', 'one-handed-right', 'high-contrast']Debug
debug
get debug(): InputDebugAPI | nullThe debug API instance. Returns null in production (import.meta.env.PROD) or before the plugin finishes setup. Use this to build devtools integrations or debug overlays.
const debug = useInput().debug
if (debug) {
debug.onFrame(snap => console.log(snap.players[0].actions))
}