LitDev Extension API
LDHID
USB control for HID (Human Interface Devices).
The VID and PID (4 character hex codes) for the device are required.
Only HIDs will work using these methods.
Hopefully this includes most game controllers, simple robotic devices and sensors.
AddDevice | FindDevices | GetBits |
Input | InputLength | LastDevice |
LastInput | Output | OutputLength |
Removed | SetBits |
AddDevice(VID,PID,name)
Add a HID connected device from its VID and PID.
The VID and PID are 4 character (hex) values, and can be found from:
Device Manager->Properties->Details->Hardware ids
For example: HID\VID_046D PID_C215 REV_0204 has VID "046D" and PID "C215".
Only add a device once.
VID The device VID.
PID The device PID.
name A name for the device.
returns "True" or "False" for success or failure
FindDevices()
List all found HID (Human Interface Devices).
returns A 2D array of all found devices.
The first dimension is the found device indexed from 1.
The second dimension is "VID", "PID" and "Description" holding the hex values of VID, PID and a device description.
GetBits(data)
Get an 8 element array of 1s and 0s indicating which bit of a byte are set.
data A byte number (0 to 255).
returns An 8 element bit array (small bit first) or "" on failure.
Input
Event when the HID input changes.
InputLength(name)
Get the input record length for a HID device.
name The device name.
returns The number of bytes in the input record.
LastDevice
The last HID device that had input.
returns The last device name.
LastInput
An array of the last HID input data.
This a set of values from 0 to 255 (bytes).
returns An array of input data or "" for none.
Output(name,data)
Send data to the HID device.
This must be an array of bytes (0 to 255).
The array must be indexed from 1 and have size OutputLength.
name The HID device name.
data The data to send.
returns "True" or "False" for data consistency.
OutputLength(name)
Get the output record length for a HID device.
name The HID device name.
returns The number of bytes in the output record.
Removed
Event when the HID device is removed.
SetBits(data)
Set a byte from an 8 element array of 1s and 0s indicating which bit of a byte are set.
data An 8 element array of 1s and 0s (small bit first).
returns A byte number (0 to 255) or -1 on failure.