Skip to main content

Class: Device

Reads and subscribes to device input values.

Constructors

Constructor

new Device(): Device;

Returns

Device

Methods

GetValue()

static GetValue(devicePath): Promise<undefined | number | vec2>;

Gets the current value of a device path.

Parameters

ParameterTypeDescription
devicePathstringThe device path to read.

Returns

Promise<undefined | number | vec2>

A promise that resolves to the current input value, or undefined if no value is available.


SubscribeValueChange()

static SubscribeValueChange(devicePath, callback): Promise<number>;

Subscribes to value changes for a device path.

Parameters

ParameterTypeDescription
devicePathstringThe device path to observe.
callback(value) => voidThe callback that receives updated input values.

Returns

Promise<number>

A promise that resolves to the DeviceSubscription handle.


UnsubscribeValueChange()

static UnsubscribeValueChange(handle): Promise<boolean>;

Unsubscribes from a device value change subscription.

Parameters

ParameterTypeDescription
handlenumberThe DeviceSubscription handle to remove.

Returns

Promise<boolean>

A promise that resolves to true if the subscription was removed, or false otherwise.