Class Keyboard_Controller

Class Keyboard_Controller

Placement in the overall structure

Module
machine
Base classes
None
Derived classes
Keyboard (Task 2)
Time of creation
Task 1
Files
keyctrl.h keyctrl.cc

Description

The Keyboard_Controller class is used to initialize the PC keyboard and determine the scan and ASCII code of the pressed key from the make and break codes sent.

Public methods

Keyboard_Controller ()
Keyboard initialization: disables all LEDs and sets the repeat rate to maximum.
Key key_hit ()
Waits until a code is provided in the keyboard controller buffer and then fetches it. If a meaningful interpretation is possible, the scan code, the "modifier" keys (Shift, Ctrl, Alt, Capslock, etc.) that may have been pressed at the same time, and the ASCII code of the key are returned as an object of the class Key. If only one of the special keys Shift, Alt, CapsLock, etc. was pressed, the method returns an invalid Key object. Whether the result is valid or not can be checked with the method Key::valid().
void reboot ()
Reboots the PC. Yes, in a PC the keyboard controller is responsible for this.
set_repeat_rate (int speed, int delay)
Method for setting the keyboard repeat rate. The delay parameter determines how long a key has to be pressed until automatic repetition starts. Accepted values are between 0 (minimal waiting time) and 3 (maximal waiting time). The parameter speed determines how fast the key codes should come in during the repetition phase. Allowed values are between 0 (very fast) and 31 (very slow).
void set_led (char led, bool on)
This method can be used to turn on or off one of the three keyboard LEDs led::caps_lock, led::num_lock or led::scroll_lock.