Rev 1490 | Rev 1499 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1490 | Rev 1497 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | #include <unistd.h> |
38 | #include <unistd.h> |
39 | #include <async.h> |
39 | #include <async.h> |
40 | #include <libadt/fifo.h> |
40 | #include <libadt/fifo.h> |
41 | #include <screenbuffer.h> |
41 | #include <screenbuffer.h> |
42 | 42 | ||
43 | #define CONSOLE_COUNT 8 |
43 | #define CONSOLE_COUNT 12 |
44 | #define MAX_KEYREQUESTS_BUFFERED 32 |
44 | #define MAX_KEYREQUESTS_BUFFERED 32 |
45 | 45 | ||
46 | #define NAME "CONSOLE" |
46 | #define NAME "CONSOLE" |
47 | 47 | ||
48 | int active_console = 1; |
48 | int active_console = 1; |
Line 87... | Line 87... | ||
87 | ++i; |
87 | ++i; |
88 | } |
88 | } |
89 | return CONSOLE_COUNT; |
89 | return CONSOLE_COUNT; |
90 | } |
90 | } |
91 | 91 | ||
- | 92 | /** Check key and process special keys. |
|
- | 93 | * |
|
- | 94 | * */ |
|
- | 95 | static void write_char(int console, char key) |
|
- | 96 | { |
|
- | 97 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
|
- | 98 | ||
- | 99 | switch (key) { |
|
- | 100 | case '\n': |
|
- | 101 | scr->position_y += 1; |
|
- | 102 | scr->position_x = 0; |
|
- | 103 | break; |
|
- | 104 | case '\r': |
|
- | 105 | break; |
|
- | 106 | case '\t': |
|
- | 107 | scr->position_x += 8; |
|
- | 108 | scr->position_x -= scr->position_x % 8; |
|
- | 109 | break; |
|
- | 110 | case '\b': |
|
- | 111 | if (scr->position_x == 0) |
|
- | 112 | break; |
|
- | 113 | ||
- | 114 | scr->position_x--; |
|
- | 115 | ||
- | 116 | if (console == active_console) { |
|
- | 117 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL); |
|
- | 118 | } |
|
- | 119 | ||
- | 120 | screenbuffer_putchar(scr, ' '); |
|
- | 121 | ||
- | 122 | break; |
|
- | 123 | default: |
|
- | 124 | if (console == active_console) { |
|
- | 125 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL); |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | screenbuffer_putchar(scr, key); |
|
- | 129 | scr->position_x++; |
|
- | 130 | } |
|
- | 131 | ||
- | 132 | scr->position_y += (scr->position_x >= scr->size_x); |
|
- | 133 | ||
- | 134 | if (scr->position_y >= scr->size_y) { |
|
- | 135 | scr->position_y = scr->size_y - 1; |
|
- | 136 | screenbuffer_clear_line(scr, scr->top_line++); |
|
- | 137 | ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL); |
|
- | 138 | } |
|
- | 139 | ||
- | 140 | scr->position_x = scr->position_x % scr->size_x; |
|
- | 141 | scr->position_y = scr->position_y % scr->size_y; |
|
- | 142 | ||
- | 143 | } |
|
- | 144 | ||
- | 145 | ||
92 | /* Handler for keyboard */ |
146 | /* Handler for keyboard */ |
93 | static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) |
147 | static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) |
94 | { |
148 | { |
95 | ipc_callid_t callid; |
149 | ipc_callid_t callid; |
96 | ipc_call_t call; |
150 | ipc_call_t call; |
Line 116... | Line 170... | ||
116 | 170 | ||
117 | conn = &connections[active_console]; |
171 | conn = &connections[active_console]; |
118 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
172 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
119 | if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) { |
173 | if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) { |
120 | /*FIXME: draw another console content from buffer */ |
174 | /*FIXME: draw another console content from buffer */ |
- | 175 | if (c - KBD_KEY_F1 == active_console) |
|
121 | 176 | break; |
|
122 | active_console = c - '1'; |
177 | active_console = c - '1'; |
123 | conn = &connections[active_console]; |
178 | conn = &connections[active_console]; |
124 | 179 | ||
125 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL); |
180 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL); |
126 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
181 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
- | 182 | ||
127 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
183 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
128 | for (j = 0; j < conn->screenbuffer.size_y; j++) { |
184 | for (j = 0; j < conn->screenbuffer.size_y; j++) { |
129 | d = get_field_at(&(conn->screenbuffer),i, j)->character; |
185 | d = get_field_at(&(conn->screenbuffer),i, j)->character; |
130 | if (d && d != ' ') |
186 | if (d && d != ' ') |
131 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL); |
187 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL); |
Line 164... | Line 220... | ||
164 | 220 | ||
165 | if ((consnum = find_free_connection()) == CONSOLE_COUNT) { |
221 | if ((consnum = find_free_connection()) == CONSOLE_COUNT) { |
166 | ipc_answer_fast(iid,ELIMIT,0,0); |
222 | ipc_answer_fast(iid,ELIMIT,0,0); |
167 | return; |
223 | return; |
168 | } |
224 | } |
169 | 225 | ||
170 | connections[consnum].used = 1; |
226 | connections[consnum].used = 1; |
171 | connections[consnum].client_phone = IPC_GET_ARG3(call); |
227 | connections[consnum].client_phone = IPC_GET_ARG3(call); |
172 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
228 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
173 | 229 | ||
174 | /* Accept the connection */ |
230 | /* Accept the connection */ |
175 | ipc_answer_fast(iid,0,0,0); |
231 | ipc_answer_fast(iid,0,0,0); |
176 | 232 | ||
177 | while (1) { |
233 | while (1) { |
178 | callid = async_get_call(&call); |
234 | callid = async_get_call(&call); |
Line 180... | Line 236... | ||
180 | case IPC_M_PHONE_HUNGUP: |
236 | case IPC_M_PHONE_HUNGUP: |
181 | /* TODO */ |
237 | /* TODO */ |
182 | ipc_answer_fast(callid, 0,0,0); |
238 | ipc_answer_fast(callid, 0,0,0); |
183 | return; |
239 | return; |
184 | case CONSOLE_PUTCHAR: |
240 | case CONSOLE_PUTCHAR: |
185 | - | ||
186 | /* Send message to fb */ |
- | |
187 | if (consnum == active_console) { |
- | |
188 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \ |
- | |
189 | connections[consnum].screenbuffer.position_x, NULL, NULL); |
- | |
190 | } |
- | |
191 | - | ||
192 | screenbuffer_putchar(&(connections[consnum].screenbuffer), IPC_GET_ARG2(call)); |
241 | write_char(consnum, IPC_GET_ARG1(call)); |
193 | break; |
242 | break; |
194 | case CONSOLE_CLEAR: |
243 | case CONSOLE_CLEAR: |
195 | /* Send message to fb */ |
244 | /* Send message to fb */ |
196 | if (consnum == active_console) { |
245 | if (consnum == active_console) { |
197 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
246 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
Line 268... | Line 317... | ||
268 | /*FIXME: handle error */ |
317 | /*FIXME: handle error */ |
269 | return -1; |
318 | return -1; |
270 | } |
319 | } |
271 | } |
320 | } |
272 | 321 | ||
- | 322 | ||
273 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
323 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
274 | return -1; |
324 | return -1; |
275 | }; |
325 | }; |
276 | 326 | ||
277 | async_manager(); |
327 | async_manager(); |