Rev 3425 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3425 | Rev 4377 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | 55 | ||
56 | #include "input.h" |
56 | #include "input.h" |
57 | #include "tetris.h" |
57 | #include "tetris.h" |
58 | 58 | ||
59 | #include <async.h> |
59 | #include <async.h> |
60 | #include "../../srv/console/console.h" |
60 | #include <ipc/console.h> |
- | 61 | #include <console.h> |
|
- | 62 | #include <kbd/kbd.h> |
|
61 | 63 | ||
62 | /* return true iff the given timeval is positive */ |
64 | /* return true iff the given timeval is positive */ |
63 | #define TV_POS(tv) \ |
65 | #define TV_POS(tv) \ |
64 | ((tv)->tv_sec > 0 || ((tv)->tv_sec == 0 && (tv)->tv_usec > 0)) |
66 | ((tv)->tv_sec > 0 || ((tv)->tv_sec == 0 && (tv)->tv_usec > 0)) |
65 | 67 | ||
Line 109... | Line 111... | ||
109 | s = &endtv; |
111 | s = &endtv; |
110 | } else |
112 | } else |
111 | s = NULL; |
113 | s = NULL; |
112 | 114 | ||
113 | if (!lastchar) { |
115 | if (!lastchar) { |
- | 116 | again: |
|
114 | if (!getchar_inprog) { |
117 | if (!getchar_inprog) { |
115 | cons_phone = get_cons_phone(); |
118 | cons_phone = console_open(true); |
116 | getchar_inprog = async_send_2(cons_phone, |
119 | getchar_inprog = async_send_2(cons_phone, |
117 | CONSOLE_GETCHAR, 0, 0, &charcall); |
120 | CONSOLE_GETKEY, 0, 0, &charcall); |
118 | } |
121 | } |
119 | if (!s) |
122 | if (!s) |
120 | async_wait_for(getchar_inprog, &rc); |
123 | async_wait_for(getchar_inprog, &rc); |
121 | else if (async_wait_timeout(getchar_inprog, &rc, s->tv_usec) == ETIMEOUT) { |
124 | else if (async_wait_timeout(getchar_inprog, &rc, s->tv_usec) == ETIMEOUT) { |
122 | tvp->tv_sec = 0; |
125 | tvp->tv_sec = 0; |
Line 125... | Line 128... | ||
125 | } |
128 | } |
126 | getchar_inprog = 0; |
129 | getchar_inprog = 0; |
127 | if (rc) { |
130 | if (rc) { |
128 | stop("end of file, help"); |
131 | stop("end of file, help"); |
129 | } |
132 | } |
- | 133 | if (IPC_GET_ARG1(charcall) == KE_RELEASE) |
|
- | 134 | goto again; |
|
- | 135 | ||
130 | lastchar = IPC_GET_ARG1(charcall); |
136 | lastchar = IPC_GET_ARG4(charcall); |
131 | } |
137 | } |
132 | if (tvp) { |
138 | if (tvp) { |
133 | /* since there is input, we may not have timed out */ |
139 | /* since there is input, we may not have timed out */ |
134 | (void) gettimeofday(&endtv, NULL); |
140 | (void) gettimeofday(&endtv, NULL); |
135 | TV_SUB(&endtv, &starttv); |
141 | TV_SUB(&endtv, &starttv); |