/// <reference types="w3c-web-hid" />
/// <reference types="node" />
import type { HID } from "node-hid";
import { InputId } from "../id";
import { ByteArray } from "./byte_array";
export * from "../id";
/** Maps a HID input of 0...n to -1...1 */
export declare function mapAxis(value: number, max?: number): number;
/** Maps a HID input of 0...255 to 0...1 */
export declare function mapTrigger(value: number): number;
/**
 * Maps a HID input for either gyroscope or acceleration.
 * Adapted from https://github.com/nondebug/dualsense
 */
export declare function mapGyroAccel(v0: number, v1: number): number;
/** Describes an observation of the input state of a Dualsense controller */
export interface DualsenseHIDState {
    [InputId.LeftAnalogX]: number;
    [InputId.LeftAnalogY]: number;
    [InputId.RightAnalogX]: number;
    [InputId.RightAnalogY]: number;
    [InputId.LeftTrigger]: number;
    [InputId.RightTrigger]: number;
    [InputId.Triangle]: boolean;
    [InputId.Circle]: boolean;
    [InputId.Cross]: boolean;
    [InputId.Square]: boolean;
    [InputId.Dpad]: number;
    [InputId.Up]: boolean;
    [InputId.Down]: boolean;
    [InputId.Left]: boolean;
    [InputId.Right]: boolean;
    [InputId.RightAnalogButton]: boolean;
    [InputId.LeftAnalogButton]: boolean;
    [InputId.Options]: boolean;
    [InputId.Create]: boolean;
    [InputId.RightTriggerButton]: boolean;
    [InputId.LeftTriggerButton]: boolean;
    [InputId.RightBumper]: boolean;
    [InputId.LeftBumper]: boolean;
    [InputId.Playstation]: boolean;
    [InputId.TouchButton]: boolean;
    [InputId.Mute]: boolean;
    [InputId.Status]: boolean;
    [InputId.TouchX0]: number;
    [InputId.TouchY0]: number;
    [InputId.TouchContact0]: boolean;
    [InputId.TouchId0]: number;
    [InputId.TouchX1]: number;
    [InputId.TouchY1]: number;
    [InputId.TouchContact1]: boolean;
    [InputId.TouchId1]: number;
    [InputId.GyroX]: number;
    [InputId.GyroY]: number;
    [InputId.GyroZ]: number;
    [InputId.AccelX]: number;
    [InputId.AccelY]: number;
    [InputId.AccelZ]: number;
}
/** Default values for all inputs */
export declare const DefaultDualsenseHIDState: DualsenseHIDState;
/** Supports a connection to a physical or virtual Dualsense device */
export declare abstract class HIDProvider {
    /** HID vendorId for a Dualsense controller */
    static readonly vendorId: number;
    /** HID productId for a Dualsense controller */
    static readonly productId: number;
    /** HID usagePage for a Dualsense controller */
    static readonly usagePage: number;
    /** HID usage for a Dualsense controller */
    static readonly usage: number;
    /** Callback to use for new input events */
    onData: (state: DualsenseHIDState) => void;
    /** Callback to use for Error events */
    onError: (error: Error) => void;
    /** Search for a controller and connect to it */
    abstract connect(): void;
    /** Stop accepting input from the controller */
    abstract disconnect(): void;
    /** Returns true if a device is currently connected and working */
    abstract get connected(): boolean;
    /** The underlying HID device handle */
    abstract device?: HIDDevice | HID;
    /** Returns true if a device is connected wirelessly */
    abstract wireless?: boolean;
    /** Debug: The most recent HID report buffer */
    abstract buffer?: Buffer | DataView;
    /** Converts the HID report to a simpler format */
    abstract process(input: unknown): DualsenseHIDState;
    /** Write to the HID device */
    abstract write(data: Uint8Array): Promise<void>;
    /** If true, gyroscope, touchpad, accelerometer are disabled */
    limited?: boolean;
    /**
     * Sselects the correct method for reading the report.
     * @param buffer HID report buffer
     */
    protected processReport(buffer: ByteArray): DualsenseHIDState;
    /**
     * Reset the HIDProvider state when the device is disconnected
     */
    protected reset(): void;
    /**
     * Process a bluetooth input report of type 01.
     * @param buffer the report
     */
    protected processBluetoothInputReport01(buffer: ByteArray): DualsenseHIDState;
    /** Process bluetooth input report of type 31 */
    protected processBluetoothInputReport31(buffer: ByteArray): {
        LX: number;
        LY: number;
        RX: number;
        RY: number;
        L2: number;
        R2: number;
        Triangle: boolean;
        Circle: boolean;
        Cross: boolean;
        Square: boolean;
        Dpad: number;
        Up: boolean;
        Down: boolean;
        Left: boolean;
        Right: boolean;
        L2Button: boolean;
        R2Button: boolean;
        L1: boolean;
        R1: boolean;
        Create: boolean;
        Options: boolean;
        L3: boolean;
        R3: boolean;
        Playstation: boolean;
        TouchButton: boolean;
        Mute: boolean;
        GyroX: number;
        GyroY: number;
        GyroZ: number;
        AccelX: number;
        AccelY: number;
        AccelZ: number;
        TouchId0: number;
        TouchContact0: boolean;
        TouchX0: number;
        TouchY0: number;
        TouchId1: number;
        TouchContact1: boolean;
        TouchX1: number;
        TouchY1: number;
        Status: boolean;
    };
    /**
     * Process a USB input report of type 01.
     * @param buffer the report
     */
    protected processUsbInputReport01(buffer: ByteArray): DualsenseHIDState;
}
//# sourceMappingURL=hid_provider.d.ts.map