Difference between revisions of "Unit PS2"
(2 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
'''PS2 Keyboard/Mouse Controller Support unit''' | '''PS2 Keyboard/Mouse Controller Support unit''' | ||
− | This unit provides supporting functions and | + | This unit provides supporting functions and definitions for PS/2 keyboard and mouse controller drivers. |
The constants defined here are not a complete set but represent the most commonly used PS/2 functions and operations. Of most importance is the mouse packet and the keyboard scancode structures which provide support for receiving the actual data from a keyboard or a mouse. | The constants defined here are not a complete set but represent the most commonly used PS/2 functions and operations. Of most importance is the mouse packet and the keyboard scancode structures which provide support for receiving the actual data from a keyboard or a mouse. | ||
Line 518: | Line 518: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! LEDs |
| The Keyboard LED values to map (eg KEYBOARD_LED_NUMLOCK) | | The Keyboard LED values to map (eg KEYBOARD_LED_NUMLOCK) | ||
|- | |- | ||
− | ! | + | ! PS2LEDs |
| The returned PS/2 Keyboard LED values (eg PS2_KEYBOARD_SET_LEDS_NUMLOCK) | | The returned PS/2 Keyboard LED values (eg PS2_KEYBOARD_SET_LEDS_NUMLOCK) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 536: | Line 536: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Rate |
| The Keyboard Repeat Rate to translate (Milliseconds between repeats) | | The Keyboard Repeat Rate to translate (Milliseconds between repeats) | ||
|- | |- | ||
− | ! | + | ! Delay |
| The Keyboard Repeat Delay to translate (Number of Repeat Rate intervals before first repeat) | | The Keyboard Repeat Delay to translate (Number of Repeat Rate intervals before first repeat) | ||
|- | |- | ||
− | ! | + | ! PS2Typematic |
| The translated PS/2 Typematic value returned | | The translated PS/2 Typematic value returned | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 557: | Line 557: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! KeyboardScancode |
| Pointer to the scancode bytes and scancode set information | | Pointer to the scancode bytes and scancode set information | ||
|- | |- | ||
− | ! | + | ! Index |
| The index of the matching scancode on success or the nearest match on not found (Pass -1 to start search from first entry, on subsequent calls pass the previous value to continue) | | The index of the matching scancode on success or the nearest match on not found (Pass -1 to start search from first entry, on subsequent calls pass the previous value to continue) | ||
|- | |- | ||
− | ! | + | ! Return |
− | | ERROR_SUCCESS if matched, ERROR_NOT_FOUND if not matched or another error code on failure | + | | ERROR_SUCCESS if matched, ERROR_NOT_FOUND if not matched or another error code on failure. |
|- | |- | ||
|} | |} | ||
Line 575: | Line 575: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! KeyboardScancode |
| Pointer to the scancode bytes and scancode set information | | Pointer to the scancode bytes and scancode set information | ||
|- | |- | ||
− | ! | + | ! Index |
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match) | | The index value returned by PS2KeyboardScancodeMatch (-1 to search for match) | ||
|- | |- | ||
− | ! | + | ! ScanCode |
| The returned keyboard scan code value (eg SCAN_CODE_A) | | The returned keyboard scan code value (eg SCAN_CODE_A) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure (ERROR_NOT_FOUND if not matched) | | ERROR_SUCCESS if completed or another error code on failure (ERROR_NOT_FOUND if not matched) | ||
|- | |- | ||
Line 596: | Line 596: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Index |
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match) | | The index value returned by PS2KeyboardScancodeMatch (-1 to search for match) | ||
|- | |- | ||
− | ! | + | ! Modifiers |
| The returned keyboard modifiers flags (eg KEYBOARD_LEFT_CTRL) | | The returned keyboard modifiers flags (eg KEYBOARD_LEFT_CTRL) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure (ERROR_NOT_FOUND if not matched) | | ERROR_SUCCESS if completed or another error code on failure (ERROR_NOT_FOUND if not matched) | ||
|- | |- | ||
Line 614: | Line 614: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Rate |
| The Mouse Sample Rate to translate (Samples per second) | | The Mouse Sample Rate to translate (Samples per second) | ||
|- | |- | ||
− | ! | + | ! PS2Rate |
| The translated PS/2 Sample Rate value returned | | The translated PS/2 Sample Rate value returned | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 627: | Line 627: | ||
<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 PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags:LongWord):LongWord;</pre> | + | <pre style="border: 0; padding-bottom:0px;">function PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags,Rotation:LongWord):LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Translate a PS/2 Mouse Packet into a Mouse Data structure</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Translate a PS/2 Mouse Packet into a Mouse Data structure</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;" | ||
|- | |- | ||
− | ! | + | ! MousePacket |
| Pointer to the PS/2 Mouse Packet received from the mouse | | Pointer to the PS/2 Mouse Packet received from the mouse | ||
|- | |- | ||
− | ! | + | ! MouseData |
| Pointer to the Mouse Data structure to return | | Pointer to the Mouse Data structure to return | ||
|- | |- | ||
− | ! | + | ! Flags |
| The Mouse device flags (eg MOUSE_FLAG_SWAP_BUTTONS) | | The Mouse device flags (eg MOUSE_FLAG_SWAP_BUTTONS) | ||
|- | |- | ||
− | ! | + | ! Rotation |
+ | | The Mouse device rotation setting (eg MOUSE_ROTATION_180) | ||
+ | |- | ||
+ | ! Return | ||
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- |
Latest revision as of 04:45, 13 September 2022
Return to Unit Reference
Contents
[hide]Description
PS2 Keyboard/Mouse Controller Support unit
This unit provides supporting functions and definitions for PS/2 keyboard and mouse controller drivers.
The constants defined here are not a complete set but represent the most commonly used PS/2 functions and operations. Of most importance is the mouse packet and the keyboard scancode structures which provide support for receiving the actual data from a keyboard or a mouse.
This unit also includes the PS/2 scancode sets which define the actual values that are received in response to each key press and release. Currently only scancode set 2 is defined as in many instances that is considered the standard scancode set and some devices simply do not support scancode set 1 or 3.
Constants
PS2_KEYBOARD_COMMAND_*
PS2_KEYBOARD_SET_LEDS_*
PS2_KEYBOARD_SCANCODE_*
PS2_KEYBOARD_SET_*_MASK
PS2_KEYBOARD_SET_REPEAT_RATE_*
PS2_KEYBOARD_SET_DELAY_*
PS2_MOUSE_COMMAND_*
PS2_RESPONSE_*
PS2_MOUSE_BITS_*
PS2_SCANCODE_MAKE*
PS2_SCANCODE_*_COUNT
Type definitions
PS2 scancode data
PPS2ScancodeData = ^TPS2ScancodeData;
TPS2ScancodeData = array[0..(PS2_SCANCODE_COUNT * 2) - 1] of array[0..9] of Byte;
Keyboard scancode
Mouse packet types
Public variables
None defined
Function declarations
PS2 helper functions
function KeyboardLEDsToPS2LEDs(LEDs:LongWord; var PS2LEDs:Byte):LongWord;
function KeyboardRateAndDelayToPS2Typematic(Rate,Delay:LongWord; var PS2Typematic:Byte):LongWord;
function PS2KeyboardScancodeMatch(KeyboardScancode:PPS2KeyboardScancode; var Index:LongInt):LongWord;
function PS2KeyboardScancodeToScanCode(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var ScanCode:Word):LongWord;
function PS2KeyboardScancodeToModifiers(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var Modifiers:LongWord):LongWord;
function MouseSampleRateToPS2SampleRate(Rate:LongWord; var PS2Rate:Byte):LongWord;
function PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags,Rotation:LongWord):LongWord;
Return to Unit Reference