@flare-engine/input 0.2.0 → 0.3.0

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.
package/dist/index.d.ts CHANGED
@@ -1,42 +1,6 @@
1
- import { Vec2 } from '@flare-engine/math';
2
- import { Signal } from '@flare-engine/events';
3
-
4
- /** State of a single pointer (primary touch or mouse). */
5
- interface Pointer {
6
- /** Current position in screen coordinates. */
7
- position: Vec2;
8
- /** Position delta since last frame. */
9
- delta: Vec2;
10
- /** Whether the pointer is currently held down. */
11
- isDown: boolean;
12
- /** True only on the frame the pointer was pressed. */
13
- justPressed: boolean;
14
- /** True only on the frame the pointer was released. */
15
- justReleased: boolean;
16
- }
17
- /** State of a single touch point in a multitouch scenario. */
18
- interface TouchPoint {
19
- /** Unique touch identifier. */
20
- id: number;
21
- /** Current position in screen coordinates. */
22
- position: Vec2;
23
- /** Whether this touch is currently active. */
24
- isDown: boolean;
25
- }
26
- /** Create a default pointer state. */
27
- declare function createPointer(): Pointer;
28
- /**
29
- * Update pointer state for a new frame.
30
- * Call this at the start of each frame to clear per-frame flags.
31
- */
32
- declare function resetPointerFrame(pointer: Pointer): void;
33
- /** Feed a pointer-down event into the pointer state. */
34
- declare function pointerDown(pointer: Pointer, x: number, y: number): void;
35
- /** Feed a pointer-move event into the pointer state. */
36
- declare function pointerMove(pointer: Pointer, x: number, y: number): void;
37
- /** Feed a pointer-up event into the pointer state. */
38
- declare function pointerUp(pointer: Pointer, x: number, y: number): void;
39
-
1
+ import { Signal } from "@flare-engine/events";
2
+ import { Vec2 } from "@flare-engine/math";
3
+ //#region src/gamepad.d.ts
40
4
  /**
41
5
  * Gamepad — poll-based state for a single connected controller.
42
6
  *
@@ -46,60 +10,60 @@ declare function pointerUp(pointer: Pointer, x: number, y: number): void;
46
10
  */
47
11
  /** W3C Standard Gamepad button indices. */
48
12
  declare const GamepadButton: {
49
- readonly A: 0;
50
- readonly B: 1;
51
- readonly X: 2;
52
- readonly Y: 3;
53
- readonly LB: 4;
54
- readonly RB: 5;
55
- readonly LT: 6;
56
- readonly RT: 7;
57
- readonly Back: 8;
58
- readonly Start: 9;
59
- readonly LS: 10;
60
- readonly RS: 11;
61
- readonly DpadUp: 12;
62
- readonly DpadDown: 13;
63
- readonly DpadLeft: 14;
64
- readonly DpadRight: 15;
65
- readonly Home: 16;
13
+ readonly A: 0;
14
+ readonly B: 1;
15
+ readonly X: 2;
16
+ readonly Y: 3;
17
+ readonly LB: 4;
18
+ readonly RB: 5;
19
+ readonly LT: 6;
20
+ readonly RT: 7;
21
+ readonly Back: 8;
22
+ readonly Start: 9;
23
+ readonly LS: 10;
24
+ readonly RS: 11;
25
+ readonly DpadUp: 12;
26
+ readonly DpadDown: 13;
27
+ readonly DpadLeft: 14;
28
+ readonly DpadRight: 15;
29
+ readonly Home: 16;
66
30
  };
67
31
  type GamepadButtonId = (typeof GamepadButton)[keyof typeof GamepadButton];
68
32
  /** W3C Standard Gamepad axes. */
69
33
  declare const GamepadAxis: {
70
- readonly LeftX: 0;
71
- readonly LeftY: 1;
72
- readonly RightX: 2;
73
- readonly RightY: 3;
34
+ readonly LeftX: 0;
35
+ readonly LeftY: 1;
36
+ readonly RightX: 2;
37
+ readonly RightY: 3;
74
38
  };
75
39
  type GamepadAxisId = (typeof GamepadAxis)[keyof typeof GamepadAxis];
76
40
  interface GamepadButtonState {
77
- pressed: boolean;
78
- value: number;
79
- /** True for exactly one frame after a press. */
80
- pressedThisFrame: boolean;
81
- /** True for exactly one frame after a release. */
82
- releasedThisFrame: boolean;
41
+ pressed: boolean;
42
+ value: number;
43
+ /** True for exactly one frame after a press. */
44
+ pressedThisFrame: boolean;
45
+ /** True for exactly one frame after a release. */
46
+ releasedThisFrame: boolean;
83
47
  }
84
48
  interface GamepadState {
85
- connected: boolean;
86
- id: string;
87
- index: number;
88
- buttons: GamepadButtonState[];
89
- axes: number[];
90
- /** Monotonically increasing timestamp from the source (ms). */
91
- timestamp: number;
49
+ connected: boolean;
50
+ id: string;
51
+ index: number;
52
+ buttons: GamepadButtonState[];
53
+ axes: number[];
54
+ /** Monotonically increasing timestamp from the source (ms). */
55
+ timestamp: number;
92
56
  }
93
57
  /** Raw snapshot from a `GamepadSource` — values only, no derived state. */
94
58
  interface GamepadSnapshot {
95
- id: string;
96
- index: number;
97
- buttons: {
98
- pressed: boolean;
99
- value: number;
100
- }[];
101
- axes: number[];
102
- timestamp: number;
59
+ id: string;
60
+ index: number;
61
+ buttons: {
62
+ pressed: boolean;
63
+ value: number;
64
+ }[];
65
+ axes: number[];
66
+ timestamp: number;
103
67
  }
104
68
  declare function createGamepadState(index?: number, buttonCount?: number, axisCount?: number): GamepadState;
105
69
  /**
@@ -116,7 +80,8 @@ declare function isButtonDown(state: GamepadState, button: number): boolean;
116
80
  declare function wasButtonPressed(state: GamepadState, button: number): boolean;
117
81
  declare function wasButtonReleased(state: GamepadState, button: number): boolean;
118
82
  declare function getAxis(state: GamepadState, axis: number): number;
119
-
83
+ //#endregion
84
+ //#region src/gamepad-source.d.ts
120
85
  /**
121
86
  * Platform abstraction for sampling connected gamepads.
122
87
  *
@@ -128,28 +93,207 @@ declare function getAxis(state: GamepadState, axis: number): number;
128
93
  * via the `GamepadSource` interface — the package itself ships no native deps.
129
94
  */
130
95
  interface GamepadSource {
131
- poll(): (GamepadSnapshot | null)[];
96
+ poll(): (GamepadSnapshot | null)[];
132
97
  }
133
98
  interface NavigatorLike {
134
- getGamepads?: () => (WebGamepad | null)[];
99
+ getGamepads?: () => (WebGamepad | null)[];
135
100
  }
136
101
  interface WebGamepad {
137
- id: string;
138
- index: number;
139
- connected: boolean;
140
- timestamp: number;
141
- buttons: readonly {
142
- pressed: boolean;
143
- value: number;
144
- }[];
145
- axes: readonly number[];
102
+ id: string;
103
+ index: number;
104
+ connected: boolean;
105
+ timestamp: number;
106
+ buttons: readonly {
107
+ pressed: boolean;
108
+ value: number;
109
+ }[];
110
+ axes: readonly number[];
146
111
  }
147
112
  /**
148
113
  * Wrap `navigator.getGamepads()` (W3C Gamepad API). If `nav` is not supplied,
149
114
  * uses `globalThis.navigator`. Returns an empty array when the API is absent.
150
115
  */
151
116
  declare function createWebGamepadSource(nav?: NavigatorLike): GamepadSource;
152
-
117
+ //#endregion
118
+ //#region src/gestures.d.ts
119
+ /** Swipe direction. */
120
+ type SwipeDirection = 'left' | 'right' | 'up' | 'down';
121
+ /** Gesture detection configuration. */
122
+ interface GestureConfig {
123
+ /** Max time (seconds) for a tap (default 0.3). */
124
+ tapMaxDuration?: number;
125
+ /** Max distance (px) for a tap (default 20). */
126
+ tapMaxDistance?: number;
127
+ /** Min time (seconds) for a long press (default 0.5). */
128
+ longPressMinDuration?: number;
129
+ /** Min distance (px) for a swipe (default 50). */
130
+ swipeMinDistance?: number;
131
+ /** Max time (seconds) for a swipe (default 0.4). */
132
+ swipeMaxDuration?: number;
133
+ }
134
+ /** Swipe event data. */
135
+ interface SwipeEvent {
136
+ direction: SwipeDirection;
137
+ distance: number;
138
+ duration: number;
139
+ }
140
+ /** Pinch event data. */
141
+ interface PinchEvent {
142
+ /** Scale factor (>1 = spread, <1 = pinch). */
143
+ scale: number;
144
+ /** Center point between the two touches. */
145
+ center: Vec2;
146
+ }
147
+ /**
148
+ * GestureDetector recognizes tap, long press, swipe, and pinch gestures
149
+ * from raw pointer events.
150
+ */
151
+ declare class GestureDetector {
152
+ readonly onTap: Signal<Vec2>;
153
+ readonly onLongPress: Signal<Vec2>;
154
+ readonly onSwipe: Signal<SwipeEvent>;
155
+ readonly onPinch: Signal<PinchEvent>;
156
+ private tapMaxDuration;
157
+ private tapMaxDistance;
158
+ private longPressMinDuration;
159
+ private swipeMinDistance;
160
+ private swipeMaxDuration;
161
+ private _startPos;
162
+ private _startTime;
163
+ private _isTracking;
164
+ private _longPressFired;
165
+ private _pinchStartDistance;
166
+ private _pinchTouches;
167
+ constructor(config?: GestureConfig);
168
+ /** Feed a pointer-down event. */
169
+ pointerDown(x: number, y: number): void;
170
+ /** Feed a pointer-up event. */
171
+ pointerUp(x: number, y: number, elapsedSinceDown: number): void;
172
+ /**
173
+ * Update gesture tracking. Call each frame with dt.
174
+ * @param dt Delta time in seconds.
175
+ * @param currentX Current pointer X.
176
+ * @param currentY Current pointer Y.
177
+ */
178
+ update(dt: number, currentX: number, currentY: number): void;
179
+ /**
180
+ * Feed a two-finger pinch update. Call when two touches are active.
181
+ * @param t1 First touch position.
182
+ * @param t2 Second touch position.
183
+ */
184
+ pinchUpdate(t1: Vec2, t2: Vec2): void;
185
+ /** Call when pinch ends (fewer than 2 touches). */
186
+ pinchEnd(): void;
187
+ }
188
+ //#endregion
189
+ //#region src/keyboard.d.ts
190
+ /** Minimal keyboard event shape — no DOM type dep. */
191
+ interface KeyboardEventLike {
192
+ readonly code: string;
193
+ readonly type: string;
194
+ /** Optional — real DOM events have it; synthetic feeds may not. */
195
+ preventDefault?(): void;
196
+ }
197
+ /** Minimal event target shape for attaching keyboard listeners. */
198
+ interface KeyboardEventTargetLike {
199
+ addEventListener(type: string, handler: (ev: KeyboardEventLike) => void): void;
200
+ removeEventListener(type: string, handler: (ev: KeyboardEventLike) => void): void;
201
+ }
202
+ /**
203
+ * Buffered per-frame keyboard state.
204
+ *
205
+ * Edge flags (`wasPressed`, `wasReleased`) clear each frame via `reset()`.
206
+ * `keyDown` / `keyUp` are the platform-neutral injection points: web feeds
207
+ * them via `attachKeyboardListeners`; mobile/RN feeds them from a
208
+ * hardware-keyboard native module or an on-screen source.
209
+ */
210
+ interface KeyboardState {
211
+ /** True while the key is physically held. */
212
+ isDown(code: string): boolean;
213
+ /** True only on the frame the key was pressed. */
214
+ wasPressed(code: string): boolean;
215
+ /** True only on the frame the key was released. */
216
+ wasReleased(code: string): boolean;
217
+ /** Platform-neutral injection. OS auto-repeat is de-edged by the pressButton guard. */
218
+ keyDown(code: string): void;
219
+ /** Platform-neutral injection. */
220
+ keyUp(code: string): void;
221
+ /** Frame-start edge clear. Zero-alloc. */
222
+ reset(): void;
223
+ /** Blur/stuck-key guard: emits a release edge for every held code, then drops held. */
224
+ clear(): void;
225
+ }
226
+ /** Create a fresh keyboard state. */
227
+ declare function createKeyboard(): KeyboardState;
228
+ /** Free-function parity with `resetPointerFrame`. Delegates to `kb.reset()`. */
229
+ declare function resetKeyboardFrame(kb: KeyboardState): void;
230
+ /**
231
+ * Web turnkey adapter: registers `keydown`, `keyup`, and `blur` listeners on
232
+ * `target`. `blur` calls `kb.clear()` (stuck-key guard). Returns a detach fn.
233
+ *
234
+ * `target` is structural `{ addEventListener, removeEventListener }` — no DOM
235
+ * types dep. On web, pass `window`; for mobile/RN, feed `keyDown`/`keyUp`
236
+ * directly from a hardware-keyboard native module or an on-screen source.
237
+ *
238
+ * Does NOT call `preventDefault` — bare use lets Space/arrows scroll and Tab
239
+ * move DOM focus. For game-mode input, attach your own listener that calls
240
+ * `preventDefault` for game keys and forwards `kb.keyDown(ev.code)`.
241
+ */
242
+ declare function attachKeyboardListeners(kb: KeyboardState, target: KeyboardEventTargetLike): () => void;
243
+ /**
244
+ * Action → code binding map. Keys are action names; values are arrays of
245
+ * `KeyboardEvent.code` strings. Multiple codes OR-reduce (any bound key
246
+ * triggers the action).
247
+ */
248
+ type KeyBindings = Readonly<Record<string, readonly string[]>>;
249
+ /** True if any bound code for `action` is currently held. */
250
+ declare function isActionDown(kb: KeyboardState, bindings: KeyBindings, action: string): boolean;
251
+ /** True if any bound code for `action` was pressed this frame. */
252
+ declare function wasActionPressed(kb: KeyboardState, bindings: KeyBindings, action: string): boolean;
253
+ /**
254
+ * True if any bound code for `action` was released this frame AND no bound
255
+ * code is still held. Release fires only when the last held bound key lifts.
256
+ */
257
+ declare function wasActionReleased(kb: KeyboardState, bindings: KeyBindings, action: string): boolean;
258
+ //#endregion
259
+ //#region src/pointer.d.ts
260
+ /** State of a single pointer (primary touch or mouse). */
261
+ interface Pointer {
262
+ /** Current position in screen coordinates. */
263
+ position: Vec2;
264
+ /** Position delta since last frame. */
265
+ delta: Vec2;
266
+ /** Whether the pointer is currently held down. */
267
+ isDown: boolean;
268
+ /** True only on the frame the pointer was pressed. */
269
+ justPressed: boolean;
270
+ /** True only on the frame the pointer was released. */
271
+ justReleased: boolean;
272
+ }
273
+ /** State of a single touch point in a multitouch scenario. */
274
+ interface TouchPoint {
275
+ /** Unique touch identifier. */
276
+ id: number;
277
+ /** Current position in screen coordinates. */
278
+ position: Vec2;
279
+ /** Whether this touch is currently active. */
280
+ isDown: boolean;
281
+ }
282
+ /** Create a default pointer state. */
283
+ declare function createPointer(): Pointer;
284
+ /**
285
+ * Update pointer state for a new frame.
286
+ * Call this at the start of each frame to clear per-frame flags.
287
+ */
288
+ declare function resetPointerFrame(pointer: Pointer): void;
289
+ /** Feed a pointer-down event into the pointer state. */
290
+ declare function pointerDown(pointer: Pointer, x: number, y: number): void;
291
+ /** Feed a pointer-move event into the pointer state. */
292
+ declare function pointerMove(pointer: Pointer, x: number, y: number): void;
293
+ /** Feed a pointer-up event into the pointer state. */
294
+ declare function pointerUp(pointer: Pointer, x: number, y: number): void;
295
+ //#endregion
296
+ //#region src/remap.d.ts
153
297
  /**
154
298
  * Button / axis remap table.
155
299
  *
@@ -160,13 +304,13 @@ declare function createWebGamepadSource(nav?: NavigatorLike): GamepadSource;
160
304
  * Y on some controllers; `scale` supports half-range triggers.
161
305
  */
162
306
  interface AxisMap {
163
- index: number;
164
- invert: boolean;
165
- scale: number;
307
+ index: number;
308
+ invert: boolean;
309
+ scale: number;
166
310
  }
167
311
  interface RemapTable {
168
- buttons: number[];
169
- axes: AxisMap[];
312
+ buttons: number[];
313
+ axes: AxisMap[];
170
314
  }
171
315
  declare function createIdentityRemap(buttonCount?: number, axisCount?: number): RemapTable;
172
316
  /** Apply a remap table to a raw snapshot, returning a new snapshot with logical ordering. */
@@ -176,14 +320,15 @@ declare function applyRemap(snapshot: GamepadSnapshot, table: RemapTable): Gamep
176
320
  * but declared locally so this package does not take a hard dep on storage.
177
321
  */
178
322
  interface RemapStore {
179
- get(key: string): Promise<string | null>;
180
- set(key: string, value: string): Promise<void>;
323
+ get(key: string): Promise<string | null>;
324
+ set(key: string, value: string): Promise<void>;
181
325
  }
182
326
  /** Persist a remap table under the given key. Throws on invalid table shape. */
183
327
  declare function saveRemap(store: RemapStore, key: string, table: RemapTable): Promise<void>;
184
328
  /** Load a remap table. Returns `null` if absent or malformed. */
185
329
  declare function loadRemap(store: RemapStore, key: string): Promise<RemapTable | null>;
186
-
330
+ //#endregion
331
+ //#region src/input-manager.d.ts
187
332
  /**
188
333
  * InputManager provides a polling-based input model.
189
334
  *
@@ -191,121 +336,73 @@ declare function loadRemap(store: RemapStore, key: string): Promise<RemapTable |
191
336
  * Feed events from the platform (RN touch/gesture handlers) via the on* methods.
192
337
  */
193
338
  declare class InputManager {
194
- /** Primary pointer (first touch or mouse). */
195
- readonly pointer: Pointer;
196
- /** All active touch points. */
197
- readonly touches: TouchPoint[];
198
- private _touchMap;
199
- private _gamepads;
200
- private _gamepadDeadZone;
201
- private _gamepadRemaps;
202
- /** Call once per frame to reset per-frame flags. */
203
- update(): void;
204
- /** Feed a touch/pointer begin event. */
205
- onPointerDown(id: number, x: number, y: number): void;
206
- /** Feed a touch/pointer move event. */
207
- onPointerMove(id: number, x: number, y: number): void;
208
- /** Feed a touch/pointer end event. */
209
- onPointerUp(id: number, x: number, y: number): void;
210
- /** Access the gamepad state at `index`. Allocates on first access. */
211
- gamepad(index: number): GamepadState;
212
- /** Dead zone in [0, 1). Axes at or below this magnitude read as 0. */
213
- setGamepadDeadZone(deadZone: number): void;
214
- /** Install a remap table for a specific gamepad index. Pass `null` to clear. */
215
- setGamepadRemap(index: number, table: RemapTable | null): void;
216
- /** Poll all gamepads from the given source, applying remap + dead zones. */
217
- pollGamepads(source: GamepadSource): void;
218
- private _addOrUpdateTouch;
219
- private _removeTouch;
220
- }
221
-
222
- /** Swipe direction. */
223
- type SwipeDirection = 'left' | 'right' | 'up' | 'down';
224
- /** Gesture detection configuration. */
225
- interface GestureConfig {
226
- /** Max time (seconds) for a tap (default 0.3). */
227
- tapMaxDuration?: number;
228
- /** Max distance (px) for a tap (default 20). */
229
- tapMaxDistance?: number;
230
- /** Min time (seconds) for a long press (default 0.5). */
231
- longPressMinDuration?: number;
232
- /** Min distance (px) for a swipe (default 50). */
233
- swipeMinDistance?: number;
234
- /** Max time (seconds) for a swipe (default 0.4). */
235
- swipeMaxDuration?: number;
236
- }
237
- /** Swipe event data. */
238
- interface SwipeEvent {
239
- direction: SwipeDirection;
240
- distance: number;
241
- duration: number;
242
- }
243
- /** Pinch event data. */
244
- interface PinchEvent {
245
- /** Scale factor (>1 = spread, <1 = pinch). */
246
- scale: number;
247
- /** Center point between the two touches. */
248
- center: Vec2;
339
+ /** Primary pointer (first touch or mouse). */
340
+ readonly pointer: Pointer;
341
+ /** Buffered keyboard state. Feed via `attachKeyboardListeners` (web) or `keyboard.keyDown`/`keyUp` (mobile/RN). */
342
+ readonly keyboard: KeyboardState;
343
+ /** All active touch points. */
344
+ readonly touches: TouchPoint[];
345
+ private _touchMap;
346
+ private _gamepads;
347
+ private _gamepadDeadZone;
348
+ private _gamepadRemaps;
349
+ /** Call once per frame to reset per-frame flags. */
350
+ update(): void;
351
+ /** Feed a touch/pointer begin event. */
352
+ onPointerDown(id: number, x: number, y: number): void;
353
+ /** Feed a touch/pointer move event. */
354
+ onPointerMove(id: number, x: number, y: number): void;
355
+ /** Feed a touch/pointer end event. */
356
+ onPointerUp(id: number, x: number, y: number): void;
357
+ /** Access the gamepad state at `index`. Allocates on first access. */
358
+ gamepad(index: number): GamepadState;
359
+ /** Dead zone in [0, 1). Axes at or below this magnitude read as 0. */
360
+ setGamepadDeadZone(deadZone: number): void;
361
+ /** Install a remap table for a specific gamepad index. Pass `null` to clear. */
362
+ setGamepadRemap(index: number, table: RemapTable | null): void;
363
+ /** Poll all gamepads from the given source, applying remap + dead zones. */
364
+ pollGamepads(source: GamepadSource): void;
365
+ private _addOrUpdateTouch;
366
+ private _removeTouch;
249
367
  }
250
- /**
251
- * GestureDetector recognizes tap, long press, swipe, and pinch gestures
252
- * from raw pointer events.
253
- */
254
- declare class GestureDetector {
255
- readonly onTap: Signal<Vec2>;
256
- readonly onLongPress: Signal<Vec2>;
257
- readonly onSwipe: Signal<SwipeEvent>;
258
- readonly onPinch: Signal<PinchEvent>;
259
- private tapMaxDuration;
260
- private tapMaxDistance;
261
- private longPressMinDuration;
262
- private swipeMinDistance;
263
- private swipeMaxDuration;
264
- private _startPos;
265
- private _startTime;
266
- private _isTracking;
267
- private _longPressFired;
268
- private _pinchStartDistance;
269
- private _pinchTouches;
270
- constructor(config?: GestureConfig);
271
- /** Feed a pointer-down event. */
272
- pointerDown(x: number, y: number): void;
273
- /** Feed a pointer-up event. */
274
- pointerUp(x: number, y: number, elapsedSinceDown: number): void;
275
- /**
276
- * Update gesture tracking. Call each frame with dt.
277
- * @param dt Delta time in seconds.
278
- * @param currentX Current pointer X.
279
- * @param currentY Current pointer Y.
280
- */
281
- update(dt: number, currentX: number, currentY: number): void;
282
- /**
283
- * Feed a two-finger pinch update. Call when two touches are active.
284
- * @param t1 First touch position.
285
- * @param t2 Second touch position.
286
- */
287
- pinchUpdate(t1: Vec2, t2: Vec2): void;
288
- /** Call when pinch ends (fewer than 2 touches). */
289
- pinchEnd(): void;
368
+ //#endregion
369
+ //#region src/virtual-button.d.ts
370
+ /** Virtual button state — pure data, no UI. */
371
+ interface VirtualButtonState {
372
+ /** Whether the button is currently pressed. */
373
+ isPressed: boolean;
374
+ /** Whether the button was just pressed this frame. */
375
+ justPressed: boolean;
376
+ /** Whether the button was just released this frame. */
377
+ justReleased: boolean;
290
378
  }
291
-
379
+ /** Create a default button state. */
380
+ declare function createButtonState(): VirtualButtonState;
381
+ /** Call at the start of each frame to reset per-frame flags. */
382
+ declare function resetButtonFrame(state: VirtualButtonState): void;
383
+ /** Call when the button is pressed. */
384
+ declare function pressButton(state: VirtualButtonState): void;
385
+ /** Call when the button is released. */
386
+ declare function releaseButton(state: VirtualButtonState): void;
387
+ //#endregion
388
+ //#region src/virtual-joystick.d.ts
292
389
  /** Virtual joystick configuration. */
293
390
  interface VirtualJoystickConfig {
294
- /** Dead zone radius in pixels (default 10). */
295
- deadZone?: number;
296
- /** Maximum radius in pixels (default 50). */
297
- maxRadius?: number;
391
+ /** Dead zone radius in pixels (default 10). */
392
+ deadZone?: number;
393
+ /** Maximum radius in pixels (default 50). */
394
+ maxRadius?: number;
298
395
  }
299
396
  /** Virtual joystick state — pure data, no UI. */
300
397
  interface VirtualJoystickState {
301
- /** Whether the joystick is currently being touched. */
302
- active: boolean;
303
- /** Normalized direction vector (-1 to 1 per axis). */
304
- direction: Vec2;
305
- /** Magnitude 0-1 (0 = center/dead zone, 1 = max radius). */
306
- magnitude: number;
307
- /** Raw offset from center in pixels. */
308
- offset: Vec2;
398
+ /** Whether the joystick is currently being touched. */
399
+ active: boolean;
400
+ /** Normalized direction vector (-1 to 1 per axis). */
401
+ direction: Vec2;
402
+ /** Magnitude 0-1 (0 = center/dead zone, 1 = max radius). */
403
+ magnitude: number;
404
+ /** Raw offset from center in pixels. */
405
+ offset: Vec2;
309
406
  }
310
407
  /** Create a default joystick state. */
311
408
  declare function createJoystickState(): VirtualJoystickState;
@@ -322,23 +419,6 @@ declare function createJoystickState(): VirtualJoystickState;
322
419
  declare function updateJoystick(state: VirtualJoystickState, centerX: number, centerY: number, touchX: number, touchY: number, config?: VirtualJoystickConfig): void;
323
420
  /** Reset joystick state when touch is released. */
324
421
  declare function releaseJoystick(state: VirtualJoystickState): void;
325
-
326
- /** Virtual button state — pure data, no UI. */
327
- interface VirtualButtonState {
328
- /** Whether the button is currently pressed. */
329
- isPressed: boolean;
330
- /** Whether the button was just pressed this frame. */
331
- justPressed: boolean;
332
- /** Whether the button was just released this frame. */
333
- justReleased: boolean;
334
- }
335
- /** Create a default button state. */
336
- declare function createButtonState(): VirtualButtonState;
337
- /** Call at the start of each frame to reset per-frame flags. */
338
- declare function resetButtonFrame(state: VirtualButtonState): void;
339
- /** Call when the button is pressed. */
340
- declare function pressButton(state: VirtualButtonState): void;
341
- /** Call when the button is released. */
342
- declare function releaseButton(state: VirtualButtonState): void;
343
-
344
- export { type AxisMap, GamepadAxis, type GamepadAxisId, GamepadButton, type GamepadButtonId, type GamepadButtonState, type GamepadSnapshot, type GamepadSource, type GamepadState, type GestureConfig, GestureDetector, InputManager, type PinchEvent, type Pointer, type RemapStore, type RemapTable, type SwipeDirection, type SwipeEvent, type TouchPoint, type VirtualButtonState, type VirtualJoystickConfig, type VirtualJoystickState, applyRemap, createButtonState, createGamepadState, createIdentityRemap, createJoystickState, createPointer, createWebGamepadSource, getAxis, isButtonDown, loadRemap, pointerDown, pointerMove, pointerUp, pressButton, releaseButton, releaseJoystick, resetButtonFrame, resetGamepadFrame, resetPointerFrame, saveRemap, updateGamepadFromSnapshot, updateJoystick, wasButtonPressed, wasButtonReleased };
422
+ //#endregion
423
+ export { type AxisMap, GamepadAxis, type GamepadAxisId, GamepadButton, type GamepadButtonId, type GamepadButtonState, type GamepadSnapshot, type GamepadSource, type GamepadState, type GestureConfig, GestureDetector, InputManager, type KeyBindings, type KeyboardEventLike, type KeyboardEventTargetLike, type KeyboardState, type PinchEvent, type Pointer, type RemapStore, type RemapTable, type SwipeDirection, type SwipeEvent, type TouchPoint, type VirtualButtonState, type VirtualJoystickConfig, type VirtualJoystickState, applyRemap, attachKeyboardListeners, createButtonState, createGamepadState, createIdentityRemap, createJoystickState, createKeyboard, createPointer, createWebGamepadSource, getAxis, isActionDown, isButtonDown, loadRemap, pointerDown, pointerMove, pointerUp, pressButton, releaseButton, releaseJoystick, resetButtonFrame, resetGamepadFrame, resetKeyboardFrame, resetPointerFrame, saveRemap, updateGamepadFromSnapshot, updateJoystick, wasActionPressed, wasActionReleased, wasButtonPressed, wasButtonReleased };
424
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/gamepad.ts","../src/gamepad-source.ts","../src/gestures.ts","../src/keyboard.ts","../src/pointer.ts","../src/remap.ts","../src/input-manager.ts","../src/virtual-button.ts","../src/virtual-joystick.ts"],"mappings":"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"}