1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +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:
Andreas Kling 2019-01-12 05:20:56 +01:00
parent 52e019f9aa
commit fd4e86460b
5 changed files with 31 additions and 36 deletions

View file

@ -2,6 +2,11 @@
#include "Event.h"
#include "Object.h"
#include "WindowManager.h"
#include "AbstractScreen.h"
#ifdef SERENITY
#include "PS2MouseDevice.h"
#endif
static EventLoop* s_mainEventLoop;
@ -60,6 +65,13 @@ void EventLoop::postEvent(Object* receiver, OwnPtr<Event>&& event)
#ifdef SERENITY
void EventLoop::waitForEvent()
{
auto& mouse = PS2MouseDevice::the();
while (mouse.has_data_available_for_reading()) {
signed_byte data[3];
ssize_t nread = mouse.read((byte*)data, 3);
ASSERT(nread == 3);
AbstractScreen::the().on_receive_mouse_data(data[1], -data[2], data[0] & 1, data[0] & 2);
}
}
#endif