2 ** Copyright 2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
6 #include <sys/syscalls.h>
10 #include <win/Event.h>
11 using namespace os::gui
;
13 #include "InputServer.h"
14 #include "KeyboardDevice.h"
15 #include "PS2Device.h"
17 InputServer::InputServer()
19 mEventPort
= _kern_port_create(64, "input_event_port");
20 mLock
= _kern_sem_create(1, "input_event_lock");
23 InputServer::~InputServer()
25 _kern_port_delete(mEventPort
);
26 _kern_sem_delete(mLock
);
29 int InputServer::FindDevices()
33 // for now we'll just cycle through every possible type
34 fd
= open("/dev/keyboard", 0);
36 InputDevice
*dev
= new KeyboardDevice(fd
, this);
41 fd
= open("/dev/ps2mouse", 0);
43 InputDevice
*dev
= new PS2Device(fd
, this);
51 void InputServer::PostEvent(const Event
&event
)
53 _kern_sem_acquire(mLock
, 1);
56 printf("InputServer::PostEvent: what %d ", event
.what
);
60 printf("key 0x%x mod 0x%x\n", event
.key
, event
.modifiers
);
63 printf("x %d y %d mod 0x%x\n", event
.x
, event
.y
, event
.modifiers
);
66 printf("unknown format\n");
70 _kern_port_write(mEventPort
, 0, const_cast<Event
*>(&event
), sizeof(event
));
72 _kern_sem_release(mLock
, 1);
75 int InputServer::Run()