blob: 20ba6c917b364f024215a4258567956bef49255e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "GUIEventDevice.h"
#include <Kernel/Process.h>
#include <AK/Lock.h>
#include <LibC/errno_numbers.h>
//#define GUIEVENTDEVICE_DEBUG
GUIEventDevice::GUIEventDevice()
: CharacterDevice(66, 1)
{
}
GUIEventDevice::~GUIEventDevice()
{
}
bool GUIEventDevice::can_read(Process& process) const
{
return !process.gui_events().is_empty();
}
ssize_t GUIEventDevice::read(Process& process, byte* buffer, size_t size)
{
#ifdef GUIEVENTDEVICE_DEBUG
dbgprintf("GUIEventDevice::read(): %s<%u>, size=%u, sizeof(GUI_Event)=%u\n", process.name().characters(), process.pid(), size, sizeof(GUI_Event));
#endif
if (process.gui_events().is_empty())
return 0;
LOCKER(process.gui_events_lock());
ASSERT(size == sizeof(GUI_Event));
*reinterpret_cast<GUI_Event*>(buffer) = process.gui_events().take_first();
return size;
}
ssize_t GUIEventDevice::write(Process&, const byte*, size_t)
{
return -EINVAL;
}
|