跳转到内容

@gamepadly/sdk

此内容尚不支持你的语言。

@gamepadly/sdk — Headless Web Controller, Adaptive Triggers, HD Rumble & Haptics SDK

Subpath exports:

  • @gamepadly/sdk — Core multi-controller hub, WebHID/Gamepad protocols, Action Map & cross-brand haptics
  • @gamepadly/sdk/audio — Optional sample-driven audio & 4ch VCM haptics bank (any AudioContext)
  • @gamepadly/sdk/mic — Optional microphone blow sensor
  • @gamepadly/sdk/link — Optional 3-layer audio engine & Gamepadly Link 4-channel WASAPI client
  • @gamepadly/sdk/game — Optional portable mini-game contract, reference host & test mock
  • @gamepadly/sdk/diagnostics — Optional tester toolkit: circularity, drift, bounce & telemetry
  • @gamepadly/sdk/bridge — Optional declarative Key/Mouse bridge for adapting open-source H5 games
  • @gamepadly/sdk/loop — Optional lightweight DPR canvas stage, fixed-step loop & disposables

Defined in: hid/index.ts:654

new ControllerManager(options?): ControllerManager

Defined in: hid/index.ts:657

DualSenseControllerManagerOptions = {}

ControllerManager

get device(): HIDDevice | null

Defined in: hid/index.ts:698

Active slot’s WebHID device (null if active slot is a Gamepad API controller or disconnected).

HIDDevice | null

get firmwareInfo(): DualSenseFirmwareInfo | undefined

Defined in: hid/index.ts:713

Active slot’s read-only DualSense firmware metadata, if available.

DualSenseFirmwareInfo | undefined

get hidDeviceCount(): number

Defined in: hid/index.ts:718

Count of currently open WebHID sessions (multi-DualSense support).

number

get transport(): TransportType

Defined in: hid/index.ts:708

Active slot’s WebHID transport (or ‘disconnected’ when active slot is not WebHID).

TransportType

attachHidHotplug(): void

Defined in: hid/index.ts:741

Listens for previously authorized DualSense / Switch Pro devices re-connecting over USB or Bluetooth while the page is open, automatically re-attaching WebHID with zero browser prompts.

void

attachKeyboardFallback(): void

Defined in: hid/index.ts:762

void

connect(): Promise<boolean>

Defined in: hid/index.ts:984

Opens the browser WebHID device picker to connect (or append) a DualSense / DualSense Edge or Nintendo Switch Pro controller. Existing connected controllers remain active and untouched.

Promise<boolean>

detachHidHotplug(): void

Defined in: hid/index.ts:747

void

detachKeyboardFallback(): void

Defined in: hid/index.ts:770

void

disconnect(slotId?, options?): Promise<void>

Defined in: hid/index.ts:1535

Disconnects a specific WebHID controller slot, or the active WebHID slot when slotId is omitted. With forget: true the browser permission is revoked too (HIDDevice.forget()), so the controller is not silently re-attached by reconnectAuthorized() on the next visit.

string

boolean

Promise<void>

disconnectAll(): Promise<void>

Defined in: hid/index.ts:1588

Promise<void>

emergencyReset(): void

Defined in: hid/index.ts:2456

Fire-and-forget safety reset across ALL connected WebHID and Gamepad controllers used inside pagehide / beforeunload so no controller ever stays stuck with stiff triggers or rumble.

void

flushOutput(opts?): Promise<boolean>

Defined in: hid/index.ts:2380

boolean

boolean

boolean

Promise<boolean>

getActiveGamepad(): ExtendedGamepad | null

Defined in: hid/index.ts:958

ExtendedGamepad | null

getActiveSlotId(): string | null

Defined in: hid/index.ts:899

string | null

getCapabilityMatrix(opts?): Record<CapabilityId, CapabilityStatus>

Defined in: hid/index.ts:2072

boolean

boolean

Record<CapabilityId, CapabilityStatus>

getCapabilityMatrixForSlot(slotId?, opts?): Record<CapabilityId, CapabilityStatus>

Defined in: hid/index.ts:1880

Computes a real-time capability matrix for the active controller slot (or a specific slotId).

string

boolean

boolean

Record<CapabilityId, CapabilityStatus>

getConnectedControllers(): ControllerSlotInfo[]

Defined in: hid/index.ts:824

Returns all connected controllers across WebHID and Gamepad API, automatically deduplicating DualSense and Switch Pro controllers that appear in both APIs simultaneously.

ControllerSlotInfo[]

getGamepadActuatorEffects(slotId?): readonly string[]

Defined in: hid/index.ts:962

string

readonly string[]

getHidDevice(slotId?): HIDDevice | null

Defined in: hid/index.ts:703

WebHID device behind a slot (default: active slot), or null for Gamepad API / unknown slots.

string

HIDDevice | null

getInputState(slotId?): UnifiedInputState

Defined in: hid/index.ts:1814

string

UnifiedInputState

getInputStateForSlot(slotId): UnifiedInputState

Defined in: hid/index.ts:1797

Returns a live input snapshot for a specific controller slot (e.g. hid-1 or gp-0). Returns a disconnected empty snapshot when that slot is not currently connected.

string

UnifiedInputState

hasDualRumbleSupport(slotId?): boolean

Defined in: hid/index.ts:975

string

boolean

hasTriggerRumbleSupport(slotId?): boolean

Defined in: hid/index.ts:971

string

boolean

onStatusChange(fn): () => void

Defined in: hid/index.ts:779

(evt) => void

() => void

playDualRumble(weakMagnitude, strongMagnitude, durationMs, slotId?): Promise<boolean>

Defined in: hid/index.ts:2224

Standard Gamepad API dual-rumble for Xbox / Switch / Generic controllers. Automatically uses true HD Rumble when the targeted slot is a WebHID Switch Pro.

number

number

number

string

Promise<boolean>

playSwitchHdRumble(spec, slotId?): Promise<boolean>

Defined in: hid/index.ts:2082

Drives Nintendo Switch Pro dual-band HD Rumble (LRA) over WebHID Report 0x10. Automatically returns both motors to neutral off after durationMs.

SwitchHdRumbleSpec

string

Promise<boolean>

playSwitchHdRumbleSequence(steps, slotId?): Promise<boolean>

Defined in: hid/index.ts:2107

Plays a timed sequence of Switch Pro HD Rumble steps (e.g., ice-cube sweep or L/R stereo pulse).

(SwitchHdRumbleSpec & object)[]

string

Promise<boolean>

playTriggerRumble(leftTrigger, rightTrigger, durationMs, weakMagnitude?, strongMagnitude?, slotId?): Promise<boolean>

Defined in: hid/index.ts:2165

Native Xbox Series Impulse Triggers (Chrome/Edge 126+, zero WebHID / zero install). Automatically maps to HD Rumble when the targeted slot is a WebHID Switch Pro.

number

number

number

number = 0

number = 0

string

Promise<boolean>

pulseLegacyRumble(left?, right?, durationMs?, slotId?): Promise<boolean>

Defined in: hid/index.ts:2509

number = 200

number = 200

number = 250

string

Promise<boolean>

reconnectAuthorized(): Promise<boolean>

Defined in: hid/index.ts:1010

Silently re-attaches all previously authorized DualSense & Switch Pro WebHID devices (zero browser prompts).

Promise<boolean>

resetTriggers(slotId?): Promise<boolean>

Defined in: hid/index.ts:2432

string

Promise<boolean>

setActiveSlot(slotId): boolean

Defined in: hid/index.ts:904

string

boolean

setAudioConfig(cfg): Promise<boolean>

Defined in: hid/index.ts:2390

AudioRouteMode

number

number

number

Promise<boolean>

setGamepadMappings(rules): void

Defined in: hid/index.ts:662

Replace the custom Gamepad API layouts (first matching rule wins).

GamepadMappingRule[]

void

setLightbar(r, g, b, slotId?): Promise<boolean>

Defined in: hid/index.ts:2476

number

number

number

string

Promise<boolean>

setMuteLed(mode, slotId?): Promise<boolean>

Defined in: hid/index.ts:2502

Controls the DualSense / DualSense Edge orange microphone mute button LED ('off' | 'on' | 'pulse').

MuteLedMode

string

Promise<boolean>

setPlayerLeds(mask, slotId?): Promise<boolean>

Defined in: hid/index.ts:2488

Sets the player indicator LED bitmask over WebHID:

  • DualSense / DualSense Edge: 5 white LEDs below touchpad (0x00..0x1f, e.g. 0x04 = center, 0x1f = all 5).
  • Switch Pro: 4 green LEDs on bottom edge (0x00..0x0f, e.g. 0x01, 0x03, 0x07, 0x0f).

number

string

Promise<boolean>

setTriggers(left?, right?, slotId?): Promise<boolean>

Defined in: hid/index.ts:2405

TriggerEffectSpec

TriggerEffectSpec

string

Promise<boolean>

stopGamepadRumble(slotId?): void

Defined in: hid/index.ts:2257

string

void

stopSwitchHdRumble(slotId?): void

Defined in: hid/index.ts:2145

string

void

triggerGamepadRumbleFallback(weakMagnitude, strongMagnitude, durationMs, slotId?): void

Defined in: hid/index.ts:2278

Backwards-compatible helper used when 4ch VCM audio is not active.

number

number

number

string

void

static isGamepadSupported(): boolean

Defined in: hid/index.ts:726

boolean

static isWebHIDSupported(): boolean

Defined in: hid/index.ts:722

boolean


Defined in: input/slotSwitcher.ts:41

Tracks multi-controller activity to:

  1. Auto-switch the active tester tab to whichever controller is intentionally operated.
  2. Detect intentional input on any controller (single or multi) to scroll the tester into view. Ignores static stick drift, micro-noise, and stick spring-back to center.

new SlotAutoSwitcher(): SlotAutoSwitcher

SlotAutoSwitcher

detectTargetSlot(samples, activeSlotId, now): string | null

Defined in: input/slotSwitcher.ts:136

SlotMotionSample[]

string | null

number

string | null

evaluate(samples, activeSlotId, now): SlotActivityResult

Defined in: input/slotSwitcher.ts:50

SlotMotionSample[]

string | null

number

SlotActivityResult

notifyManualSelect(samples, now): void

Defined in: input/slotSwitcher.ts:45

SlotMotionSample[]

number

void


Defined in: haptics/triggerWrites.ts:26

Tracks DualSense adaptive-trigger preset writes and cleanup responsibility so failed preset switches, failed “Off” clears, rapid clicks, or mid-write unmounts never drop the obligation to call hid.resetTriggers() on teardown.

new TriggerFeedbackController(): TriggerFeedbackController

TriggerFeedbackController

get hasActiveTrigger(): boolean

Defined in: haptics/triggerWrites.ts:44

boolean

get leftPreset(): string

Defined in: haptics/triggerWrites.ts:36

string

get needsCleanup(): boolean

Defined in: haptics/triggerWrites.ts:53

boolean

get rightPreset(): string

Defined in: haptics/triggerWrites.ts:40

string

applyPreset(hid, target, presetId, spec): Promise<TriggerApplyResult>

Defined in: haptics/triggerWrites.ts:65

TriggerHidAdapter

TriggerWriteTarget

string

TriggerEffectSpec

Promise<TriggerApplyResult>

cleanupOnSlotChange(hid): boolean

Defined in: haptics/triggerWrites.ts:174

TriggerHidAdapter

boolean

cleanupOnUnmount(hid): boolean

Defined in: haptics/triggerWrites.ts:163

TriggerHidAdapter

boolean

markMounted(): void

Defined in: haptics/triggerWrites.ts:57

void

markRumbleActive(): void

Defined in: haptics/triggerWrites.ts:61

void

Defined in: input/actions.ts:64

The bindings of an action map, as plain JSON-safe data (for saving and restoring player remaps).

TActions extends string = string

TAxes extends string = string

actions: Record<TActions, ActionBinding[]>

Defined in: input/actions.ts:65

axes: Record<TAxes, AxisActionSpec>

Defined in: input/actions.ts:66


Defined in: input/actions.ts:33

TActions extends string = string

TAxes extends string = string

optional actions?: Record<TActions, ActionBinding[]>

Defined in: input/actions.ts:37

optional analogThreshold?: number

Defined in: input/actions.ts:40

Analog threshold (0..1) above which a trigger or stick direction counts as pressed. Default 0.45.

optional attachWindowListeners?: boolean

Defined in: input/actions.ts:42

Attach window keyboard/mouse listeners automatically when window exists. Default true.

optional axes?: Record<TAxes, AxisActionSpec>

Defined in: input/actions.ts:38

optional ignoreHeldOnStart?: boolean

Defined in: input/actions.ts:60

Keep actions whose inputs are already held when the map is created released until they are let go, so the button that closed a menu or started the game does not also fire a game action. Default false.

optional mouseTarget?: EventTarget

Defined in: input/actions.ts:44

Optional DOM element for mouse button tracking (defaults to window).

optional preventDefaultKeys?: boolean

Defined in: input/actions.ts:49

Call preventDefault() on bound navigation/scroll keys (Space, Arrow*, Tab) when focus is not inside a form field. Default true.

optional repeat?: object

Defined in: input/actions.ts:54

Timing for repeated(), for menus that keep moving while a direction is held: the first repeat comes delayMs after the press, then one every intervalMs. Default { delayMs: 400, intervalMs: 100 }.

optional delayMs?: number

optional intervalMs?: number


Defined in: input/actions.ts:69

heldMs: number

Defined in: input/actions.ts:73

justPressed: boolean

Defined in: input/actions.ts:71

justReleased: boolean

Defined in: input/actions.ts:72

pressed: boolean

Defined in: input/actions.ts:70

repeated: boolean

Defined in: input/actions.ts:75

True on the press, then once per repeat interval while held (see ActionMapSpec.repeat).

value: number

Defined in: input/actions.ts:77

Analog intensity 0..1 (e.g. R2 pull depth, stick tilt magnitude, or 1 when digital key pressed).


Defined in: input/actions.ts:80

TActions extends string = string

TAxes extends string = string

action(name): ActionState

Defined in: input/actions.ts:87

Digital + edge state for a declared action.

TActions

ActionState

axis(name): number

Defined in: input/actions.ts:98

Combined -1..+1 axis value fusing gamepad stick, buttons, and keyboard keys.

TAxes

number

dispose(): void

Defined in: input/actions.ts:122

Clears all held states and detaches any window/DOM listeners.

void

getBindings(): ActionBindings<TActions, TAxes>

Defined in: input/actions.ts:100

A copy of the current bindings, safe to JSON.stringify() and pass back to setBindings().

ActionBindings<TActions, TAxes>

isPressed(name): boolean

Defined in: input/actions.ts:89

Convenience boolean checks.

TActions

boolean

justPressed(name): boolean

Defined in: input/actions.ts:90

TActions

boolean

justReleased(name): boolean

Defined in: input/actions.ts:91

TActions

boolean

lastPressed(): ActionBinding | null

Defined in: input/actions.ts:117

The input that went down during the latest update(), as a binding: a controller button (position names such as 'south' for face buttons), 'l2' / 'r2', a stick direction, a KeyboardEvent.code or a mouse button. null when nothing new was pressed. For “press a button for Jump” screens.

ActionBinding | null

repeated(name): boolean

Defined in: input/actions.ts:96

True on the update the action is pressed, then again every repeat interval while it stays held. Use it to move through menus with a held direction.

TActions

boolean

setBindings(bindings): void

Defined in: input/actions.ts:107

Replaces the bindings of the listed actions and axes; the others keep theirs. Names the map does not declare are ignored, so bindings saved by an older version of the game load safely. A rebound action stays released until its inputs are released, so the press used to pick a binding does not also trigger the action.

Partial<Record<TActions, ActionBinding[]>>

Partial<Record<TAxes, AxisActionSpec>>

void

setKeyDown(code, down): void

Defined in: input/actions.ts:119

Marks a keyboard code as held or released, as a keydown / keyup would (useful in tests).

string

boolean

void

setMouseButton(button, down): void

Defined in: input/actions.ts:120

MouseButtonBinding

boolean

void

update(input, nowMs?): void

Defined in: input/actions.ts:85

Poll once per frame with the latest UnifiedInputState and timestamp (ms).

UnifiedInputState

number

void


Defined in: input/actions.ts:23

optional deadzone?: number

Defined in: input/actions.ts:25

optional invert?: boolean

Defined in: input/actions.ts:30

optional negativeButtons?: ButtonInput[]

Defined in: input/actions.ts:26

optional negativeKeys?: string[]

Defined in: input/actions.ts:28

optional positiveButtons?: ButtonInput[]

Defined in: input/actions.ts:27

optional positiveKeys?: string[]

Defined in: input/actions.ts:29

optional stick?: "lx" | "ly" | "rx" | "ry"

Defined in: input/actions.ts:24


Defined in: hid/index.ts:116

charging: boolean

Defined in: hid/index.ts:118

full: boolean

Defined in: hid/index.ts:119

known: boolean

Defined in: hid/index.ts:120

percent: number

Defined in: hid/index.ts:117


Defined in: hub.ts:156

active: PlayerCapabilities

Defined in: hub.ts:158

slots: ControllerSlotInfo[]

Defined in: hub.ts:157


Defined in: hid/index.ts:59

availability: CapabilityAvailability

Defined in: hid/index.ts:61

inherent: boolean

Defined in: hid/index.ts:60

optional reason?: string

Defined in: hid/index.ts:62


Defined in: haptics/router.ts:59

stop(): void

Defined in: haptics/router.ts:61

void

update(params): void

Defined in: haptics/router.ts:60

number

number

number

number

void


Defined in: hid/index.ts:72

brand: ControllerBrand

Defined in: hid/index.ts:73

displayName: string

Defined in: hid/index.ts:75

optional firmwareInfo?: DualSenseFirmwareInfo

Defined in: hid/index.ts:81

model: ControllerModel

Defined in: hid/index.ts:74

optional productId?: number

Defined in: hid/index.ts:78

rawId: string

Defined in: hid/index.ts:76

source: "none" | "webhid" | "gamepad" | "keyboard_mouse"

Defined in: hid/index.ts:80

transport: TransportType

Defined in: hid/index.ts:79

optional vendorId?: number

Defined in: hid/index.ts:77


Defined in: lifecycle.ts:16

optional audio?: LifecycleAudio | (() => LifecycleAudio | null) | null

Defined in: lifecycle.ts:29

Audio layer to silence on exit; a getter lets hosts swap engines at runtime.

optional autoEmergencyReset?: boolean

Defined in: lifecycle.ts:25

On pagehide / beforeunload: reset triggers, rumble and HD Rumble on every controller and stop continuous audio haptics. Default true.

optional autoHotplug?: boolean

Defined in: lifecycle.ts:18

Listen for WebHID hotplug and Gamepad API connect/disconnect events. Default true.

optional detachHotplugOnCleanup?: boolean

Defined in: lifecycle.ts:20

Detach WebHID hotplug again when the returned cleanup runs. Default true.

optional onChange?: (reason) => void

Defined in: lifecycle.ts:36

Called when controllers may have changed: 'status' (manager connect/disconnect/upgrade), 'gamepad' (Gamepad API event) or 'poll'. Diff cheaply; this fires every poll tick.

ControllerLifecycleReason

void

optional pollMs?: number

Defined in: lifecycle.ts:31

Poll interval (ms) for Gamepad API changes that fire no event. Default 250; 0 disables.

optional teardownAudioOnExit?: boolean

Defined in: lifecycle.ts:27

Also release the DualSense 4-channel audio output on page exit. Default false.


Defined in: hid/index.ts:544

battery: BatteryStatus

Defined in: hid/index.ts:551

id: string

Defined in: hid/index.ts:546

Stable slot identifier: hid-1, hid-2, gp-0, gp-1, …

identity: ControllerIdentity

Defined in: hid/index.ts:550

lastActivityAt: number

Defined in: hid/index.ts:554

Timestamp (performance.now()) of most recent button press on this slot

observedReportHz: number | null

Defined in: hid/index.ts:552

playerNumber: number

Defined in: hid/index.ts:548

1-based player index in the current deduplicated controller list (P1, P2, …)

source: "webhid" | "gamepad"

Defined in: hid/index.ts:549


Defined in: hid/index.ts:165

optional gamepadMappings?: GamepadMappingRule[]

Defined in: hid/index.ts:167

Custom layouts for Gamepad API controllers; the first matching rule wins.


Defined in: hid/index.ts:65

buildDate: string

Defined in: hid/index.ts:66

buildTime: string

Defined in: hid/index.ts:67

fwVersionHex: string

Defined in: hid/index.ts:69

hwInfoHex: string

Defined in: hid/index.ts:68


Defined in: hub.ts:161

readonly hid: ControllerManager

Defined in: hub.ts:162

get active(): PlayerHandle

Defined in: hub.ts:177

Gets the currently active player handle (single-player convenience).

PlayerHandle

attachAudio(audio): void

Defined in: hub.ts:173

Attaches or detaches a 3-layer audio / Link engine at runtime.

HapticAudioSink | null

void

connectWebHID(): Promise<boolean>

Defined in: hub.ts:164

Connects a DualSense / Switch Pro controller via browser WebHID picker (must be called in a user gesture).

Promise<boolean>

disconnectWebHID(slotId?, options?): Promise<void>

Defined in: hub.ts:169

Disconnects a WebHID controller (default: the active one). With forget: true the browser permission is revoked too, so it will not silently reconnect on the next visit.

string

boolean

Promise<void>

dispose(): void

Defined in: hub.ts:193

Stops all active haptics/rumble/continuous audio, resets triggers & lightbar, and frees listeners.

void

getSlots(): ControllerSlotInfo[]

Defined in: hub.ts:175

Lists all deduplicated connected controllers (P1..P4).

ControllerSlotInfo[]

onCapabilitiesChange(listener): () => void

Defined in: hub.ts:189

Subscribes to controller connect/disconnect, WebHID upgrade, slot switch, or 4ch audio changes.

(event) => void

() => void

player(target?): PlayerHandle

Defined in: hub.ts:187

Returns a player handle by 0-based player index (0 = P1, 1 = P2, … up to 3) or explicit slotId. If target is omitted or 'active', follows the manager’s active slot.

A numbered player keeps its controller: when another controller disconnects, connects or is upgraded to WebHID, player(1) still reads P2’s controller. When P2’s controller disconnects, player(1) reads an idle state and getSlotId() returns null until a newly connected controller takes the free seat (the lowest free player number first).

string | number

PlayerHandle

reconnectAuthorized(): Promise<boolean>

Defined in: hub.ts:171

Re-attaches previously authorized WebHID controllers with zero prompts.

Promise<boolean>

syncCapabilities(): void

Defined in: hub.ts:191

Manually checks and emits capability changes if anything changed (useful in tests or custom loops).

void


Defined in: hub.ts:124

optional attachKeyboardFallback?: boolean

Defined in: hub.ts:144

Automatically attach keyboard fallback on the underlying manager when owned. Default false.

optional audio?: HapticAudioSink | null

Defined in: hub.ts:133

Optional 3-layer audio / 4ch Link engine (from @gamepadly/sdk/link).

optional autoEmergencyReset?: boolean

Defined in: hub.ts:149

On pagehide / beforeunload: reset triggers, rumble and HD Rumble on every controller and stop continuous audio haptics. Default true.

optional autoHotplug?: boolean

Defined in: hub.ts:142

Automatically listen for WebHID hotplug & Gamepad API connect/disconnect events. Default true.

optional capabilityPollMs?: number

Defined in: hub.ts:153

Poll interval (ms) for detecting Gamepad API capability changes. Default 250. Set 0 to disable.

optional gamepadMappings?: GamepadMappingRule[]

Defined in: hub.ts:131

Custom layouts for controllers the browser exposes with a non-standard Gamepad API mapping (check player.input.getState().mapping === 'nonstandard'). First matching rule wins.

optional hid?: ControllerManager

Defined in: hub.ts:126

Reuse an existing controller manager (e.g. from a host app context).

optional samples?: SampleAudioSink | null

Defined in: hub.ts:140

Optional 4-channel sample bank (createSampleBank(provider) from @gamepadly/sdk/audio). Not needed when audio is created via createLinkAudio(), which already bundles a sample bank. Controller-routed samples ('speaker' / 'vcm' / 'quad') only reach the DualSense when audio reports a bound 4-channel device for this player.

optional teardownAudioOnExit?: boolean

Defined in: hub.ts:151

Also release the DualSense 4-channel audio output on page exit. Default false.


Defined in: hid/index.ts:154

Custom Gamepad API layout for controllers the browser exposes with a non-standard mapping (common in Firefox and Safari, and for some third-party pads). Unlisted buttons/axes keep their W3C standard index. Pass rules via createGamepadly({ gamepadMappings }) or manager.setGamepadMappings().

optional axes?: Partial<Record<"lx" | "ly" | "rx" | "ry", GamepadAxisSource>>

Defined in: hid/index.ts:160

Stick axis → raw pad.axes[] index (optionally inverted).

optional buttons?: Partial<Record<ButtonName, number>>

Defined in: hid/index.ts:158

SDK button name → raw pad.buttons[] index.

match: (pad) => boolean

Defined in: hid/index.ts:156

Return true when this rule applies, e.g. (pad) => pad.mapping === '' && pad.id.includes('054c').

string

number

string

boolean

optional triggers?: Partial<Record<"l2" | "r2", GamepadTriggerSource>>

Defined in: hid/index.ts:162

Analog trigger → raw button or axis.


Defined in: haptics/router.ts:95

Structural audio/4ch-haptics sink satisfied by ThreeLayerAudioEngine in @gamepadly/sdk/link. Keeping this interface in core ensures @gamepadly/sdk stays tree-shakable with zero audio dependency.

readonly dsMaxChannelCount: number

Defined in: haptics/router.ts:97

readonly dsMode: "none" | "companion" | "setsinkid"

Defined in: haptics/router.ts:96

createContinuous(preset): ContinuousHapticHandle

Defined in: haptics/router.ts:100

ContinuousPreset

ContinuousHapticHandle

optional hasSample(id): boolean

Defined in: haptics/router.ts:110

string

boolean

optional loadSample(id, source): Promise<boolean>

Defined in: haptics/router.ts:109

string

SampleSource

Promise<boolean>

playComboPreset(presetId, pan?): void

Defined in: haptics/router.ts:101

ComboPresetId

number

void

playControllerSpeakerTone(spec): void

Defined in: haptics/router.ts:104

ToneSpec

void

playHapticPulse(spec): void

Defined in: haptics/router.ts:98

HapticPulseSpec

void

playHapticSweep(spec): void

Defined in: haptics/router.ts:99

HapticSweepSpec

void

playPcNoiseBurst(opts): void

Defined in: haptics/router.ts:103

NoiseBurstSpec

void

playPcTone(spec): void

Defined in: haptics/router.ts:102

ToneSpec

void

optional playSample(id, options?): SamplePlaybackHandle

Defined in: haptics/router.ts:112

string

PlaySampleOptions

SamplePlaybackHandle

optional stopAllContinuous(): void

Defined in: haptics/router.ts:106

Optional: silences every continuous haptic/audio layer (called on page exit).

void

optional teardownDsOutput(): Promise<void>

Defined in: haptics/router.ts:108

Optional: releases the DualSense 4-channel output (called on page exit when enabled).

Promise<void>

optional unloadSample(id): void

Defined in: haptics/router.ts:111

string

void


Defined in: haptics/router.ts:16

optional delayMs?: number

Defined in: haptics/router.ts:23

durationMs: number

Defined in: haptics/router.ts:20

optional endFreqHz?: number

Defined in: haptics/router.ts:19

freqHz: number

Defined in: haptics/router.ts:18

intensity: number

Defined in: haptics/router.ts:21

optional pan?: number

Defined in: haptics/router.ts:17

optional wave?: OscillatorType

Defined in: haptics/router.ts:22


Defined in: haptics/router.ts:117

optional allow4ChAudio?: boolean

Defined in: haptics/router.ts:122

Whether this slot can use the attached 4ch audio stream (true for active/primary DualSense).

optional audio?: HapticAudioSink | null

Defined in: haptics/router.ts:119

hid: ControllerManager

Defined in: haptics/router.ts:118

optional slotId?: string

Defined in: haptics/router.ts:120


Defined in: haptics/router.ts:26

durationMs: number

Defined in: haptics/router.ts:31

fromHz: number

Defined in: haptics/router.ts:29

fromPan: number

Defined in: haptics/router.ts:27

intensity: number

Defined in: haptics/router.ts:32

toHz: number

Defined in: haptics/router.ts:30

toPan: number

Defined in: haptics/router.ts:28

optional wave?: OscillatorType

Defined in: haptics/router.ts:33


Defined in: hid/index.ts:557

optional deviceName?: string

Defined in: hid/index.ts:560

optional firmwareInfo?: DualSenseFirmwareInfo

Defined in: hid/index.ts:563

optional productId?: number

Defined in: hid/index.ts:561

optional slotId?: string

Defined in: hid/index.ts:559

optional transport?: TransportType

Defined in: hid/index.ts:562

type: "disconnected" | "connected" | "slots_changed"

Defined in: hid/index.ts:558


Defined in: haptics/router.ts:75

optional durationMs?: number

Defined in: haptics/router.ts:78

optional left?: number

Defined in: haptics/router.ts:76

optional right?: number

Defined in: haptics/router.ts:77

optional strongGrip?: number

Defined in: haptics/router.ts:80

optional weakGrip?: number

Defined in: haptics/router.ts:79


Defined in: lifecycle.ts:9

Optional audio layer silenced on page exit (ThreeLayerAudioEngine satisfies it).

optional stopAllContinuous(): void

Defined in: lifecycle.ts:10

void

optional teardownDsOutput(): Promise<void>

Defined in: lifecycle.ts:11

Promise<void>


Defined in: input/motion.ts:32

active: boolean

Defined in: input/motion.ts:34

True once connected IMU data (non-zero accel or gyro) has been observed.

angularSpeed: number

Defined in: input/motion.ts:46

Instantaneous angular speed magnitude (hypot(gyro.x, gyro.y, gyro.z)).

flickDirection: FlickDirection

Defined in: input/motion.ts:56

Dominant direction of the latest flick ('none' when justFlicked is false).

justFlicked: boolean

Defined in: input/motion.ts:54

Single-frame rising edge triggered on a brisk wrist flick (casting, throwing, whipping).

linearAccelDelta: number

Defined in: input/motion.ts:48

Gravity-removed high-pass linear acceleration magnitude.

pitch: number

Defined in: input/motion.ts:36

Calibrated pitch angle in radians (nose up positive, relative to recenter()).

pitchNorm: number

Defined in: input/motion.ts:42

Normalized pitch tilt (-1..1 at ±fullTiltRad).

roll: number

Defined in: input/motion.ts:38

Calibrated roll angle in radians (tilted right positive, relative to recenter()).

rollNorm: number

Defined in: input/motion.ts:44

Normalized roll tilt (-1..1 at ±fullTiltRad).

shakeIntensity: number

Defined in: input/motion.ts:50

Smoothed continuous shaking energy (0..1).

shaking: boolean

Defined in: input/motion.ts:52

True when shakeIntensity >= shakeThreshold.

yaw: number

Defined in: input/motion.ts:40

Integrated relative yaw angle in radians (relative to recenter()).


Defined in: input/motion.ts:59

getState(): MotionState

Defined in: input/motion.ts:63

Returns the latest computed motion pose and gesture snapshot.

MotionState

recenter(): void

Defined in: input/motion.ts:65

Zeroes the current physical controller orientation as the neutral (pitch=0, roll=0, yaw=0) pose.

void

reset(): void

Defined in: input/motion.ts:67

Resets all calibration offsets, filters, and gesture history.

void

update(input, dtSec?, nowMs?): MotionState

Defined in: input/motion.ts:61

Advances the complementary filter and gesture detectors with the latest controller state.

UnifiedInputState

number

number

MotionState


Defined in: input/motion.ts:5

optional flickCooldownMs?: number

Defined in: input/motion.ts:25

Minimum cooldown (ms) between consecutive justFlicked events. Default 320.

optional flickThreshold?: number

Defined in: input/motion.ts:23

Combined impulse threshold triggering justFlicked. Default 0.62.

optional fullTiltRad?: number

Defined in: input/motion.ts:21

Angle in radians mapped to pitchNorm = ±1 / rollNorm = ±1. Default Math.PI / 4 (45 degrees).

optional gyroScaleRadPerSec?: number

Defined in: input/motion.ts:16

Maps normalized input.gyro.{x,y,z} (-1..1) to radians/sec. Default 4.5 rad/s.

optional gyroWeight?: number

Defined in: input/motion.ts:11

Complementary filter weight on integrated gyroscope vs gravity accelerometer (0..1). Higher values feel snappier with less linear-acceleration wobble; lower values self-level faster. Default 0.94.

optional shakeDecay?: number

Defined in: input/motion.ts:27

Shake energy decay rate per second. Default 2.4.

optional shakeThreshold?: number

Defined in: input/motion.ts:29

Threshold (0..1) above which shaking is true. Default 0.35.


Defined in: haptics/router.ts:46

optional delayMs?: number

Defined in: haptics/router.ts:54

durationMs: number

Defined in: haptics/router.ts:47

optional endFreqHz?: number

Defined in: haptics/router.ts:50

optional filterType?: BiquadFilterType

Defined in: haptics/router.ts:48

freqHz: number

Defined in: haptics/router.ts:49

optional intensity?: number

Defined in: haptics/router.ts:52

optional pan?: number

Defined in: haptics/router.ts:53

optional q?: number

Defined in: haptics/router.ts:51


Defined in: hub.ts:56

has4ChHaptics: boolean

Defined in: hub.ts:66

hasAdaptiveTriggers: boolean

Defined in: hub.ts:62

hasControllerSpeaker: boolean

Defined in: hub.ts:67

hasDualRumble: boolean

Defined in: hub.ts:65

hasGyro: boolean

Defined in: hub.ts:68

hasHdRumble: boolean

Defined in: hub.ts:64

hasImpulseTriggers: boolean

Defined in: hub.ts:63

hasTouchpad: boolean

Defined in: hub.ts:69

identity: ControllerIdentity

Defined in: hub.ts:59

matrix: Record<CapabilityId, CapabilityStatus>

Defined in: hub.ts:60

slotId: string | null

Defined in: hub.ts:57

tier: HardwareTier

Defined in: hub.ts:58

has(cap): boolean

Defined in: hub.ts:61

CapabilityId

boolean


Defined in: hub.ts:72

readonly audio: object

Defined in: hub.ts:103

hasSample(id): boolean

string

boolean

loadSample(id, source): Promise<boolean>

string

SampleSource

Promise<boolean>

playControllerSpeakerTone(spec): void

ToneSpec

void

playPcNoise(opts): void

NoiseBurstSpec

void

playPcTone(spec): void

ToneSpec

void

playSample(id, options?): SamplePlaybackHandle

string

PlaySampleOptions

SamplePlaybackHandle

unloadSample(id): void

string

void

readonly haptics: object

Defined in: hub.ts:91

createContinuous(preset): ContinuousHapticHandle

ContinuousPreset

ContinuousHapticHandle

hdRumble(spec): void

SwitchHdRumbleSpec

void

hdSequence(steps): void

(SwitchHdRumbleSpec & object)[]

void

playComboPreset(presetId, pan?): void

ComboPresetId

number

void

playPreset(presetId, opts?): HapticRouteTier

TactilePresetId

number

number

HapticRouteTier

pulse(spec): HapticRouteTier

HapticPulseSpec

HapticRouteTier

rumble(opts): void

number

number

number

void

stop(): void

void

sweep(spec): HapticRouteTier

HapticSweepSpec

HapticRouteTier

readonly input: object

Defined in: hub.ts:77

applyDeadzone(value, threshold?): number

number

number

number

getState(): UnifiedInputState

UnifiedInputState

readonly lightbar: object

Defined in: hub.ts:113

flash(r, g, b, durationMs?): void

number

number

number

number

void

setColor(r, g, b): void

number

number

number

void

readonly triggers: object

Defined in: hub.ts:82

applyPreset(presetId, side?): void

TriggerPresetId

"both" | "left" | "right"

void

pulseImpulse(spec): void

ImpulseTriggerSpec

void

reset(): void

void

setBoth(left, right): void

TriggerEffectSpec

TriggerEffectSpec

void

setLeft(effect): void

TriggerEffectSpec

void

setRight(effect): void

TriggerEffectSpec

void

createActions<TActions, TAxes>(spec): ActionTracker<TActions, TAxes>

Defined in: hub.ts:119

Creates a semantic Action Map tracker scoped to this hub’s disposal lifecycle.

TActions extends string = string

TAxes extends string = string

ActionMapSpec<TActions, TAxes>

ActionTracker<TActions, TAxes>

getCapabilities(): PlayerCapabilities

Defined in: hub.ts:75

PlayerCapabilities

getSlotId(): string | null

Defined in: hub.ts:74

Resolves the current physical slot ID bound to this handle, or null if disconnected.

string | null


Defined in: haptics/samples.ts:22

optional delayMs?: number

Defined in: haptics/samples.ts:41

Optional start delay in milliseconds. Default 0.

optional fallbackHaptic?: object

Defined in: haptics/samples.ts:46

Optional cross-brand fallback tactile pulse used by PlayerHandle when route is 'vcm' or 'quad' on non-4ch hardware (Switch Pro HD Rumble, Xbox Impulse Triggers, standard rumble).

optional durationMs?: number

optional freqHz?: number

optional intensity?: number

optional gain?: number

Defined in: haptics/samples.ts:35

Playback gain 0..1.5. Default 0.85.

optional loop?: boolean

Defined in: haptics/samples.ts:39

Loop continuously until .stop() is called. Default false.

optional pan?: number

Defined in: haptics/samples.ts:33

Stereo pan -1 (left) .. +1 (right). Default 0.

optional playbackRate?: number

Defined in: haptics/samples.ts:37

Playback rate 0.25..4.0 (modulate pitch/texture with movement speed). Default 1.0.

optional route?: SampleRoute

Defined in: haptics/samples.ts:31

Output bus routing:

  • 'pc' — PC speakers / headphones (stereo panned)
  • 'speaker' — DualSense built-in controller speaker Ch0+Ch1 (falls back to PC if unbound)
  • 'vcm' — DualSense L/R voice-coil actuators Ch2+Ch3 (falls back via cross-brand haptics router)
  • 'quad' — Synchronized 4-channel playback: Ch0/1 -> Controller Speaker, Ch2/3 -> L/R VCM Default 'pc'.

Defined in: haptics/samples.ts:8

channels: Float32Array<ArrayBufferLike>[]

Defined in: haptics/samples.ts:17

Channel PCM arrays (-1..1 float samples):

  • 1 channel: mono
  • 2 channels: stereo [left, right]
  • 4 channels (for route: 'quad'): [speakerL, speakerR, vcmLeft, vcmRight]

sampleRate: number

Defined in: haptics/samples.ts:10

Sample rate in Hz (48000 recommended for DualSense 4-channel VCM fidelity).


Defined in: haptics/router.ts:84

Structural 4-channel sample playback sink satisfied by SampleBank and LinkAudioEngine.

hasSample(id): boolean

Defined in: haptics/router.ts:86

string

boolean

loadSample(id, source): Promise<boolean>

Defined in: haptics/router.ts:85

string

SampleSource

Promise<boolean>

playSample(id, options?): SamplePlaybackHandle

Defined in: haptics/router.ts:88

string

PlaySampleOptions

SamplePlaybackHandle

unloadSample(id): void

Defined in: haptics/router.ts:87

string

void


Defined in: haptics/samples.ts:53

readonly active: boolean

Defined in: haptics/samples.ts:59

True while the sample node is still active.

stop(fadeOutMs?): void

Defined in: haptics/samples.ts:57

Stops playback cleanly, with an optional smooth fade-out in milliseconds.

number

void

update(params): void

Defined in: haptics/samples.ts:55

Dynamically modulates an active (especially looping) sample’s pan, gain, or playback rate.

number

number

number

void


Defined in: input/touchpad.ts:20

active: boolean

Defined in: input/touchpad.ts:21

dx: number

Defined in: input/touchpad.ts:26

dy: number

Defined in: input/touchpad.ts:27

justReleased: boolean

Defined in: input/touchpad.ts:23

justTouched: boolean

Defined in: input/touchpad.ts:22

x: number

Defined in: input/touchpad.ts:24

y: number

Defined in: input/touchpad.ts:25


Defined in: input/slotSwitcher.ts:12

switchTo: string | null

Defined in: input/slotSwitcher.ts:14

Non-null when an inactive controller was intentionally operated and should become active.

triggeredSlotId: string | null

Defined in: input/slotSwitcher.ts:16

Non-null whenever any controller (active or inactive) received intentional fresh input.


Defined in: input/slotSwitcher.ts:1

id: string

Defined in: input/slotSwitcher.ts:2

l2: number

Defined in: input/slotSwitcher.ts:8

lastActivityAt: number

Defined in: input/slotSwitcher.ts:3

lx: number

Defined in: input/slotSwitcher.ts:4

ly: number

Defined in: input/slotSwitcher.ts:5

r2: number

Defined in: input/slotSwitcher.ts:9

rx: number

Defined in: input/slotSwitcher.ts:6

ry: number

Defined in: input/slotSwitcher.ts:7


Defined in: hid/index.ts:223

highAmp: number

Defined in: hid/index.ts:227

High-band amplitude (0.0 - 1.0, safely clamped at 0.85 to protect LRAs)

highFreqHz: number

Defined in: hid/index.ts:225

High-band frequency in Hz (81.75 - 1252.6 Hz, default 320 Hz)

lowAmp: number

Defined in: hid/index.ts:231

Low-band amplitude (0.0 - 1.0, safely clamped at 0.85 to protect LRAs)

lowFreqHz: number

Defined in: hid/index.ts:229

Low-band frequency in Hz (40.88 - 626.3 Hz, default 160 Hz)


Defined in: hid/index.ts:234

optional durationMs?: number

Defined in: hid/index.ts:238

Auto-stop duration in ms (default 220, clamped 30..2500)

optional left?: SwitchHdRumbleSide

Defined in: hid/index.ts:235

optional right?: SwitchHdRumbleSide

Defined in: hid/index.ts:236


Defined in: haptics/presets.ts:36

durationMs: number

Defined in: haptics/presets.ts:39

optional endFreqHz?: number

Defined in: haptics/presets.ts:38

freqHz: number

Defined in: haptics/presets.ts:37

intensity: number

Defined in: haptics/presets.ts:40

optional switchHd?: object

Defined in: haptics/presets.ts:45

Optional Switch Pro dual-band fine tuning

highFreqHz: number

highWeight: number

lowFreqHz: number

lowWeight: number

optional triggerEmphasis?: number

Defined in: haptics/presets.ts:43

Optional Xbox impulse trigger emphasis (0..1)

optional wave?: OscillatorType

Defined in: haptics/presets.ts:41


Defined in: haptics/router.ts:36

optional delayMs?: number

Defined in: haptics/router.ts:43

durationMs: number

Defined in: haptics/router.ts:39

optional endFreqHz?: number

Defined in: haptics/router.ts:38

freqHz: number

Defined in: haptics/router.ts:37

optional intensity?: number

Defined in: haptics/router.ts:40

optional pan?: number

Defined in: haptics/router.ts:41

optional wave?: OscillatorType

Defined in: haptics/router.ts:42


Defined in: hid/index.ts:123

active: boolean

Defined in: hid/index.ts:124

x: number

Defined in: hid/index.ts:125

y: number

Defined in: hid/index.ts:126


Defined in: input/touchpad.ts:5

optional doubleTapWindowMs?: number

Defined in: input/touchpad.ts:11

Max gap (ms) between two taps to trigger justDoubleTapped. Default 320.

optional swipeMinDistance?: number

Defined in: input/touchpad.ts:15

Minimum total displacement required for justSwiped. Default 0.12.

optional swipeMinSpeed?: number

Defined in: input/touchpad.ts:13

Minimum release velocity (normalized units/sec) to trigger justSwiped. Default 1.15.

optional tapMaxMove?: number

Defined in: input/touchpad.ts:9

Max total displacement (normalized 0..1) to classify as a tap. Default 0.06.

optional tapMaxMs?: number

Defined in: input/touchpad.ts:7

Max contact duration (ms) to classify as a tap. Default 240.

optional velocitySmoothing?: number

Defined in: input/touchpad.ts:17

EMA smoothing factor (0..1) for velocity (vx, vy). Default 0.45.


Defined in: input/touchpad.ts:30

active: boolean

Defined in: input/touchpad.ts:34

True while primary finger 1 is contacting the touchpad.

clicked: boolean

Defined in: input/touchpad.ts:78

Physical touchpad press button (input.buttons.touchpadClick).

dx: number

Defined in: input/touchpad.ts:44

Per-frame primary finger X delta.

dy: number

Defined in: input/touchpad.ts:46

Per-frame primary finger Y delta.

fingerCount: 0 | 1 | 2

Defined in: input/touchpad.ts:32

Number of active fingers on the touchpad (0, 1, or 2).

justClicked: boolean

Defined in: input/touchpad.ts:80

Single-frame rising edge on physical touchpad click.

justDoubleTapped: boolean

Defined in: input/touchpad.ts:60

Single-frame edge fired when two quick taps land within doubleTapWindowMs.

justReleased: boolean

Defined in: input/touchpad.ts:42

Falling edge on primary finger lift.

justSwiped: boolean

Defined in: input/touchpad.ts:64

Single-frame edge fired when a brisk swipe completes on release.

justTapped: boolean

Defined in: input/touchpad.ts:58

Single-frame edge fired on a quick single-finger tap.

justTouched: boolean

Defined in: input/touchpad.ts:40

Rising edge on primary finger contact.

justTwoFingerTapped: boolean

Defined in: input/touchpad.ts:62

Single-frame edge fired on a quick two-finger tap.

pinchActive: boolean

Defined in: input/touchpad.ts:68

True while both fingers are touching simultaneously.

pinchDelta: number

Defined in: input/touchpad.ts:72

Per-frame change in pinchDistance (>0 spreading apart, <0 pinching together).

pinchDistance: number

Defined in: input/touchpad.ts:70

Current Euclidean distance between finger 1 and finger 2 (normalized).

pinchScale: number

Defined in: input/touchpad.ts:74

Relative pinch ratio (1.0 at two-finger touch start).

secondFinger: SecondFingerState

Defined in: input/touchpad.ts:76

Independent state for the second finger (input.touch2).

speed: number

Defined in: input/touchpad.ts:56

Smoothed primary finger speed (hypot(vx, vy)).

swipeDirection: SwipeDirection

Defined in: input/touchpad.ts:66

Dominant direction of the latest swipe ('none' when justSwiped is false).

totalDx: number

Defined in: input/touchpad.ts:48

Total X displacement since primary touch began.

totalDy: number

Defined in: input/touchpad.ts:50

Total Y displacement since primary touch began.

vx: number

Defined in: input/touchpad.ts:52

Smoothed primary finger horizontal velocity (normalized units/sec).

vy: number

Defined in: input/touchpad.ts:54

Smoothed primary finger vertical velocity (normalized units/sec).

x: number

Defined in: input/touchpad.ts:36

Primary finger X (0..1, left to right).

y: number

Defined in: input/touchpad.ts:38

Primary finger Y (0..1, top to bottom).


Defined in: input/touchpad.ts:83

getState(): TouchpadGestureState

Defined in: input/touchpad.ts:87

Returns the latest gesture snapshot.

TouchpadGestureState

reset(): void

Defined in: input/touchpad.ts:89

Clears all active touch, velocity, and tap history.

void

update(input, dtSec?, nowMs?): TouchpadGestureState

Defined in: input/touchpad.ts:85

Updates gesture recognition from the latest UnifiedInputState.

UnifiedInputState

number

number

TouchpadGestureState


Defined in: haptics/triggerWrites.ts:10

hadActiveBefore: boolean

Defined in: haptics/triggerWrites.ts:14

hadActiveTargetBefore: boolean

Defined in: haptics/triggerWrites.ts:15

leftPreset: string

Defined in: haptics/triggerWrites.ts:16

needsReset: boolean

Defined in: haptics/triggerWrites.ts:18

ok: boolean

Defined in: haptics/triggerWrites.ts:11

rightPreset: string

Defined in: haptics/triggerWrites.ts:17

stale: boolean

Defined in: haptics/triggerWrites.ts:12

unmounted: boolean

Defined in: haptics/triggerWrites.ts:13


Defined in: haptics/triggerWrites.ts:5

resetTriggers(): Promise<boolean>

Defined in: haptics/triggerWrites.ts:7

Promise<boolean>

setTriggers(left?, right?): Promise<boolean>

Defined in: haptics/triggerWrites.ts:6

TriggerEffectSpec

TriggerEffectSpec

Promise<boolean>


Defined in: hid/index.ts:170

accel: object

Defined in: hid/index.ts:193

x: number

y: number

z: number

battery: BatteryStatus

Defined in: hid/index.ts:198

buttons: Record<ButtonName, boolean>

Defined in: hid/index.ts:185

connected: boolean

Defined in: hid/index.ts:171

deviceName: string

Defined in: hid/index.ts:175

gyro: object

Defined in: hid/index.ts:188

x: number

y: number

z: number

identity: ControllerIdentity

Defined in: hid/index.ts:177

isDualSense: boolean

Defined in: hid/index.ts:176

l2: number

Defined in: hid/index.ts:183

lx: number

Defined in: hid/index.ts:179

Raw un-deadzoned axes (-1..1). Use applyDeadzone() in games if smoothing is desired.

ly: number

Defined in: hid/index.ts:180

mapping: InputMapping

Defined in: hid/index.ts:174

How buttons/axes were mapped for this snapshot (see InputMapping).

observedReportHz: number | null

Defined in: hid/index.ts:200

Browser-observed WebHID inputreport frequency (Hz). Null when not streaming WebHID.

r2: number

Defined in: hid/index.ts:184

rx: number

Defined in: hid/index.ts:181

ry: number

Defined in: hid/index.ts:182

source: "none" | "webhid" | "gamepad" | "keyboard_mouse"

Defined in: hid/index.ts:172

touch: TouchFinger

Defined in: hid/index.ts:186

touch2: TouchFinger

Defined in: hid/index.ts:187

ActionBinding = ButtonInput | TriggerBinding | StickDirectionBinding | MouseButtonBinding | string & object

Defined in: input/actions.ts:16

Any binding accepted in a digital action array:

  • Controller buttons ('cross', 'r1', 'up', …) or position-based aliases ('south', 'east', 'start', …)
  • Analog triggers ('l2', 'r2')
  • Stick directions ('lx+', 'lx-', 'ly+', 'ly-', 'rx+', 'rx-', 'ry+', 'ry-')
  • Mouse buttons ('MouseLeft', 'MouseRight', 'MouseMiddle')
  • Keyboard KeyboardEvent.code strings ('Space', 'KeyW', 'ArrowUp', 'ShiftLeft', …)

AudioRouteMode = "speaker" | "headphone" | "both"

Defined in: hid/index.ts:18


ButtonAlias = "south" | "east" | "west" | "north" | "select" | "start" | "home"

Defined in: input/buttons.ts:7

Brand-neutral, position-based button names (the SDL / Unity Input System convention). south is the bottom face button on every controller: Xbox A, PlayStation Cross, Nintendo B.


ButtonInput = ButtonName | ButtonAlias

Defined in: input/buttons.ts:10

Any button name accepted by action maps and the key/mouse bridge.


ButtonName = "cross" | "circle" | "square" | "triangle" | "l1" | "r1" | "l2Btn" | "r2Btn" | "l3" | "r3" | "up" | "down" | "left" | "right" | "create" | "options" | "ps" | "touchpadClick" | "mute" | "fnL" | "fnR" | "paddleL" | "paddleR"

Defined in: hid/index.ts:84


CapabilityAvailability = "ready" | "permission_required" | "bridge_required" | "configuration_required" | "unsupported" | "unknown" | "disconnected" | "busy"

Defined in: hid/index.ts:49


CapabilityId = "standard_input" | "analog_triggers" | "dual_motor_rumble" | "impulse_triggers" | "hd_rumble" | "adaptive_triggers" | "audio_haptics" | "controller_speaker" | "gyro" | "accelerometer" | "touchpad" | "lightbar" | "battery"

Defined in: hid/index.ts:34


ComboPresetId = "ratchet_tick" | "lock_sweet_spot" | "lock_unlock" | "fish_bite" | "fish_splash" | "pistol" | "shotgun" | "bow_release" | "thunder"

Defined in: haptics/router.ts:64


ContinuousPreset = "ice" | "metal" | "gravel" | "grass" | "water" | "engine" | "tension"

Defined in: haptics/router.ts:57


ControllerBrand = "sony" | "xbox" | "nintendo" | "generic" | "none"

Defined in: hid/index.ts:20


ControllerLifecycleReason = "status" | "gamepad" | "poll"

Defined in: lifecycle.ts:14


ControllerModel = "dualsense" | "dualsense_edge" | "dualshock4" | "xbox_series" | "xbox_one" | "xbox_360" | "switch_pro" | "switch2_pro" | "joycon" | "generic" | "none"

Defined in: hid/index.ts:21


FlickDirection = "none" | "up" | "down" | "left" | "right"

Defined in: input/motion.ts:3


GamepadAxisSource = number | { index: number; invert?: boolean; }

Defined in: hid/index.ts:140

Raw axis source for a remapped stick axis.


GamepadTriggerSource = { button: number; } | { axis: number; range?: "signed" | "unsigned"; }

Defined in: hid/index.ts:143

Raw source for a remapped analog trigger (0..1).

{ button: number; }


{ axis: number; range?: "signed" | "unsigned"; }

range: 'signed' (default) treats -1 as released and 1 as fully pressed; 'unsigned' reads 0..1.


HapticRouteTier = "4ch_vcm" | "hd_rumble" | "impulse_triggers" | "dual_rumble" | "none"

Defined in: haptics/router.ts:115


HardwareTier = "dualsense_full_4ch" | "dualsense_hid_only" | "switch_pro_hid" | "xbox_impulse" | "standard_gamepad" | "keyboard_mouse"

Defined in: hub.ts:48


InputMapping = "standard" | "nonstandard" | "custom" | "hid" | "none"

Defined in: hid/index.ts:137

How the active input snapshot’s buttons and axes were mapped.

  • standard: browser reports the W3C “standard” Gamepad layout (indices are reliable)
  • nonstandard: browser reports mapping === ''; indices are read as if standard and may be misnamed
  • custom: a GamepadMappingRule matched this pad and remapped it
  • hid: decoded directly from WebHID reports (always correct)
  • none: keyboard/mouse fallback or disconnected

MouseButtonBinding = "MouseLeft" | "MouseRight" | "MouseMiddle"

Defined in: input/actions.ts:6


MuteLedMode = "off" | "on" | "pulse"

Defined in: hid/index.ts:19


SampleRoute = "pc" | "speaker" | "vcm" | "quad"

Defined in: haptics/samples.ts:6

Sample-driven audio & 4-channel VCM haptics types + procedural PCM tactile buffer builder. Pure TypeScript with zero Web Audio dependency so core @gamepadly/sdk stays headless & tree-shakable.


SampleSource = string | ArrayBuffer | RawPcmSample

Defined in: haptics/samples.ts:20


StickDirectionBinding = "lx+" | "lx-" | "ly+" | "ly-" | "rx+" | "rx-" | "ry+" | "ry-"

Defined in: input/actions.ts:4


SwipeDirection = "none" | "up" | "down" | "left" | "right"

Defined in: input/touchpad.ts:3


TactileBufferPreset = "footstep_ice" | "footstep_metal" | "footstep_gravel" | "footstep_water" | "zipper_tick" | "spring_boing" | "engine_hum"

Defined in: haptics/samples.ts:70


TactilePresetId = "click" | "ratchet" | "wall_hit" | "marble_click" | "recoil" | "heavy_impact" | "lock_unlock" | "splash" | "boost" | "error_buzz"

Defined in: haptics/presets.ts:24


TransportType = "usb" | "bluetooth" | "unknown" | "disconnected"

Defined in: hid/index.ts:17

@gamepadly/sdk — Cross-Brand Controller Protocol & Capability Layer

Key guarantees:

  • ZERO hidden deadzone on raw analog axes (micro-drift is never masked in diagnostics)
  • Complete 18-button standard mapping (including L3/R3/Create/Options/Home/Touchpad)
  • Multi-controller slot addressing (P1–P4) across WebHID + Gamepad API
  • Native Xbox Series Impulse Triggers (trigger-rumble in Chrome/Edge 126+, zero install)
  • Sony DualSense (0x054C:0x0CE6) & DualSense Edge (0x054C:0x0DF2) via WebHID (USB 0x02 & BT 0x31 CRC32)
    • Official 10-zone Adaptive Triggers (works over BOTH USB & Bluetooth, zero companion needed!)
    • 6-axis Gyro/Accel, dual-finger Touchpad, Battery, RGB Lightbar, read-only firmware metadata
    • Speaker amplifier unlock for optional 4ch USB audio workflows
  • Nintendo Switch Pro (0x057E:0x2009) via WebHID: dual-band LRA HD Rumble, 6-axis Gyro/Accel, read-only SPI calibration
  • SSR-safe (never crashes when window / navigator are unavailable during static prerendering)

TriggerBinding = "l2" | "r2"

Defined in: input/actions.ts:5


TriggerEffectSpec = { type: "off"; } | { startZone: number; strength: number; type: "feedback"; } | { endStrength: number; endZone: number; startStrength: number; startZone: number; type: "slope"; } | { endZone: number; startZone: number; strength: number; type: "weapon"; } | { amplitude: number; frequencyHz: number; startZone: number; type: "vibration"; }

Defined in: hid/index.ts:109


TriggerPresetId = "off" | "weapon" | "heavy_weapon" | "bow" | "abs" | "soft_wall" | "rapid_pulse" | "precision_damp"

Defined in: haptics/presets.ts:3


TriggerWriteTarget = "both" | "left" | "right"

Defined in: haptics/triggerWrites.ts:3

const BUTTON_ALIASES: Readonly<Record<ButtonAlias, ButtonName>>

Defined in: input/buttons.ts:13

Position-based alias → SDK button name. SDK names follow the physical position, not the printed label.


const DEFAULT_DUALSENSE_SPEAKER_PREAMP: 5 = 5

Defined in: hid/index.ts:631

Balanced DualSense built-in speaker hardware preamp (0..7; 5 stays crisp without harsh clipping).


const DEFAULT_DUALSENSE_SPEAKER_VOLUME: 88 = 0x58

Defined in: hid/index.ts:629

Balanced DualSense built-in speaker volume (inside official 0x3D..0x64 audible span).


const NOOP_SAMPLE_HANDLE: SamplePlaybackHandle

Defined in: haptics/samples.ts:62


const TACTILE_PRESETS: Record<TactilePresetId, TactilePresetSpec>

Defined in: haptics/presets.ts:53


const TRIGGER_PRESETS: Record<TriggerPresetId, TriggerEffectSpec>

Defined in: haptics/presets.ts:13

applyDeadzone(value, threshold?): number

Defined in: hid/index.ts:302

number

number = 0.06

number


attachControllerLifecycle(hid, options?): () => void

Defined in: lifecycle.ts:40

Wires the lifecycle and returns an idempotent cleanup function. Safe to call during SSR (no-op).

ControllerManager

ControllerLifecycleOptions = {}

() => void


buildSwitchHdFromPulse(opts): SwitchHdRumbleSpec

Defined in: haptics/presets.ts:149

Helper to build a Switch Pro stereo HD Rumble frame from pan (-1..+1), frequency, and intensity (0..1).

number

number

number

number

number

number

number

number

SwitchHdRumbleSpec


crc32WithSeed(seedByte, reportId, bytes): number

Defined in: hid/index.ts:402

CRC-32 (zlib polynomial) over [seedByte, reportId, ...bytes], as appended to DualSense Bluetooth output reports.

number

number

Uint8Array

number


createActionTracker<TActions, TAxes>(spec): ActionTracker<TActions, TAxes>

Defined in: input/actions.ts:232

TActions extends string = string

TAxes extends string = string

ActionMapSpec<TActions, TAxes>

ActionTracker<TActions, TAxes>


createEmptyInput(): UnifiedInputState

Defined in: hid/index.ts:489

UnifiedInputState


createGamepadly(options?): GamepadlyHub

Defined in: hub.ts:272

GamepadlyHubOptions = {}

GamepadlyHub


createMotionTracker(options?): MotionTracker

Defined in: input/motion.ts:78

Fuses canonical 6-axis gyroscope + accelerometer readings (PS5 DualSense / Switch Pro) into drift-compensated pitch / roll / yaw angles plus ready-to-use shake and flick gestures.

MotionTrackerOptions = {}

MotionTracker


createTactileBuffer(preset, sampleRate?): RawPcmSample

Defined in: haptics/samples.ts:96

Generates deterministic 48 kHz 4-channel quad PCM tactile samples ([spkL, spkR, vcmL, vcmR]) with synchronized near-field speaker transients (Ch0/1) and voice-coil waveforms (Ch2/3). Ideal for prototyping Astro-style surface footsteps, zipper ticks, and springs with zero external assets.

TactileBufferPreset

number = 48000

RawPcmSample


createTouchpadGestures(options?): TouchpadGestureTracker

Defined in: input/touchpad.ts:101

Turns raw DualSense dual-finger touchpad coordinates (input.touch / input.touch2) into game-ready gestures: drag deltas, smoothed swipe velocity (for ball rolling / sliders), single/double/two-finger taps, directional swipes, and two-finger pinch scale.

TouchpadGestureOptions = {}

TouchpadGestureTracker


encodeSwitchHdRumbleSide(side?): Uint8Array

Defined in: hid/index.ts:273

Encodes one side (Left or Right LRA) of Nintendo Switch Pro HD Rumble into the 4-byte HID payload. Returns neutral off [0x00, 0x01, 0x40, 0x40] when both band amplitudes are silent.

SwitchHdRumbleSide

Uint8Array


encodeTriggerEffect(spec): Uint8Array

Defined in: hid/index.ts:412

TriggerEffectSpec

Uint8Array


getButtonLabel(button, brand): string

Defined in: input/buttons.ts:68

Human-readable label for on-screen prompts, matching what is printed on the player’s controller. Generic and unknown controllers use the Xbox-style labels most PC pads print (A/B/X/Y). Plain text only: render your own icons if you want glyphs. Also accepts 'l2' / 'r2'; any other string, such as a stick direction or a key code, is returned unchanged.

"l2" | "r2" | ButtonInput | string & object

ControllerBrand

string

getButtonLabel('south', hub.active.getCapabilities().identity.brand) // 'A' | 'Cross' | 'B'

identifyGamepadFromId(rawId): Omit<ControllerIdentity, "source" | "transport">

Defined in: hid/index.ts:339

string

Omit<ControllerIdentity, "source" | "transport">


isControllerBinding(binding): boolean

Defined in: input/actions.ts:178

Whether a binding is a controller input (a button, 'l2' / 'r2' or a stick direction) rather than a keyboard key or mouse button. Use it to replace only the controller side of an action when a player remaps it, so keyboard bindings keep working.

string

boolean


resolveButtonName(name): ButtonName

Defined in: input/buttons.ts:24

Returns the SDK button name for a position-based alias, or the name itself when it is not an alias.

ButtonInput

ButtonName

resolveButtonName(name): string

Defined in: input/buttons.ts:25

Returns the SDK button name for a position-based alias, or the name itself when it is not an alias.

string

string


routeHapticPulse(ctx, spec): HapticRouteTier

Defined in: haptics/router.ts:139

Routes a tactile pulse across hardware tiers with faithful stereo & frequency preservation:

  1. DualSense 4ch VCM audio (when attached & active)
  2. Nintendo Switch Pro dual-band LRA HD Rumble (preserves pan + freqHz)
  3. Xbox Series Impulse Triggers (maps pan + crisp frequencies into L/R trigger motors)
  4. Standard Gamepad / DualSense legacy dual-motor fallback

Returns the actual hardware tier selected (HapticRouteTier).

HapticRouteContext

HapticPulseSpec

HapticRouteTier


routeHapticSweep(ctx, spec): HapticRouteTier

Defined in: haptics/router.ts:191

Routes a tactile sweep across hardware tiers:

  1. DualSense 4ch VCM audio sweep
  2. Switch Pro multi-step stereo HD Rumble sequence (interpolating pan & frequency)
  3. Xbox / standard dual-motor fallback

Returns the actual hardware tier selected (HapticRouteTier).

HapticRouteContext

HapticSweepSpec

HapticRouteTier


routeTactilePreset(ctx, presetId, opts?): HapticRouteTier

Defined in: haptics/router.ts:241

Plays a named cross-brand tactile preset with optional pan & intensity scale overrides. Returns the actual hardware tier selected (HapticRouteTier).

HapticRouteContext

TactilePresetId

number

number

HapticRouteTier

Renames and re-exports ControllerManager