Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::drivers::peripherals::KeyboardInterpreter Class Reference

Interprets the scan codes from the keyboard. More...

#include <keyboard.h>

Inheritance diagram for MaxOS::drivers::peripherals::KeyboardInterpreter:
MaxOS::common::InputStreamEventHandler< uint8_t > MaxOS::common::EventManager< KeyboardEvents > MaxOS::drivers::peripherals::KeyboardInterpreterEN_US

Public Member Functions

 KeyboardInterpreter ()
 Construct a new Keyboard Interpreter object.
 
void on_key_read (bool, const KeyboardState &, KeyCode)
 Handle the key event.
 
- Public Member Functions inherited from MaxOS::common::InputStreamEventHandler< uint8_t >
 InputStreamEventHandler ()
 _______________________________________________TEMPLATES_________________________________________________________________///
 
 ~InputStreamEventHandler ()
 Destroys the InputStreamProcessor and disconnects it from all streams.
 
virtual void on_stream_read (uint8_t)
 Called when data is read from a stream (overridden by subclasses)
 
virtual void on_end_of_stream (GenericInputStream< uint8_t > *)
 Called when a stream has finished. Removes the stream from the array of streams.
 
- Public Member Functions inherited from MaxOS::common::EventManager< KeyboardEvents >
void connect_event_handler (EventHandler< KeyboardEvents > *handler)
 connect an event handler to the event manager if it is not already connected
 
void disconnect_event_handler (EventHandler< KeyboardEvents > *handler)
 disconnect an event handler from the event manager if it is connected
 
Vector< Event< KeyboardEvents > * > raise_event (Event< KeyboardEvents > *event)
 Calls the on_event function of all the event m_handlers connected to the event manager and returns a list of the results.
 

Protected Attributes

KeyboardState m_keyboard_state
 The current state of what special keys are pressed on the keyboard.
 
bool m_next_is_first_extended_code = false
 If true, the next code should be interpreted as an extended code (set when receiving 0xE0)
 
uint8_t m_extended_scan_code_bytes = 0
 How many bytes are left to read for the current extended scan code.
 
uint16_t m_extended_code_buffer = 0
 The storage for scan codes that take more than one byte.
 
- Protected Attributes inherited from MaxOS::common::InputStreamEventHandler< uint8_t >
common::Vector< GenericInputStream< uint8_t > * > m_generic_input_streams
 List of streams being observed by this handler.
 
- Protected Attributes inherited from MaxOS::common::EventManager< KeyboardEvents >
Vector< EventHandler< KeyboardEvents > * > m_handlers
 

Detailed Description

Interprets the scan codes from the keyboard.

Definition at line 289 of file keyboard.h.

Constructor & Destructor Documentation

◆ KeyboardInterpreter()

KeyboardInterpreter::KeyboardInterpreter ( )

Construct a new Keyboard Interpreter object.

Definition at line 128 of file keyboard.cpp.

130{
131
132}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22

Member Function Documentation

◆ on_key_read()

void KeyboardInterpreter::on_key_read ( bool  released,
const KeyboardState state,
KeyCode  key_code 
)

Handle the key event.

Parameters
releasedTrue if the key was released, false if it was pressed
stateThe state of the keyboard
key_codeThe key code of the key

Definition at line 143 of file keyboard.cpp.

143 {
144
145 // Pass the key event to the handlers
146 if (released)
147 raise_event(new KeyUpEvent(key_code, state));
148 else
149 raise_event(new KeyDownEvent(key_code, state));
150
151}
Vector< Event< KeyboardEvents > * > raise_event(Event< KeyboardEvents > *event)
Calls the on_event function of all the event m_handlers connected to the event manager and returns a ...
Event that is triggered when a key is pressed.
Definition keyboard.h:261
Event that is triggered when a key is released.
Definition keyboard.h:248

References MaxOS::common::EventManager< KeyboardEvents >::raise_event().

Referenced by MaxOS::drivers::peripherals::KeyboardInterpreterEN_US::on_stream_read().

Member Data Documentation

◆ m_extended_code_buffer

uint16_t MaxOS::drivers::peripherals::KeyboardInterpreter::m_extended_code_buffer = 0
protected

The storage for scan codes that take more than one byte.

Definition at line 296 of file keyboard.h.

Referenced by MaxOS::drivers::peripherals::KeyboardInterpreterEN_US::on_stream_read().

◆ m_extended_scan_code_bytes

uint8_t MaxOS::drivers::peripherals::KeyboardInterpreter::m_extended_scan_code_bytes = 0
protected

How many bytes are left to read for the current extended scan code.

Definition at line 295 of file keyboard.h.

Referenced by MaxOS::drivers::peripherals::KeyboardInterpreterEN_US::on_stream_read().

◆ m_keyboard_state

KeyboardState MaxOS::drivers::peripherals::KeyboardInterpreter::m_keyboard_state
protected

The current state of what special keys are pressed on the keyboard.

Definition at line 292 of file keyboard.h.

Referenced by MaxOS::drivers::peripherals::KeyboardInterpreterEN_US::on_stream_read().

◆ m_next_is_first_extended_code

bool MaxOS::drivers::peripherals::KeyboardInterpreter::m_next_is_first_extended_code = false
protected

If true, the next code should be interpreted as an extended code (set when receiving 0xE0)

Definition at line 294 of file keyboard.h.

Referenced by MaxOS::drivers::peripherals::KeyboardInterpreterEN_US::on_stream_read().


The documentation for this class was generated from the following files: