use-control
Version:
A powerful set of hooks for elegantly handling keyboard, mouse and gamepad input (soon)
20 lines (19 loc) • 800 B
TypeScript
import { Subject } from 'rxjs';
export declare const presses$: Subject<GamepadAction>;
export declare const held$: Subject<GamepadAction>;
export declare const releases$: Subject<GamepadAction>;
export declare const axes$: Subject<GamepadAxisReading>;
declare type GamepadAction = {
controllerIndex: number;
buttonIndex: number;
};
declare type GamepadAxisReading = {
controllerIndex: number;
axisIndex: number;
value: number;
};
export declare function init(pollIntervalMs?: number): void;
export declare function teardown(): void;
export declare function useGamepadButtonPressed(controllerIndex: number, buttonIndex: number, sink: () => void): void;
export declare function useGamepadAxis(controllerIndex: number, axisIndex: number, sink: (v: number) => void): void;
export {};