UNPKG

@rbuljan/gamepad

Version:

Multi-touch gamepad with buttons and joystick for JavaScript games, apps, IOT

42 lines (41 loc) 1.21 kB
import { ControllerOptions } from "./ControllerOptions"; import { ControllerState } from "./ControllerState"; export interface Position { top?: string; left?: string; right?: string; bottom?: string; } export type ControllerType = "joystick" | "button"; export type ControllerAxisType = "all" | "x" | "y"; export declare class Controller { private type; /** * parentElement -> anchorElement -> gamepadControllerElement */ parentElement: HTMLElement; anchorElement: HTMLElement; gamepadControllerElement: HTMLElement; isJoystick: boolean; /** contains oll the initial options */ options: ControllerOptions; /** * the current and changing state of the controller */ protected state: ControllerState; constructor(options: ControllerOptions, type: ControllerType); onInput(): void; onStart(): void; onMove(): void; onEnd(): void; _noDefault(evt: MouseEvent): void; getPointerXY(evt: PointerEvent): { x: number; y: number; }; handleStart(evt: PointerEvent): void; handleMove(evt: PointerEvent): void; handleEnd(evt: PointerEvent): void; init(): void; destroy(): void; }