@gamepadly/sdk 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +137 -2
  3. package/SECURITY.md +19 -0
  4. package/dist/bridge/index.d.ts +50 -0
  5. package/dist/bridge/index.d.ts.map +1 -0
  6. package/dist/bridge/index.js +422 -0
  7. package/dist/bridge/index.js.map +7 -0
  8. package/dist/bridge/profiles.d.ts +51 -0
  9. package/dist/bridge/profiles.d.ts.map +1 -0
  10. package/dist/browser.d.ts +15 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +4234 -0
  13. package/dist/browser.js.map +7 -0
  14. package/dist/browser.min.js +1 -0
  15. package/dist/chunks/chunk-GMU2WEFE.js +1850 -0
  16. package/dist/chunks/chunk-GMU2WEFE.js.map +7 -0
  17. package/dist/haptics/presets.d.ts +35 -0
  18. package/dist/haptics/presets.d.ts.map +1 -0
  19. package/dist/haptics/router.d.ts +102 -0
  20. package/dist/haptics/router.d.ts.map +1 -0
  21. package/dist/hid/index.d.ts +323 -0
  22. package/dist/hid/index.d.ts.map +1 -0
  23. package/dist/hub.d.ts +112 -0
  24. package/dist/hub.d.ts.map +1 -0
  25. package/dist/index.d.ts +15 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +819 -0
  28. package/dist/index.js.map +7 -0
  29. package/dist/input/actions.d.ts +64 -0
  30. package/dist/input/actions.d.ts.map +1 -0
  31. package/dist/link/engine.d.ts +213 -0
  32. package/dist/link/engine.d.ts.map +1 -0
  33. package/dist/link/index.d.ts +8 -0
  34. package/dist/link/index.d.ts.map +1 -0
  35. package/dist/link/index.js +966 -0
  36. package/dist/link/index.js.map +7 -0
  37. package/dist/loop/index.d.ts +69 -0
  38. package/dist/loop/index.d.ts.map +1 -0
  39. package/dist/loop/index.js +214 -0
  40. package/dist/loop/index.js.map +7 -0
  41. package/package.json +79 -4
@@ -0,0 +1,323 @@
1
+ /**
2
+ * @gamepadly/sdk — Cross-Brand Controller Protocol & Capability Layer
3
+ *
4
+ * Key guarantees:
5
+ * - ZERO hidden deadzone on raw analog axes (micro-drift is never masked in diagnostics)
6
+ * - Complete 18-button standard mapping (including L3/R3/Create/Options/Home/Touchpad)
7
+ * - Multi-controller slot addressing (P1–P4) across WebHID + Gamepad API
8
+ * - Native Xbox Series Impulse Triggers (`trigger-rumble` in Chrome/Edge 126+, zero install)
9
+ * - Sony DualSense (0x054C:0x0CE6) & DualSense Edge (0x054C:0x0DF2) via WebHID (USB 0x02 & BT 0x31 CRC32)
10
+ * - Official 10-zone Adaptive Triggers (works over BOTH USB & Bluetooth, zero companion needed!)
11
+ * - 6-axis Gyro/Accel, dual-finger Touchpad, Battery, RGB Lightbar, read-only firmware metadata
12
+ * - Speaker amplifier unlock for optional 4ch USB audio workflows
13
+ * - Nintendo Switch Pro (0x057E:0x2009) via WebHID: dual-band LRA HD Rumble, 6-axis Gyro/Accel, read-only SPI calibration
14
+ * - SSR-safe (never crashes when `window` / `navigator` are unavailable during static prerendering)
15
+ */
16
+ export type TransportType = 'usb' | 'bluetooth' | 'unknown' | 'disconnected';
17
+ export type AudioRouteMode = 'speaker' | 'headphone' | 'both';
18
+ export type ControllerBrand = 'sony' | 'xbox' | 'nintendo' | 'generic' | 'none';
19
+ export type ControllerModel = 'dualsense' | 'dualsense_edge' | 'dualshock4' | 'xbox_series' | 'xbox_one' | 'xbox_360' | 'switch_pro' | 'switch2_pro' | 'joycon' | 'generic' | 'none';
20
+ export type CapabilityId = 'standard_input' | 'analog_triggers' | 'dual_motor_rumble' | 'impulse_triggers' | 'hd_rumble' | 'adaptive_triggers' | 'audio_haptics' | 'controller_speaker' | 'gyro' | 'accelerometer' | 'touchpad' | 'lightbar' | 'battery';
21
+ export type CapabilityAvailability = 'ready' | 'permission_required' | 'bridge_required' | 'configuration_required' | 'unsupported' | 'unknown' | 'disconnected' | 'busy';
22
+ export interface CapabilityStatus {
23
+ inherent: boolean;
24
+ availability: CapabilityAvailability;
25
+ reason?: string;
26
+ }
27
+ export interface DualSenseFirmwareInfo {
28
+ buildDate: string;
29
+ buildTime: string;
30
+ hwInfoHex: string;
31
+ fwVersionHex: string;
32
+ }
33
+ export interface ControllerIdentity {
34
+ brand: ControllerBrand;
35
+ model: ControllerModel;
36
+ displayName: string;
37
+ rawId: string;
38
+ vendorId?: number;
39
+ productId?: number;
40
+ transport: TransportType;
41
+ source: 'webhid' | 'gamepad' | 'keyboard_mouse' | 'none';
42
+ firmwareInfo?: DualSenseFirmwareInfo;
43
+ }
44
+ export type ButtonName = 'cross' | 'circle' | 'square' | 'triangle' | 'l1' | 'r1' | 'l2Btn' | 'r2Btn' | 'l3' | 'r3' | 'up' | 'down' | 'left' | 'right' | 'create' | 'options' | 'ps' | 'touchpadClick';
45
+ export type TriggerEffectSpec = {
46
+ type: 'off';
47
+ } | {
48
+ type: 'feedback';
49
+ startZone: number;
50
+ strength: number;
51
+ } | {
52
+ type: 'slope';
53
+ startZone: number;
54
+ endZone: number;
55
+ startStrength: number;
56
+ endStrength: number;
57
+ } | {
58
+ type: 'weapon';
59
+ startZone: number;
60
+ endZone: number;
61
+ strength: number;
62
+ } | {
63
+ type: 'vibration';
64
+ startZone: number;
65
+ amplitude: number;
66
+ frequencyHz: number;
67
+ };
68
+ export interface BatteryStatus {
69
+ percent: number;
70
+ charging: boolean;
71
+ full: boolean;
72
+ known: boolean;
73
+ }
74
+ export interface TouchFinger {
75
+ active: boolean;
76
+ x: number;
77
+ y: number;
78
+ }
79
+ export interface UnifiedInputState {
80
+ connected: boolean;
81
+ source: 'webhid' | 'gamepad' | 'keyboard_mouse' | 'none';
82
+ deviceName: string;
83
+ isDualSense: boolean;
84
+ identity: ControllerIdentity;
85
+ /** Raw un-deadzoned axes (-1..1). Use applyDeadzone() in games if smoothing is desired. */
86
+ lx: number;
87
+ ly: number;
88
+ rx: number;
89
+ ry: number;
90
+ l2: number;
91
+ r2: number;
92
+ buttons: Record<ButtonName, boolean>;
93
+ touch: TouchFinger;
94
+ touch2: TouchFinger;
95
+ gyro: {
96
+ x: number;
97
+ y: number;
98
+ z: number;
99
+ };
100
+ accel: {
101
+ x: number;
102
+ y: number;
103
+ z: number;
104
+ };
105
+ battery: BatteryStatus;
106
+ /** Browser-observed WebHID inputreport frequency (Hz). Null when not streaming WebHID. */
107
+ observedReportHz: number | null;
108
+ }
109
+ interface ExtendedHapticActuator {
110
+ effects?: readonly string[];
111
+ playEffect?: (type: string, params: {
112
+ startDelay?: number;
113
+ duration: number;
114
+ weakMagnitude?: number;
115
+ strongMagnitude?: number;
116
+ leftTrigger?: number;
117
+ rightTrigger?: number;
118
+ }) => Promise<string | void>;
119
+ reset?: () => Promise<string | void>;
120
+ }
121
+ type ExtendedGamepad = Omit<Gamepad, 'vibrationActuator'> & {
122
+ vibrationActuator?: ExtendedHapticActuator | null;
123
+ };
124
+ export interface SwitchHdRumbleSide {
125
+ /** High-band frequency in Hz (81.75 - 1252.6 Hz, default 320 Hz) */
126
+ highFreqHz: number;
127
+ /** High-band amplitude (0.0 - 1.0, safely clamped at 0.85 to protect LRAs) */
128
+ highAmp: number;
129
+ /** Low-band frequency in Hz (40.88 - 626.3 Hz, default 160 Hz) */
130
+ lowFreqHz: number;
131
+ /** Low-band amplitude (0.0 - 1.0, safely clamped at 0.85 to protect LRAs) */
132
+ lowAmp: number;
133
+ }
134
+ export interface SwitchHdRumbleSpec {
135
+ left?: SwitchHdRumbleSide;
136
+ right?: SwitchHdRumbleSide;
137
+ /** Auto-stop duration in ms (default 220, clamped 30..2500) */
138
+ durationMs?: number;
139
+ }
140
+ /**
141
+ * Encodes one side (Left or Right LRA) of Nintendo Switch Pro HD Rumble into the 4-byte HID payload.
142
+ * Returns neutral off `[0x00, 0x01, 0x40, 0x40]` when both band amplitudes are silent.
143
+ */
144
+ export declare function encodeSwitchHdRumbleSide(side?: SwitchHdRumbleSide): Uint8Array;
145
+ export declare function applyDeadzone(value: number, threshold?: number): number;
146
+ export declare function identifyGamepadFromId(rawId: string): Omit<ControllerIdentity, 'source' | 'transport'>;
147
+ /** CRC-32 (zlib polynomial) over `[seedByte, reportId, ...bytes]`, as appended to DualSense Bluetooth output reports. */
148
+ export declare function crc32WithSeed(seedByte: number, reportId: number, bytes: Uint8Array): number;
149
+ export declare function encodeTriggerEffect(spec: TriggerEffectSpec): Uint8Array;
150
+ export declare function createEmptyInput(): UnifiedInputState;
151
+ export interface ControllerSlotInfo {
152
+ /** Stable slot identifier: `hid-1`, `hid-2`, `gp-0`, `gp-1`, ... */
153
+ id: string;
154
+ /** 1-based player index in the current deduplicated controller list (P1, P2, ...) */
155
+ playerNumber: number;
156
+ source: 'webhid' | 'gamepad';
157
+ identity: ControllerIdentity;
158
+ battery: BatteryStatus;
159
+ observedReportHz: number | null;
160
+ /** Timestamp (`performance.now()`) of most recent button press on this slot */
161
+ lastActivityAt: number;
162
+ }
163
+ export interface HIDStatusEvent {
164
+ type: 'connected' | 'disconnected' | 'slots_changed';
165
+ slotId?: string;
166
+ deviceName?: string;
167
+ productId?: number;
168
+ transport?: TransportType;
169
+ firmwareInfo?: DualSenseFirmwareInfo;
170
+ }
171
+ export declare class DualSenseControllerManager {
172
+ private hidSessions;
173
+ private nextHidSeq;
174
+ private activeSlotId;
175
+ private hidDisconnectAttached;
176
+ private hidConnectAttached;
177
+ private listeners;
178
+ private gamepadInputs;
179
+ private gamepadLastActivity;
180
+ private gamepadPrevBtnMask;
181
+ private fallbackInput;
182
+ private keysDown;
183
+ private kbmAttached;
184
+ private boundConnect;
185
+ private boundDisconnect;
186
+ private boundKeyDown;
187
+ private boundKeyUp;
188
+ private boundWindowBlur;
189
+ /** Active slot's WebHID device (null if active slot is a Gamepad API controller or disconnected). */
190
+ get device(): HIDDevice | null;
191
+ /** Active slot's WebHID transport (or 'disconnected' when active slot is not WebHID). */
192
+ get transport(): TransportType;
193
+ /** Active slot's read-only DualSense firmware metadata, if available. */
194
+ get firmwareInfo(): DualSenseFirmwareInfo | undefined;
195
+ /** Count of currently open WebHID sessions (multi-DualSense support). */
196
+ get hidDeviceCount(): number;
197
+ static isWebHIDSupported(): boolean;
198
+ static isGamepadSupported(): boolean;
199
+ private isSupportedHidDevice;
200
+ /**
201
+ * Listens for previously authorized DualSense / Switch Pro devices re-connecting over USB or Bluetooth
202
+ * while the page is open, automatically re-attaching WebHID with zero browser prompts.
203
+ */
204
+ attachHidHotplug(): void;
205
+ detachHidHotplug(): void;
206
+ private handleConnect;
207
+ attachKeyboardFallback(): void;
208
+ detachKeyboardFallback(): void;
209
+ onStatusChange(fn: (evt: HIDStatusEvent) => void): () => void;
210
+ private emit;
211
+ private getAllRawGamepads;
212
+ private pollGamepadActivity;
213
+ /**
214
+ * Returns all connected controllers across WebHID and Gamepad API, automatically
215
+ * deduplicating DualSense and Switch Pro controllers that appear in both APIs simultaneously.
216
+ */
217
+ getConnectedControllers(): ControllerSlotInfo[];
218
+ getActiveSlotId(): string | null;
219
+ setActiveSlot(slotId: string): boolean;
220
+ private getHidSessionForSlot;
221
+ private getActiveHidSession;
222
+ private getGamepadForSlot;
223
+ getActiveGamepad(): ExtendedGamepad | null;
224
+ getGamepadActuatorEffects(slotId?: string): readonly string[];
225
+ hasTriggerRumbleSupport(slotId?: string): boolean;
226
+ hasDualRumbleSupport(slotId?: string): boolean;
227
+ /**
228
+ * Opens the browser WebHID device picker to connect (or append) a DualSense / DualSense Edge
229
+ * or Nintendo Switch Pro controller. Existing connected controllers remain active and untouched.
230
+ */
231
+ connect(): Promise<boolean>;
232
+ /**
233
+ * Silently re-attaches all previously authorized DualSense & Switch Pro WebHID devices (zero browser prompts).
234
+ */
235
+ reconnectAuthorized(): Promise<boolean>;
236
+ private readFirmwareInfoSafe;
237
+ private attachDevice;
238
+ private attachSwitchProDevice;
239
+ private sendSwitchUsbCmd;
240
+ private sendSwitchSubcommand;
241
+ private sendSwitchRumbleBytes;
242
+ private clearSwitchRumbleTimers;
243
+ private initSwitchProSession;
244
+ private parseSwitchStickCalibration;
245
+ private handleSwitchProInputReport;
246
+ /**
247
+ * Disconnects a specific WebHID controller slot, or the active WebHID slot when `slotId` is omitted.
248
+ */
249
+ disconnect(slotId?: string): Promise<void>;
250
+ disconnectAll(): Promise<void>;
251
+ private handleDisconnect;
252
+ private handleInputReport;
253
+ private populateGamepadInput;
254
+ /**
255
+ * Returns a live input snapshot for a specific controller slot (e.g. `hid-1` or `gp-0`).
256
+ * Returns a disconnected empty snapshot when that slot is not currently connected.
257
+ */
258
+ getInputStateForSlot(slotId: string): UnifiedInputState;
259
+ getInputState(slotId?: string): UnifiedInputState;
260
+ /**
261
+ * Computes a real-time capability matrix for the active controller slot (or a specific `slotId`).
262
+ */
263
+ getCapabilityMatrixForSlot(slotId?: string, opts?: {
264
+ has4ChAudio?: boolean;
265
+ hasControllerSpeaker?: boolean;
266
+ }): Record<CapabilityId, CapabilityStatus>;
267
+ getCapabilityMatrix(opts?: {
268
+ has4ChAudio?: boolean;
269
+ hasControllerSpeaker?: boolean;
270
+ }): Record<CapabilityId, CapabilityStatus>;
271
+ /**
272
+ * Drives Nintendo Switch Pro dual-band HD Rumble (LRA) over WebHID Report 0x10.
273
+ * Automatically returns both motors to neutral off after `durationMs`.
274
+ */
275
+ playSwitchHdRumble(spec: SwitchHdRumbleSpec, slotId?: string): Promise<boolean>;
276
+ /**
277
+ * Plays a timed sequence of Switch Pro HD Rumble steps (e.g., ice-cube sweep or L/R stereo pulse).
278
+ */
279
+ playSwitchHdRumbleSequence(steps: Array<SwitchHdRumbleSpec & {
280
+ delayMs: number;
281
+ }>, slotId?: string): Promise<boolean>;
282
+ stopSwitchHdRumble(slotId?: string): void;
283
+ /**
284
+ * Native Xbox Series Impulse Triggers (Chrome/Edge 126+, zero WebHID / zero install).
285
+ * Automatically maps to HD Rumble when the targeted slot is a WebHID Switch Pro.
286
+ */
287
+ playTriggerRumble(leftTrigger: number, rightTrigger: number, durationMs: number, weakMagnitude?: number, strongMagnitude?: number, slotId?: string): Promise<boolean>;
288
+ /**
289
+ * Standard Gamepad API dual-rumble for Xbox / Switch / Generic controllers.
290
+ * Automatically uses true HD Rumble when the targeted slot is a WebHID Switch Pro.
291
+ */
292
+ playDualRumble(weakMagnitude: number, strongMagnitude: number, durationMs: number, slotId?: string): Promise<boolean>;
293
+ stopGamepadRumble(slotId?: string): void;
294
+ /**
295
+ * Backwards-compatible helper used when 4ch VCM audio is not active.
296
+ */
297
+ triggerGamepadRumbleFallback(weakMagnitude: number, strongMagnitude: number, durationMs: number, slotId?: string): void;
298
+ private buildCommonPayload;
299
+ private flushSessionOutput;
300
+ flushOutput(opts?: {
301
+ includeAudioConfig?: boolean;
302
+ includeTriggers?: boolean;
303
+ includeLeds?: boolean;
304
+ }): Promise<boolean>;
305
+ setAudioConfig(cfg: {
306
+ speakerVolume?: number;
307
+ headphoneVolume?: number;
308
+ audioRoute?: AudioRouteMode;
309
+ speakerPreamp?: number;
310
+ }): Promise<boolean>;
311
+ setTriggers(left?: TriggerEffectSpec, right?: TriggerEffectSpec, slotId?: string): Promise<boolean>;
312
+ resetTriggers(slotId?: string): Promise<boolean>;
313
+ /**
314
+ * Fire-and-forget safety reset across ALL connected WebHID and Gamepad controllers
315
+ * used inside `pagehide` / `beforeunload` so no controller ever stays stuck with stiff triggers or rumble.
316
+ */
317
+ emergencyReset(): void;
318
+ setLightbar(r: number, g: number, b: number, slotId?: string): Promise<boolean>;
319
+ pulseLegacyRumble(left?: number, right?: number, durationMs?: number, slotId?: string): Promise<boolean>;
320
+ }
321
+ /** Semantic alias for external consumers building brand-agnostic controller apps. */
322
+ export { DualSenseControllerManager as ControllerManager };
323
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hid/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS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EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;CA2BpB;AAED,qFAAqF;AACrF,OAAO,EAAE,0BAA0B,IAAI,iBAAiB,EAAE,CAAC"}
package/dist/hub.d.ts ADDED
@@ -0,0 +1,112 @@
1
+ import { DualSenseControllerManager, type CapabilityId, type CapabilityStatus, type ControllerIdentity, type ControllerSlotInfo, type SwitchHdRumbleSpec, type TriggerEffectSpec, type UnifiedInputState } from './hid/index.js';
2
+ import { type TactilePresetId, type TriggerPresetId } from './haptics/presets.js';
3
+ import { type ComboPresetId, type ContinuousHapticHandle, type ContinuousPreset, type HapticAudioSink, type HapticPulseSpec, type HapticSweepSpec, type ImpulseTriggerSpec, type NoiseBurstSpec, type ToneSpec } from './haptics/router.js';
4
+ import { type ActionMapSpec, type ActionTracker } from './input/actions.js';
5
+ export type HardwareTier = 'dualsense_full_4ch' | 'dualsense_hid_only' | 'switch_pro_hid' | 'xbox_impulse' | 'standard_gamepad' | 'keyboard_mouse';
6
+ export interface PlayerCapabilities {
7
+ slotId: string | null;
8
+ tier: HardwareTier;
9
+ identity: ControllerIdentity;
10
+ matrix: Record<CapabilityId, CapabilityStatus>;
11
+ has(cap: CapabilityId): boolean;
12
+ hasAdaptiveTriggers: boolean;
13
+ hasImpulseTriggers: boolean;
14
+ hasHdRumble: boolean;
15
+ hasDualRumble: boolean;
16
+ has4ChHaptics: boolean;
17
+ hasControllerSpeaker: boolean;
18
+ hasGyro: boolean;
19
+ hasTouchpad: boolean;
20
+ }
21
+ export interface PlayerHandle {
22
+ /** Resolves the current physical slot ID bound to this handle, or `null` if disconnected. */
23
+ getSlotId(): string | null;
24
+ getCapabilities(): PlayerCapabilities;
25
+ readonly input: {
26
+ getState(): UnifiedInputState;
27
+ applyDeadzone(value: number, threshold?: number): number;
28
+ };
29
+ readonly triggers: {
30
+ reset(): void;
31
+ setLeft(effect: TriggerEffectSpec): void;
32
+ setRight(effect: TriggerEffectSpec): void;
33
+ setBoth(left: TriggerEffectSpec, right: TriggerEffectSpec): void;
34
+ applyPreset(presetId: TriggerPresetId, side?: 'left' | 'right' | 'both'): void;
35
+ pulseImpulse(spec: ImpulseTriggerSpec): void;
36
+ };
37
+ readonly haptics: {
38
+ pulse(spec: HapticPulseSpec): void;
39
+ sweep(spec: HapticSweepSpec): void;
40
+ rumble(opts: {
41
+ weak: number;
42
+ strong: number;
43
+ durationMs: number;
44
+ }): void;
45
+ hdRumble(spec: SwitchHdRumbleSpec): void;
46
+ hdSequence(steps: Array<SwitchHdRumbleSpec & {
47
+ delayMs: number;
48
+ }>): void;
49
+ playPreset(presetId: TactilePresetId, opts?: {
50
+ pan?: number;
51
+ intensity?: number;
52
+ }): void;
53
+ createContinuous(preset: ContinuousPreset): ContinuousHapticHandle;
54
+ playComboPreset(presetId: ComboPresetId, pan?: number): void;
55
+ stop(): void;
56
+ };
57
+ readonly audio: {
58
+ playPcTone(spec: ToneSpec): void;
59
+ playPcNoise(opts: NoiseBurstSpec): void;
60
+ playControllerSpeakerTone(spec: ToneSpec): void;
61
+ };
62
+ readonly lightbar: {
63
+ setColor(r: number, g: number, b: number): void;
64
+ flash(r: number, g: number, b: number, durationMs?: number): void;
65
+ };
66
+ /** Creates a semantic Action Map tracker scoped to this hub's disposal lifecycle. */
67
+ createActions<TActions extends string = string, TAxes extends string = string>(spec: ActionMapSpec<TActions, TAxes>): ActionTracker<TActions, TAxes>;
68
+ }
69
+ export interface GamepadlyHubOptions {
70
+ /** Reuse an existing controller manager (e.g. from a host app context). */
71
+ hid?: DualSenseControllerManager;
72
+ /** Optional 3-layer audio / 4ch Link engine (from `@gamepadly/sdk/link`). */
73
+ audio?: HapticAudioSink | null;
74
+ /** Automatically listen for WebHID hotplug & Gamepad API connect/disconnect events. Default true. */
75
+ autoHotplug?: boolean;
76
+ /** Automatically attach keyboard fallback on the underlying manager when owned. Default false. */
77
+ attachKeyboardFallback?: boolean;
78
+ /** Automatically reset triggers/rumble on `pagehide` / `beforeunload`. Default true. */
79
+ autoEmergencyReset?: boolean;
80
+ /** Poll interval (ms) for detecting Gamepad API capability changes. Default 250. Set 0 to disable. */
81
+ capabilityPollMs?: number;
82
+ }
83
+ export interface CapabilitiesChangeEvent {
84
+ slots: ControllerSlotInfo[];
85
+ active: PlayerCapabilities;
86
+ }
87
+ export interface GamepadlyHub {
88
+ readonly hid: DualSenseControllerManager;
89
+ /** Connects a DualSense / Switch Pro controller via browser WebHID picker (must be called in a user gesture). */
90
+ connectWebHID(): Promise<boolean>;
91
+ /** Re-attaches previously authorized WebHID controllers with zero prompts. */
92
+ reconnectAuthorized(): Promise<boolean>;
93
+ /** Attaches or detaches a 3-layer audio / Link engine at runtime. */
94
+ attachAudio(audio: HapticAudioSink | null): void;
95
+ /** Lists all deduplicated connected controllers (P1..P4). */
96
+ getSlots(): ControllerSlotInfo[];
97
+ /** Gets the currently active player handle (single-player convenience). */
98
+ get active(): PlayerHandle;
99
+ /**
100
+ * Returns a player handle by 0-based player index (`0` = P1, `1` = P2, ...) or explicit `slotId`.
101
+ * If `target` is omitted or `'active'`, follows the manager's active slot.
102
+ */
103
+ player(target?: number | string): PlayerHandle;
104
+ /** Subscribes to controller connect/disconnect, WebHID upgrade, slot switch, or 4ch audio changes. */
105
+ onCapabilitiesChange(listener: (event: CapabilitiesChangeEvent) => void): () => void;
106
+ /** Manually checks and emits capability changes if anything changed (useful in tests or custom loops). */
107
+ syncCapabilities(): void;
108
+ /** Stops all active haptics/rumble/continuous audio, resets triggers & lightbar, and frees listeners. */
109
+ dispose(): void;
110
+ }
111
+ export declare function createGamepadly(options?: GamepadlyHubOptions): GamepadlyHub;
112
+ //# sourceMappingURL=hub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../src/hub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE1B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,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,CAAC;IAC5B,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,0BAA0B,CAAC;IACzC,iHAAiH;IACjH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,8EAA8E;IAC9E,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,qEAAqE;IACrE,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;IACjD,6DAA6D;IAC7D,QAAQ,IAAI,kBAAkB,EAAE,CAAC;IACjC,2EAA2E;IAC3E,IAAI,MAAM,IAAI,YAAY,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;IAC/C,sGAAsG;IACtG,oBAAoB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACrF,0GAA0G;IAC1G,gBAAgB,IAAI,IAAI,CAAC;IACzB,yGAAyG;IACzG,OAAO,IAAI,IAAI,CAAC;CACjB;AA+DD,wBAAgB,eAAe,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAuY/E"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @gamepadly/sdk — Headless Web Controller, Adaptive Triggers, HD Rumble & Haptics SDK
3
+ *
4
+ * Subpath exports:
5
+ * - `@gamepadly/sdk` — Core multi-controller hub, WebHID/Gamepad protocols, Action Map & cross-brand haptics
6
+ * - `@gamepadly/sdk/link` — Optional 3-layer audio & Gamepadly Link 4-channel WASAPI client
7
+ * - `@gamepadly/sdk/bridge` — Optional declarative Key/Mouse bridge for adapting open-source H5 games
8
+ * - `@gamepadly/sdk/loop` — Optional lightweight DPR canvas stage, fixed-step loop & disposables
9
+ */
10
+ export { ControllerManager, DualSenseControllerManager, applyDeadzone, crc32WithSeed, createEmptyInput, encodeSwitchHdRumbleSide, encodeTriggerEffect, identifyGamepadFromId, type AudioRouteMode, type BatteryStatus, type ButtonName, type CapabilityAvailability, type CapabilityId, type CapabilityStatus, type ControllerBrand, type ControllerIdentity, type ControllerModel, type ControllerSlotInfo, type DualSenseFirmwareInfo, type HIDStatusEvent, type SwitchHdRumbleSide, type SwitchHdRumbleSpec, type TouchFinger, type TransportType, type TriggerEffectSpec, type UnifiedInputState, } from './hid/index.js';
11
+ export { TACTILE_PRESETS, TRIGGER_PRESETS, buildSwitchHdFromPulse, type TactilePresetId, type TactilePresetSpec, type TriggerPresetId, } from './haptics/presets.js';
12
+ export { routeHapticPulse, routeHapticSweep, routeTactilePreset, type ComboPresetId, type ContinuousHapticHandle, type ContinuousPreset, type HapticAudioSink, type HapticPulseSpec, type HapticRouteContext, type HapticSweepSpec, type ImpulseTriggerSpec, type NoiseBurstSpec, type ToneSpec, } from './haptics/router.js';
13
+ export { createActionTracker, type ActionBinding, type ActionMapSpec, type ActionState, type ActionTracker, type AxisActionSpec, type MouseButtonBinding, type StickDirectionBinding, type TriggerBinding, } from './input/actions.js';
14
+ export { createGamepadly, type CapabilitiesChangeEvent, type GamepadlyHub, type GamepadlyHubOptions, type HardwareTier, type PlayerCapabilities, type PlayerHandle, } from './hub.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,kBAA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