Difference between revisions of "Unit PS2"

From Ultibo.org
Jump to: navigation, search
 
(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 defintions for PS/2 keyboard and mouse controller drivers.  
+
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'''
+
! 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



PS2 keyboard command PS2_KEYBOARD_COMMAND_*
Note: See: http://wiki.osdev.org/PS/2_Keyboard
PS2_KEYBOARD_COMMAND_SET_LEDS = $ED; Set LEDS (Data: See below)
PS2_KEYBOARD_COMMAND_ECHO = $EE; Echo (Data: None)
PS2_KEYBOARD_COMMAND_SCANCODE = $F0; Get/set current scan code (Data: See below)
PS2_KEYBOARD_COMMAND_IDENTIFY = $F2; Identify (Data: None) (See: http://wiki.osdev.org/%228042%22_PS/2_Controller#Detecting_PS.2F2_Device_Types)
PS2_KEYBOARD_COMMAND_SET_RATE_DELAY = $F3; Set typematic rate and delay (Data: See below)
PS2_KEYBOARD_COMMAND_ENABLE_SCAN = $F4; Enable scanning (keyboard will send scan codes) (Data: None)
PS2_KEYBOARD_COMMAND_DISABLE_SCAN = $F5; Disable scanning (keyboard won't send scan codes) (Data: None) Note: May also restore default parameters
PS2_KEYBOARD_COMMAND_SET_DEFAULTS = $F6; Set default parameters (Data: None)
PS2_KEYBOARD_COMMAND_SET_ALL_TYPEMATIC_ONLY = $F7; Set all keys to typematic/autorepeat only (Scancode set 3 only) (Data: None)
PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_RELEASE = $F8; Set all keys to make/release (Scancode set 3 only) (Data: None)
PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_ONLY = $F9; Set all keys to make only (Scancode set 3 only) (Data: None)
PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_TYPEMATIC = $FA; Set all keys to typematic/autorepeat/make/release (Scancode set 3 only) (Data: None)
PS2_KEYBOARD_COMMAND_SET_TYPEMATIC_ONLY = $FB; Set specific key to typematic/autorepeat only (Scancode set 3 only) (Data: Scancode for key)
PS2_KEYBOARD_COMMAND_SET_MAKE_RELEASE = $FC; Set specific key to make/release (Scancode set 3 only) (Data: Scancode for key)
PS2_KEYBOARD_COMMAND_SET_MAKE_ONLY = $FD; Set specific key to make only (Scancode set 3 only) (Data: Scancode for key)
PS2_KEYBOARD_COMMAND_RESEND = $FE; Resend last byte (Data: None)
PS2_KEYBOARD_COMMAND_RESET = $FF; Reset and start self-test (Data: None)


PS2 keyboard set LEDs PS2_KEYBOARD_SET_LEDS_*
PS2_KEYBOARD_SET_LEDS_SCROLLLOCK = (1 shl 0); ScrollLock
PS2_KEYBOARD_SET_LEDS_NUMLOCK = (1 shl 1); NumberLock
PS2_KEYBOARD_SET_LEDS_CAPSLOCK = (1 shl 2); CapsLock


PS2 keyboard scancode PS2_KEYBOARD_SCANCODE_*
PS2_KEYBOARD_SCANCODE_GET = 0; Get current scan code set
PS2_KEYBOARD_SCANCODE_SET1 = 1; Set scan code set 1
PS2_KEYBOARD_SCANCODE_SET2 = 2; Set scan code set 2
PS2_KEYBOARD_SCANCODE_SET3 = 3; Set scan code set 3


PS2 keyboard set mask PS2_KEYBOARD_SET_*_MASK
PS2_KEYBOARD_SET_REPEAT_RATE_MASK = $0F; Repeat rate (00000b = 30 Hz, ..., 11111b = 2 Hz)
PS2_KEYBOARD_SET_DELAY_MASK = $70; Delay before keys repeat (00b = 250 ms, 01b = 500 ms, 10b = 750 ms, 11b = 1000 ms)
Bit 7 Must be zero


PS2 keyboard set repeat rate PS2_KEYBOARD_SET_REPEAT_RATE_*
PS2_KEYBOARD_SET_REPEAT_RATE_30_0 = $00; 30.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_26_7 = $01; 26.7cps
PS2_KEYBOARD_SET_REPEAT_RATE_24_0 = $02; 24.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_21_8 = $03; 21.8cps
PS2_KEYBOARD_SET_REPEAT_RATE_20_7 = $04; 20.7cps
PS2_KEYBOARD_SET_REPEAT_RATE_18_5 = $05; 18.5cps
PS2_KEYBOARD_SET_REPEAT_RATE_17_1 = $06; 17.1cps
PS2_KEYBOARD_SET_REPEAT_RATE_16_0 = $07; 16.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_15_0 = $08; 15.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_13_3 = $09; 13.3cps
PS2_KEYBOARD_SET_REPEAT_RATE_12_0 = $0A; 12.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_10_9 = $0B; 10.9cps
PS2_KEYBOARD_SET_REPEAT_RATE_10_0 = $0C; 10.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_9_2 = $0D; 9.2cps
PS2_KEYBOARD_SET_REPEAT_RATE_8_6 = $0E; 8.6cps
PS2_KEYBOARD_SET_REPEAT_RATE_8_0 = $0F; 8.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_7_5 = $10; 7.5cps
PS2_KEYBOARD_SET_REPEAT_RATE_6_7 = $11; 6.7cps
PS2_KEYBOARD_SET_REPEAT_RATE_6_0 = $12; 6.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_5_5 = $13; 5.5cps
PS2_KEYBOARD_SET_REPEAT_RATE_5_0 = $14; 5.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_4_6 = $15; 4.6cps
PS2_KEYBOARD_SET_REPEAT_RATE_4_3 = $16; 4.3cps
PS2_KEYBOARD_SET_REPEAT_RATE_4_0 = $17; 4.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_3_7 = $18; 3.7cps
PS2_KEYBOARD_SET_REPEAT_RATE_3_3 = $19; 3.3cps
PS2_KEYBOARD_SET_REPEAT_RATE_3_0 = $1A; 3.0cps
PS2_KEYBOARD_SET_REPEAT_RATE_2_7 = $1B; 2.7cps
PS2_KEYBOARD_SET_REPEAT_RATE_2_5 = $1C; 2.5cps
PS2_KEYBOARD_SET_REPEAT_RATE_2_3 = $1D; 2.3cps
PS2_KEYBOARD_SET_REPEAT_RATE_2_1 = $1E; 2.1cps
PS2_KEYBOARD_SET_REPEAT_RATE_2_0 = $1F; 2.0cps


PS2 keyboard set delay PS2_KEYBOARD_SET_DELAY_*
PS2_KEYBOARD_SET_DELAY_250 = $00; 250ms
PS2_KEYBOARD_SET_DELAY_500 = $10; 500ms
PS2_KEYBOARD_SET_DELAY_750 = $20; 750ms
PS2_KEYBOARD_SET_DELAY_1000 = $30; 1000ms


PS2 mouse command PS2_MOUSE_COMMAND_*
Note: See: http://wiki.osdev.org/PS/2_Mouse
PS2_MOUSE_COMMAND_RESET = $FF; Reset (Data: None)
PS2_MOUSE_COMMAND_RESEND = $FE; Resend (Data: None)
PS2_MOUSE_COMMAND_SET_DEFAULTS = $F6; Set Defaults (Data: None)
PS2_MOUSE_COMMAND_DISABLE_REPORT = $F5; Disable Data Reporting (Data: None)
PS2_MOUSE_COMMAND_ENABLE_REPORT = $F4; Enable Data Reporting (Data: None)
PS2_MOUSE_COMMAND_SET_SAMPLE_RATE = $F3; Set Sample Rate (Data: Sample rate, ranges from 10-200)
PS2_MOUSE_COMMAND_GET_DEVICE_ID = $F2; Get Device ID (Data: None) (See: http://wiki.osdev.org/%228042%22_PS/2_Controller#Detecting_PS.2F2_Device_Types)
PS2_MOUSE_COMMAND_SET_REMOTE_MODE = $F0; Set Remote Mode (Data: None)
PS2_MOUSE_COMMAND_SET_WRAP_MODE = $EE; Set Wrap Mode (Data: None)
PS2_MOUSE_COMMAND_RESET_WRAP_MODE = $EC; Reset Wrap Mode (Data: None)
PS2_MOUSE_COMMAND_READ_DATA = $EB; Read Data (Data: None)
PS2_MOUSE_COMMAND_SET_STREAM_MODE = $EA; Set Stream Mode (Data: None)
PS2_MOUSE_COMMAND_STATUS_REQUEST = $E9; Status Request (Data: None)
PS2_MOUSE_COMMAND_SET_RESOLUTION = $E8; Set Resolution (Data: See below)
 
PS2_MOUSE_COMMAND_SAMPLE_RATE_10 = 10; 10 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_20 = 20; 20 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_40 = 40; 40 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_60 = 60; 60 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_80 = 80; 80 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_100 = 100; 100 samples/sec
PS2_MOUSE_COMMAND_SAMPLE_RATE_200 = 200; 200 samples/sec
 
PS2_MOUSE_COMMAND_RESOLUTION_1 = $00; 1 count/mm
PS2_MOUSE_COMMAND_RESOLUTION_2 = $01; 2 count/mm
PS2_MOUSE_COMMAND_RESOLUTION_4 = $02; 4 count/mm
PS2_MOUSE_COMMAND_RESOLUTION_5 = $03; 8 count/mm


PS2 response constants PS2_RESPONSE_*
PS2_RESPONSE_NONE = $00; Key detection error or internal buffer overrun
PS2_RESPONSE_SELF_TEST_PASS = $AA; Self test passed (sent after "0xFF (reset)" command or keyboard power up)
PS2_RESPONSE_ECHO = $EE; Response to "0xEE (echo)" command
PS2_RESPONSE_ACK = $FA; Command acknowledged (ACK)
PS2_RESPONSE_SELFTEST_FAIL1 = $FC; Self test failed (sent after "0xFF (reset)" command or keyboard power up)
PS2_RESPONSE_SELFTEST_FAIL2 = $FD; Self test failed (sent after "0xFF (reset)" command or keyboard power up)
PS2_RESPONSE_RESEND = $FE; Resend (keyboard wants controller to repeat last command it sent)
PS2_RESPONSE_ERROR = $FF; Key detection error or internal buffer overrun


PS2 mouse packets PS2_MOUSE_BITS_*
PS2_MOUSE_BITS_YO = (1 shl 7); Y-Axis Overflow
PS2_MOUSE_BITS_XO = (1 shl 6); X-Axis Overflow
PS2_MOUSE_BITS_YS = (1 shl 5); Y-Axis Sign Bit (9-Bit Y-Axis Relative Offset)
PS2_MOUSE_BITS_XS = (1 shl 4); X-Axis Sign Bit (9-Bit X-Axis Relative Offset)
PS2_MOUSE_BITS_AO = (1 shl 3); Always One
PS2_MOUSE_BITS_BM = (1 shl 2); Button Middle (Normally Off = 0)
PS2_MOUSE_BITS_BR = (1 shl 1); Button Right (Normally Off = 0)
PS2_MOUSE_BITS_BL = (1 shl 0); Button Left (Normally Off = 0)


PS2 keyboard scancode types PS2_SCANCODE_MAKE*
PS2_SCANCODE_MAKE = 0; Key Down (Press)
PS2_SCANCODE_BREAK = 1; Key Up (Release)


PS2 keyboard scancode counts PS2_SCANCODE_*_COUNT
PS2_SCANCODE_PC104_COUNT = 104;  
PS2_SCANCODE_ACPI_COUNT = 3;  
PS2_SCANCODE_MULTIMEDIA_COUNT = 18;  
PS2_SCANCODE_COUNT = PS2_SCANCODE_PC104_COUNT + PS2_SCANCODE_ACPI_COUNT + PS2_SCANCODE_MULTIMEDIA_COUNT;  


Type definitions



PS2 scancode data

PPS2ScancodeData = ^TPS2ScancodeData;

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

 

Keyboard scancode

PPS2KeyboardScancode = ^TPS2KeyboardScancode;

TPS2KeyboardScancode = record

ScancodeSet:Byte;  
Scancode:array[0..7] of Byte;  

Mouse packet types

PPS2MousePacket = ^TPS2MousePacket;

TPS2MousePacket = record

MouseBits:Byte; Bits (See PS2_MOUSE_BITS_* above)
MouseX:Byte; X-Axis Movement Value (Relative)
MouseY:Byte; Y-Axis Movement Value (Relative)


Public variables


None defined

Function declarations



PS2 helper functions

function KeyboardLEDsToPS2LEDs(LEDs:LongWord; var PS2LEDs:Byte):LongWord;
Description: Map the Keyboard LED values to the PS/2 Keyboard LED values
LEDs The Keyboard LED values to map (eg KEYBOARD_LED_NUMLOCK)
PS2LEDs The returned PS/2 Keyboard LED values (eg PS2_KEYBOARD_SET_LEDS_NUMLOCK)
Return ERROR_SUCCESS if completed or another error code on failure


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
Rate The Keyboard Repeat Rate to translate (Milliseconds between repeats)
Delay The Keyboard Repeat Delay to translate (Number of Repeat Rate intervals before first repeat)
PS2Typematic The translated PS/2 Typematic value returned
Return ERROR_SUCCESS if completed or another error code on failure


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
KeyboardScancode 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)
Return ERROR_SUCCESS if matched, ERROR_NOT_FOUND if not matched or another error code on failure.


function PS2KeyboardScancodeToScanCode(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var ScanCode:Word):LongWord;
Description: Return the Keyboard Scan Code value for a PS/2 scancode value
KeyboardScancode Pointer to the scancode bytes and scancode set information
Index The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
ScanCode 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)


function PS2KeyboardScancodeToModifiers(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var Modifiers:LongWord):LongWord;
Description: Return the Keyboard Modifiers flags for a PS/2 scancode value
Index The index value returned by PS2KeyboardScancodeMatch (-1 to search for match)
Modifiers 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)


function MouseSampleRateToPS2SampleRate(Rate:LongWord; var PS2Rate:Byte):LongWord;
Description: Translate a Mouse Sample Rate value to the PS/2 Mouse Sample Rate value
Rate The Mouse Sample Rate to translate (Samples per second)
PS2Rate The translated PS/2 Sample Rate value returned
Return ERROR_SUCCESS if completed or another error code on failure


function PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags,Rotation:LongWord):LongWord;
Description: Translate a PS/2 Mouse Packet into a Mouse Data structure
MousePacket Pointer to the PS/2 Mouse Packet received from the mouse
MouseData Pointer to the Mouse Data structure to return
Flags 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


Return to Unit Reference