get dirty
[winnie] / src / fbdev / event.cc
1 #ifdef WINNIE_FBDEV
2 #include <stdio.h>
3
4 #include <errno.h>
5 #include <unistd.h>
6 #include <sys/select.h>
7
8 #include "event.h"
9 #include "wm.h"
10 #include "keyboard.h"
11 #include "mouse.h"
12
13 void process_events()
14 {
15         int keyb_fd = get_keyboard_fd();
16         int mouse_fd = get_mouse_fd();
17
18         for(;;) {
19                 wm->process_windows();
20
21                 fd_set read_set;
22
23                 FD_ZERO(&read_set);
24                 FD_SET(keyb_fd, &read_set);
25                 FD_SET(mouse_fd, &read_set);
26
27                 int maxfd = keyb_fd > mouse_fd ? keyb_fd : mouse_fd;
28
29                 while(select(maxfd + 1, &read_set, 0, 0, 0) == -1 && errno == EINTR);
30
31                 if(FD_ISSET(keyb_fd, &read_set)) {
32                         process_keyboard_event();
33                 }
34                 if(FD_ISSET(mouse_fd, &read_set)) {
35                         process_mouse_event();
36                 }
37         }
38 }
39 #endif // WINNIE_FBDEV