summaryrefslogtreecommitdiff
path: root/Kernel/PS2MouseDevice.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-12 05:20:56 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-12 05:23:16 +0100
commitfd4e86460bd54acd1ff80688e7dde6ad4aed4beb (patch)
treeab879147e4b55e4e0effa190e9b6a8be4f22b270 /Kernel/PS2MouseDevice.h
parent52e019f9aa39be08ac3c178f046e60841159c0aa (diff)
downloadserenity-fd4e86460bd54acd1ff80688e7dde6ad4aed4beb.zip
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.
Diffstat (limited to 'Kernel/PS2MouseDevice.h')
-rw-r--r--Kernel/PS2MouseDevice.h21
1 files changed, 7 insertions, 14 deletions
diff --git a/Kernel/PS2MouseDevice.h b/Kernel/PS2MouseDevice.h
index 9ed7770499..3c8d77f664 100644
--- a/Kernel/PS2MouseDevice.h
+++ b/Kernel/PS2MouseDevice.h
@@ -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; }
-
-private:
+ // ^CharacterDevice
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;
+ virtual ssize_t read(byte* buffer, size_t) override;
+ virtual ssize_t write(const byte* buffer, size_t) override;
+private:
+ // ^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;
-};