16 static int dev_fd = -1;
17 static enum {RAW, CANONICAL} ttystate = CANONICAL;
21 if((dev_fd = open("/dev/tty", O_RDWR)) == -1) {
22 fprintf(stderr, "Cannot open /dev/tty : %s\n", strerror(errno));
28 if(tcgetattr(dev_fd, &buf) < 0) {
29 fprintf(stderr, "Cannot get the tty parameters : %s\n", strerror(errno));
33 buf.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
34 buf.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
35 buf.c_cflag &= ~(CSIZE | PARENB);
37 buf.c_oflag &= ~(OPOST);
39 if(tcsetattr(dev_fd, TCSAFLUSH, &buf) < 0) {
47 void destroy_keyboard()
51 if(tcgetattr(dev_fd, &buf) < 0) {
52 fprintf(stderr, "Cannot get the tty parameters : %s\n", strerror(errno));
55 buf.c_lflag |= (ECHO | ICANON | IEXTEN | ISIG);
56 buf.c_iflag |= (BRKINT | ICRNL | INPCK | ISTRIP | IXON);
57 buf.c_cflag |= (CSIZE | PARENB);
59 buf.c_oflag |= (OPOST);
61 if(tcsetattr(dev_fd, TCSAFLUSH, &buf) < 0) {
62 fprintf(stderr, "Cannot set the tty parameters : %s\n", strerror(errno));
78 void process_keyboard_event()
81 if(read(dev_fd, &key, 1) < 1) {
89 Window *focused_win = wm->get_focused_window();
91 KeyboardFuncType keyb_callback = focused_win->get_keyboard_callback();
93 keyb_callback(focused_win, key, true); //TODO: true??
98 * - handle system-wide key combinations (alt-tab?)
99 * - otherwise send keypress/release to focused window
102 #endif // WINNIE_FBDEV