import type { AttachInputOptions, GamepadAxisKind, GamepadButtonKind, GamepadMappingKind, InputKeyRepeatOptions, InputKeyRepeatTimer, InputManager, InputPointerData, InputSignals, InputState, MouseWheelMode } from '@flighthq/types/contract'; /** * Filters a single gamepad axis value through a simple dead zone. * Values within `[-deadZone, deadZone]` are mapped to `0`; values outside * are rescaled linearly to `[-1, 1]` so the live range is continuous. * `deadZone` must be in `[0, 1)`. */ export declare function applyGamepadAxisDeadZone(value: number, deadZone: number): number; /** * Filters a 2-D stick (left or right) through a **radial** dead zone. * The magnitude of `(x, y)` is compared against `deadZone`; if within the * dead zone the output is `(0, 0)`, otherwise the input direction is * preserved and the magnitude is rescaled linearly to `[0, 1]`. * * Writes the filtered X and Y into `out.x` and `out.y`. * Safe when `out` is the same object as the input (alias-safe). * * `deadZone` must be in `[0, 1)`. */ export declare function applyGamepadStickDeadZone(out: { x: number; y: number; }, x: number, y: number, deadZone: number): void; export declare function attachGamepadInput(manager: InputManager, target: Window, options?: Readonly): void; export declare function attachKeyboardInput(manager: InputManager, target: EventTarget, options?: Readonly): void; export declare function attachPointerInput(manager: InputManager, element: HTMLElement, options?: Readonly): void; export declare function attachRelativePointerInput(manager: InputManager, element: HTMLElement, options?: Readonly): void; export declare function attachTextInput(manager: InputManager, element: HTMLElement, options?: Readonly): void; export declare function attachWheelInput(manager: InputManager, element: HTMLElement, options?: Readonly): void; /** * Subscribes `state` to all signals on `manager` to maintain a live held-state snapshot. * Also tracks per-frame edge sets (`justPressedKeys`, `justReleasedKeys`, * `justPressedGamepadButtons`, `justReleasedGamepadButtons`) that accumulate * until `endInputStateFrame` is called. * Returns a disposer that disconnects the subscriptions. */ export declare function connectInputStateToInputManager(state: InputState, manager: InputManager): () => void; /** * Creates a key-repeat timer for non-DOM sources (gamepad d-pad buttons, * virtual on-screen keys, native backends) that do not generate their own * auto-repeat events. * * Call `start(callback)` when a "key" is pressed. The `callback` is invoked * immediately on press, then again after `options.delay` ms, then every * `options.interval` ms until `stop()` is called. * * Returns a handle with `start(callback)` and `stop()` methods. * The handle may be reused across multiple press/release cycles. * * ```ts * const timer = createInputKeyRepeatTimer({ delay: 500, interval: 33 }); * // on press: * timer.start(() => emitSignal(manager.onKeyDown, dpadData)); * // on release: * timer.stop(); * ``` */ export declare function createInputKeyRepeatTimer(options: Readonly): InputKeyRepeatTimer; export declare function createInputManager(): InputManager; export declare function createInputSignals(): InputSignals; /** * Creates a fresh `InputState` with empty held-state maps/sets and empty * frame-edge sets. Connect it to an `InputManager` via * `connectInputStateToInputManager`, and call `endInputStateFrame` once per * logical frame to roll the edge sets. */ export declare function createInputState(): InputState; export declare function detachGamepadInput(manager: InputManager, target: Window): void; export declare function detachKeyboardInput(manager: InputManager, target: EventTarget): void; export declare function detachPointerInput(manager: InputManager, element: HTMLElement): void; export declare function detachRelativePointerInput(manager: InputManager, element: HTMLElement): void; export declare function detachTextInput(manager: InputManager, element: HTMLElement): void; export declare function detachWheelInput(manager: InputManager, element: HTMLElement): void; /** * Rolls the per-frame edge sets on `state`, clearing `justPressedKeys`, * `justReleasedKeys`, `justPressedGamepadButtons`, and * `justReleasedGamepadButtons`. Call this once at the end of each logical * frame (or input-poll cycle) to prepare the edge sets for the next frame. */ export declare function endInputStateFrame(state: InputState): void; /** * Exits pointer lock, returning the pointer to normal movement. * No-op if pointer lock is not currently active. */ export declare function exitInputPointerLock(): void; /** * Returns coalesced pointer event data for a `pointermove` event, iterating * over the high-frequency intermediate positions captured since the last * delivered event. Falls back to a single entry with the event itself when * `getCoalescedEvents` is unavailable (e.g. in jsdom). * * The callback receives each coalesced `InputPointerData` in order. The * payload object is reused across calls — do not retain a reference to it. */ export declare function getCoalescedInputPointerEvents(event: PointerEvent, callback: (data: Readonly) => void): void; /** * Returns the semantic name string (a `GamepadAxisKind`) for `index` in the * standard gamepad mapping, or `null` if `mapping` is not `'standard'` or * `index` is out of the standard range. */ export declare function getGamepadAxisName(mapping: GamepadMappingKind, index: number): GamepadAxisKind | null; /** * Returns the semantic name string (a `GamepadButtonKind`) for `index` in the * standard gamepad mapping, or `null` if `mapping` is not `'standard'` or * `index` is out of the standard range. */ export declare function getGamepadButtonName(mapping: GamepadMappingKind, index: number): GamepadButtonKind | null; /** * Returns the current value of a gamepad axis from `state`, or `0` if not recorded. * `gamepad` is the gamepad index; `axis` is the axis index. */ export declare function getInputGamepadAxis(state: Readonly, gamepad: number, axis: number): number; export declare function getKeyCodeFromDomKeyboardEvent(event: Readonly): number; export declare function getKeyModifierFromDomKeyboardEvent(event: Readonly): number; export declare function getMouseWheelModeFromDomWheelEvent(event: Readonly): MouseWheelMode; /** * Returns `true` if pointer lock is currently active on any element. */ export declare function hasInputPointerLock(): boolean; /** * Returns `true` if the given gamepad button is currently held. * `gamepad` is the gamepad index; `button` is the button index. */ export declare function isInputGamepadButtonDown(state: Readonly, gamepad: number, button: number): boolean; /** * Returns `true` if the given `keyCode` (from `KeyCode`) is currently held. */ export declare function isInputKeyDown(state: Readonly, keyCode: number): boolean; /** * Returns `true` if the given pointer button is currently held for the given `pointerId`. * `button` corresponds to `MouseEvent.button` (0 = primary, 1 = middle, 2 = secondary, …). */ export declare function isInputPointerButtonDown(state: Readonly, pointerId: number, button: number): boolean; export declare function pollGamepadInput(manager: InputManager): void; /** * Releases pointer capture for `pointerId` from `element`, allowing pointer * events to fire on the element under the pointer again. * No-op if `element` does not have capture for this pointer. */ export declare function releaseInputPointerCapture(element: HTMLElement, pointerId: number): void; /** * Requests pointer lock on `element`. Returns a `Promise` that * resolves to `true` when lock is granted or `false` if the request is * rejected (e.g. outside a user gesture, or the browser denies it). */ export declare function requestInputPointerLock(element: HTMLElement): Promise; /** * Explicitly captures all pointer events for `pointerId` to `element`, * regardless of where the pointer moves. Useful for drag operations. * Automatically released on `pointerup` or `pointercancel` per the spec. */ export declare function setInputPointerCapture(element: HTMLElement, pointerId: number): void; /** * Returns `true` if the gamepad button at `gamepad`/`button` was pressed * this frame (i.e. transitioned from up → down since the last * `endInputStateFrame` call). */ export declare function wasInputGamepadButtonPressed(state: Readonly, gamepad: number, button: number): boolean; /** * Returns `true` if the gamepad button at `gamepad`/`button` was released * this frame (i.e. transitioned from down → up since the last * `endInputStateFrame` call). */ export declare function wasInputGamepadButtonReleased(state: Readonly, gamepad: number, button: number): boolean; /** * Returns `true` if the key with `keyCode` was pressed this frame (i.e. * transitioned from up → down since the last `endInputStateFrame` call). */ export declare function wasInputKeyPressed(state: Readonly, keyCode: number): boolean; /** * Returns `true` if the key with `keyCode` was released this frame (i.e. * transitioned from down → up since the last `endInputStateFrame` call). */ export declare function wasInputKeyReleased(state: Readonly, keyCode: number): boolean; //# sourceMappingURL=inputManager.d.ts.map