pixijs-input-devices 0.3.0 → 0.5.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/README.md +191 -183
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +196 -120
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ declare class InputDeviceManager {
|
|
|
58
58
|
private readonly _gamepadDeviceMap;
|
|
59
59
|
private readonly _customDevices;
|
|
60
60
|
private readonly _emitter;
|
|
61
|
-
private readonly
|
|
61
|
+
private readonly _bindEmitter;
|
|
62
62
|
private _hasFocus;
|
|
63
63
|
private _lastInteractedDevice?;
|
|
64
64
|
private constructor();
|
|
@@ -88,12 +88,12 @@ declare class InputDeviceManager {
|
|
|
88
88
|
on<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
|
|
89
89
|
/** Remove an event listener (or all if none provided) */
|
|
90
90
|
off<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
/** Remove a named
|
|
94
|
-
|
|
95
|
-
/** Report a named
|
|
96
|
-
|
|
91
|
+
/** Adds a named bind event listener. */
|
|
92
|
+
onBind<N extends string>(name: N | readonly N[], listener: (event: NamedBindEvent<N>) => void): this;
|
|
93
|
+
/** Remove a named bind event listener (or all if none provided). */
|
|
94
|
+
offBind(name: string | string[], listener?: (event: NamedBindEvent) => void): this;
|
|
95
|
+
/** Report a named bind event (from a CustomDevice). */
|
|
96
|
+
emitBind(e: NamedBindEvent): void;
|
|
97
97
|
/** Add a custom device. */
|
|
98
98
|
add(device: Device): void;
|
|
99
99
|
/** Remove a custom device. */
|
|
@@ -111,38 +111,46 @@ declare class InputDeviceManager {
|
|
|
111
111
|
}
|
|
112
112
|
declare class NavigationManager {
|
|
113
113
|
static global: NavigationManager;
|
|
114
|
-
/**
|
|
115
|
-
* Set the stage root to automatically handle global
|
|
116
|
-
* navigation intents.
|
|
117
|
-
*/
|
|
118
|
-
stage?: Container;
|
|
119
114
|
options: {
|
|
120
|
-
/**
|
|
121
|
-
* When set to false, navigation will be disabled globally.
|
|
122
|
-
*/
|
|
123
|
-
enabled: boolean;
|
|
124
115
|
/**
|
|
125
116
|
* When enabled, if no "pointover"/"mouseover" listeners
|
|
126
117
|
* exist, a default alpha effect will be used instead.
|
|
127
118
|
*/
|
|
128
119
|
useFallbackHoverEffect: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Minimum distance in a direction that a container has to be to
|
|
122
|
+
* appear as selectable in that direction.
|
|
123
|
+
*/
|
|
124
|
+
minimumDirectionDistance: number;
|
|
129
125
|
};
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Whether navigation is enabled globally.
|
|
128
|
+
*/
|
|
129
|
+
enabled: boolean;
|
|
130
|
+
private _responders;
|
|
131
|
+
private _root?;
|
|
132
|
+
private _rootFocused?;
|
|
132
133
|
private constructor();
|
|
133
134
|
/**
|
|
134
|
-
*
|
|
135
|
+
* Current navigation target.
|
|
136
|
+
*/
|
|
137
|
+
get focusTarget(): Container | undefined;
|
|
138
|
+
set focusTarget(target: Container | undefined);
|
|
139
|
+
/**
|
|
140
|
+
* Active global interaction target.
|
|
135
141
|
*/
|
|
136
142
|
get firstResponder(): NavigationResponder | undefined;
|
|
137
143
|
/**
|
|
138
|
-
* Stack of global interaction targets
|
|
144
|
+
* Stack of global interaction targets.
|
|
139
145
|
*/
|
|
140
146
|
get responders(): readonly NavigationResponder[];
|
|
141
147
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
148
|
+
* Initialize navigation and set the root navigation responder.
|
|
149
|
+
*
|
|
150
|
+
* @param stage - Root navigation responder container, where navigatable
|
|
151
|
+
* containers can live.
|
|
144
152
|
*/
|
|
145
|
-
|
|
153
|
+
configureWithRoot(stage: Container): void;
|
|
146
154
|
/**
|
|
147
155
|
* Remove the top-most global interaction target
|
|
148
156
|
*/
|
|
@@ -150,18 +158,38 @@ declare class NavigationManager {
|
|
|
150
158
|
/**
|
|
151
159
|
* Set the new top-most global interaction target.
|
|
152
160
|
*/
|
|
153
|
-
pushResponder(responder: NavigationResponder): void;
|
|
161
|
+
pushResponder(responder: Container | NavigationResponder): void;
|
|
154
162
|
/**
|
|
155
163
|
* Focus on the first navigatable element.
|
|
156
164
|
*/
|
|
157
165
|
autoFocus(): void;
|
|
158
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Current root container for navigation.
|
|
168
|
+
*/
|
|
169
|
+
getResponderStage(): Container;
|
|
170
|
+
private _propagate;
|
|
159
171
|
private _handleGlobalIntent;
|
|
160
172
|
private _emitBlur;
|
|
161
173
|
private _emitFocus;
|
|
162
174
|
private _emitTrigger;
|
|
163
|
-
private
|
|
175
|
+
private _invalidateFocusedIfNeeded;
|
|
164
176
|
}
|
|
177
|
+
declare const Axis: {
|
|
178
|
+
readonly LeftStickX: 0;
|
|
179
|
+
readonly LeftStickY: 1;
|
|
180
|
+
readonly RightStickX: 2;
|
|
181
|
+
readonly RightStickY: 3;
|
|
182
|
+
};
|
|
183
|
+
declare const AxisCode: readonly [
|
|
184
|
+
"LeftStickLeft",
|
|
185
|
+
"LeftStickRight",
|
|
186
|
+
"LeftStickUp",
|
|
187
|
+
"LeftStickDown",
|
|
188
|
+
"RightStickLeft",
|
|
189
|
+
"RightStickRight",
|
|
190
|
+
"RightStickUp",
|
|
191
|
+
"RightStickDown"
|
|
192
|
+
];
|
|
165
193
|
declare const ButtonCode: readonly [
|
|
166
194
|
"A",
|
|
167
195
|
"B",
|
|
@@ -173,8 +201,8 @@ declare const ButtonCode: readonly [
|
|
|
173
201
|
"RightTrigger",
|
|
174
202
|
"Back",
|
|
175
203
|
"Start",
|
|
176
|
-
"
|
|
177
|
-
"
|
|
204
|
+
"LStick",
|
|
205
|
+
"RStick",
|
|
178
206
|
"DPadUp",
|
|
179
207
|
"DPadDown",
|
|
180
208
|
"DPadLeft",
|
|
@@ -191,6 +219,8 @@ declare const ButtonCode: readonly [
|
|
|
191
219
|
*/
|
|
192
220
|
export declare class GamepadDevice {
|
|
193
221
|
source: Gamepad;
|
|
222
|
+
/** Set named binds for newly connected gamepads */
|
|
223
|
+
static configureDefaultBinds(binds: Partial<Record<string, BindableCode[]>>): void;
|
|
194
224
|
static defaultOptions: {
|
|
195
225
|
/**
|
|
196
226
|
* When set to `"physical"` _(default)_, ABXY refer to the equivalent
|
|
@@ -202,55 +232,67 @@ export declare class GamepadDevice {
|
|
|
202
232
|
* When set to `"none"`, ABXY refer to the unmapped buttons in the 0, 1,
|
|
203
233
|
* 2, and 3 positions respectively.
|
|
204
234
|
*/
|
|
205
|
-
|
|
235
|
+
nintendoRemapMode: NintendoRemapMode;
|
|
206
236
|
/**
|
|
207
|
-
* Create named
|
|
237
|
+
* Create named binds of buttons.
|
|
208
238
|
*
|
|
209
|
-
* This can be used with `
|
|
239
|
+
* This can be used with `pressedBind( name )`.
|
|
210
240
|
*
|
|
211
241
|
* @example
|
|
212
242
|
* // set by names
|
|
213
|
-
* Gamepad.defaultOptions.
|
|
243
|
+
* Gamepad.defaultOptions.binds = {
|
|
244
|
+
* ...Gamepad.defaultOptions.binds,
|
|
214
245
|
* jump: [ "A" ],
|
|
215
246
|
* crouch: [ "X" ],
|
|
216
247
|
* }
|
|
217
248
|
*
|
|
218
249
|
* // check by named presses
|
|
219
|
-
* if ( gamepad.
|
|
250
|
+
* if ( gamepad.pressedBind( "jump" ) )
|
|
220
251
|
* {
|
|
221
252
|
* // ...
|
|
222
253
|
* }
|
|
223
254
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
255
|
+
binds: Partial<Record<string, BindableCode[]>>;
|
|
256
|
+
joystick: {
|
|
257
|
+
/**
|
|
258
|
+
* The range of movement in a joystick recognized as input, to
|
|
259
|
+
* prevent unintended movements caused by imprecision or wear.
|
|
260
|
+
*
|
|
261
|
+
* @default [ 0, 1 ]
|
|
262
|
+
*/
|
|
263
|
+
deadzone: [
|
|
264
|
+
number,
|
|
265
|
+
number
|
|
266
|
+
];
|
|
267
|
+
/**
|
|
268
|
+
* The threshold joysticks must reach to emit navigation and bind events.
|
|
269
|
+
*
|
|
270
|
+
* @default 0.25
|
|
271
|
+
*/
|
|
272
|
+
threshold: number;
|
|
273
|
+
/**
|
|
274
|
+
* The amount of time (in milliseconds) between emitting axis events in a
|
|
275
|
+
* given direction, given as [first, subsequent].
|
|
276
|
+
*
|
|
277
|
+
* @default [ delay: 400, repeat: 80 ]
|
|
278
|
+
*/
|
|
279
|
+
autoRepeatDelayMs: [
|
|
280
|
+
number,
|
|
281
|
+
number
|
|
282
|
+
];
|
|
283
|
+
};
|
|
284
|
+
trigger: {
|
|
285
|
+
/**
|
|
286
|
+
* The range of movement in a trigger recognized as input, to
|
|
287
|
+
* revent unintended movements caused by imprecision or wear.
|
|
288
|
+
*
|
|
289
|
+
* @default [ 0, 1 ]
|
|
290
|
+
*/
|
|
291
|
+
deadzone: [
|
|
292
|
+
number,
|
|
293
|
+
number
|
|
294
|
+
];
|
|
233
295
|
};
|
|
234
|
-
/**
|
|
235
|
-
* The range of movement in a joystick recognized as input, to
|
|
236
|
-
* prevent unintended movements caused by imprecision or wear.
|
|
237
|
-
*
|
|
238
|
-
* @default [ 0, 1 ]
|
|
239
|
-
*/
|
|
240
|
-
joystickDeadzone: [
|
|
241
|
-
number,
|
|
242
|
-
number
|
|
243
|
-
];
|
|
244
|
-
/**
|
|
245
|
-
* The range of movement in a trigger recognized as input, to
|
|
246
|
-
* revent unintended movements caused by imprecision or wear.
|
|
247
|
-
*
|
|
248
|
-
* @default [ 0, 1 ]
|
|
249
|
-
*/
|
|
250
|
-
triggerDeadzone: [
|
|
251
|
-
number,
|
|
252
|
-
number
|
|
253
|
-
];
|
|
254
296
|
vibration: {
|
|
255
297
|
enabled: boolean;
|
|
256
298
|
intensity: number;
|
|
@@ -284,13 +326,9 @@ export declare class GamepadDevice {
|
|
|
284
326
|
y: number;
|
|
285
327
|
};
|
|
286
328
|
/** Accessors for buttons */
|
|
287
|
-
button: Record<ButtonCode, boolean>;
|
|
288
|
-
private _btnPrevState;
|
|
289
|
-
private _axisIntents;
|
|
290
|
-
private readonly _throttleIdLeftStickX;
|
|
291
|
-
private readonly _throttleIdLeftStickY;
|
|
329
|
+
button: Record<AxisCode | ButtonCode, boolean>;
|
|
292
330
|
private readonly _emitter;
|
|
293
|
-
private readonly
|
|
331
|
+
private readonly _bindEmitter;
|
|
294
332
|
/** A scalar 0.0 to 1.0 representing the left trigger value */
|
|
295
333
|
leftTrigger: number;
|
|
296
334
|
/** A scalar 0.0 to 1.0 representing the right trigger value */
|
|
@@ -299,20 +337,22 @@ export declare class GamepadDevice {
|
|
|
299
337
|
leftShoulder: number;
|
|
300
338
|
/** A scalar 0.0 to 1.0 representing the right shoulder value */
|
|
301
339
|
rightShoulder: number;
|
|
302
|
-
/** @returns true if any button from the named
|
|
303
|
-
|
|
340
|
+
/** @returns true if any button from the named bind is pressed. */
|
|
341
|
+
pressedBind(name: string): boolean;
|
|
304
342
|
/** @returns true if any of the given buttons are pressed. */
|
|
305
|
-
|
|
343
|
+
pressedAny(btns: BindableCode[]): boolean;
|
|
306
344
|
/** @returns true if all of the given buttons are pressed. */
|
|
307
|
-
|
|
345
|
+
pressedAll(btns: BindableCode[]): boolean;
|
|
346
|
+
/** Set named binds for this gamepad */
|
|
347
|
+
configureBinds(binds: Partial<Record<string, BindableCode[]>>): void;
|
|
308
348
|
/** Add an event listener */
|
|
309
349
|
on<K extends keyof GamepadDeviceEvent>(event: K, listener: (event: GamepadDeviceEvent[K]) => void): this;
|
|
310
350
|
/** Remove an event listener (or all if none provided). */
|
|
311
351
|
off<K extends keyof GamepadDeviceEvent>(event: K, listener?: (event: GamepadDeviceEvent[K]) => void): this;
|
|
312
|
-
/** Add a named
|
|
313
|
-
|
|
314
|
-
/** Remove a named
|
|
315
|
-
|
|
352
|
+
/** Add a named bind event listener (or all if none provided). */
|
|
353
|
+
onBind(name: string, listener: (event: GamepadNamedBindEvent) => void): this;
|
|
354
|
+
/** Remove a named bind event listener (or all if none provided). */
|
|
355
|
+
offBind(name: string, listener?: (event: GamepadNamedBindEvent) => void): this;
|
|
316
356
|
/**
|
|
317
357
|
* Play a vibration effect (if supported).
|
|
318
358
|
*
|
|
@@ -348,13 +388,13 @@ export declare class KeyboardDevice {
|
|
|
348
388
|
detected: boolean;
|
|
349
389
|
options: {
|
|
350
390
|
/**
|
|
351
|
-
* Create named
|
|
391
|
+
* Create named binds of buttons.
|
|
352
392
|
*
|
|
353
|
-
* This can be used with `
|
|
393
|
+
* This can be used with `pressedBind( name )`.
|
|
354
394
|
*
|
|
355
395
|
* @example
|
|
356
396
|
* // set by names
|
|
357
|
-
* Keyboard.options.
|
|
397
|
+
* Keyboard.options.binds = {
|
|
358
398
|
* jump: [ "ArrowUp", "KeyW" ],
|
|
359
399
|
* left: [ "ArrowLeft", "KeyA" ],
|
|
360
400
|
* crouch: [ "ArrowDown", "KeyS" ],
|
|
@@ -362,21 +402,24 @@ export declare class KeyboardDevice {
|
|
|
362
402
|
* }
|
|
363
403
|
*
|
|
364
404
|
* // check by named presses
|
|
365
|
-
* if ( keyboard.
|
|
405
|
+
* if ( keyboard.pressedBind( "jump" ) )
|
|
366
406
|
* {
|
|
367
407
|
* // ...
|
|
368
408
|
* }
|
|
369
409
|
*/
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
410
|
+
binds: Partial<Record<string, KeyCode[]>>;
|
|
411
|
+
/**
|
|
412
|
+
* These are the binds that are allowed to repeat when a key
|
|
413
|
+
* is held down.
|
|
414
|
+
*
|
|
415
|
+
* @default ["navigate.down", "navigate.left", "navigate.right", "navigate.up"]
|
|
416
|
+
*/
|
|
417
|
+
repeatableBinds: string[];
|
|
375
418
|
};
|
|
376
419
|
/** Accessors for keys */
|
|
377
420
|
key: Record<KeyCode, boolean>;
|
|
378
421
|
private readonly _emitter;
|
|
379
|
-
private readonly
|
|
422
|
+
private readonly _bindEmitter;
|
|
380
423
|
private _layout;
|
|
381
424
|
private _layoutSource;
|
|
382
425
|
private _deferredKeydown;
|
|
@@ -403,20 +446,22 @@ export declare class KeyboardDevice {
|
|
|
403
446
|
set layout(value: KeyboardLayout);
|
|
404
447
|
/** How the keyboard layout was determined. */
|
|
405
448
|
get layoutSource(): KeyboardLayoutSource;
|
|
406
|
-
/** @returns true if any key from the named
|
|
407
|
-
|
|
449
|
+
/** @returns true if any key from the named bind is pressed. */
|
|
450
|
+
pressedBind(name: string): boolean;
|
|
408
451
|
/** @returns true if any of the given keys are pressed. */
|
|
409
|
-
|
|
452
|
+
pressedAny(keys: KeyCode[]): boolean;
|
|
410
453
|
/** @returns true if all of the given keys are pressed. */
|
|
411
|
-
|
|
454
|
+
pressedAll(keys: KeyCode[]): boolean;
|
|
455
|
+
/** Set custom binds */
|
|
456
|
+
configureBinds(binds: Partial<Record<string, KeyCode[]>>): void;
|
|
412
457
|
/** Add an event listener. */
|
|
413
458
|
on<K extends keyof KeyboardDeviceEvent>(event: K, listener: (event: KeyboardDeviceEvent[K]) => void): this;
|
|
414
459
|
/** Remove an event listener (or all if none provided). */
|
|
415
|
-
off<K extends keyof KeyboardDeviceEvent>(event: K, listener
|
|
416
|
-
/** Add a named
|
|
417
|
-
|
|
418
|
-
/** Remove a named
|
|
419
|
-
|
|
460
|
+
off<K extends keyof KeyboardDeviceEvent>(event: K, listener?: (event: KeyboardDeviceEvent[K]) => void): this;
|
|
461
|
+
/** Add a named bind event listener (or all if none provided). */
|
|
462
|
+
onBind(name: string, listener: (event: KeyboardDeviceNamedBindKeydownEvent) => void): this;
|
|
463
|
+
/** Remove a named bind event listener (or all if none provided). */
|
|
464
|
+
offBind(name: string, listener?: (event: KeyboardDeviceNamedBindKeydownEvent) => void): this;
|
|
420
465
|
/**
|
|
421
466
|
* Get the label for the given key code in the current keyboard
|
|
422
467
|
* layout. Attempts to use the Navigator KeyboardLayoutMap API
|
|
@@ -432,9 +477,7 @@ export declare class KeyboardDevice {
|
|
|
432
477
|
*/
|
|
433
478
|
getKeyLabel(key: KeyCode, layout?: KeyboardLayout): string;
|
|
434
479
|
/**
|
|
435
|
-
* Process
|
|
436
|
-
*
|
|
437
|
-
* @returns any group events to trigger
|
|
480
|
+
* Process deferred keyboard events.
|
|
438
481
|
*/
|
|
439
482
|
update(now: number): void;
|
|
440
483
|
/**
|
|
@@ -466,9 +509,9 @@ export declare const Button: {
|
|
|
466
509
|
/** Start Button (Xbox: "Start", PlayStation: "Options", Nintendo: "Plus") */
|
|
467
510
|
readonly Start: 9;
|
|
468
511
|
/** Left Stick Press (Xbox / PlayStation: "LS", Nintendo: "L3") */
|
|
469
|
-
readonly
|
|
512
|
+
readonly LeftStickClick: 10;
|
|
470
513
|
/** Right Stick Press (Xbox / PlayStation: "RS", Nintendo: "R3") */
|
|
471
|
-
readonly
|
|
514
|
+
readonly RightStickClick: 11;
|
|
472
515
|
/** D-Pad Up */
|
|
473
516
|
readonly DPadUp: 12;
|
|
474
517
|
/** D-Pad Down */
|
|
@@ -618,8 +661,15 @@ export declare const KeyCode: {
|
|
|
618
661
|
*
|
|
619
662
|
* Set stage to enable the global responder behaviors.
|
|
620
663
|
*/
|
|
621
|
-
export declare const
|
|
622
|
-
export declare const
|
|
664
|
+
export declare const UINavigation: NavigationManager;
|
|
665
|
+
export declare const navigationIntents: readonly [
|
|
666
|
+
"navigate.left",
|
|
667
|
+
"navigate.right",
|
|
668
|
+
"navigate.up",
|
|
669
|
+
"navigate.down",
|
|
670
|
+
"navigate.back",
|
|
671
|
+
"navigate.trigger"
|
|
672
|
+
];
|
|
623
673
|
/**
|
|
624
674
|
* @returns all navigatable containers in some container
|
|
625
675
|
*/
|
|
@@ -631,12 +681,13 @@ export declare function getFirstNavigatable(root: Container, currentFocus?: Cont
|
|
|
631
681
|
minimumDistance?: number;
|
|
632
682
|
}): NavigatableContainer | undefined;
|
|
633
683
|
export declare function isChildOf(child: Container, root: Container): boolean;
|
|
684
|
+
export declare function isVisible(target: Container): boolean;
|
|
634
685
|
/**
|
|
635
686
|
* Register the mixin for PIXI.Container.
|
|
636
687
|
*
|
|
637
688
|
* @param container A reference to `PIXI.Container`.
|
|
638
689
|
*/
|
|
639
|
-
export declare function
|
|
690
|
+
export declare function registerPixiJSNavigationMixin(container: any): void;
|
|
640
691
|
export interface CustomDevice {
|
|
641
692
|
readonly type: "custom";
|
|
642
693
|
readonly id: string;
|
|
@@ -653,14 +704,16 @@ export interface CustomDevice {
|
|
|
653
704
|
*/
|
|
654
705
|
clear?(): void;
|
|
655
706
|
}
|
|
707
|
+
export interface GamepadAxisEvent {
|
|
708
|
+
device: GamepadDevice;
|
|
709
|
+
axis: Axis;
|
|
710
|
+
axisCode: AxisCode;
|
|
711
|
+
}
|
|
656
712
|
export interface GamepadButtonPressEvent {
|
|
657
713
|
device: GamepadDevice;
|
|
658
714
|
button: Button;
|
|
659
715
|
buttonCode: ButtonCode;
|
|
660
716
|
}
|
|
661
|
-
export interface GamepadNamedGroupButtonPressEvent extends GamepadButtonPressEvent {
|
|
662
|
-
groupName: string;
|
|
663
|
-
}
|
|
664
717
|
export interface InputDeviceEvent {
|
|
665
718
|
deviceadded: {
|
|
666
719
|
device: Device;
|
|
@@ -681,8 +734,9 @@ export interface KeyboardDeviceLayoutUpdatedEvent {
|
|
|
681
734
|
layout: KeyboardLayout;
|
|
682
735
|
layoutSource: KeyboardLayoutSource;
|
|
683
736
|
}
|
|
684
|
-
export interface
|
|
685
|
-
|
|
737
|
+
export interface KeyboardDeviceNamedBindKeydownEvent extends KeyboardDeviceKeydownEvent {
|
|
738
|
+
name: string;
|
|
739
|
+
repeat: boolean;
|
|
686
740
|
}
|
|
687
741
|
/**
|
|
688
742
|
* A target that responds to navigation on the stack.
|
|
@@ -695,6 +749,10 @@ export interface NavigationResponder {
|
|
|
695
749
|
* @default true
|
|
696
750
|
*/
|
|
697
751
|
autoFocus?: boolean;
|
|
752
|
+
/**
|
|
753
|
+
* Currently focused container.
|
|
754
|
+
*/
|
|
755
|
+
focusTarget?: Container;
|
|
698
756
|
/**
|
|
699
757
|
* Called when received a navigation intent. The target should handle, and
|
|
700
758
|
* respond with a boolean indicating whether or not the intent was handled.
|
|
@@ -717,16 +775,35 @@ export interface NavigationResponder {
|
|
|
717
775
|
*/
|
|
718
776
|
resignedAsFirstResponder?(): void;
|
|
719
777
|
}
|
|
778
|
+
export type Axis = (typeof Axis)[keyof typeof Axis];
|
|
779
|
+
export type AxisCode = typeof AxisCode[number];
|
|
780
|
+
/**
|
|
781
|
+
* Bindable codes for button and joystick events.
|
|
782
|
+
*/
|
|
783
|
+
export type BindableCode = ButtonCode | AxisCode;
|
|
720
784
|
export type Button = (typeof Button)[keyof typeof Button];
|
|
721
785
|
export type ButtonCode = typeof ButtonCode[number];
|
|
722
786
|
export type Device = GamepadDevice | KeyboardDevice | CustomDevice;
|
|
723
787
|
export type GamepadButtonDownEvent = (gamepad: GamepadDevice, button: Button) => void;
|
|
724
788
|
export type GamepadDeviceEvent = {
|
|
725
|
-
|
|
789
|
+
bind: GamepadNamedBindEvent;
|
|
726
790
|
} & {
|
|
727
|
-
[
|
|
791
|
+
[axis in AxisCode]: GamepadAxisEvent;
|
|
728
792
|
} & {
|
|
729
|
-
[button in
|
|
793
|
+
[button in ButtonCode]: GamepadButtonPressEvent;
|
|
794
|
+
};
|
|
795
|
+
export type GamepadNamedBindEvent = {
|
|
796
|
+
device: GamepadDevice;
|
|
797
|
+
name: string;
|
|
798
|
+
type: "button";
|
|
799
|
+
button: Button;
|
|
800
|
+
buttonCode: ButtonCode;
|
|
801
|
+
} | {
|
|
802
|
+
device: GamepadDevice;
|
|
803
|
+
name: string;
|
|
804
|
+
type: "axis";
|
|
805
|
+
axis: Axis;
|
|
806
|
+
axisCode: AxisCode;
|
|
730
807
|
};
|
|
731
808
|
export type GamepadVibration = GamepadEffectParameters & {
|
|
732
809
|
vibrationType?: GamepadHapticEffectType;
|
|
@@ -734,28 +811,27 @@ export type GamepadVibration = GamepadEffectParameters & {
|
|
|
734
811
|
export type KeyCode = (typeof KeyCode)[keyof typeof KeyCode];
|
|
735
812
|
export type KeyboardDeviceEvent = {
|
|
736
813
|
layoutdetected: KeyboardDeviceLayoutUpdatedEvent;
|
|
737
|
-
|
|
814
|
+
bind: KeyboardDeviceNamedBindKeydownEvent;
|
|
738
815
|
} & {
|
|
739
816
|
[key in KeyCode]: KeyboardDeviceKeydownEvent;
|
|
740
817
|
};
|
|
741
818
|
export type KeyboardLayout = "QWERTY" | "AZERTY" | "JCUKEN" | "QWERTZ";
|
|
742
819
|
export type KeyboardLayoutSource = "browser" | "lang" | "keypress" | "manual";
|
|
743
|
-
export type
|
|
820
|
+
export type NamedBindEvent<BindName extends string = string> = {
|
|
744
821
|
device: Device;
|
|
745
|
-
|
|
822
|
+
name: BindName;
|
|
746
823
|
};
|
|
747
824
|
export type NavigatableContainer = Container;
|
|
748
|
-
export type
|
|
749
|
-
export type
|
|
750
|
-
export type
|
|
751
|
-
export type
|
|
752
|
-
export type RemapNintendoMode = "none" | "accurate" | "physical";
|
|
825
|
+
export type NavigationDirection = "navigate.left" | "navigate.right" | "navigate.up" | "navigate.down";
|
|
826
|
+
export type NavigationIntent = typeof navigationIntents[number];
|
|
827
|
+
export type NavigationTargetEvent = "deviceover" | "devicedown" | "deviceout";
|
|
828
|
+
export type NintendoRemapMode = "none" | "accurate" | "physical";
|
|
753
829
|
/**
|
|
754
830
|
* Common gamepad platform layouts, which may indicate button layout.
|
|
755
831
|
*
|
|
756
832
|
* Note: Non-comprehensive list, covers the most brands only.
|
|
757
833
|
*/
|
|
758
|
-
type GamepadLayout = "logitech" | "nintendo" | "playstation" | "steam" | "xbox" | "
|
|
834
|
+
type GamepadLayout = "logitech" | "nintendo" | "playstation" | "steam" | "xbox" | "standard";
|
|
759
835
|
|
|
760
836
|
export {
|
|
761
837
|
GamepadLayout as GamepadPlatform,
|