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

Driver for the PS/2 mouse, manages the mouse and triggers events when the mouse moves or a button is pressed. More...

#include <mouse.h>

Inheritance diagram for MaxOS::drivers::peripherals::MouseDriver:
MaxOS::hardwarecommunication::InterruptHandler MaxOS::drivers::Driver MaxOS::common::EventManager< MouseEvents >

Public Member Functions

 MouseDriver ()
 Constructs a new MouseDriver object and registers it as an interrupt handler for interrupt 0x2C.
 
void activate () final
 activate the mouse
 
string device_name () final
 Get the name of the device.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler
virtual system::cpu_status_thandle_interrupt (system::cpu_status_t *status)
 Handles an interrupt and returns the status.
 
- Public Member Functions inherited from MaxOS::drivers::Driver
virtual void deactivate ()
 Deactivate the driver.
 
virtual void initialise ()
 Initialise the driver.
 
virtual uint32_t reset ()
 Reset the driver.
 
virtual string vendor_name ()
 Get who created the device.
 
- Public Member Functions inherited from MaxOS::common::EventManager< MouseEvents >
void connect_event_handler (EventHandler< MouseEvents > *handler)
 connect an event handler to the event manager if it is not already connected
 
void disconnect_event_handler (EventHandler< MouseEvents > *handler)
 disconnect an event handler from the event manager if it is connected
 
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 list of the results.
 

Additional Inherited Members

- Protected Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler
 InterruptHandler (uint8_t interrupt_number, int64_t redirect=-1, uint64_t redirect_index=0)
 Creates a new interrupt handler and registers it with the interrupt manager.
 
 ~InterruptHandler ()
 Destroys the interrupt handler and unregisters it from the interrupt manager.
 
- Protected Attributes inherited from MaxOS::hardwarecommunication::InterruptHandler
uint8_t m_interrupt_number
 The interrupt number this handler handles.
 
- Protected Attributes inherited from MaxOS::common::EventManager< MouseEvents >
Vector< EventHandler< MouseEvents > * > m_handlers
 

Detailed Description

Driver for the PS/2 mouse, manages the mouse and triggers events when the mouse moves or a button is pressed.

Definition at line 90 of file mouse.h.

Constructor & Destructor Documentation

◆ MouseDriver()

MouseDriver::MouseDriver ( )

Constructs a new MouseDriver object and registers it as an interrupt handler for interrupt 0x2C.

Definition at line 79 of file mouse.cpp.

80 : InterruptHandler(0x2C, 0xC, 0x28),
81 data_port(0x60),
82 command_port(0x64) {
83
84}
Handles a certain interrupt number.
Definition interrupts.h:30

Member Function Documentation

◆ activate()

void MouseDriver::activate ( )
finalvirtual

activate the mouse

Reimplemented from MaxOS::drivers::Driver.

Definition at line 91 of file mouse.cpp.

91 {
92
93 // Get the current state of the mouse
94 command_port.write(0x20);
95 uint8_t status = (data_port.read() | 2);
96
97 // Write the new state
98 command_port.write(0x60);
99 data_port.write(status);
100
101 // Tell the PIC to start listening to the mouse
102 command_port.write(0xAB);
103
104 // Activate the mouse
105 command_port.write(0xD4);
106 data_port.write(0xF4);
107 data_port.read();
108}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
virtual uint8_t read()
read a byte from the port
Definition port.cpp:51
virtual void write(uint8_t data)
write a byte to the port
Definition port.cpp:41

References MaxOS::hardwarecommunication::Port8Bit::read(), and MaxOS::hardwarecommunication::Port8Bit::write().

◆ device_name()

string MouseDriver::device_name ( )
finalvirtual

Get the name of the device.

Returns
The name of the device

Reimplemented from MaxOS::drivers::Driver.

Definition at line 155 of file mouse.cpp.

155 {
156 return "Mouse";
157}

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