keyboard.bas

Contains a standard AT keyboard driver

Author

Marcel Sondaar

License

Public Domain

Summary
keyboard.basContains a standard AT keyboard driver
Variables
buttonsStores the up/down values for all of the keys
keycodesStores the last 64 keyboard events
lastkeycounterStores the keypress counter
LastReadStores the last byte read from the keyboard controller
Functions
ModMainContains the driver’s startup code
handlerhandles the incoming calls
handlerstubconverts the register calling convention into a FB-compatible convention
ReadKeyboardreads a keypress from the kbc and adjusts the state accordingly

Variables

buttons

Dim Shared buttons(to 255) As Long

Stores the up/down values for all of the keys

keycodes

Dim Shared keycodes(to 63) As Long

Stores the last 64 keyboard events

lastkeycounter

Dim Shared lastkeycounter As Long

Stores the keypress counter

LastRead

Dim Shared LastRead As Unsigned Byte

Stores the last byte read from the keyboard controller

Functions

ModMain

Sub ModMain CDecl Alias "main" ()

Contains the driver’s startup code

handler

Sub handler (ByVal f As Long,
ByVal button As Long,
ByVal state As Long,
ByVal x As Long)

handles the incoming calls

in

ffirst (mangled) parameter
buttonsecond parameter
statethird parameter
xfourth parameter

out

ffirst return paramter (success value)
buttonsecond return parameter
statethird return parameter
xfourth return parameter

handlerstub

Sub handlerstub()

converts the register calling convention into a FB-compatible convention

ReadKeyboard

Sub ReadKeyboard()

reads a keypress from the kbc and adjusts the state accordingly

a byte is read and acknowledged, and if it equals e0, another byte is read and acked. then the msb of the last byte is set it is a release, and if its clear its a press the presence of e0 tells us wether it is an extended key or not.

Dim Shared buttons(to 255) As Long
Stores the up/down values for all of the keys
Dim Shared keycodes(to 63) As Long
Stores the last 64 keyboard events
Dim Shared lastkeycounter As Long
Stores the keypress counter
Dim Shared LastRead As Unsigned Byte
Stores the last byte read from the keyboard controller
Sub ModMain CDecl Alias "main" ()
Contains the driver’s startup code
Sub handler (ByVal f As Long,
ByVal button As Long,
ByVal state As Long,
ByVal x As Long)
handles the incoming calls
Sub handlerstub()
converts the register calling convention into a FB-compatible convention
Sub ReadKeyboard()
reads a keypress from the kbc and adjusts the state accordingly