Difference between revisions of "Unit Keyboard"

From Ultibo.org
Jump to: navigation, search
Line 811: Line 811:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Called only during system startup
 
| Called only during system startup
 
|-
 
|-
Line 826: Line 826:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''KeyCode'''
+
! 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'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! 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()
+
| 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 845:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! 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 857:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the keyboard data packets to
 
| Pointer to a buffer to copy the keyboard data packets to
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! Count
 
| The number of keyboard data packets copied to the buffer
 
| The number of keyboard data packets copied to the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 877: Line 878:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the keyboard data packets to
 
| Pointer to a buffer to copy the keyboard data packets to
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! 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'''
+
! Count
 
| The number of keyboard data packets copied to the buffer
 
| The number of keyboard data packets copied to the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 901: Line 902:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''ScanCode'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 922: Line 923:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the keyboard data packets from
 
| Pointer to a buffer to copy the keyboard data packets from
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! Count
 
| The number of keyboard data packets to copy from the buffer
 
| The number of keyboard data packets to copy from the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 943: Line 944:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 955: Line 956:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to get from
 
| The keyboard device to get from
 
|-
 
|-
! '''Keycode'''
+
! 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'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! 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()
+
| 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 978:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to read from
 
| The keyboard device to read from
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to copy the keyboard data packets to
 
| Pointer to a buffer to copy the keyboard data packets to
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! Count
 
| The number of keyboard data packets copied to the buffer
 
| The number of keyboard data packets copied to the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 1,000: Line 1,002:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to control
 
| The keyboard device to control
 
|-
 
|-
! '''Request'''
+
! Request
 
| The request code for the operation (eg KEYBOARD_CONTROL_GET_FLAG)
 
| The request code for the operation (eg KEYBOARD_CONTROL_GET_FLAG)
 
|-
 
|-
! '''Argument1'''
+
! Argument1
 
| The first argument for the operation (Dependent on request code)
 
| The first argument for the operation (Dependent on request code)
 
|-
 
|-
! '''Argument2'''
+
! Argument2
 
| The second argument for the operation (Dependent on request code)
 
| The second argument for the operation (Dependent on request code)
 
|-
 
|-
! '''Return'''
+
! 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,026:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard to set the state for
 
| The keyboard to set the state for
 
|-
 
|-
! '''State'''
+
! State
 
| The new state to set and notify
 
| The new state to set and notify
 
|-
 
|-
! '''Return'''
+
! 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,044:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! 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,056:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Size'''
+
! 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'''
+
! 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,071:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to destroy
 
| The keyboard device to destroy
 
|-
 
|-
! '''Return'''
+
! 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,086:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to register
 
| The keyboard device to register
 
|-
 
|-
! '''Return'''
+
! 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,101:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to deregister
 
| The keyboard device to deregister
 
|-
 
|-
! '''Return'''
+
! 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,116:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''KeyboardId'''
+
! KeyboardId
 
| The ID number of the keyboard to find
 
| The ID number of the keyboard to find
 
|-
 
|-
! '''Return'''
+
! 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,131:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Name'''
+
! Name
 
| The name of the keyboard to find (eg Keyboard0)
 
| The name of the keyboard to find (eg Keyboard0)
 
|-
 
|-
! '''Return'''
+
! 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,146:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Description'''
+
! Description
 
| The description of the keyboard to find (eg USB HID Keyboard)
 
| The description of the keyboard to find (eg USB HID Keyboard)
 
|-
 
|-
! '''Return'''
+
! 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,161:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The callback function to call for each keyboard in the table
 
| The callback function to call for each keyboard in the table
 
|-
 
|-
! '''Data'''
+
! 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'''
+
! 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,179:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! 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'''
+
! Callback
 
| The function to call when a notification event occurs
 
| The function to call when a notification event occurs
 
|-
 
|-
! '''Data'''
+
! 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'''
+
! Notification
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
|-
 
|-
! '''Flags'''
+
! 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,206:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,216: Line 1,218:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,228: Line 1,230:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,240: Line 1,242:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,255: Line 1,257:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use KeyboardDeviceRead instead
+
| Not intended to be called directly by applications, use KeyboardDeviceRead instead.
 
|-
 
|-
 
|}
 
|}
Line 1,267: Line 1,269:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use KeyboardDeviceControl instead
+
| Not intended to be called directly by applications, use KeyboardDeviceControl instead.
 
|-
 
|-
 
|}
 
|}
Line 1,279: Line 1,281:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Device'''
+
! Device
 
| The USB device to attempt to bind to
 
| The USB device to attempt to bind to
 
|-
 
|-
! '''Interface'''
+
! Interrface
 
| The USB interface to attempt to bind to (or nil for whole device)
 
| The USB interface to attempt to bind to (or nil for whole device)
 
|-
 
|-
! '''Return'''
+
! Return
| USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure
+
| USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure.
 
|-
 
|-
 
|}
 
|}
Line 1,297: Line 1,299:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Device'''
+
! Device
 
| The USB device to unbind from
 
| The USB device to unbind from
 
|-
 
|-
! '''Interface'''
+
! Interrface
 
| The USB interface to unbind from (or nil for whole device)
 
| The USB interface to unbind from (or nil for whole device)
 
|-
 
|-
! '''Return'''
+
! Return
 
| USB_STATUS_SUCCESS if completed or another error code on failure
 
| USB_STATUS_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 1,315: Line 1,317:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Request'''
+
! Request
 
| The USB request which has completed
 
| The USB request which has completed
 
|-
 
|-
Line 1,327: Line 1,329:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Request'''
+
! Request
 
| The USB request which has completed
 
| The USB request which has completed
 
|-
 
|-
! '''Note'''
+
! Note
 
| Request is passed to worker thread for processing to prevent blocking the USB completion
 
| Request is passed to worker thread for processing to prevent blocking the USB completion
 
|-
 
|-
Line 1,345: Line 1,347:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,357: Line 1,359:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,369: Line 1,371:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,381: Line 1,383:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,393: Line 1,395:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,405: Line 1,407:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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,419:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! 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'''
+
! 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,438:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! 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'''
+
! 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,457:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to insert data for
 
| The keyboard device to insert data for
 
|-
 
|-
! '''Data'''
+
! Data
 
| The TKeyboardData entry to insert
 
| The TKeyboardData entry to insert
 
|-
 
|-
! '''Signal'''
+
! Signal
 
| If True then signal that new data is availale in the buffer
 
| If True then signal that new data is availale in the buffer
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 1,477: Line 1,481:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,489: Line 1,493:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,501: Line 1,505:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,513: Line 1,517:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,525: Line 1,529:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,540: Line 1,544:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to insert data for
 
| The USB keyboard device to insert data for
 
|-
 
|-
! '''Data'''
+
! Data
 
| The TKeyboardData entry to insert
 
| The TKeyboardData entry to insert
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 1,561: Line 1,565:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to check for
 
| The USB keyboard device to check for
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The keyboard scan code to check
 
| The keyboard scan code to check
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 1,579: Line 1,583:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to check for
 
| The USB keyboard device to check for
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The keyboard scan code to check
 
| The keyboard scan code to check
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 1,597: Line 1,601:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to check for
 
| The USB keyboard device to check for
 
|-
 
|-
! '''Report'''
+
! Report
 
| The USB keyboard report to compare against (Current)
 
| The USB keyboard report to compare against (Current)
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The keyboard scan code to check
 
| The keyboard scan code to check
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 1,618: Line 1,622:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to set the LEDs for
 
| The USB keyboard device to set the LEDs for
 
|-
 
|-
! '''LEDs'''
+
! LEDs
 
| The LED state to set (eg KEYBOARD_LED_NUMLOCK)
 
| The LED state to set (eg KEYBOARD_LED_NUMLOCK)
 
|-
 
|-
! '''Return'''
+
! Return
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
|-
 
|-
Line 1,636: Line 1,640:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to set the idle duration for
 
| The USB keyboard device to set the idle duration for
 
|-
 
|-
! '''Duration'''
+
! Duration
 
| The idle duration to set (Milliseconds divided by 4)
 
| The idle duration to set (Milliseconds divided by 4)
 
|-
 
|-
! '''ReportId'''
+
! ReportId
 
| The report Id to set the idle duration for (eg USB_HID_REPORTID_NONE)
 
| The report Id to set the idle duration for (eg USB_HID_REPORTID_NONE)
 
|-
 
|-
! '''Return'''
+
! Return
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
|-
 
|-
Line 1,657: Line 1,661:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The USB keyboard device to set the report protocol for
 
| The USB keyboard device to set the report protocol for
 
|-
 
|-
! '''Protocol'''
+
! Protocol
 
| The report protocol to set (eg USB_HID_PROTOCOL_BOOT)
 
| The report protocol to set (eg USB_HID_PROTOCOL_BOOT)
 
|-
 
|-
! '''Return'''
+
! Return
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
| USB_STATUS_SUCCESS if completed or another USB error code on failure
 
|-
 
|-

Revision as of 04:12, 20 April 2018

Return to Unit Reference


Description


Ultibo Keyboard interface unit

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



[Expand]
Keyboard specific constants KEYBOARD_NAME_*


[Expand]
Keyboard device type KEYBOARD_TYPE_*


[Expand]
Keyboard device state KEYBOARD_STATE_*


[Expand]
Keyboard device flag KEYBOARD_FLAG_*


[Expand]
Keyboard device control code KEYBOARD_CONTROL_*


[Expand]
Keyboard device LED KEYBOARD_LED_*


[Expand]
Keyboard buffer size KEYBOARD_BUFFER_*


[Expand]
Keyboard sampling rate KEYBOARD_REPEAT_*


[Expand]
Keyboard data definition KEYBOARD_*


[Expand]
Keyboard logging KEYBOARD_LOG_*


[Expand]
USB keyboard specific constants USBKEYBOARD_*


[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



Keyboard data

[Expand]

PKeyboardData = ^TKeyboardData;

TKeyboardData = record

Keyboard buffer

[Expand]

PKeyboardBuffer = ^TKeyboardBuffer;

TKeyboardBuffer = record

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

Keyboard device

[Expand]

PKeyboardDevice = ^TKeyboardDevice;

TKeyboardDevice = record

USB keyboard report

[Expand]

PUSBKeyboardReport = ^TUSBKeyboardReport;

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

USB keyboard device

[Expand]

PUSBKeyboardDevice = ^TUSBKeyboardDevice;

TUSBKeyboardDevice = record


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

[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]
function KeyboardInsertData(Keyboard:PKeyboardDevice; Data:PKeyboardData; Signal:Boolean):LongWord;
Description: Insert a TKeyboardData entry into the keyboard buffer (Direct or Global)


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


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


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


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


[Expand]
procedure KeyboardLogDebug(Keyboard:PKeyboardDevice; const AText:String); inline;
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