Difference between revisions of "Unit Keyboard"
(13 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Ultibo Keyboard | + | '''Ultibo Keyboard Interface unit''' |
'''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 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 === | === Constants === | ||
Line 84: | 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 294: | 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 636: | 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 716: | Line 712: | ||
| <code>Next:PKeyboardDevice;</code> | | <code>Next:PKeyboardDevice;</code> | ||
| Next entry in Keyboard table | | Next entry in Keyboard table | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''USB HID descriptor''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PUSBHIDDescriptor = ^TUSBHIDDescriptor;</code> | ||
+ | |||
+ | <code>TUSBHIDDescriptor = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>bLength:Byte;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>bDescriptorType:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bcdHID:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bCountryCode:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bNumDescriptors:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>bHIDDescriptorType:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>wHIDDescriptorLength:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''Note: Up to two optional bHIDDescriptorType/wHIDDescriptorLength pairs after the Report descriptor details'' | ||
|- | |- | ||
|} | |} | ||
Line 759: | Line 790: | ||
| <code>ReportEndpoint:PUSBEndpointDescriptor;</code> | | <code>ReportEndpoint:PUSBEndpointDescriptor;</code> | ||
| USB Keyboard Interrupt IN Endpoint | | USB Keyboard Interrupt IN Endpoint | ||
+ | |- | ||
+ | | <code>HIDDescriptor:PUSBHIDDescriptor;</code> | ||
+ | | USB HID Descriptor for keyboard | ||
+ | |- | ||
+ | | <code>ReportDescriptor:Pointer;</code> | ||
+ | | USB HID Report Descriptor for keyboard | ||
|- | |- | ||
| <code>LastCode:Word;</code> | | <code>LastCode:Word;</code> | ||
Line 807: | 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;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Called only during system startup | | Called only during system startup | ||
|- | |- | ||
Line 826: | Line 863: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! KeyCode |
| The returned key code read from the buffer (eg KEY_CODE_A) | | The returned key code read from the buffer (eg KEY_CODE_A) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Key code is the value translated from the scan code using the current keymap it may not be a character code and it may include non printable characters | + | | Key code is the value translated from the scan code using the current keymap it may not be a character code and it may include non printable characters |
+ | To translate a key code to a character call KeymapGetCharCode() | ||
|- | |- | ||
|} | |} | ||
Line 844: | Line 882: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
− | | ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure | + | | ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure. |
|- | |- | ||
|} | |} | ||
Line 856: | Line 894: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to copy the keyboard data packets to | | Pointer to a buffer to copy the keyboard data packets to | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer in bytes (Must be at least TKeyboardData or greater) | | The size of the buffer in bytes (Must be at least TKeyboardData or greater) | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of keyboard data packets copied to the buffer | | The number of keyboard data packets copied to the buffer | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 877: | Line 915: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to copy the keyboard data packets to | | Pointer to a buffer to copy the keyboard data packets to | ||
|- | |- | ||
− | ! | + | ! Size |
| TThe size of the buffer in bytes (Must be at least TKeyboardData or greater) | | TThe size of the buffer in bytes (Must be at least TKeyboardData or greater) | ||
|- | |- | ||
− | ! | + | ! Flags |
| The flags to use for the read (eg KEYBOARD_FLAG_NON_BLOCK) | | The flags to use for the read (eg KEYBOARD_FLAG_NON_BLOCK) | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of keyboard data packets copied to the buffer | | The number of keyboard data packets copied to the buffer | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 901: | Line 939: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! ScanCode |
| The scan code to write to the buffer (eg SCAN_CODE_A) | | The scan code to write to the buffer (eg SCAN_CODE_A) | ||
|- | |- | ||
− | ! | + | ! KeyCode |
| The key code to write to the buffer (eg KEY_CODE_A) | | The key code to write to the buffer (eg KEY_CODE_A) | ||
|- | |- | ||
− | ! | + | ! Modifiers |
| The modifier keys to write to the buffer (eg KEYBOARD_LEFT_CTRL) | | The modifier keys to write to the buffer (eg KEYBOARD_LEFT_CTRL) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 922: | Line 960: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to copy the keyboard data packets from | | Pointer to a buffer to copy the keyboard data packets from | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer in bytes (Must be at least TKeyboardData or greater) | | The size of the buffer in bytes (Must be at least TKeyboardData or greater) | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of keyboard data packets to copy from the buffer | | The number of keyboard data packets to copy from the buffer | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 943: | Line 981: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 955: | Line 993: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to get from | | The keyboard device to get from | ||
|- | |- | ||
− | ! | + | ! Keycode |
| The returned key code read from the buffer (eg KEY_CODE_A) | | The returned key code read from the buffer (eg KEY_CODE_A) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Key code is the value translated from the scan code using the current keymap it may not be a character code and it may include non printable characters | + | | Key code is the value translated from the scan code using the current keymap it may not be a character code and it may include non printable characters |
+ | To translate a key code to a character call KeymapGetCharCode() | ||
|- | |- | ||
|} | |} | ||
Line 976: | Line 1,015: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to read from | | The keyboard device to read from | ||
|- | |- | ||
− | ! | + | ! Buffer |
| Pointer to a buffer to copy the keyboard data packets to | | Pointer to a buffer to copy the keyboard data packets to | ||
|- | |- | ||
− | ! | + | ! Size |
| The size of the buffer in bytes (Must be at least TKeyboardData or greater) | | The size of the buffer in bytes (Must be at least TKeyboardData or greater) | ||
|- | |- | ||
− | ! | + | ! Count |
| The number of keyboard data packets copied to the buffer | | The number of keyboard data packets copied to the buffer | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 995: | 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;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to control | | The keyboard device to control | ||
|- | |- | ||
− | ! | + | ! Request |
| The request code for the operation (eg KEYBOARD_CONTROL_GET_FLAG) | | The request code for the operation (eg KEYBOARD_CONTROL_GET_FLAG) | ||
|- | |- | ||
− | ! | + | ! Argument1 |
| The first argument for the operation (Dependent on request code) | | The first argument for the operation (Dependent on request code) | ||
|- | |- | ||
− | ! | + | ! Argument2 |
| The second argument for the operation (Dependent on request code) | | The second argument for the operation (Dependent on request code) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,024: | Line 1,063: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard to set the state for | | The keyboard to set the state for | ||
|- | |- | ||
− | ! | + | ! State |
| The new state to set and notify | | The new state to set and notify | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,042: | Line 1,081: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new Keyboard device entry or nil if keyboard could not be created | | Pointer to new Keyboard device entry or nil if keyboard could not be created | ||
|- | |- | ||
Line 1,054: | Line 1,093: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Size |
| Size in bytes to allocate for new keyboard (Including the keyboard device entry) | | Size in bytes to allocate for new keyboard (Including the keyboard device entry) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new Keyboard device entry or nil if keyboard could not be created | | Pointer to new Keyboard device entry or nil if keyboard could not be created | ||
|- | |- | ||
Line 1,069: | Line 1,108: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to destroy | | The keyboard device to destroy | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,084: | Line 1,123: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to register | | The keyboard device to register | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,099: | Line 1,138: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to deregister | | The keyboard device to deregister | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,114: | Line 1,153: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! KeyboardId |
| The ID number of the keyboard to find | | The ID number of the keyboard to find | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to keyboard device entry or nil if not found | | Pointer to keyboard device entry or nil if not found | ||
|- | |- | ||
Line 1,129: | Line 1,168: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Name |
| The name of the keyboard to find (eg Keyboard0) | | The name of the keyboard to find (eg Keyboard0) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to keyboard device entry or nil if not found | | Pointer to keyboard device entry or nil if not found | ||
|- | |- | ||
Line 1,144: | Line 1,183: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Description |
| The description of the keyboard to find (eg USB HID Keyboard) | | The description of the keyboard to find (eg USB HID Keyboard) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to keyboard device entry or nil if not found | | Pointer to keyboard device entry or nil if not found | ||
|- | |- | ||
Line 1,159: | Line 1,198: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Callback |
| The callback function to call for each keyboard in the table | | The callback function to call for each keyboard in the table | ||
|- | |- | ||
− | ! | + | ! Data |
| A private data pointer to pass to callback for each keyboard in the table | | A private data pointer to pass to callback for each keyboard in the table | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 1,177: | Line 1,216: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to notify changes for (Optional, pass nil for all keyboards) | | The keyboard device to notify changes for (Optional, pass nil for all keyboards) | ||
|- | |- | ||
− | ! | + | ! Callback |
| The function to call when a notification event occurs | | The function to call when a notification event occurs | ||
|- | |- | ||
− | ! | + | ! Data |
| A private data pointer to pass to callback when a notification event occurs | | A private data pointer to pass to callback when a notification event occurs | ||
|- | |- | ||
− | ! | + | ! Notification |
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
|- | |- | ||
− | ! | + | ! Flags |
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
|- | |- | ||
Line 1,204: | Line 1,243: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,216: | Line 1,255: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,228: | Line 1,267: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,240: | Line 1,279: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|} | |} | ||
Line 1,340: | 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;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,357: | Line 1,306: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,369: | Line 1,318: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,381: | Line 1,330: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,393: | Line 1,342: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,405: | Line 1,354: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must check for Left-Ctrl or Right-Ctrl modifiers | | Caller must check for Left-Ctrl or Right-Ctrl modifiers | ||
|- | |- | ||
Line 1,417: | Line 1,366: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
− | | Returns True if the key was remapped, False if it was not | + | | Returns True if the key was remapped, False if it was not. |
|- | |- | ||
− | ! | + | ! See |
− | | http://www.freepascal.org/docs-html/rtl/keyboard/kbdscancode.html See also: \source\packages\rtl-console\src\inc\keyscan.inc | + | | http://www.freepascal.org/docs-html/rtl/keyboard/kbdscancode.html |
+ | See also: \source\packages\rtl-console\src\inc\keyscan.inc | ||
|- | |- | ||
− | ! | + | ! Note |
| See below for a version that uses SCAN_CODE_* values instead of translated KEY_CODE_* values | | See below for a version that uses SCAN_CODE_* values instead of translated KEY_CODE_* values | ||
|- | |- | ||
Line 1,435: | Line 1,385: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Returns True if the key was remapped, False if it was not | | Returns True if the key was remapped, False if it was not | ||
|- | |- | ||
− | ! | + | ! See |
− | | http://www.freepascal.org/docs-html/rtl/keyboard/kbdscancode.html See also: \source\packages\rtl-console\src\inc\keyscan.inc | + | | http://www.freepascal.org/docs-html/rtl/keyboard/kbdscancode.html |
+ | See also: \source\packages\rtl-console\src\inc\keyscan.inc | ||
|- | |- | ||
− | ! | + | ! Note |
| Same as above except using SCAN_CODE_* values instead of translated KEY_CODE_* values | | Same as above except using SCAN_CODE_* values instead of translated KEY_CODE_* values | ||
|- | |- | ||
Line 1,453: | Line 1,404: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Keyboard |
| The keyboard device to insert data for | | The keyboard device to insert data for | ||
|- | |- | ||
− | ! | + | ! Data |
| The TKeyboardData entry to insert | | The TKeyboardData entry to insert | ||
|- | |- | ||
− | ! | + | ! Signal |
− | | If True then signal that new data is | + | | If True then signal that new data is available in the buffer |
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
− | ! | + | ! Note |
| Caller must hold the keyboard lock | | Caller must hold the keyboard lock | ||
|- | |- | ||
Line 1,477: | Line 1,428: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,489: | Line 1,440: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,501: | Line 1,452: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,513: | Line 1,464: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,525: | Line 1,476: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! 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