12using namespace MaxOS::common;
13using namespace MaxOS::drivers;
14using namespace MaxOS::drivers::peripherals;
15using namespace MaxOS::hardwarecommunication;
17MouseEventHandler::MouseEventHandler() =
default;
28 case MouseEvents::MOVE:
33 case MouseEvents::DOWN:
74MouseEventHandler::~MouseEventHandler() =
default;
86MouseDriver::~MouseDriver() =
default;
94 command_port.
write(0x20);
98 command_port.
write(0x60);
99 data_port.
write(status);
102 command_port.
write(0xAB);
105 command_port.
write(0xD4);
106 data_port.
write(0xF4);
113void MouseDriver::handle_interrupt() {
121 m_buffer[m_offset] = data_port.
read();
122 m_offset = (m_offset + 1) % 3;
129 if(m_buffer[1] != 0 || m_buffer[2] != 0)
133 for(
int i = 0; i < 3; ++i) {
136 if((m_buffer[0] & (0x1 << i)) == (m_buttons & (0x1 << i)))
140 bool is_pressed = (m_buttons & (0x1 << i)) != 0;
147 m_buttons = m_buffer[0];
170MouseUpEvent::~MouseUpEvent() =
default;
182MouseDownEvent::~MouseDownEvent() =
default;
196MouseMoveEvent::~MouseMoveEvent() =
default;
Vector< Event< MouseEvents > * > raise_event(Event< MouseEvents > *event)
Calls the on_event function of all the event m_handlers connected to the event manager and returns a ...
Used to store information about an event, has a type and a return value.
Stores the left, top, width and height of a rectangle.
Event that is triggered when a mouse button is pressed, holds the button that was pressed.
MouseDownEvent(uint8_t)
Constructor for the MouseDownEvent class.
void activate() final
activate the mouse
MouseDriver()
Constructs a new MouseDriver object and registers it as an interrupt handler for interrupt 0x2C.
string device_name() final
Get the name of the device.
virtual void on_mouse_down_event(uint8_t button)
Called when the mouse is pressed.
virtual void on_mouse_up_event(uint8_t button)
Called when the mouse is released.
virtual void on_mouse_move_event(int8_t x, int8_t y)
Called when the mouse is moved.
common::Event< MouseEvents > * on_event(common::Event< MouseEvents > *) override
Handles the triggered event and calls the appropriate function.
Event that is triggered when the mouse moves, holds the x and y coordinates.
MouseMoveEvent(int8_t x, int8_t y)
Constructor for the MouseMoveEvent class.
Event that is triggered when a mouse button is released, holds the button that was released.
MouseUpEvent(uint8_t)
Constructor for the MouseUpEvent class.
Handles a certain interrupt number.
virtual uint8_t read()
read a byte from the port
virtual void write(uint8_t data)
write a byte to the port
Defines a MouseDriver for handling PS/2 mouse input and generating mouse events.
MouseEvents
The different types of mouse events that can be triggered.