-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConsole_io.cpp
64 lines (49 loc) · 1.6 KB
/
Console_io.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "Console_io.h"
#include "fifo.h"
fifo_t serial_in;
Console console;
T2Input t2input;
extern "C" void console_char_in(char ch){
console.put_c(ch);
}
extern "C" void console_str_in(const char* str){
console.putstr(str);
}
extern "C" void console_str_with_length_in(const char* str, int length){
console.putstr(str, length);
}
extern "C" void console_char_out(char ch){
fifo_add(serial_in, &ch); // Add to FIFO buffer
}
extern "C" void console_str_out(const char* str){
for(unsigned int i = 0; i < strlen(str); i++){
console_char_out(str[i]);
}
}
extern "C" void console_str_with_length_out(const char* str, int length){
console_str_out((char*)str);
}
extern "C" void terminal_init(){
console.init();
t2input.init();
}
extern "C" void t2input_draw(VMUINT8* layerbuf1){
int scr_w = vm_graphic_get_screen_width();
int scr_h = vm_graphic_get_screen_height();
vm_graphic_fill_rect(layerbuf1, 0, 0, scr_w, scr_h, tr_color, tr_color);
vm_graphic_line(layerbuf1, console.cursor_x*char_width, (console.cursor_y+1)*char_height,
(console.cursor_x+1)*char_width, (console.cursor_y+1)*char_height, console.cur_textcolor);
t2input.draw();
}
extern "C" void set_layer_handler(VMUINT8* layerbuf0, VMUINT8* layerbuf1, VMINT layerhdl){
console.scr_buf=layerbuf0;
console.draw_all();
t2input.scr_buf=layerbuf1;
t2input.layer_handle=layerhdl;
}
extern "C" void t2input_handle_keyevt(int event, int keycode){
t2input.handle_keyevt(event, keycode);
}
extern "C" void t2input_handle_penevt(int event, int x, int y){
t2input.handle_penevt(event, x, y);
}