diff options
Diffstat (limited to 'apps/wm/wm.c')
-rw-r--r-- | apps/wm/wm.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/apps/wm/wm.c b/apps/wm/wm.c index b248bc2..49913dc 100644 --- a/apps/wm/wm.c +++ b/apps/wm/wm.c @@ -335,7 +335,7 @@ static void handle_event_keyboard(struct event_keyboard *event) else ch = keymap->map[event->scancode]; - (void)ch; + UNUSED(ch); } static void handle_event_mouse(struct event_mouse *event) @@ -518,33 +518,34 @@ int main(int argc, char **argv) gfx_load_wallpaper(&cursor->ctx, "/res/cursor.png"); window_redraw(wallpaper); - /* u8 msg[1024] = { 0 }; */ - /* struct event_keyboard event_keyboard = { 0 }; */ - /* struct event_mouse event_mouse = { 0 }; */ - /* const char *listeners[] = { "/dev/kbd", "/dev/mouse", "/proc/self/msg", NULL }; */ + u8 msg[1024] = { 0 }; + struct event_keyboard event_keyboard = { 0 }; + struct event_mouse event_mouse = { 0 }; + u32 listeners[] = { IO_KEYBOARD, IO_MOUSE, IO_BUS, 0 }; + while (1) { - /* int poll_ret = 0; */ - /* if (1) { */ - /* if (poll_ret == 0) { */ - /* if (read(listeners[poll_ret], &event_keyboard, 0, */ - /* sizeof(event_keyboard)) > 0) { */ - /* handle_event_keyboard(&event_keyboard); */ - /* continue; */ - /* } */ - /* } else if (poll_ret == 1) { */ - /* if (read(listeners[poll_ret], &event_mouse, 0, */ - /* sizeof(event_mouse)) > 0) { */ - /* handle_event_mouse(&event_mouse); */ - /* continue; */ - /* } */ - /* } else if (poll_ret == 2) { */ - /* if (msg_receive(msg, sizeof(msg)) > 0) { */ - /* handle_message(msg); */ - /* continue; */ - /* } */ - /* } */ - /* } */ - /* panic("Poll/read error: %s\n", strerror(errno)); */ + res poll_ret = 0; + if ((poll_ret = io_poll(listeners)) >= 0) { + if (poll_ret == 0) { + if (io_read(listeners[poll_ret], &event_keyboard, 0, + sizeof(event_keyboard)) > 0) { + handle_event_keyboard(&event_keyboard); + continue; + } + } else if (poll_ret == 1) { + if (io_read(listeners[poll_ret], &event_mouse, 0, + sizeof(event_mouse)) > 0) { + handle_event_mouse(&event_mouse); + continue; + } + } else if (poll_ret == 2) { + if (msg_receive(msg, sizeof(msg)) > 0) { + handle_message(msg); + continue; + } + } + } + panic("Poll/read error: %s\n", strerror(errno)); } return 1; |