Rev 4317 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4317 | Rev 4488 | ||
---|---|---|---|
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 <vfs/vfs.h> |
|
- | 61 | #include <io/console.h> |
|
60 | #include <ipc/console.h> |
62 | #include <ipc/console.h> |
61 | #include <console.h> |
- | |
62 | #include <kbd/kbd.h> |
- | |
63 | 63 | ||
64 | /* return true iff the given timeval is positive */ |
64 | /* return true iff the given timeval is positive */ |
65 | #define TV_POS(tv) \ |
65 | #define TV_POS(tv) \ |
66 | ((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)) |
67 | 67 | ||
Line 96... | Line 96... | ||
96 | rwait(struct timeval *tvp) |
96 | rwait(struct timeval *tvp) |
97 | { |
97 | { |
98 | struct timeval starttv, endtv, *s; |
98 | struct timeval starttv, endtv, *s; |
99 | static ipc_call_t charcall; |
99 | static ipc_call_t charcall; |
100 | ipcarg_t rc; |
100 | ipcarg_t rc; |
101 | int cons_phone; |
- | |
102 | 101 | ||
103 | /* |
102 | /* |
104 | * Someday, select() will do this for us. |
103 | * Someday, select() will do this for us. |
105 | * Just in case that day is now, and no one has |
104 | * Just in case that day is now, and no one has |
106 | * changed this, we use a temporary. |
105 | * changed this, we use a temporary. |
Line 113... | Line 112... | ||
113 | s = NULL; |
112 | s = NULL; |
114 | 113 | ||
115 | if (!lastchar) { |
114 | if (!lastchar) { |
116 | again: |
115 | again: |
117 | if (!getchar_inprog) { |
116 | if (!getchar_inprog) { |
118 | cons_phone = console_open(true); |
- | |
119 | getchar_inprog = async_send_2(cons_phone, |
117 | getchar_inprog = async_send_0(fphone(stdin), |
120 | CONSOLE_GETKEY, 0, 0, &charcall); |
118 | CONSOLE_GET_EVENT, &charcall); |
121 | } |
119 | } |
122 | if (!s) |
120 | if (!s) |
123 | async_wait_for(getchar_inprog, &rc); |
121 | async_wait_for(getchar_inprog, &rc); |
124 | else if (async_wait_timeout(getchar_inprog, &rc, s->tv_usec) == ETIMEOUT) { |
122 | else if (async_wait_timeout(getchar_inprog, &rc, s->tv_usec) == ETIMEOUT) { |
125 | tvp->tv_sec = 0; |
123 | tvp->tv_sec = 0; |
126 | tvp->tv_usec = 0; |
124 | tvp->tv_usec = 0; |
127 | return (0); |
125 | return (0); |
128 | } |
126 | } |
129 | getchar_inprog = 0; |
127 | getchar_inprog = 0; |
130 | if (rc) { |
128 | if (rc) { |
131 | stop("end of file, help"); |
129 | stop("end of file, help"); |
132 | } |
130 | } |
133 | if (IPC_GET_ARG1(charcall) == KE_RELEASE) |
131 | if (IPC_GET_ARG1(charcall) == KEY_RELEASE) |
134 | goto again; |
132 | goto again; |
135 | 133 | ||
136 | lastchar = IPC_GET_ARG4(charcall); |
134 | lastchar = IPC_GET_ARG4(charcall); |
137 | } |
135 | } |
138 | if (tvp) { |
136 | if (tvp) { |