Unit Keyboard

From Ultibo.org
Revision as of 05:24, 2 September 2016 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


Description


Keyboard Devices

This unit provides both the Keyboard device interface and the generic USB HID keyboard driver. The keyboard unit also provides the STDIN interface for the Run Time Library (RTL).

USB Keyboard Devices

This driver currently uses HID Boot Protocol only and could be redesigned in future to use the HID Report Protocol instead to allow for greater language support etc.

Constants


To be documented

Type definitions


To be documented

Public variables


To be documented

Function declarations



Initialization functions

[Expand]
procedure KeyboardInit;
Description: Initialize the keyboard unit, device table and USB keyboard driver


Keyboard functions

[Expand]
function KeyboardGet(var KeyCode:Word):LongWord;
Description: Get the first key code from the global keyboard buffer


[Expand]
function KeyboardPeek:LongWord;
Description: Peek at the global keyboard buffer to see if any data packets are ready


[Expand]
function KeyboardRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
Description: Read keyboard data packets from the global keyboard buffer


[Expand]
function KeyboardReadEx(Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read keyboard data packets from the global keyboard buffer


[Expand]
function KeyboardPut(ScanCode,KeyCode:Word; Modifiers:LongWord):LongWord;
Description: Put a scan code and key code in the global keyboard buffer


[Expand]
function KeyboardWrite(Buffer:Pointer; Size,Count:LongWord):LongWord;
Description: Write keyboard data packets to the global keyboard buffer


[Expand]
function KeyboardFlush:LongWord;
Description: Flush the contents of the global keyboard buffer


[Expand]
function KeyboardDeviceGet(Keyboard:PKeyboardDevice; var KeyCode:Word):LongWord;
Description: Get the first key code from the buffer of the specified keyboard


[Expand]
function KeyboardDeviceRead(Keyboard:PKeyboardDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Read keyboard data packets from the buffer of the specified keyboard


[Expand]
function KeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: Perform a control request on the specified keyboard device


[Expand]
function KeyboardDeviceSetState(Keyboard:PKeyboardDevice; State:LongWord):LongWord;
Description: Set the state of the specified keyboard and send a notification


[Expand]
function KeyboardDeviceCreate:PKeyboardDevice;
Description: Create a new Keyboard device entry


[Expand]
function KeyboardDeviceCreateEx(Size:LongWord):PKeyboardDevice;
Description: Create a new Keyboard device entry


[Expand]
function KeyboardDeviceDestroy(Keyboard:PKeyboardDevice):LongWord;
Description: Destroy an existing Keyboard device entry


[Expand]
function KeyboardDeviceRegister(Keyboard:PKeyboardDevice):LongWord;
Description: Register a new Keyboard device in the Keyboard table


[Expand]
function KeyboardDeviceDeregister(Keyboard:PKeyboardDevice):LongWord;
Description: Deregister a Keyboard device from the Keyboard table


[Expand]
function KeyboardDeviceFind(KeyboardId:LongWord):PKeyboardDevice;
Description: Find a keyboard device by ID in the keyboard table


[Expand]
function KeyboardDeviceFindByName(const Name:String):PKeyboardDevice; inline;
Description: Find a keyboard device by name in the keyboard table


[Expand]
function KeyboardDeviceFindByDescription(const Description:String):PKeyboardDevice; inline;
Description: Find a keyboard device by description in the keyboard table


[Expand]
function KeyboardDeviceEnumerate(Callback:TKeyboardEnumerate; Data:Pointer):LongWord;
Description: Enumerate all keyboard devices in the keyboard table


[Expand]
function KeyboardDeviceNotification(Keyboard:PKeyboardDevice; Callback:TKeyboardNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for keyboard device changes


RTL console functions

[Expand]
function SysConsoleGetKey(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleGetKey function


[Expand]
function SysConsolePeekKey(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsolePeekKey function


[Expand]
function SysConsoleReadChar(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadChar function


[Expand]
function SysConsoleReadWideChar(var ACh:WideChar; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadWideChar function


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:LongWord; var Argument2:LongWord):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


Keyboard helper functions

[Expand]
function KeyboardGetCount:LongWord; inline;
Description: Get the current keyboard count


[Expand]
function KeyboardDeviceCheck(Keyboard:PKeyboardDevice):PKeyboardDevice;
Description: Check if the supplied Keyboard is in the keyboard table


[Expand]
function KeyboardDeviceTypeToString(KeyboardType:LongWord):String;
Description: To be documented


[Expand]
function KeyboardDeviceStateToString(KeyboardState:LongWord):String;
Description: To be documented


[Expand]
function KeyboardDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Keyboard state value into the notification code for device notifications


[Expand]
function KeyboardRemapCtrlCode(KeyCode,CharCode:Word):Word;
Description: Remap Ctrl-<Key> combinations to ASCII control codes


[Expand]
function KeyboardRemapKeyCode(ScanCode,KeyCode:Word; var CharCode:Byte; Modifiers:LongWord):Boolean;
Description: Remap the SCAN_CODE_* and KEY_CODE_* values to DOS compatible scan codes


[Expand]
function KeyboardRemapScanCode(ScanCode,KeyCode:Word; var CharCode:Byte; Modifiers:LongWord):Boolean;
Description: Remap the SCAN_CODE_* and KEY_CODE_* values to DOS compatible scan codes


[Expand]
procedure KeyboardLog(Level:LongWord; Keyboard:PKeyboardDevice; const AText:String);
Description: To be documented


[Expand]
procedure KeyboardLogInfo(Keyboard:PKeyboardDevice; const AText:String);
Description: To be documented


[Expand]
procedure KeyboardLogError(Keyboard:PKeyboardDevice; const AText:String);
Description: To be documented


[Expand]
procedure KeyboardLogDebug(Keyboard:PKeyboardDevice; const AText:String);
Description: To be documented


USB keyboard helper functions

[Expand]
function USBKeyboardInsertData(Keyboard:PUSBKeyboardDevice; Data:PKeyboardData):LongWord;
Description: Insert a TKeyboardData entry into the keyboard buffer (Direct or Global)


[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


Return to Unit Reference