Unit USBKEYBOARD

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo USB Keyboard Driver unit

USB Keyboard Devices

The USB keyboard driver in this unit uses HID Boot Protocol only and has been replaced by the HIDKeyboard unit which provides complete HID Report Protocol support for USB keyboards. It is retained here for legacy uses and backwards compatibility only.

To use this driver in place of the default HID Keyboard driver set the following configuration variables in your application during system initialization.

HID_REGISTER_KEYBOARD := False;
USB_KEYBOARD_REGISTER_DRIVER := True;

This driver does not recognize devices that do not report themselves as boot keyboards.

Constants



[Expand]
USB keyboard specific constants NAME_*


[Expand]
USB HID interface subclass USB_HID_SUBCLASS_*


[Expand]
USB HID interface protocol USB_HID_BOOT_PROTOCOL_*


[Expand]
USB HID class descriptor USB_HID_DESCRIPTOR_*


[Expand]
USB HID request USB_HID_REQUEST_*


[Expand]
USB HID protocol USB_HID_PROTOCOL_*


[Expand]
USB HID report USB_HID_REPORT_*


[Expand]
USB HID report Ids USB_HID_REPORTID_*


[Expand]
USB HID boot protocol USB_HID_BOOT_LEFT_*, USB_HID_BOOT_RIGHT_*


[Expand]
USB HID boot protocol report data USB_HID_BOOT_REPORT_*


[Expand]
USB HID boot protocol output USB_HID_BOOT_*_LED


[Expand]
USB HID boot protocol output data USB_HID_BOOT_OUTPUT_*


Type definitions



USB HID descriptor

[Expand]

PUSBHIDDescriptor = ^TUSBHIDDescriptor;

TUSBHIDDescriptor = packed record

USB boot keyboard report

[Expand]

PUSBKeyboardReport = ^TUSBKeyboardReport;

TUSBKeyboardReport = array[0..7] of Byte;

USB keyboard device

[Expand]

PUSBKeyboardDevice = ^TUSBKeyboardDevice;

TUSBKeyboardDevice = record


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure USBKeyboardInit;
Description: Initialize the USB keyboard driver


USB keyboard functions

[Expand]
function USBKeyboardDeviceRead(Keyboard:PKeyboardDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Implementation of KeyboardDeviceRead API for USB Keyboard


[Expand]
function USBKeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: Implementation of KeyboardDeviceControl API for USB Keyboard


[Expand]
function USBKeyboardDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Bind the Keyboard driver to a USB device if it is suitable


[Expand]
function USBKeyboardDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Unbind the Keyboard driver from a USB device


[Expand]
procedure USBKeyboardReportWorker(Request:PUSBRequest);
Description: Called (by a Worker thread) to process a completed USB request from a USB keyboard IN interrupt endpoint


[Expand]
procedure USBKeyboardReportComplete(Request:PUSBRequest);
Description: Called when a USB request from a USB keyboard IN interrupt endpoint completes


USB helper functions

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


[Expand]
function USBKeyboardCheckPressed(Keyboard:PUSBKeyboardDevice; ScanCode:Byte):Boolean;
Description: Check if the passed scan code has been pressed (True if not pressed in last report)


[Expand]
function USBKeyboardCheckRepeated(Keyboard:PUSBKeyboardDevice; ScanCode:Byte):Boolean;
Description: Check if the passed scan code was the last key pressed and if the repeat delay has expired


[Expand]
function USBKeyboardCheckReleased(Keyboard:PUSBKeyboardDevice; Report:PUSBKeyboardReport; ScanCode:Byte):Boolean;
Description: Check if the passed scan code has been released (True if not pressed in current report)


[Expand]
function USBKeyboardDeviceSetLEDs(Keyboard:PUSBKeyboardDevice; LEDs:Byte):LongWord;
Description: Set the state of the LEDs for a USB keyboard device


[Expand]
function USBKeyboardDeviceSetIdle(Keyboard:PUSBKeyboardDevice; Duration,ReportId:Byte):LongWord;
Description: Set the idle duration (Time between reports when no changes) for a USB keyboard device


[Expand]
function USBKeyboardDeviceSetProtocol(Keyboard:PUSBKeyboardDevice; Protocol:Byte):LongWord;
Description: Set the report protocol for a USB keyboard device


[Expand]
function USBKeyboardDeviceGetHIDDescriptor(Keyboard:PUSBKeyboardDevice; Descriptor:PUSBHIDDescriptor):LongWord;
Description: Get the HID Descriptor for a USB keyboard device


[Expand]
function USBKeyboardDeviceGetReportDescriptor(Keyboard:PUSBKeyboardDevice; Descriptor:Pointer; Size:LongWord):LongWord;
Description: Get the Report Descriptor for a USB keyboard device


Return to Unit Reference