Difference between revisions of "Unit PS2"

From Ultibo.org
Jump to: navigation, search
Line 16: Line 16:
 
----
 
----
  
''To be documented''
+
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard command''' <code> PS2_KEYBOARD_COMMAND_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: See: http://wiki.osdev.org/PS/2_Keyboard
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_LEDS = $ED;</code>
 +
| Set LEDS (Data: See below)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_ECHO = $EE;</code>
 +
| Echo (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SCANCODE = $F0;</code>
 +
| Get/set current scan code (Data: See below)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_IDENTIFY = $F2;</code>
 +
| Identify (Data: None) (See: http://wiki.osdev.org/%228042%22_PS/2_Controller#Detecting_PS.2F2_Device_Types)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_RATE_DELAY = $F3;</code>
 +
| Set typematic rate and delay (Data: See below)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_ENABLE_SCAN = $F4;</code>
 +
| Enable scanning (keyboard will send scan codes) (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_DISABLE_SCAN = $F5;</code>
 +
| Disable scanning (keyboard won't send scan codes) (Data: None) Note: May also restore default parameters
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_DEFAULTS = $F6;</code>
 +
| Set default parameters (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_ALL_TYPEMATIC_ONLY = $F7;</code>
 +
| Set all keys to typematic/autorepeat only (Scancode set 3 only) (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_RELEASE = $F8;</code>
 +
| Set all keys to make/release (Scancode set 3 only) (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_ONLY = $F9;</code>
 +
| Set all keys to make only (Scancode set 3 only) (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_ALL_MAKE_TYPEMATIC = $FA;</code>
 +
| Set all keys to typematic/autorepeat/make/release (Scancode set 3 only) (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_TYPEMATIC_ONLY = $FB;</code>
 +
| Set specific key to typematic/autorepeat only (Scancode set 3 only) (Data: Scancode for key)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_MAKE_RELEASE = $FC;</code>
 +
| Set specific key to make/release (Scancode set 3 only) (Data: Scancode for key)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_SET_MAKE_ONLY = $FD;</code>
 +
| Set specific key to make only (Scancode set 3 only) (Data: Scancode for key)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_RESEND = $FE;</code>
 +
| Resend last byte (Data: None)
 +
|-
 +
| <code>PS2_KEYBOARD_COMMAND_RESET = $FF;</code>
 +
| Reset and start self-test (Data: None)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard set LEDs''' <code> PS2_KEYBOARD_SET_LEDS_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_KEYBOARD_SET_LEDS_SCROLLLOCK = (1 shl 0);</code>
 +
| ScrollLock
 +
|-
 +
| <code>PS2_KEYBOARD_SET_LEDS_NUMLOCK = (1 shl 1);</code>
 +
| NumberLock
 +
|-
 +
| <code>PS2_KEYBOARD_SET_LEDS_CAPSLOCK = (1 shl 2);</code>
 +
| CapsLock
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard scancode''' <code> PS2_KEYBOARD_SCANCODE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_KEYBOARD_SCANCODE_GET = 0;</code>
 +
| Get current scan code set
 +
|-
 +
| <code>PS2_KEYBOARD_SCANCODE_SET1 = 1;</code>
 +
| Set scan code set 1
 +
|-
 +
| <code>PS2_KEYBOARD_SCANCODE_SET2 = 2;</code>
 +
| Set scan code set 2
 +
|-
 +
| <code>PS2_KEYBOARD_SCANCODE_SET3 = 3;</code>
 +
| Set scan code set 3
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard set mask''' <code> PS2_KEYBOARD_SET_*_MASK </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_MASK = $0F;</code>
 +
| Repeat rate (00000b = 30 Hz, ..., 11111b = 2 Hz)
 +
|-
 +
| <code>PS2_KEYBOARD_SET_DELAY_MASK = $70;</code>
 +
| Delay before keys repeat (00b = 250 ms, 01b = 500 ms, 10b = 750 ms, 11b = 1000 ms)
 +
|-
 +
|colspan="2"|''Bit 7 Must be zero''
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard set repeat rate''' <code> PS2_KEYBOARD_SET_REPEAT_RATE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_30_0 = $00;</code>
 +
| 30.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_26_7 = $01;</code>
 +
| 26.7cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_24_0 = $02;</code>
 +
| 24.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_21_8 = $03;</code>
 +
| 21.8cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_20_7 = $04;</code>
 +
| 20.7cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_18_5 = $05;</code>
 +
| 18.5cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_17_1 = $06;</code>
 +
| 17.1cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_16_0 = $07;</code>
 +
| 16.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_15_0 = $08;</code>
 +
| 15.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_13_3 = $09;</code>
 +
| 13.3cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_12_0 = $0A;</code>
 +
| 12.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_10_9 = $0B;</code>
 +
| 10.9cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_10_0 = $0C;</code>
 +
| 10.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_9_2 = $0D;</code>
 +
| 9.2cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_8_6 = $0E;</code>
 +
| 8.6cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_8_0 = $0F;</code>
 +
| 8.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_7_5 = $10;</code>
 +
| 7.5cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_6_7 = $11;</code>
 +
| 6.7cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_6_0 = $12;</code>
 +
| 6.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_5_5 = $13;</code>
 +
| 5.5cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_5_0 = $14;</code>
 +
| 5.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_4_6 = $15;</code>
 +
| 4.6cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_4_3 = $16;</code>
 +
| 4.3cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_4_0 = $17;</code>
 +
| 4.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_3_7 = $18;</code>
 +
| 3.7cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_3_3 = $19;</code>
 +
| 3.3cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_3_0 = $1A;</code>
 +
| 3.0cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_2_7 = $1B;</code>
 +
| 2.7cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_2_5 = $1C;</code>
 +
| 2.5cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_2_3 = $1D;</code>
 +
| 2.3cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_2_1 = $1E;</code>
 +
| 2.1cps
 +
|-
 +
| <code>PS2_KEYBOARD_SET_REPEAT_RATE_2_0 = $1F;</code>
 +
| 2.0cps
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard set delay''' <code> PS2_KEYBOARD_SET_DELAY_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_KEYBOARD_SET_DELAY_250 = $00;</code>
 +
| 250ms
 +
|-
 +
| <code>PS2_KEYBOARD_SET_DELAY_500 = $10;</code>
 +
| 500ms
 +
|-
 +
| <code>PS2_KEYBOARD_SET_DELAY_750 = $20;</code>
 +
| 750ms
 +
|-
 +
| <code>PS2_KEYBOARD_SET_DELAY_1000 = $30;</code>
 +
| 1000ms
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 mouse command''' <code> PS2_MOUSE_COMMAND_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: See: http://wiki.osdev.org/PS/2_Mouse
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESET = $FF;</code>
 +
| Reset (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESEND = $FE;</code>
 +
| Resend (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_DEFAULTS = $F6;</code>
 +
| Set Defaults (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_DISABLE_REPORT = $F5;</code>
 +
| Disable Data Reporting (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_ENABLE_REPORT = $F4;</code>
 +
| Enable Data Reporting (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_SAMPLE_RATE = $F3;</code>
 +
| Set Sample Rate (Data: Sample rate, ranges from 10-200)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_GET_DEVICE_ID = $F2;</code>
 +
| Get Device ID (Data: None) (See: http://wiki.osdev.org/%228042%22_PS/2_Controller#Detecting_PS.2F2_Device_Types)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_REMOTE_MODE = $F0;</code>
 +
| Set Remote Mode (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_WRAP_MODE = $EE;</code>
 +
| Set Wrap Mode (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESET_WRAP_MODE = $EC;</code>
 +
| Reset Wrap Mode (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_READ_DATA = $EB;</code>
 +
| Read Data (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_STREAM_MODE = $EA;</code>
 +
| Set Stream Mode (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_STATUS_REQUEST = $E9;</code>
 +
| Status Request (Data: None)
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SET_RESOLUTION = $E8;</code>
 +
| Set Resolution (Data: See below)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_10 = 10;</code>
 +
| 10 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_20 = 20;</code>
 +
| 20 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_40 = 40;</code>
 +
| 40 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_60 = 60;</code>
 +
| 60 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_80 = 80;</code>
 +
| 80 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_100 = 100;</code>
 +
| 100 samples/sec
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_SAMPLE_RATE_200 = 200;</code>
 +
| 200 samples/sec
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESOLUTION_1 = $00;</code>
 +
| 1 count/mm
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESOLUTION_2 = $01;</code>
 +
| 2 count/mm
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESOLUTION_4 = $02;</code>
 +
| 4 count/mm
 +
|-
 +
| <code>PS2_MOUSE_COMMAND_RESOLUTION_5 = $03;</code>
 +
| 8 count/mm
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 response constants''' <code> PS2_RESPONSE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_RESPONSE_NONE = $00;</code>
 +
| Key detection error or internal buffer overrun
 +
|-
 +
| <code>PS2_RESPONSE_SELF_TEST_PASS = $AA;</code>
 +
| Self test passed (sent after "0xFF (reset)" command or keyboard power up)
 +
|-
 +
| <code>PS2_RESPONSE_ECHO = $EE;</code>
 +
| Response to "0xEE (echo)" command
 +
|-
 +
| <code>PS2_RESPONSE_ACK = $FA;</code>
 +
| Command acknowledged (ACK)
 +
|-
 +
| <code>PS2_RESPONSE_SELFTEST_FAIL1 = $FC;</code>
 +
| Self test failed (sent after "0xFF (reset)" command or keyboard power up)
 +
|-
 +
| <code>PS2_RESPONSE_SELFTEST_FAIL2 = $FD;</code>
 +
| Self test failed (sent after "0xFF (reset)" command or keyboard power up)
 +
|-
 +
| <code>PS2_RESPONSE_RESEND = $FE;</code>
 +
| Resend (keyboard wants controller to repeat last command it sent)
 +
|-
 +
| <code>PS2_RESPONSE_ERROR = $FF;</code>
 +
| Key detection error or internal buffer overrun
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 mouse packets''' <code> PS2_MOUSE_BITS_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_MOUSE_BITS_YO = (1 shl 7);</code>
 +
| Y-Axis Overflow
 +
|-
 +
| <code>PS2_MOUSE_BITS_XO = (1 shl 6);</code>
 +
| X-Axis Overflow
 +
|-
 +
| <code>PS2_MOUSE_BITS_YS = (1 shl 5);</code>
 +
| Y-Axis Sign Bit (9-Bit Y-Axis Relative Offset)
 +
|-
 +
| <code>PS2_MOUSE_BITS_XS = (1 shl 4);</code>
 +
| X-Axis Sign Bit (9-Bit X-Axis Relative Offset)
 +
|-
 +
| <code>PS2_MOUSE_BITS_AO = (1 shl 3);</code>
 +
| Always One
 +
|-
 +
| <code>PS2_MOUSE_BITS_BM = (1 shl 2);</code>
 +
| Button Middle (Normally Off = 0)
 +
|-
 +
| <code>PS2_MOUSE_BITS_BR = (1 shl 1);</code>
 +
| Button Right (Normally Off = 0)
 +
|-
 +
| <code>PS2_MOUSE_BITS_BL = (1 shl 0);</code>
 +
| Button Left (Normally Off = 0)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard scancode types''' <code> PS2_SCANCODE_MAKE* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_SCANCODE_MAKE = 0;</code>
 +
| Key Down (Press)
 +
|-
 +
| <code>PS2_SCANCODE_BREAK = 1;</code>
 +
| Key Up (Release)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''PS2 keyboard scancode counts''' <code> PS2_SCANCODE_*_COUNT </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PS2_SCANCODE_PC104_COUNT = 104;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PS2_SCANCODE_ACPI_COUNT = 3;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PS2_SCANCODE_MULTIMEDIA_COUNT = 18;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PS2_SCANCODE_COUNT = PS2_SCANCODE_PC104_COUNT + PS2_SCANCODE_ACPI_COUNT + PS2_SCANCODE_MULTIMEDIA_COUNT;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''PS2 scancode data'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PPS2ScancodeData = ^TPS2ScancodeData;</code>
 +
 
 +
<code>TPS2ScancodeData = array[0..(PS2_SCANCODE_COUNT * 2) - 1] of array[0..9] of Byte;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>NAME_</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Keyboard scancode'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PPS2KeyboardScancode = ^TPS2KeyboardScancode;</code>
 +
 
 +
<code>TPS2KeyboardScancode = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>ScancodeSet:Byte;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Scancode:array[0..7] of Byte;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Mouse packet types'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PPS2MousePacket = ^TPS2MousePacket;</code>
 +
 
 +
<code>TPS2MousePacket = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MouseBits:Byte;</code>
 +
| Bits (See PS2_MOUSE_BITS_* above)
 +
|-
 +
| <code>MouseX:Byte;</code>
 +
| X-Axis Movement Value (Relative)
 +
|-
 +
| <code>MouseY:Byte;</code>
 +
| Y-Axis Movement Value (Relative)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
''None defined''
  
 
=== Function declarations ===
 
=== Function declarations ===
 
----
 
----
  
''To be documented''
 
  
 +
'''PS2 helper 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 KeyboardLEDsToPS2LEDs(LEDs:LongWord; var PS2LEDs:Byte):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Map the Keyboard LED values to the PS/2 Keyboard LED values</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</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 KeyboardRateAndDelayToPS2Typematic(Rate,Delay:LongWord; var PS2Typematic:Byte):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Translate the Keyboard Repeat Rate and Delay values to the PS/2 Keyboard Typematic value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</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 PS2KeyboardScancodeMatch(KeyboardScancode:PPS2KeyboardScancode; var Index:LongInt):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check a set of scancode bytes against the specified PS/2 Scancode set for a match</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</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 PS2KeyboardScancodeToScanCode(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var ScanCode:Word):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Return the Keyboard Scan Code value for a PS/2 scancode value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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)
 +
|-
 +
|}
 +
</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 PS2KeyboardScancodeToModifiers(KeyboardScancode:PPS2KeyboardScancode; Index:LongInt; var Modifiers:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Return the Keyboard Modifiers flags for a PS/2 scancode value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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)
 +
|-
 +
|}
 +
</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 MouseSampleRateToPS2SampleRate(Rate:LongWord; var PS2Rate:Byte):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Translate a Mouse Sample Rate value to the PS/2 Mouse Sample Rate value</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</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 PS2MousePacketToMouseData(MousePacket:PPS2MousePacket; MouseData:PMouseData; Flags: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 class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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)
 +
|-
 +
! '''Return'''
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
Return to [[Unit_Reference|Unit Reference]]
 
Return to [[Unit_Reference|Unit Reference]]

Revision as of 06:10, 24 April 2017

Return to Unit Reference


Description


PS2 Keyboard/Mouse Controller Support unit

This unit provides supporting functions and defintions 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:LongWord):LongWord;
Description: Translate a PS/2 Mouse Packet into a Mouse Data structure


Return to Unit Reference