import { GameEventBus } from "../eventBus.d.ts"; import { Action } from "../../interfaces/action.d.ts"; import { Binding, ToggleBindingDefinition } from "../../interfaces/binding.d.ts"; import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts"; /** * Options for configuring a toggle binding */ export interface ToggleBindingOptions { /** * If true, toggle on falling edge (true -> false) instead of rising edge (false -> true) */ invert?: boolean; /** * Initial toggle state (defaults to false - off) */ initialState?: boolean; /** * Threshold for analog inputs (0.0 to 1.0) * When input value is >= threshold, it's considered "active" (true) * When input value is < threshold, it's considered "inactive" (false) * Defaults to 0.5 for analog inputs */ threshold?: number; /** * Value to emit when the toggle is in the "on" state for digital actions * If undefined, will emit boolean true * Ignored for analog actions */ onValue?: boolean | number; /** * Value to emit when the toggle is in the "off" state for digital actions * If undefined, will emit boolean false * Ignored for analog actions */ offValue?: boolean | number; /** * Optional context name this binding belongs to */ context?: string; } /** * Implementation of a toggle binding, which maintains and toggles state between true/false * when a button/key is pressed or released, remaining in that state until toggled again. * Can handle both digital and analog inputs with configurable threshold. * Can output either digital or analog values based on the action type. */ export declare class ToggleBinding implements Binding { readonly type: "toggle"; readonly action: Action; readonly context?: string; readonly deviceID: string; readonly deviceType: DeviceType; readonly reader: DeviceValueReader; private readonly _invert; private readonly _threshold; private readonly _initialState; private readonly _onValue; private readonly _offValue; private _lastDigitalState; private _toggleState; /** * Get the current toggle state (true = on, false = off) */ get state(): boolean; /** * Set the toggle state directly (useful for programmatic control) */ set state(value: boolean); /** * Get the value emitted when toggle is in the "on" state */ get onValue(): boolean | number; /** * Get the value emitted when toggle is in the "off" state */ get offValue(): boolean | number; /** * Get the current value based on toggle state. * For analog actions, returns min/max value. For digital, returns on/off value. */ get value(): boolean | number; /** * Get the current options for this toggle binding. */ get options(): ToggleBindingOptions; /** * Create a new toggle binding * * @param action * @param deviceID * @param deviceType * @param reader * @param options */ constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: ToggleBindingOptions); /** * Process input state and emit an action event if the toggle flipped. * * @param state * @param eventBus */ process(state: InputState, eventBus: GameEventBus): void; /** * Reset edge-detection state for a context activation. When a state is provided, primes from the current physical * input so that already-held inputs don't produce phantom edges in the newly activated context. */ resetEdgeState(state?: InputState): void; /** * Reset toggle to its initial state */ reset(): void; /** * Returns a JSON-serializable representation of this toggle binding. */ toJSON(): ToggleBindingDefinition; }