UNPKG

ive-connect

Version:

A universal haptic device control library for interactive experiences

89 lines (88 loc) 2.33 kB
/** * Buttplug Device Implementation * * Implements the HapticDevice interface for Buttplug devices */ import { DeviceCapability, DeviceInfo, HapticDevice, ScriptData, ScriptOptions } from "../../core/device-interface"; import { EventEmitter } from "../../core/events"; import { ButtplugSettings } from "./types"; /** * Buttplug device implementation */ export declare class ButtplugDevice extends EventEmitter implements HapticDevice { private _api; private _config; private _connectionState; private _isPlaying; private _loadedScript; private _currentScriptActions; private _lastActionIndex; private _playbackInterval; private _playbackStartTime; private _playbackRate; private _loopPlayback; readonly id: string; readonly name: string; readonly type: string; readonly capabilities: DeviceCapability[]; constructor(config?: Partial<ButtplugSettings>); /** * Get connected state */ get isConnected(): boolean; /** * Get playing state */ get isPlaying(): boolean; /** * Connect to Buttplug server */ connect(config?: Partial<ButtplugSettings>): Promise<boolean>; /** * Disconnect from the server */ disconnect(): Promise<boolean>; /** * Get current configuration */ getConfig(): ButtplugSettings; /** * Update configuration */ updateConfig(config: Partial<ButtplugSettings>): Promise<boolean>; /** * Load a script for playback */ loadScript(scriptData: ScriptData, options?: ScriptOptions): Promise<{ success: boolean; scriptContent?: any; }>; /** * Play the loaded script */ play(timeMs: number, playbackRate?: number, loop?: boolean): Promise<boolean>; /** * Stop playback */ stop(): Promise<boolean>; /** * Sync playback time */ syncTime(timeMs: number): Promise<boolean>; /** * Get device information */ getDeviceInfo(): DeviceInfo | null; /** * Process script actions based on current time */ private _processActions; /** * Find the action index for the given time */ private _findActionIndexForTime; /** * Set up event handlers for the Buttplug API */ private _setupApiEventHandlers; }