/** * Valid input device types */ export declare const validDeviceTypes: readonly ["keyboard", "mouse", "gamepad"]; export type DeviceType = typeof validDeviceTypes[number]; /** * Base input device interface */ export interface InputDevice { id: string; name: string; type: DeviceType; connected: boolean; } /** * Keyboard device information */ export interface KeyboardDevice extends InputDevice { type: 'keyboard'; } /** * Mouse device information */ export interface MouseDevice extends InputDevice { type: 'mouse'; } /** * Gamepad device information */ export interface GamepadDevice extends InputDevice { type: 'gamepad'; index: number; mapping: string; axes: number[]; buttons: GamepadButton[]; } /** * Base interface for all input device states */ export interface BaseInputState { event?: Event; } /** * Button state interface (for both mouse and gamepad) */ export interface ButtonState { pressed: boolean; touched?: boolean; value?: number; } /** * Mouse position interface */ export interface Position { absolute: { x: number; y: number; }; relative: { x: number; y: number; }; } /** * Unified keyboard input state with object literals instead of Maps */ export interface KeyboardInputState extends BaseInputState { type: 'keyboard'; keys: Record; delta: Record; event?: KeyboardEvent; } /** * Unified mouse input state with object literals instead of Maps */ export interface MouseInputState extends BaseInputState { type: 'mouse'; buttons: Record; axes: Record; position: Position; wheel?: { deltaX: number; deltaY: number; deltaZ: number; deltaMode: number; }; event?: MouseEvent | WheelEvent; } /** * Unified gamepad input state with object literals instead of Maps */ export interface GamepadInputState extends BaseInputState { type: 'gamepad'; buttons: Record; axes: Record; event?: GamepadEvent; } /** * Unified input state interface that can represent any input device */ export type InputState = KeyboardInputState | MouseInputState | GamepadInputState; /** * Type guard to check if an input state is from a keyboard */ export declare function isKeyboardState(state: InputState): state is KeyboardInputState; /** * Type guard to check if an input state is from a mouse */ export declare function isMouseState(state: InputState): state is MouseInputState; /** * Type guard to check if an input state is from a gamepad */ export declare function isGamepadState(state: InputState): state is GamepadInputState; /** * Base interface for serialized device value readers */ export interface DeviceValueReaderDefinitionBase { /** The device type: 'keyboard', 'mouse', or 'gamepad' */ type: DeviceType; /** The input source category (e.g. 'key', 'button', 'axis', 'position', 'wheel') */ sourceType: string; /** The specific input identifier (e.g. 'KeyA', 'button-0', 'axis-1', 'absolute:x') */ sourceKey: string; } /** * Keyboard value reader definition */ export interface KeyboardValueReaderDefinition extends DeviceValueReaderDefinitionBase { type: 'keyboard'; sourceType: 'key'; sourceKey: string; options?: { useDelta?: boolean; }; } /** * Mouse value reader definition */ export interface MouseValueReaderDefinition extends DeviceValueReaderDefinitionBase { type: 'mouse'; sourceType: string; sourceKey: string; } /** * Gamepad value reader definition */ export interface GamepadValueReaderDefinition extends DeviceValueReaderDefinitionBase { type: 'gamepad'; sourceType: string; sourceKey: string; options?: { useAnalogValue?: boolean; deadzone?: number; invert?: boolean; }; } /** * Union type of all device value reader definitions */ export type DeviceValueReaderDefinition = KeyboardValueReaderDefinition | MouseValueReaderDefinition | GamepadValueReaderDefinition; /** * Interface for all device value readers * Unified interface for all types of input sources that can extract values from device states */ export interface DeviceValueReader { /** The input source category (e.g. 'key', 'button', 'axis', 'position', 'wheel') */ readonly sourceType: string; /** The specific input identifier (e.g. 'KeyA', 'button-0', 'axis-1', 'absolute:x') */ readonly sourceKey: string; /** * Gets the value from an input state, or undefined if this reader doesn't apply to the given state type. * * @param state */ getValue(state: InputState): boolean | number | undefined; /** * Convert the reader to a JSON-serializable object. */ toJSON(): DeviceValueReaderDefinition; }