mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
Make PS2MouseDevice behave more like a proper character device.
Get rid of the goofy MouseClient interface and have the GUI event loop just read mouse data from the character device. The previous approach was awful as it was sending us into random GUI code in the mouse interrupt handler.
This commit is contained in:
parent
52e019f9aa
commit
fd4e86460b
5 changed files with 31 additions and 36 deletions
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <VirtualFileSystem/CharacterDevice.h>
|
||||
#include "DoubleBuffer.h"
|
||||
#include "IRQHandler.h"
|
||||
|
||||
class MouseClient;
|
||||
|
||||
class PS2MouseDevice final : public IRQHandler, public CharacterDevice {
|
||||
public:
|
||||
PS2MouseDevice();
|
||||
|
@ -12,13 +11,13 @@ public:
|
|||
|
||||
static PS2MouseDevice& the();
|
||||
|
||||
void set_client(MouseClient* client) { m_client = client; }
|
||||
// ^CharacterDevice
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual ssize_t read(byte* buffer, size_t) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t) override;
|
||||
|
||||
private:
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual ssize_t read(byte* buffer, size_t buffer_size) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t buffer_size) override;
|
||||
|
||||
// ^IRQHandler
|
||||
virtual void handle_irq() override;
|
||||
|
||||
void initialize();
|
||||
|
@ -29,13 +28,7 @@ private:
|
|||
void wait_then_write(byte port, byte data);
|
||||
byte wait_then_read(byte port);
|
||||
|
||||
MouseClient* m_client { nullptr };
|
||||
DoubleBuffer m_buffer;
|
||||
byte m_data_state { 0 };
|
||||
signed_byte m_data[3];
|
||||
};
|
||||
|
||||
class MouseClient {
|
||||
public:
|
||||
virtual ~MouseClient();
|
||||
virtual void did_receive_mouse_data(int dx, int dy, bool left_button, bool right_button) = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue