StuBS
|
PS/2 Controller. More...
Functions | |
static uint8_t | receiveData () |
Receive requested data / answer from the controller (or the PS/2 device) | |
static void | sendCommand (ControllerCommand cmd) |
Send command to the controller by writing it into the command register. | |
static void MAYBE_UNUSED | sendData (uint8_t value) |
Send a command or data to a connected PS/2 device. | |
void | init () |
Initialization of connected devices. | |
bool | fetch (Key &pressed) |
Retrieve the keyboard event. | |
bool | fetch (Pointer &state) |
Retrieve the mouse event. | |
void | setRepeatRate (Speed speed, Delay delay) |
Configure the repeat rate of the keyboard. | |
void | setLed (enum LED led, bool on) |
Enable or disable a keyboard LED. | |
void | drainBuffer () |
Empties the keyboard buffer. | |
Constants | |
static const IOPort | ctrl_port (0x64) |
Access status- (read) and command (write) register. | |
static const IOPort | data_port (0x60) |
Access PS/2 device [keyboard] output- (read) and input (write) buffer. | |
static KeyDecoder | key_decoder |
static MouseDecoder | mouse_decoder |
static uint8_t MAYBE_UNUSED | leds = 0 |
PS/2 Controller.
Initializes the PS/2 devices (Keyboard and optional Mouse), and determines both the scan code and ASCII character of a pressed key from the transmitted make and break codes using the KeyDecoder.
Flags in the PS/2 controller status register.
Commands to be send to the Keyboard.
Commands for the PS/2 Controller.
These commands are processed by the controller and not send to keyboard/mouse. They have to be written into the command register.
Commands to be send to the mouse.
Repeat Rate of Characters.
Receive requested data / answer from the controller (or the PS/2 device)
|
static |
Send command to the controller by writing it into the command register.
cmd | Controller command |
|
static |
Send a command or data to a connected PS/2 device.
The value must only be written into the input buffer after the previously written values have been fetched (INPUT_PENDING in the status register).
value | data to be sent |
void PS2Controller::init | ( | ) |
Initialization of connected devices.
All status LEDs of the keyboard are switched off and the repetition rate is set to maximum speed.
Retrieve the keyboard event.
Retrieves make and brake events from the keyboard. If a valid (non special) key was pressed, the scan code is determined using KeyDecoder::decode into a Key object. Events on special keys like Shift, Alt, CapsLock etc. are stored (in KeyDecoder) and applied on subsequent keystrokes, while no valid key is retrieved.
Mouse events are ignored.
pressed | Reference to an object which will contain the pressed Key on success |
true
if a valid key was decoded Retrieve the mouse event.
If a full mouse state was retrieved (all 3 packets have been successfully processed by the MouseDecoder) the new state is retrieved. Keyboard events are not processed.
state | Reference to an object which will contain the Mouse Pointer state on success |
true
if a valid mouse pointer state was decoded Configure the repeat rate of the keyboard.
delay | configures how long a key must be pressed before the repetition begins. |
speed | determines how fast the key codes should follow each other. Valid values are between 0 (30 characters per second) and 31 (2 characters per second). |
Enable or disable a keyboard LED.
led | LED to enable or disable |
on | true will enable the specified LED, false disable |
void PS2Controller::drainBuffer | ( | ) |
Empties the keyboard buffer.
The keyboard may not send any interrupts if the buffer is not empty. To prevent unhandled keystrokes (for example during boot) the buffer should be emptied once right before allowing keyboard interrupts (even if keystrokes might be lost).
Access status- (read) and command (write) register.
Access PS/2 device [keyboard] output- (read) and input (write) buffer.
|
static |
|
static |
|
static |