ive-connect
Version:
A universal haptic device control library for interactive experiences
106 lines (105 loc) • 2.83 kB
TypeScript
import { EventEmitter } from "../../core/events";
import { ButtplugConnectionState, ButtplugConnectionType, ButtplugDeviceInfo, DevicePreference } from "./types";
export declare class ButtplugApi extends EventEmitter {
private client;
private devices;
private devicePreferences;
isScanning: boolean;
private connectionState;
private connectedUrl?;
private clientName;
constructor(clientName?: string);
/**
* Get the current connection state
*/
getConnectionState(): ButtplugConnectionState;
/**
* Get the current connected server URL if any
*/
getConnectedUrl(): string | undefined;
/**
* Get the list of connected devices
*/
getDevices(): ButtplugDeviceInfo[];
/**
* Get the scanning state
*/
getIsScanning(): boolean;
/**
* Set a device preference
*/
setDevicePreference(deviceIndex: number, preference: DevicePreference): void;
/**
* Get device preferences
*/
getDevicePreferences(): Map<number, DevicePreference>;
/**
* Connect to a Buttplug server
*/
connect(type: ButtplugConnectionType, serverUrl?: string): Promise<boolean>;
/**
* Disconnect from the server
*/
disconnect(): Promise<boolean>;
/**
* Start scanning for devices
*/
startScanning(): Promise<boolean>;
/**
* Stop scanning for devices
*/
stopScanning(): Promise<boolean>;
/**
* Send a vibrate command to a device
*/
vibrateDevice(index: number, speed: number): Promise<boolean>;
/**
* Send a linear command to a device
*/
linearDevice(index: number, position: number, duration: number): Promise<boolean>;
/**
* Send a rotate command to a device
*/
rotateDevice(index: number, speed: number, clockwise: boolean): Promise<boolean>;
oscillateDevice(index: number, speed: number, frequency: number): Promise<boolean>;
/**
* Stop a specific device
*/
stopDevice(index: number): Promise<boolean>;
/**
* Stop all devices
*/
stopAllDevices(): Promise<boolean>;
/**
* Set up listeners for client events
*/
private setupClientListeners;
/**
* Clean up resources when disconnecting
*/
private cleanup;
/**
* Handle a device added event
*/
private handleDeviceAdded;
/**
* Handle a device removed event
*/
private handleDeviceRemoved;
/**
* Handle scanning finished event
*/
private handleScanningFinished;
/**
* Handle disconnection event
*/
private handleDisconnected;
/**
* Get a device from the client by index
*/
private getClientDevice;
/**
* Handle a device command error
*/
private handleDeviceCommandError;
}