import { GameEventBus } from "../classes/eventBus.d.ts"; import { DeviceType, DeviceValueReader, DeviceValueReaderDefinition, InputState } from "./input.d.ts"; import { Action } from "./action.d.ts"; /** * Types of bindings supported by the system */ export type BindingType = 'trigger' | 'toggle' | 'value'; /** * Array of all supported binding types for validation */ export declare const bindingTypes: BindingType[]; /** * Context for organizing bindings into groups that can be activated/deactivated together */ export interface Context { name: string; /** * Whether this context is exclusive (only one exclusive context can be active at a time) */ exclusive: boolean; } /** * Input definition that combines device ID and reader configuration into a single object */ export type InputDefinition = DeviceValueReaderDefinition & { deviceID: string; }; /** * Options for captureInput() — waits for the next intentional input and returns its descriptor. */ export interface CaptureInputOptions { /** Device types to listen for */ deviceTypes: DeviceType[]; /** Optional filter for source types (e.g. ['key', 'button', 'axis']) */ sourceTypes?: ('key' | 'button' | 'axis' | 'position' | 'wheel')[]; /** Optional AbortSignal for cancellation or timeout */ signal?: AbortSignal; } /** * Base interface for binding definitions with object-based sources */ export interface BindingDefinitionBase { type: BindingType; /** Name of an already-registered action */ action: string; input: InputDefinition; context?: string; options?: Record; } /** * Trigger binding definition */ export interface TriggerBindingDefinition extends BindingDefinitionBase { type: 'trigger'; options?: { edgeMode?: 'rising' | 'falling' | 'both'; threshold?: number; passthrough?: boolean; }; } /** * Toggle binding definition */ export interface ToggleBindingDefinition extends BindingDefinitionBase { type: 'toggle'; state?: boolean; options?: { invert?: boolean; initialState?: boolean; threshold?: number; onValue?: boolean | number; offValue?: boolean | number; }; } /** * Value binding definition */ export interface ValueBindingDefinition extends BindingDefinitionBase { type: 'value'; options?: { scale?: number; offset?: number; min?: number; max?: number; invert?: boolean; emitOnChange?: boolean; deadzone?: number; }; } /** * Union type of all binding definitions */ export type BindingDefinition = TriggerBindingDefinition | ToggleBindingDefinition | ValueBindingDefinition; /** * Base interface for all input bindings */ export interface Binding { readonly type: BindingType; readonly action: Action; readonly context?: string; readonly deviceID: string; readonly deviceType: DeviceType; readonly reader: DeviceValueReader; /** * Process input state and potentially emit an action event * * @param state * @param eventBus */ process(state: InputState, eventBus: GameEventBus): void; /** * Reset edge-detection state for a context activation. When an input state is provided, the binding primes its * internal state from the current physical input so that already-held inputs don't produce phantom edges. Without * a state, resets to a clean baseline (false). * * @param state - Last known input state for this binding's device, if available */ resetEdgeState(state?: InputState): void; /** * Convert the binding to a JSON-serializable object. */ toJSON(): BindingDefinition; }