Difference between revisions of "Unit Keyboard"
(5 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
'''Keyboard Devices''' | '''Keyboard Devices''' | ||
− | This unit provides | + | This unit provides the Keyboard device interface and keyboard API to be used by both drivers and applications. |
− | The keyboard | + | The API includes functions to create, register, locate, read, write, control and configure each connected keyboard device. |
− | + | The API supports a global keyboard buffer so multiple devices can feed data into a common buffer as well as a buffer per device to allow each device to be used for a specific purpose. For example an application with two separate displays may choose to have a keyboard device to control each one individually. | |
− | + | ||
− | The | + | |
− | + | ||
− | + | ||
=== Constants === | === Constants === | ||
Line 88: | Line 84: | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
− | |||
− | |||
− | |||
|- | |- | ||
| <code>KEYBOARD_FLAG_NON_BLOCK = $00000001;</code> | | <code>KEYBOARD_FLAG_NON_BLOCK = $00000001;</code> | ||
− | | | + | | If set device reads are non blocking (Also supported in Flags parameter of KeyboardReadEx) |
|- | |- | ||
| <code>KEYBOARD_FLAG_DIRECT_READ = $00000002;</code> | | <code>KEYBOARD_FLAG_DIRECT_READ = $00000002;</code> | ||
− | | | + | | If set device writes keyboard data to its local buffer which must be read using KeyboardDeviceRead |
+ | |- | ||
+ | | <code>KEYBOARD_FLAG_PEEK_BUFFER = $00000004;</code> | ||
+ | | Peek at the buffer to see if any data is available, don't remove it (Used only in Flags parameter of KeyboardReadEx) | ||
|- | |- | ||
| <code>KEYBOARD_FLAG_PEEK_BUFFER = $00000004;</code> | | <code>KEYBOARD_FLAG_PEEK_BUFFER = $00000004;</code> | ||
Line 298: | Line 294: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | | | + | |colspan="2"|Note: The following constants are duplicated with the USBKeyboard unit for backwards compatibility |
− | | | + | |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
Line 640: | Line 632: | ||
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
|- | |- | ||
− | | <code>TKeyboardDeviceControl = function(Keyboard:PKeyboardDevice; Request:Integer; Argument1: | + | | <code>TKeyboardDeviceControl = function(Keyboard:PKeyboardDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</code> |
| style="width: 40%;"| | | style="width: 40%;"| | ||
|- | |- | ||
Line 852: | Line 844: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">procedure KeyboardInit;</pre> | <pre style="border: 0; padding-bottom:0px;">procedure KeyboardInit;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the keyboard unit | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the keyboard unit and device table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 1,042: | Line 1,034: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function KeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1: | + | <pre style="border: 0; padding-bottom:0px;">function KeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a control request on the specified keyboard device</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a control request on the specified keyboard device</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 1,289: | Line 1,281: | ||
! Note | ! Note | ||
| None documented | | None documented | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|} | |} | ||
Line 1,387: | Line 1,289: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function KeyboardGetCount:LongWord | + | <pre style="border: 0; padding-bottom:0px;">function KeyboardGetCount:LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current keyboard count</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current keyboard count</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 1,509: | Line 1,411: | ||
|- | |- | ||
! Signal | ! Signal | ||
− | | If True then signal that new data is | + | | If True then signal that new data is available in the buffer |
|- | |- | ||
! Return | ! Return | ||
Line 1,576: | Line 1,478: | ||
! Note | ! Note | ||
| None documented | | None documented | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|} | |} |
Latest revision as of 04:48, 10 October 2023
Return to Unit Reference
Contents
[hide]Description
Ultibo Keyboard Interface unit
Keyboard Devices
This unit provides the Keyboard device interface and keyboard API to be used by both drivers and applications.
The API includes functions to create, register, locate, read, write, control and configure each connected keyboard device.
The API supports a global keyboard buffer so multiple devices can feed data into a common buffer as well as a buffer per device to allow each device to be used for a specific purpose. For example an application with two separate displays may choose to have a keyboard device to control each one individually.
Constants
KEYBOARD_NAME_*
KEYBOARD_TYPE_*
KEYBOARD_STATE_*
KEYBOARD_FLAG_*
KEYBOARD_CONTROL_*
KEYBOARD_LED_*
KEYBOARD_BUFFER_*
KEYBOARD_REPEAT_*
KEYBOARD_*
KEYBOARD_LOG_*
USBKEYBOARD_*
USB_HID_SUBCLASS_*
USB_HID_BOOT_PROTOCOL_*
USB_HID_DESCRIPTOR_*
USB_HID_REQUEST_*
USB_HID_PROTOCOL_*
USB_HID_REPORT_*
USB_HID_REPORTID_*
USB_HID_BOOT_LEFT_*, USB_HID_BOOT_RIGHT_*
USB_HID_BOOT_REPORT_*
USB_HID_BOOT_*_LED
USB_HID_BOOT_OUTPUT_*
Type definitions
Keyboard data
Keyboard buffer
Keyboard enumeration callback
TKeyboardEnumerate = function(Keyboard:PKeyboardDevice; Data:Pointer):LongWord;
|
Keyboard notification callback
TKeyboardNotification = function(Device:PDevice;Data:Pointer;Notification:LongWord):LongWord;
|
Keyboard device get
TKeyboardDeviceGet = function(Keyboard:PKeyboardDevice; var KeyCode:Word):LongWord;
|
Keyboard device read
TKeyboardDeviceRead = function(Keyboard:PKeyboardDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
|
Keyboard device control
TKeyboardDeviceControl = function(Keyboard:PKeyboardDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
|
Keyboard device
USB HID descriptor
USB keyboard report
USB keyboard device
Public variables
Keyboard logging
KEYBOARD_DEFAULT_LOG_LEVEL:LongWord = KEYBOARD_LOG_LEVEL_DEBUG;
|
Minimum level for Keyboard messages. Only messages with level greater than or equal to this will be printed. |
KEYBOARD_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
Keyboard functions
function KeyboardGet(var KeyCode:Word):LongWord;
function KeyboardPeek:LongWord;
function KeyboardRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
function KeyboardReadEx(Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
function KeyboardPut(ScanCode,KeyCode:Word; Modifiers:LongWord):LongWord;
function KeyboardWrite(Buffer:Pointer; Size,Count:LongWord):LongWord;
function KeyboardFlush:LongWord;
function KeyboardDeviceGet(Keyboard:PKeyboardDevice; var KeyCode:Word):LongWord;
function KeyboardDeviceRead(Keyboard:PKeyboardDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
function KeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
function KeyboardDeviceSetState(Keyboard:PKeyboardDevice; State:LongWord):LongWord;
function KeyboardDeviceCreate:PKeyboardDevice;
function KeyboardDeviceCreateEx(Size:LongWord):PKeyboardDevice;
function KeyboardDeviceDestroy(Keyboard:PKeyboardDevice):LongWord;
function KeyboardDeviceRegister(Keyboard:PKeyboardDevice):LongWord;
function KeyboardDeviceDeregister(Keyboard:PKeyboardDevice):LongWord;
function KeyboardDeviceFind(KeyboardId:LongWord):PKeyboardDevice;
function KeyboardDeviceFindByName(const Name:String):PKeyboardDevice; inline;
function KeyboardDeviceFindByDescription(const Description:String):PKeyboardDevice; inline;
function KeyboardDeviceEnumerate(Callback:TKeyboardEnumerate; Data:Pointer):LongWord;
function KeyboardDeviceNotification(Keyboard:PKeyboardDevice; Callback:TKeyboardNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
RTL console functions
function SysConsoleGetKey(var ACh:Char; AUserData:Pointer):Boolean;
function SysConsolePeekKey(var ACh:Char; AUserData:Pointer):Boolean;
function SysConsoleReadChar(var ACh:Char; AUserData:Pointer):Boolean;
function SysConsoleReadWideChar(var ACh:WideChar; AUserData:Pointer):Boolean;
Keyboard helper functions
function KeyboardDeviceCheck(Keyboard:PKeyboardDevice):PKeyboardDevice;
function KeyboardDeviceTypeToString(KeyboardType:LongWord):String;
function KeyboardDeviceStateToString(KeyboardState:LongWord):String;
function KeyboardDeviceStateToNotification(State:LongWord):LongWord;
function KeyboardRemapCtrlCode(KeyCode,CharCode:Word):Word;
function KeyboardRemapKeyCode(ScanCode,KeyCode:Word; var CharCode:Byte; Modifiers:LongWord):Boolean;
function KeyboardRemapScanCode(ScanCode,KeyCode:Word; var CharCode:Byte; Modifiers:LongWord):Boolean;
function KeyboardInsertData(Keyboard:PKeyboardDevice; Data:PKeyboardData; Signal:Boolean):LongWord;
procedure KeyboardLog(Level:LongWord; Keyboard:PKeyboardDevice; const AText:String);
procedure KeyboardLogInfo(Keyboard:PKeyboardDevice; const AText:String); inline;
procedure KeyboardLogWarn(Keyboard:PKeyboardDevice; const AText:String); inline;
procedure KeyboardLogError(Keyboard:PKeyboardDevice; const AText:String); inline;
procedure KeyboardLogDebug(Keyboard:PKeyboardDevice; const AText:String); inline;
Return to Unit Reference