diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-11 03:52:09 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-11 03:52:09 +0100 |
commit | e5e295052faf8ea1e622c8d67c766f8213c71b81 (patch) | |
tree | 2935e76bd451c0949fd407b4b13f5f6ef7d2b55c /Kernel | |
parent | 31667b47a57c74894d66d7243aae6705898b424c (diff) | |
download | serenity-e5e295052faf8ea1e622c8d67c766f8213c71b81.zip |
Hook up the PS2MouseDevice to the AbstractScreen+WindowManager.
Render the mouse cursor by xor'ing the pixels. I don't know anything about
hardware cursors yet and this way we don't need to recompose the window
hierarchy every time you move the mouse. :^)
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/PS2MouseDevice.cpp | 14 | ||||
-rw-r--r-- | Kernel/PS2MouseDevice.h | 13 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Kernel/PS2MouseDevice.cpp b/Kernel/PS2MouseDevice.cpp index 497c655d04..6ae04de6bc 100644 --- a/Kernel/PS2MouseDevice.cpp +++ b/Kernel/PS2MouseDevice.cpp @@ -1,10 +1,13 @@ #include "PS2MouseDevice.h" #include "IO.h" +static PS2MouseDevice* s_the; + PS2MouseDevice::PS2MouseDevice() : IRQHandler(12) , CharacterDevice(10, 1) { + s_the = this; initialize(); } @@ -12,6 +15,11 @@ PS2MouseDevice::~PS2MouseDevice() { } +PS2MouseDevice& PS2MouseDevice::the() +{ + return *s_the; +} + void PS2MouseDevice::handle_irq() { byte data = IO::in8(0x60); @@ -32,6 +40,8 @@ void PS2MouseDevice::handle_irq() (m_data[0] & 1) ? "Left" : "", (m_data[0] & 2) ? "Right" : "" ); + if (m_client) + m_client->did_receive_mouse_data(m_data[1], -m_data[2], m_data[0] & 1, m_data[0] & 2); break; } } @@ -120,3 +130,7 @@ ssize_t PS2MouseDevice::write(const byte *buffer, size_t buffer_size) ASSERT_NOT_REACHED(); return 0; } + +MouseClient::~MouseClient() +{ +} diff --git a/Kernel/PS2MouseDevice.h b/Kernel/PS2MouseDevice.h index d7587949d4..9ed7770499 100644 --- a/Kernel/PS2MouseDevice.h +++ b/Kernel/PS2MouseDevice.h @@ -3,11 +3,17 @@ #include <VirtualFileSystem/CharacterDevice.h> #include "IRQHandler.h" +class MouseClient; + class PS2MouseDevice final : public IRQHandler, public CharacterDevice { public: PS2MouseDevice(); virtual ~PS2MouseDevice() override; + static PS2MouseDevice& the(); + + void set_client(MouseClient* client) { m_client = client; } + private: virtual bool has_data_available_for_reading() const override; virtual ssize_t read(byte* buffer, size_t buffer_size) override; @@ -23,6 +29,13 @@ private: void wait_then_write(byte port, byte data); byte wait_then_read(byte port); + MouseClient* m_client { nullptr }; 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; +}; |