@skewedaspect/sage 0.9.0-beta.7 → 0.9.0-beta.8
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/interfaces/action.d.ts +2 -0
- package/dist/interfaces/binding.d.ts +11 -0
- package/dist/managers/binding.d.ts +25 -1
- package/dist/sage.es.js +926 -821
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export interface DigitalAction {
|
|
5
5
|
type: 'digital';
|
|
6
6
|
name: string;
|
|
7
|
+
label?: string;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Analog action (numeric)
|
|
@@ -11,6 +12,7 @@ export interface DigitalAction {
|
|
|
11
12
|
export interface AnalogAction {
|
|
12
13
|
type: 'analog';
|
|
13
14
|
name: string;
|
|
15
|
+
label?: string;
|
|
14
16
|
minValue?: number;
|
|
15
17
|
maxValue?: number;
|
|
16
18
|
}
|
|
@@ -25,6 +25,17 @@ export interface Context {
|
|
|
25
25
|
export type InputDefinition = DeviceValueReaderDefinition & {
|
|
26
26
|
deviceID: string;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Options for captureInput() — waits for the next intentional input and returns its descriptor.
|
|
30
|
+
*/
|
|
31
|
+
export interface CaptureInputOptions {
|
|
32
|
+
/** Device types to listen for */
|
|
33
|
+
deviceTypes: DeviceType[];
|
|
34
|
+
/** Optional filter for source types (e.g. ['key', 'button', 'axis']) */
|
|
35
|
+
sourceTypes?: ('key' | 'button' | 'axis' | 'position' | 'wheel')[];
|
|
36
|
+
/** Optional AbortSignal for cancellation or timeout */
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
28
39
|
/**
|
|
29
40
|
* Base interface for binding definitions with object-based sources
|
|
30
41
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GameEventBus } from "../classes/eventBus.d.ts";
|
|
2
|
-
import { Binding, BindingDefinition, Context } from "../interfaces/binding.d.ts";
|
|
2
|
+
import { Binding, BindingDefinition, CaptureInputOptions, Context, InputDefinition } from "../interfaces/binding.d.ts";
|
|
3
3
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
4
4
|
import { DeviceType, InputDevice, InputState } from "../interfaces/input.d.ts";
|
|
5
5
|
import { Action } from "../interfaces/action.d.ts";
|
|
@@ -35,6 +35,8 @@ export declare class BindingManager implements Disposable {
|
|
|
35
35
|
private _activeContexts;
|
|
36
36
|
/** The most recent device type that produced intentional input */
|
|
37
37
|
private _lastActiveDeviceType;
|
|
38
|
+
/** Active captureInput() state, or null when not capturing */
|
|
39
|
+
private _captureState;
|
|
38
40
|
/** Event bus for handling game events */
|
|
39
41
|
private _eventBus;
|
|
40
42
|
/** Unsubscribe function for input events */
|
|
@@ -91,6 +93,19 @@ export declare class BindingManager implements Disposable {
|
|
|
91
93
|
* @throws Error if the reader type is not supported
|
|
92
94
|
*/
|
|
93
95
|
private _createInputSourceFromDefinition;
|
|
96
|
+
/**
|
|
97
|
+
* Evaluates an input event during capture mode. If the event matches the capture criteria,
|
|
98
|
+
* resolves the capture promise and cleans up. Otherwise does nothing and waits for the next event.
|
|
99
|
+
*
|
|
100
|
+
* @param device
|
|
101
|
+
* @param state
|
|
102
|
+
*/
|
|
103
|
+
private _processCaptureInput;
|
|
104
|
+
/**
|
|
105
|
+
* Tears down capture state, deactivates the temporary context, and restores the
|
|
106
|
+
* snapshotted contexts. Does not resolve or reject — the caller handles that.
|
|
107
|
+
*/
|
|
108
|
+
private _cleanupCapture;
|
|
94
109
|
/**
|
|
95
110
|
* Handle input from a device and process all relevant bindings.
|
|
96
111
|
*
|
|
@@ -122,6 +137,15 @@ export declare class BindingManager implements Disposable {
|
|
|
122
137
|
* or `null` if no input has been received yet.
|
|
123
138
|
*/
|
|
124
139
|
get lastActiveDeviceType(): DeviceType | null;
|
|
140
|
+
/**
|
|
141
|
+
* Waits for the next intentional input event and returns a descriptor suitable for constructing
|
|
142
|
+
* a binding. While capturing, all normal bindings are suppressed via a temporary exclusive context.
|
|
143
|
+
* Previous context state is restored when the capture completes or is cancelled.
|
|
144
|
+
*
|
|
145
|
+
* @param options
|
|
146
|
+
* @throws Error if a capture is already in progress
|
|
147
|
+
*/
|
|
148
|
+
captureInput(options: CaptureInputOptions): Promise<InputDefinition>;
|
|
125
149
|
/**
|
|
126
150
|
* Registers a context with specific options.
|
|
127
151
|
* Updates exclusivity if the context already exists.
|