Difference between revisions of "Unit Keyboard"
From Ultibo.org
Line 422: | Line 422: | ||
! '''Flags''' | ! '''Flags''' | ||
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''RTL console functions''' | ||
+ | |||
+ | <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 SysConsoleGetKey(var ACh:Char; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for Platform ConsoleGetKey function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <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 SysConsolePeekKey(var ACh:Char; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for Platform ConsolePeekKey function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <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 SysConsoleReadChar(var ACh:Char; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for Platform ConsoleReadChar function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <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 SysConsoleReadWideChar(var ACh:WideChar; AUserData:Pointer):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Handler for Platform ConsoleReadWideChar function</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | To be documented | ||
|- | |- | ||
|} | |} |
Revision as of 00:26, 19 August 2016
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
procedure KeyboardInit;
Description: Initialize the keyboard unit, device table and USB keyboard driver
Note | Called only during system startup |
---|
Keyboard functions
function KeyboardGet(var KeyCode:Word):LongWord;
Description: Get the first key code from the global keyboard buffer
KeyCode | The returned key code read from the buffer (eg KEY_CODE_A) |
---|---|
Return | 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. To translate a key code to a character call KeymapGetCharCode() |
function KeyboardPeek:LongWord;
Description: Peek at the global keyboard buffer to see if any data packets are ready
Return | ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure |
---|
function KeyboardRead(Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord; inline;
Description: Read keyboard data packets from the global keyboard buffer
Buffer | 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) |
Count | The number of keyboard data packets copied to the buffer |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardReadEx(Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read keyboard data packets from the global keyboard buffer
Buffer | 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) |
Flags | The flags to use for the read (eg KEYBOARD_FLAG_NON_BLOCK) |
Count | The number of keyboard data packets copied to the buffer |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardPut(ScanCode,KeyCode:Word; Modifiers:LongWord):LongWord;
Description: Put a scan code and key code in the global keyboard buffer
ScanCode | 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) |
Modifiers | The modifier keys to write to the buffer (eg KEYBOARD_LEFT_CTRL) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardWrite(Buffer:Pointer; Size,Count:LongWord):LongWord;
Description: Write keyboard data packets to the global keyboard buffer
Buffer | 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) |
Count | The number of keyboard data packets to copy from the buffer |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardFlush:LongWord;
Description: Flush the contents of the global keyboard buffer
Return | ERROR_SUCCESS if completed or another error code on failure |
---|
function KeyboardDeviceGet(Keyboard:PKeyboardDevice; var KeyCode:Word):LongWord;
Description: Get the first key code from the buffer of the specified keyboard
Keyboard | The keyboard device to get from |
---|---|
Keycode | The returned key code read from the buffer (eg KEY_CODE_A) |
Return | 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. To translate a key code to a character call KeymapGetCharCode() |
function KeyboardDeviceRead(Keyboard:PKeyboardDevice; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Description: Read keyboard data packets from the buffer of the specified keyboard
Keyboard | The keyboard device to read from |
---|---|
Buffer | 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) |
Count | The number of keyboard data packets copied to the buffer |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: Perform a control request on the specified keyboard device
Keyboard | The keyboard device to control |
---|---|
Request | The request code for the operation (eg KEYBOARD_CONTROL_GET_FLAG) |
Argument1 | The first argument for the operation (Dependant on request code) |
Argument2 | The second argument for the operation (Dependant on request code) |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceSetState(Keyboard:PKeyboardDevice; State:LongWord):LongWord;
Description: Set the state of the specified keyboard and send a notification
Keyboard | The keyboard to set the state for |
---|---|
State | The new state to set and notify |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceCreate:PKeyboardDevice;
Description: Create a new Keyboard device entry
Return | Pointer to new Keyboard device entry or nil if keyboard could not be created |
---|
function KeyboardDeviceCreateEx(Size:LongWord):PKeyboardDevice;
Description: Create a new Keyboard device entry
Size | 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 |
function KeyboardDeviceDestroy(Keyboard:PKeyboardDevice):LongWord;
Description: Destroy an existing Keyboard device entry
Keyboard | The keyboard device to destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceRegister(Keyboard:PKeyboardDevice):LongWord;
Description: Register a new Keyboard device in the Keyboard table
Keyboard | The keyboard device to register |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceDeregister(Keyboard:PKeyboardDevice):LongWord;
Description: Deregister a Keyboard device from the Keyboard table
Keyboard | The keyboard device to deregister |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceFind(KeyboardId:LongWord):PKeyboardDevice;
Description: Find a keyboard device by ID in the keyboard table
KeyboardId | The ID number of the keyboard to find |
---|---|
Return | Pointer to keyboard device entry or nil if not found |
function KeyboardDeviceFindByName(const Name:String):PKeyboardDevice; inline;
Description: Find a keyboard device by name in the keyboard table
Name | The name of the keyboard to find (eg Keyboard0) |
---|---|
Return | Pointer to keyboard device entry or nil if not found |
function KeyboardDeviceFindByDescription(const Description:String):PKeyboardDevice; inline;
Description: Find a keyboard device by description in the keyboard table
Description | The description of the keyboard to find (eg USB HID Keyboard) |
---|---|
Return | Pointer to keyboard device entry or nil if not found |
function KeyboardDeviceEnumerate(Callback:TKeyboardEnumerate; Data:Pointer):LongWord;
Description: Enumerate all keyboard devices in the keyboard table
Callback | 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 |
Return | ERROR_SUCCESS if completed or another error code on failure |
function KeyboardDeviceNotification(Keyboard:PKeyboardDevice; Callback:TKeyboardNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for keyboard device changes
Keyboard | The keyboard device to notify changes for (Optional, pass nil for all keyboards) |
---|---|
Callback | The function to call when a notification event occurs |
Data | 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) |
Flags | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) |
RTL console functions
function SysConsoleGetKey(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleGetKey function
Note | To be documented |
---|
function SysConsolePeekKey(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsolePeekKey function
Note | To be documented |
---|
function SysConsoleReadChar(var ACh:Char; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadChar function
Note | To be documented |
---|
function SysConsoleReadWideChar(var ACh:WideChar; AUserData:Pointer):Boolean;
Description: Handler for Platform ConsoleReadWideChar function
Note | To be documented |
---|
Return to Unit Reference