UNPKG

dualsense-ts

Version:

The natural interface for your DualSense Classic and DualSense Access controllers, with Typescript

72 lines 3.6 kB
import type { HID } from "node-hid"; import { ByteArray } from "../byte_array"; import { AccessInputId, AccessHIDState, DefaultAccessHIDState } from "./access_hid_state"; export { AccessInputId, type AccessHIDState, DefaultAccessHIDState }; /** Supports a connection to a physical or virtual DualSense Access device */ export declare abstract class AccessHIDProvider { /** HID vendorId for a DualSense Access controller */ static readonly vendorId: number; /** HID productId for a DualSense Access controller */ static readonly productId: number; /** HID usagePage for a DualSense Access controller */ static readonly usagePage: number; /** HID usage for a DualSense Access controller */ static readonly usage: number; /** Global set of device paths currently claimed by a provider instance */ static readonly claimedDevices: Set<string>; /** Callback to use for new input events */ onData: (state: AccessHIDState) => void; /** Callback to use for Error events */ onError: (error: Error) => void; /** Callback fired the moment a device is fully attached and ready for I/O */ onConnect: () => void; /** Callback fired the moment a device detaches (cleanly or via error) */ onDisconnect: () => void; /** Unique identifier for the connected device (path or serial) */ deviceId?: string; /** Hardware serial number of the connected device */ serialNumber?: string; /** * Returns a callback for triggering a device permission request (browser only). * In Node.js providers this is undefined. */ getRequest?(): () => Promise<unknown>; /** Search for a controller and connect to it */ abstract connect(): void | Promise<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): AccessHIDState; /** Write to the HID device */ abstract write(data: Uint8Array): Promise<void>; /** Read a feature report from the device */ abstract readFeatureReport(reportId: number, length?: number): Promise<Uint8Array>; /** Send a feature report to the device */ abstract sendFeatureReport(reportId: number, data: Uint8Array): Promise<void>; /** * Selects the correct method for reading the report. */ protected processReport(buffer: ByteArray): AccessHIDState; /** Reset the provider state when the device is disconnected */ protected reset(): void; /** * Process a BT input report 0x01 (limited mode, pre-Feature 0x05). * Only has the mapped DualSense-compatible header, no Access-specific data. */ protected processBluetoothInputReport01(_buffer: ByteArray): AccessHIDState; /** Process BT input report 0x31 (full mode, offset +1 from USB) */ protected processBluetoothInputReport31(buffer: ByteArray): AccessHIDState; /** Process USB input report 0x01 (full Access report) */ protected processUsbInputReport01(buffer: ByteArray): AccessHIDState; /** Parse Access-specific fields from the report buffer at the given offset */ private parseAccessReport; } //# sourceMappingURL=access_hid_provider.d.ts.map