Difference between revisions of "Unit PS2"

From Ultibo.org
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 518: Line 518:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''LEDs'''
+
! LEDs
 
| The Keyboard LED values to map (eg KEYBOARD_LED_NUMLOCK)
 
| The Keyboard LED values to map (eg KEYBOARD_LED_NUMLOCK)
 
|-
 
|-
! '''PS2LEDs'''
+
! 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'''
+
! 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'''
+
! Rate
 
| The Keyboard Repeat Rate to translate (Milliseconds between repeats)
 
| The Keyboard Repeat Rate to translate (Milliseconds between repeats)
 
|-
 
|-
! '''Delay'''
+
! 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'''
+
! PS2Typematic
 
| The translated PS/2 Typematic value returned
 
| The translated PS/2 Typematic value returned
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! KeyboardScancode
 
| Pointer to the scancode bytes and scancode set information
 
| Pointer to the scancode bytes and scancode set information
 
|-
 
|-
! '''Index'''
+
! 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'''
+
! 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'''
+
! KeyboardScancode
 
| Pointer to the scancode bytes and scancode set information
 
| Pointer to the scancode bytes and scancode set information
 
|-
 
|-
! '''Index'''
+
! Index
 
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
 
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The returned keyboard scan code value (eg SCAN_CODE_A)
 
| The returned keyboard scan code value (eg SCAN_CODE_A)
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! Index
 
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
 
| The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
 
|-
 
|-
! '''Modifiers'''
+
! Modifiers
 
| The returned keyboard modifiers flags (eg KEYBOARD_LEFT_CTRL)
 
| The returned keyboard modifiers flags (eg KEYBOARD_LEFT_CTRL)
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! Rate
 
| The Mouse Sample Rate to translate (Samples per second)
 
| The Mouse Sample Rate to translate (Samples per second)
 
|-
 
|-
! '''PS2Rate'''
+
! PS2Rate
 
| The translated PS/2 Sample Rate value returned
 
| The translated PS/2 Sample Rate value returned
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! MousePacket
 
| Pointer to the PS/2 Mouse Packet received from the mouse
 
| Pointer to the PS/2 Mouse Packet received from the mouse
 
|-
 
|-
! '''MouseData'''
+
! MouseData
 
| Pointer to the Mouse Data structure to return
 
| Pointer to the Mouse Data structure to return
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The Mouse device flags (eg MOUSE_FLAG_SWAP_BUTTONS)
 
| The Mouse device flags (eg MOUSE_FLAG_SWAP_BUTTONS)
 
|-
 
|-
! '''Return'''
+
! 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


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



[Expand]
PS2 keyboard command PS2_KEYBOARD_COMMAND_*


[Expand]
PS2 keyboard set LEDs PS2_KEYBOARD_SET_LEDS_*


[Expand]
PS2 keyboard scancode PS2_KEYBOARD_SCANCODE_*


[Expand]
PS2 keyboard set mask PS2_KEYBOARD_SET_*_MASK


[Expand]
PS2 keyboard set repeat rate PS2_KEYBOARD_SET_REPEAT_RATE_*


[Expand]
PS2 keyboard set delay PS2_KEYBOARD_SET_DELAY_*


[Expand]
PS2 mouse command PS2_MOUSE_COMMAND_*


[Expand]
PS2 response constants PS2_RESPONSE_*


[Expand]
PS2 mouse packets PS2_MOUSE_BITS_*


[Expand]
PS2 keyboard scancode types PS2_SCANCODE_MAKE*


[Expand]
PS2 keyboard scancode counts PS2_SCANCODE_*_COUNT


Type definitions



PS2 scancode data

[Expand]

PPS2ScancodeData = ^TPS2ScancodeData;

TPS2ScancodeData = array[0..(PS2_SCANCODE_COUNT * 2) - 1] of array[0..9] of Byte;

Keyboard scancode

[Expand]

PPS2KeyboardScancode = ^TPS2KeyboardScancode;

TPS2KeyboardScancode = record

Mouse packet types

[Expand]

PPS2MousePacket = ^TPS2MousePacket;

TPS2MousePacket = record


Public variables


None defined

Function declarations



PS2 helper functions

[Expand]
function KeyboardLEDsToPS2LEDs(LEDs:LongWord; var PS2LEDs:Byte):LongWord;
Description: Map the Keyboard LED values to the PS/2 Keyboard LED values


[Expand]
function KeyboardRateAndDelayToPS2Typematic(Rate,Delay:LongWord; var PS2Typematic:Byte):LongWord;
Description: Translate the Keyboard Repeat Rate and Delay values to the PS/2 Keyboard Typematic value


[Expand]
function PS2KeyboardScancodeMatch(KeyboardScancode:PPS2KeyboardScancode; var Index:LongInt):LongWord;
Description: Check a set of scancode bytes against the specified PS/2 Scancode set for a match


[Expand]
function PS2KeyboardScancodeToScanCode(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var ScanCode:Word):LongWord;
Description: Return the Keyboard Scan Code value for a PS/2 scancode value


[Expand]
function PS2KeyboardScancodeToModifiers(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var Modifiers:LongWord):LongWord;
Description: Return the Keyboard Modifiers flags for a PS/2 scancode value


[Expand]
function MouseSampleRateToPS2SampleRate(Rate:LongWord; var PS2Rate:Byte):LongWord;
Description: Translate a Mouse Sample Rate value to the PS/2 Mouse Sample Rate value


[Expand]
function PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags,Rotation:LongWord):LongWord;
Description: Translate a PS/2 Mouse Packet into a Mouse Data structure


Return to Unit Reference