mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-27 01:56:21 +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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user