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
| Parameter | Type | Description |
|---|---|---|
devicePath | string | The 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
| Parameter | Type | Description |
|---|---|---|
devicePath | string | The device path to observe. |
callback | (value) => void | The 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
| Parameter | Type | Description |
|---|---|---|
handle | number | The DeviceSubscription handle to remove. |
Returns
Promise<boolean>
A promise that resolves to true if the subscription was removed,
or false otherwise.