Unit USBHID

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo USB Human Interface Device (HID) Driver unit

The USB Human Interface Device (HID) class is one of the most widely used classes of USB devices. HID devices can appear as keyboard, mice, touch devices, gamepads, joysticks and many more.

Importantly HID devices can appear as controls within other devices, for example a USB headset can describe the volume and mute buttons as a HID device and a generic driver can recognize it without the need for a custom driver.

Unlike other USB devices where either an entire device or an interface on a device is used to provide a specific function, the HID standard allows multiple devices to coexist on the same interface. So a mouse and keyboard could be defined on a single USB interface and the HID implementation is able to route the reports they generate to the correct consumer.

Some HID devices (such as proprietary game devices) may require more specific handling than can be provided by the generic device infrastructure included in this unit.

In those cases a standard USB driver can be developed which claims the entire device by vendor and product (as USB offers the complete device to all drivers first). The driver can then configure the device as required and is able to use some of the services of both this unit and the HID unit to parse and examine the HID report descriptors.

Alternatively a HID consumer can be developed that claims the HID device during the optional HID DeviceBind callback which prevents other consumers from binding to the HID collections it contains. The consumer can then use some or all of the services of this unit and the HID unit to handle the HID report descriptors when dealing with reports received from the device.

Constants



[Expand]
USB HID specific constants USB_HID_*


Type definitions



USB HID request

[Expand]

PUSBHIDRequest = ^TUSBHIDRequest;

TUSBHIDRequest = record

USB HID requests

[Expand]

PUSBHIDRequests = ^TUSBHIDRequests;

TUSBHIDRequests = array[0..0] of PUSBHIDRequest;

USB HID device

[Expand]

PUSBHIDDevice = ^TUSBHIDDevice;

TUSBHIDDevice = record


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure USBHIDInit;
Description: Initialize the USB HID unit and USB HID driver


USB HID helper functions

[Expand]
function USBHIDCheckDevice(Device:PUSBDevice):Boolean;
Description: Check if the supplied USB device is suitable for detection as a USB HID Device


[Expand]
function USBHIDCheckInterface(Device:PUSBDevice; Interrface:PUSBInterface):Boolean;
Description: Check if the supplied USB device and interface are a USB HID Device


[Expand]
function USBHIDGetHIDDescriptor(Device:PUSBDevice; Interrface:PUSBInterface; Descriptor:PHIDDescriptor):LongWord;
Description: Get the HID Descriptor for a USB device and interface


[Expand]
function USBHIDStatusToErrorCode(Status:LongWord):LongWord;
Description: Convert a USB_STATUS_* code to an ERROR_* code


[Expand]
function USBHIDErrorCodeToUSBStatus(Error:LongWord):LongWord;
Description: Convert an ERROR_* code to a USB_STATUS_* code


Return to Unit Reference