Max OS 0.3
Loading...
Searching...
No Matches
mouse.h
Go to the documentation of this file.
1
9#ifndef MAX_OS_DRIVERS_PERIPHERALS_MOUSE_H
10#define MAX_OS_DRIVERS_PERIPHERALS_MOUSE_H
11
12
13#include <cstdint>
14#include <common/vector.h>
15#include <common/string.h>
16#include <common/eventHandler.h>
19#include <drivers/driver.h>
20
21
22namespace MaxOS::drivers::peripherals {
23
28 enum class MouseEvents {
29 MOVE,
30 DOWN,
31 UP
32 };
33
38 class MouseMoveEvent : public common::Event<MouseEvents> {
39 public:
40 int8_t x;
41 int8_t y;
42 MouseMoveEvent(int8_t x, int8_t y);
44 };
45
50 class MouseDownEvent : public common::Event<MouseEvents> {
51 public:
52 uint8_t button;
53 explicit MouseDownEvent(uint8_t);
55 };
56
61 class MouseUpEvent : public common::Event<MouseEvents> {
62 public:
63 uint8_t button;
64 explicit MouseUpEvent(uint8_t);
66 };
67
72 class MouseEventHandler : public common::EventHandler<MouseEvents> {
73
74 public:
77
80
81 virtual void on_mouse_down_event(uint8_t button);
82 virtual void on_mouse_up_event(uint8_t button);
83 virtual void on_mouse_move_event(int8_t x, int8_t y);
84 };
85
91
92 private:
95
96 void handle_interrupt() final;
97
98 uint8_t m_buffer[3] = { };
99 uint8_t m_offset = 0;
100 uint8_t m_buttons = 0;
101
102 public:
103 MouseDriver();
104 ~MouseDriver();
105
106 void activate() final;
107 string device_name() final;
108 };
109}
110
111
112#endif //MAX_OS_DRIVERS_PERIPHERALS_MOUSE_H
Used to handle an event.
Manages the m_handlers for a type of event, raises events and calls the m_handlers.
Used to store information about an event, has a type and a return value.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
base class for all drivers, handles the activation, deactivation, initialisation and reset of the dri...
Definition driver.h:27
Event that is triggered when a mouse button is pressed, holds the button that was pressed.
Definition mouse.h:50
uint8_t button
The button that was pressed.
Definition mouse.h:52
Driver for the PS/2 mouse, manages the mouse and triggers events when the mouse moves or a button is ...
Definition mouse.h:90
void activate() final
activate the mouse
Definition mouse.cpp:91
MouseDriver()
Constructs a new MouseDriver object and registers it as an interrupt handler for interrupt 0x2C.
Definition mouse.cpp:79
string device_name() final
Get the name of the device.
Definition mouse.cpp:155
Handles events that are triggered by the mouse driver.
Definition mouse.h:72
virtual void on_mouse_down_event(uint8_t button)
Called when the mouse is pressed.
Definition mouse.cpp:51
virtual void on_mouse_up_event(uint8_t button)
Called when the mouse is released.
Definition mouse.cpp:60
virtual void on_mouse_move_event(int8_t x, int8_t y)
Called when the mouse is moved.
Definition mouse.cpp:70
common::Event< MouseEvents > * on_event(common::Event< MouseEvents > *) override
Handles the triggered event and calls the appropriate function.
Definition mouse.cpp:25
Event that is triggered when the mouse moves, holds the x and y coordinates.
Definition mouse.h:38
int8_t x
The x coordinate of the mouse.
Definition mouse.h:40
int8_t y
The y coordinate of the mouse.
Definition mouse.h:41
Event that is triggered when a mouse button is released, holds the button that was released.
Definition mouse.h:61
uint8_t button
The button that was released.
Definition mouse.h:63
Handles a certain interrupt number.
Definition interrupts.h:30
Defines a base Driver class and DriverManager for managing drivers.
Defines classes for handling events and event managers.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
MouseEvents
The different types of mouse events that can be triggered.
Definition mouse.h:28
Defines classes for handling hardware communication ports (8, 16, and 32 bit)
Defines a String class for dynamically sized strings with various operations.
Defines a Vector class for dynamically storing an array of elements.