inpt 0.0.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/LICENSE.md +21 -0
- package/README.md +89 -0
- package/dist/index.js +1182 -0
- package/dist/types/core/BoundAction.d.ts +8 -0
- package/dist/types/core/Disposable.d.ts +11 -0
- package/dist/types/core/Input.d.ts +46 -0
- package/dist/types/core/InputManager.d.ts +179 -0
- package/dist/types/core/InputManagerEventMap.d.ts +26 -0
- package/dist/types/core/KeyCode.d.ts +7 -0
- package/dist/types/core/Modifier.d.ts +6 -0
- package/dist/types/core/PointerButton.d.ts +19 -0
- package/dist/types/core/PointerLockBehavior.d.ts +6 -0
- package/dist/types/core/WheelRotation.d.ts +30 -0
- package/dist/types/core/index.d.ts +10 -0
- package/dist/types/events/ActionEvent.d.ts +12 -0
- package/dist/types/events/MovementEvent.d.ts +28 -0
- package/dist/types/events/index.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/settings/Bindings.d.ts +125 -0
- package/dist/types/settings/InputSettings.d.ts +57 -0
- package/dist/types/settings/PointerSettings.d.ts +89 -0
- package/dist/types/settings/SettingsEventMap.d.ts +9 -0
- package/dist/types/settings/index.d.ts +4 -0
- package/package.json +92 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Modifier } from "./Modifier.js";
|
|
2
|
+
/**
|
|
3
|
+
* Input options.
|
|
4
|
+
*
|
|
5
|
+
* @group Core
|
|
6
|
+
*/
|
|
7
|
+
export interface InputOptions {
|
|
8
|
+
/**
|
|
9
|
+
* A list of required modifers.
|
|
10
|
+
*/
|
|
11
|
+
modifiers?: Modifier[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Input data.
|
|
15
|
+
*
|
|
16
|
+
* @group Core
|
|
17
|
+
*/
|
|
18
|
+
export declare class Input<T = unknown> {
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link value}
|
|
21
|
+
*/
|
|
22
|
+
_value: T;
|
|
23
|
+
/**
|
|
24
|
+
* @see {@link modifiers}
|
|
25
|
+
*/
|
|
26
|
+
_modifiers: number;
|
|
27
|
+
/**
|
|
28
|
+
* Constructs new input data.
|
|
29
|
+
*
|
|
30
|
+
* @param value - The primary input value.
|
|
31
|
+
* @param options - Additional options.
|
|
32
|
+
*/
|
|
33
|
+
constructor(value: T, { modifiers }?: InputOptions);
|
|
34
|
+
/**
|
|
35
|
+
* The primary input value.
|
|
36
|
+
*/
|
|
37
|
+
get value(): T;
|
|
38
|
+
set value(value: T);
|
|
39
|
+
/**
|
|
40
|
+
* The required modifiers, stored as a bitmask.
|
|
41
|
+
*
|
|
42
|
+
* Modifiers can be set directly as a bitmask or as a list of modifier keys.
|
|
43
|
+
*/
|
|
44
|
+
get modifiers(): number;
|
|
45
|
+
set modifiers(value: number | Modifier[]);
|
|
46
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Event, EventTarget } from "synthetic-event";
|
|
2
|
+
import { InputSettings } from "../settings/InputSettings.js";
|
|
3
|
+
import { Disposable } from "./Disposable.js";
|
|
4
|
+
import { InputManagerEventMap } from "./InputManagerEventMap.js";
|
|
5
|
+
/**
|
|
6
|
+
* InputManager options.
|
|
7
|
+
*
|
|
8
|
+
* @group Core
|
|
9
|
+
*/
|
|
10
|
+
export interface InputManagerOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The input settings.
|
|
13
|
+
*/
|
|
14
|
+
settings?: InputSettings;
|
|
15
|
+
/**
|
|
16
|
+
* The DOM element that acts as the primary event target.
|
|
17
|
+
*/
|
|
18
|
+
domElement?: HTMLElement | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An input manager.
|
|
22
|
+
*
|
|
23
|
+
* @group Core
|
|
24
|
+
*/
|
|
25
|
+
export declare class InputManager extends EventTarget<InputManagerEventMap> implements Disposable, EventListenerObject {
|
|
26
|
+
/**
|
|
27
|
+
* @see {@link domElement}
|
|
28
|
+
*/
|
|
29
|
+
private _domElement;
|
|
30
|
+
/**
|
|
31
|
+
* @see {@link enabled}
|
|
32
|
+
*/
|
|
33
|
+
private _enabled;
|
|
34
|
+
/**
|
|
35
|
+
* A collection that organizes active pointer events by ID.
|
|
36
|
+
*/
|
|
37
|
+
private readonly pointerEvents;
|
|
38
|
+
/**
|
|
39
|
+
* A collection of deferred mouse events that are handled when the pointer lock state changes.
|
|
40
|
+
*/
|
|
41
|
+
private readonly deferredMouseEvents;
|
|
42
|
+
/**
|
|
43
|
+
* A collection of actions that are currently active.
|
|
44
|
+
*/
|
|
45
|
+
private readonly activeActions;
|
|
46
|
+
private readonly movementEvent;
|
|
47
|
+
/**
|
|
48
|
+
* The settings.
|
|
49
|
+
*/
|
|
50
|
+
readonly settings: InputSettings;
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a new input manager.
|
|
53
|
+
*
|
|
54
|
+
* @param options - The options.
|
|
55
|
+
*/
|
|
56
|
+
constructor({ settings, domElement }?: InputManagerOptions);
|
|
57
|
+
/**
|
|
58
|
+
* A DOM element that acts as the primary event target.
|
|
59
|
+
*/
|
|
60
|
+
get domElement(): HTMLElement | null;
|
|
61
|
+
set domElement(value: HTMLElement | null);
|
|
62
|
+
/**
|
|
63
|
+
* Determines whether the input listeners are currently enabled.
|
|
64
|
+
*/
|
|
65
|
+
get enabled(): boolean;
|
|
66
|
+
set enabled(value: boolean);
|
|
67
|
+
/**
|
|
68
|
+
* Indicates whether the pointer is currently locked.
|
|
69
|
+
*/
|
|
70
|
+
get pointerLocked(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Registers event listeners.
|
|
73
|
+
*/
|
|
74
|
+
private addEventListeners;
|
|
75
|
+
/**
|
|
76
|
+
* Unregisters event listeners.
|
|
77
|
+
*/
|
|
78
|
+
private removeEventListeners;
|
|
79
|
+
/**
|
|
80
|
+
* Reset the input state.
|
|
81
|
+
*/
|
|
82
|
+
private resetInputState;
|
|
83
|
+
/**
|
|
84
|
+
* Locks the pointer.
|
|
85
|
+
*
|
|
86
|
+
* @return A promise that resolves when the pointer has been locked.
|
|
87
|
+
*/
|
|
88
|
+
private lockPointer;
|
|
89
|
+
/**
|
|
90
|
+
* Unlocks the pointer.
|
|
91
|
+
*/
|
|
92
|
+
private unlockPointer;
|
|
93
|
+
/**
|
|
94
|
+
* Handles pointer move events.
|
|
95
|
+
*
|
|
96
|
+
* @param event - A pointer event.
|
|
97
|
+
*/
|
|
98
|
+
private onPointerMove;
|
|
99
|
+
/**
|
|
100
|
+
* Handles pointer lock change events.
|
|
101
|
+
*/
|
|
102
|
+
private onPointerLockChange;
|
|
103
|
+
/**
|
|
104
|
+
* Handles `mousedown` events.
|
|
105
|
+
*
|
|
106
|
+
* Mouse events are used because pointer events don't fire for other mouse buttons while a pointer is active.
|
|
107
|
+
*
|
|
108
|
+
* @param event - A mouse event.
|
|
109
|
+
*/
|
|
110
|
+
private onMouseDownNative;
|
|
111
|
+
/**
|
|
112
|
+
* Handles `mouseup` events.
|
|
113
|
+
*
|
|
114
|
+
* Mouse events are used because pointer events don't fire for other mouse buttons while a pointer is active.
|
|
115
|
+
*
|
|
116
|
+
* @param event - A mouse event.
|
|
117
|
+
*/
|
|
118
|
+
private onMouseUpNative;
|
|
119
|
+
/**
|
|
120
|
+
* Handles `mousedown` events.
|
|
121
|
+
*
|
|
122
|
+
* @param event - A mouse event.
|
|
123
|
+
*/
|
|
124
|
+
private onMouseDown;
|
|
125
|
+
/**
|
|
126
|
+
* Handles `mouseup` events.
|
|
127
|
+
*
|
|
128
|
+
* @param event - A mouse event.
|
|
129
|
+
*/
|
|
130
|
+
private onMouseUp;
|
|
131
|
+
/**
|
|
132
|
+
* Handles `pointerdown` events.
|
|
133
|
+
*
|
|
134
|
+
* @param event - A pointer event.
|
|
135
|
+
*/
|
|
136
|
+
private onPointerDown;
|
|
137
|
+
/**
|
|
138
|
+
* Handles `pointerup` events.
|
|
139
|
+
*
|
|
140
|
+
* @param event - A pointer event.
|
|
141
|
+
*/
|
|
142
|
+
private onPointerUp;
|
|
143
|
+
/**
|
|
144
|
+
* Handles `contextmenu` events.
|
|
145
|
+
*
|
|
146
|
+
* @param event - A pointer event.
|
|
147
|
+
*/
|
|
148
|
+
private onContextMenu;
|
|
149
|
+
/**
|
|
150
|
+
* Handles `wheel` events.
|
|
151
|
+
*
|
|
152
|
+
* @param event - A wheel event.
|
|
153
|
+
*/
|
|
154
|
+
private onWheel;
|
|
155
|
+
/**
|
|
156
|
+
* Handles `keydown` events.
|
|
157
|
+
*
|
|
158
|
+
* @param event - A keyboard event.
|
|
159
|
+
*/
|
|
160
|
+
private onKeyDown;
|
|
161
|
+
/**
|
|
162
|
+
* Handles `keyup` events.
|
|
163
|
+
*
|
|
164
|
+
* @param event - A keyboard event.
|
|
165
|
+
*/
|
|
166
|
+
private onKeyUp;
|
|
167
|
+
/**
|
|
168
|
+
* Handles `pointercancel` events.
|
|
169
|
+
*
|
|
170
|
+
* @param event - A pointer event.
|
|
171
|
+
*/
|
|
172
|
+
private onPointerCancel;
|
|
173
|
+
/**
|
|
174
|
+
* Cancels active interactions on visibility loss.
|
|
175
|
+
*/
|
|
176
|
+
private onVisibilityChange;
|
|
177
|
+
handleEvent(event: Event): void;
|
|
178
|
+
dispose(): void;
|
|
179
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Event } from "synthetic-event";
|
|
2
|
+
import { ActionEvent } from "../events/ActionEvent.js";
|
|
3
|
+
import { MovementEvent } from "../events/MovementEvent.js";
|
|
4
|
+
/**
|
|
5
|
+
* Events emitted by the input manager.
|
|
6
|
+
*
|
|
7
|
+
* @group Core
|
|
8
|
+
*/
|
|
9
|
+
export interface InputManagerEventMap {
|
|
10
|
+
/**
|
|
11
|
+
* Indicates that a specific action was activated.
|
|
12
|
+
*/
|
|
13
|
+
activate: ActionEvent<"activate">;
|
|
14
|
+
/**
|
|
15
|
+
* Indicates that a specific action was deactivated.
|
|
16
|
+
*/
|
|
17
|
+
deactivate: ActionEvent<"deactivate">;
|
|
18
|
+
/**
|
|
19
|
+
* A pointer movement change.
|
|
20
|
+
*/
|
|
21
|
+
move: MovementEvent;
|
|
22
|
+
/**
|
|
23
|
+
* Signals that the input state has been reset.
|
|
24
|
+
*/
|
|
25
|
+
reset: Event<"reset">;
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enumeration of input keys.
|
|
3
|
+
*
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
|
|
5
|
+
* @group Core
|
|
6
|
+
*/
|
|
7
|
+
export type KeyCode = ("Backspace" | "Tab" | "Enter" | "ShiftLeft" | "ShiftRight" | "ControlLeft" | "ControlRight" | "AltLeft" | "AltRight" | "Pause" | "CapsLock" | "Escape" | "Space" | "PageUp" | "PageDown" | "End" | "Home" | "ArrowLeft" | "ArrowUp" | "ArrowRight" | "ArrowDown" | "Insert" | "Delete" | "Digit0" | "Digit1" | "Digit2" | "Digit3" | "Digit4" | "Digit5" | "Digit6" | "Digit7" | "Digit8" | "Digit9" | "KeyA" | "KeyB" | "KeyC" | "KeyD" | "KeyE" | "KeyF" | "KeyG" | "KeyH" | "KeyI" | "KeyJ" | "KeyK" | "KeyL" | "KeyM" | "KeyN" | "KeyO" | "KeyP" | "KeyQ" | "KeyR" | "KeyS" | "KeyT" | "KeyU" | "KeyV" | "KeyW" | "KeyX" | "KeyY" | "KeyZ" | "OSLeft" | "OSRight" | "MetaLeft" | "MetaRight" | "MediaSelect" | "Numpad0" | "Numpad1" | "Numpad2" | "Numpad3" | "Numpad4" | "Numpad5" | "Numpad6" | "Numpad7" | "Numpad8" | "Numpad9" | "NumpadMultiply" | "NumpadAdd" | "NumpadSubtract" | "NumpadDecimal" | "NumpadDivide" | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | "NumLock" | "ScrollLock" | "Semicolon" | "Equal" | "Comma" | "Minus" | "Period" | "Slash" | "Backquote" | "BracketLeft" | "BracketRight" | "Backslash");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enumeration of pointer buttons.
|
|
3
|
+
*
|
|
4
|
+
* @group Core
|
|
5
|
+
*/
|
|
6
|
+
export declare enum PointerButton {
|
|
7
|
+
/**
|
|
8
|
+
* The main button such as the left button on a mouse.
|
|
9
|
+
*/
|
|
10
|
+
MAIN = 0,
|
|
11
|
+
/**
|
|
12
|
+
* An auxiliary button such as the middle button on a mouse.
|
|
13
|
+
*/
|
|
14
|
+
AUXILIARY = 1,
|
|
15
|
+
/**
|
|
16
|
+
* A secondary button such as the right button on a mouse.
|
|
17
|
+
*/
|
|
18
|
+
SECONDARY = 2
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enumeration of wheel rotations.
|
|
3
|
+
*
|
|
4
|
+
* @group Core
|
|
5
|
+
*/
|
|
6
|
+
export declare enum WheelRotation {
|
|
7
|
+
/**
|
|
8
|
+
* A negative horizontal wheel rotation, i.e. scrolling left.
|
|
9
|
+
*/
|
|
10
|
+
NEGATIVE_X = "-x",
|
|
11
|
+
/**
|
|
12
|
+
* A positive horizontal wheel rotation, i.e. scrolling right.
|
|
13
|
+
*/
|
|
14
|
+
POSITIVE_X = "+x",
|
|
15
|
+
/**
|
|
16
|
+
* A negative vertical wheel rotation, i.e. scrolling up.
|
|
17
|
+
*/
|
|
18
|
+
NEGATIVE_Y = "-y",
|
|
19
|
+
/**
|
|
20
|
+
* A positive vertical wheel rotation, i.e. scrolling down.
|
|
21
|
+
*/
|
|
22
|
+
POSITIVE_Y = "+y"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves the wheel rotation from a given wheel event.
|
|
26
|
+
*
|
|
27
|
+
* @param event - The event.
|
|
28
|
+
* @return The rotation, or undefined if there is no delta information.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getWheelRotation(event: WheelEvent): WheelRotation | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./BoundAction.js";
|
|
2
|
+
export * from "./Disposable.js";
|
|
3
|
+
export * from "./Input.js";
|
|
4
|
+
export * from "./InputManager.js";
|
|
5
|
+
export * from "./InputManagerEventMap.js";
|
|
6
|
+
export * from "./KeyCode.js";
|
|
7
|
+
export * from "./Modifier.js";
|
|
8
|
+
export * from "./PointerButton.js";
|
|
9
|
+
export * from "./PointerLockBehavior.js";
|
|
10
|
+
export * from "./WheelRotation.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Event } from "synthetic-event";
|
|
2
|
+
/**
|
|
3
|
+
* A movement event.
|
|
4
|
+
*
|
|
5
|
+
* @group Events
|
|
6
|
+
*/
|
|
7
|
+
export interface MovementEvent extends Event<"move"> {
|
|
8
|
+
/**
|
|
9
|
+
* The number of active pointers.
|
|
10
|
+
*/
|
|
11
|
+
pointerCount: number;
|
|
12
|
+
/**
|
|
13
|
+
* The position change along the X-axis.
|
|
14
|
+
*/
|
|
15
|
+
deltaX: number;
|
|
16
|
+
/**
|
|
17
|
+
* The position change along the Y-axis.
|
|
18
|
+
*/
|
|
19
|
+
deltaY: number;
|
|
20
|
+
/**
|
|
21
|
+
* The position on the X-axis.
|
|
22
|
+
*/
|
|
23
|
+
x: number;
|
|
24
|
+
/**
|
|
25
|
+
* The position on the Y-axis.
|
|
26
|
+
*/
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Input } from "../core/Input.js";
|
|
2
|
+
/**
|
|
3
|
+
* Input bindings.
|
|
4
|
+
*
|
|
5
|
+
* @group Settings
|
|
6
|
+
* @param TKey - The type of the input values.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Bindings<TInput> {
|
|
9
|
+
/**
|
|
10
|
+
* The default bindings.
|
|
11
|
+
*/
|
|
12
|
+
private defaultActions;
|
|
13
|
+
/**
|
|
14
|
+
* A collection that maps inputs to actions.
|
|
15
|
+
*/
|
|
16
|
+
private actions;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs new input bindings.
|
|
19
|
+
*/
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Resets the current bindings to match the default bindings.
|
|
23
|
+
*
|
|
24
|
+
* @return This instance.
|
|
25
|
+
*/
|
|
26
|
+
reset(): this;
|
|
27
|
+
/**
|
|
28
|
+
* Resets the current bindings and establishes default bindings.
|
|
29
|
+
*
|
|
30
|
+
* @param actions - A collection that maps inputs to actions.
|
|
31
|
+
* @return This instance.
|
|
32
|
+
*/
|
|
33
|
+
setDefault(actions: Map<TInput | Input<TInput>, string>): this;
|
|
34
|
+
/**
|
|
35
|
+
* Clears the default bindings.
|
|
36
|
+
*
|
|
37
|
+
* @return This instance.
|
|
38
|
+
*/
|
|
39
|
+
clearDefault(): this;
|
|
40
|
+
/**
|
|
41
|
+
* Clears the current bindings.
|
|
42
|
+
*
|
|
43
|
+
* @return This instance.
|
|
44
|
+
*/
|
|
45
|
+
clear(): this;
|
|
46
|
+
/**
|
|
47
|
+
* Copies the given bindings, including the default bindings.
|
|
48
|
+
*
|
|
49
|
+
* @param bindings - Bindings.
|
|
50
|
+
* @return This instance.
|
|
51
|
+
*/
|
|
52
|
+
copy(bindings: Bindings<TInput>): this;
|
|
53
|
+
/**
|
|
54
|
+
* Clones these bindings.
|
|
55
|
+
*
|
|
56
|
+
* @return The cloned bindings.
|
|
57
|
+
*/
|
|
58
|
+
clone(): Bindings<TInput>;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if any actions are bound to the given input.
|
|
61
|
+
*
|
|
62
|
+
* @param input - An input.
|
|
63
|
+
* @return Whether the given input is bound to an action.
|
|
64
|
+
*/
|
|
65
|
+
has(input: TInput | Input<TInput>): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the action that exactly matches the given input.
|
|
68
|
+
*
|
|
69
|
+
* @param input - An input.
|
|
70
|
+
* @return The action, or undefined if the input is not bound to any action.
|
|
71
|
+
*/
|
|
72
|
+
get(input: TInput | Input<TInput>): string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Binds an action to an input.
|
|
75
|
+
*
|
|
76
|
+
* @param input - An input.
|
|
77
|
+
* @param action - An action.
|
|
78
|
+
* @return This instance.
|
|
79
|
+
*/
|
|
80
|
+
set(input: TInput | Input<TInput>, action: string): this;
|
|
81
|
+
/**
|
|
82
|
+
* Unbinds an action.
|
|
83
|
+
*
|
|
84
|
+
* @param input - The input.
|
|
85
|
+
* @return Whether the binding existed.
|
|
86
|
+
*/
|
|
87
|
+
delete(input: TInput | Input<TInput>): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Returns all actions that match the given mouse event.
|
|
90
|
+
*
|
|
91
|
+
* @param event - A mouse event
|
|
92
|
+
* @return The matching actions sorted by specificity, DESC, or undefined if there is no bound action.
|
|
93
|
+
*/
|
|
94
|
+
matchMouseEvent(event: MouseEvent): string[] | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Returns all actions that match the given wheel event.
|
|
97
|
+
*
|
|
98
|
+
* @param event - A wheel event
|
|
99
|
+
* @return The matching actions sorted by specificity, DESC, or undefined if there is no bound action.
|
|
100
|
+
*/
|
|
101
|
+
matchWheelEvent(event: WheelEvent): string[] | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Returns all actions that match the given keyboard event.
|
|
104
|
+
*
|
|
105
|
+
* @param event - A keyboard event
|
|
106
|
+
* @return The matching actions sorted by specificity, DESC, or undefined if there is no bound action.
|
|
107
|
+
*/
|
|
108
|
+
matchKeyboardEvent(event: KeyboardEvent): string[] | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Returns all actions that match the given input.
|
|
111
|
+
*
|
|
112
|
+
* @param input - An input.
|
|
113
|
+
* @param modifiers - A modifier bitmask. Default is `~0 >>> 0` which allows all modifiers.
|
|
114
|
+
* @return The matching actions sorted by specificity, DESC, or undefined if there is no bound action.
|
|
115
|
+
*/
|
|
116
|
+
match(input: TInput, modifiers?: number): string[] | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Copies the given JSON data.
|
|
119
|
+
*
|
|
120
|
+
* @param json - The JSON data.
|
|
121
|
+
* @return This instance.
|
|
122
|
+
*/
|
|
123
|
+
fromJSON(json: string | Bindings<TInput>): this;
|
|
124
|
+
toJSON(): Record<string, unknown>;
|
|
125
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EventTarget } from "synthetic-event";
|
|
2
|
+
import { KeyCode } from "../core/KeyCode.js";
|
|
3
|
+
import { PointerButton } from "../core/PointerButton.js";
|
|
4
|
+
import { WheelRotation } from "../core/WheelRotation.js";
|
|
5
|
+
import { Bindings } from "./Bindings.js";
|
|
6
|
+
import { PointerSettings } from "./PointerSettings.js";
|
|
7
|
+
import { SettingsEventMap } from "./SettingsEventMap.js";
|
|
8
|
+
/**
|
|
9
|
+
* Input settings.
|
|
10
|
+
*
|
|
11
|
+
* @group Settings
|
|
12
|
+
*/
|
|
13
|
+
export declare class InputSettings extends EventTarget<SettingsEventMap> {
|
|
14
|
+
/**
|
|
15
|
+
* Key bindings.
|
|
16
|
+
*/
|
|
17
|
+
readonly keyBindings: Bindings<KeyCode>;
|
|
18
|
+
/**
|
|
19
|
+
* Pointer bindings.
|
|
20
|
+
*/
|
|
21
|
+
readonly pointerBindings: Bindings<PointerButton | WheelRotation>;
|
|
22
|
+
/**
|
|
23
|
+
* Pointer settings.
|
|
24
|
+
*/
|
|
25
|
+
readonly pointer: PointerSettings;
|
|
26
|
+
/**
|
|
27
|
+
* Constructs new pointer settings.
|
|
28
|
+
*/
|
|
29
|
+
constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Copies the given pointer settings.
|
|
32
|
+
*
|
|
33
|
+
* @param settings - Pointer settings.
|
|
34
|
+
* @return This instance.
|
|
35
|
+
*/
|
|
36
|
+
copy(settings: InputSettings): this;
|
|
37
|
+
/**
|
|
38
|
+
* Clones this pointer settings instance.
|
|
39
|
+
*
|
|
40
|
+
* @return The cloned pointer settings.
|
|
41
|
+
*/
|
|
42
|
+
clone(): InputSettings;
|
|
43
|
+
/**
|
|
44
|
+
* Copies the given JSON data.
|
|
45
|
+
*
|
|
46
|
+
* @param json - The JSON data.
|
|
47
|
+
* @return This instance.
|
|
48
|
+
*/
|
|
49
|
+
fromJSON(json: string | InputSettings): InputSettings;
|
|
50
|
+
toJSON(): Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Exports these settings as a data blob.
|
|
53
|
+
*
|
|
54
|
+
* @return The settings blob.
|
|
55
|
+
*/
|
|
56
|
+
toBlob(): Blob;
|
|
57
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { EventTarget } from "synthetic-event";
|
|
2
|
+
import { PointerButton } from "../core/PointerButton.js";
|
|
3
|
+
import { PointerLockBehavior } from "../core/PointerLockBehavior.js";
|
|
4
|
+
import { SettingsEventMap } from "./SettingsEventMap.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pointer settings.
|
|
7
|
+
*
|
|
8
|
+
* @group Settings
|
|
9
|
+
*/
|
|
10
|
+
export declare class PointerSettings extends EventTarget<SettingsEventMap> {
|
|
11
|
+
/**
|
|
12
|
+
* @see {@link sensitivityX}
|
|
13
|
+
*/
|
|
14
|
+
private _sensitivityX;
|
|
15
|
+
/**
|
|
16
|
+
* @see {@link sensitivityY}
|
|
17
|
+
*/
|
|
18
|
+
private _sensitivityY;
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link lockBehavior}
|
|
21
|
+
*/
|
|
22
|
+
private _lockBehavior;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs new pointer settings.
|
|
25
|
+
*/
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* The horizontal sensitivity.
|
|
29
|
+
*
|
|
30
|
+
* This sensitivity acts as a baseline scale for pointer movement deltas.
|
|
31
|
+
*
|
|
32
|
+
* @defaultValue 1e-3
|
|
33
|
+
*/
|
|
34
|
+
get sensitivityX(): number;
|
|
35
|
+
set sensitivityX(value: number);
|
|
36
|
+
/**
|
|
37
|
+
* The vertical sensitivity.
|
|
38
|
+
*
|
|
39
|
+
* This sensitivity acts as a baseline scale for pointer movement deltas.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue 1e-3
|
|
42
|
+
*/
|
|
43
|
+
get sensitivityY(): number;
|
|
44
|
+
set sensitivityY(value: number);
|
|
45
|
+
/**
|
|
46
|
+
* Sets the horizontal and vertical rotation sensitivity.
|
|
47
|
+
*
|
|
48
|
+
* This sensitivity acts as a baseline scale for pointer movement deltas.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue 1e-3
|
|
51
|
+
*/
|
|
52
|
+
set sensitivity(value: number);
|
|
53
|
+
private set lockBehavior(value);
|
|
54
|
+
/**
|
|
55
|
+
* Returns the pointer behavior for a specific button.
|
|
56
|
+
*
|
|
57
|
+
* @param button - A pointer button.
|
|
58
|
+
* @return The behavior.
|
|
59
|
+
*/
|
|
60
|
+
getLockBehavior(button: PointerButton): PointerLockBehavior;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the pointer behavior for a specific button.
|
|
63
|
+
*
|
|
64
|
+
* @param button - The button.
|
|
65
|
+
* @param behavior - The behavior.
|
|
66
|
+
*/
|
|
67
|
+
setLockBehavior(button: PointerButton, behavior: PointerLockBehavior): void;
|
|
68
|
+
/**
|
|
69
|
+
* Copies the given pointer settings.
|
|
70
|
+
*
|
|
71
|
+
* @param settings - Pointer settings.
|
|
72
|
+
* @return This instance.
|
|
73
|
+
*/
|
|
74
|
+
copy(settings: PointerSettings): PointerSettings;
|
|
75
|
+
/**
|
|
76
|
+
* Clones this pointer settings instance.
|
|
77
|
+
*
|
|
78
|
+
* @return The cloned pointer settings.
|
|
79
|
+
*/
|
|
80
|
+
clone(): PointerSettings;
|
|
81
|
+
/**
|
|
82
|
+
* Copies the given JSON data.
|
|
83
|
+
*
|
|
84
|
+
* @param json - The JSON data.
|
|
85
|
+
* @return This instance.
|
|
86
|
+
*/
|
|
87
|
+
fromJSON(json: string | PointerSettings): PointerSettings;
|
|
88
|
+
toJSON(): Record<string, unknown>;
|
|
89
|
+
}
|