2 #include <F_Linux_Console_UI.H>
8 // ÏÓÔÁÌÓÑ ÐÏÓÌÅ probe()
11 // TODO: test if console in graphics mode (svgalib/etc.)
14 // ËÏÎÓÏÌØ ÄÏÌÖÎÁ ÉÍÅÔØ ÍÙÛØ É ËÌÁ×Õ - linux-2.6 input subsystem / gpm + kbd
17 // - 2 ÂÁÊÔÁ cursor position
18 // - char / attr array
20 void F_Linux_Console_UI::initial()
24 log("linux_console_ui", CHAT_LEVEL, "Gpm is missing.");
25 input = new F_Linux_Input;
27 log("linux_console_ui", CHAT_LEVEL, "Linux input subsystem is missing.");
28 // try to get working keyboard
30 input = new F_Linux_Keyboard;
32 log("linux_console_ui", CHAT_LEVEL, "Linux keyboard is missing, giving up.");
36 mouse->disable(); // we do not need double mouse events
37 // try to know screen width & height
40 if ((err = read(fileno(vcsa), &b, 2)) != 2) {
42 log("linux_console_ui", ALERT_LEVEL, "vcsa read error: %s",
45 log("linux_console_ui", ALERT_LEVEL, "short read from vcsa (%d) !", err);
48 log("linux_console_ui", CHAT_LEVEL, "w - %d, h - %d", b[1], b[0]);
49 display = new F_Linux_Console_Display(vcsa, b[1], b[0]);
50 // save display area to back_store
52 display->cursor(0); // cursor off
58 // ÓÏÂÉÒÁÅÍ ÓÏÂÙÔÉÑ ÏÔ ÕÓÔÒÏÊÓÔ× ÕÐÒÁ×ÌÅÎÉÑ É ÐÅÒÅÄÁÅÍ ÐÏ ÃÅÐÏÞËÅ
60 void F_Linux_Console_UI::run()
63 bool need_flush = false;
66 mouse->check_for_events();
67 input->check_for_events();
68 if (mouse->get_event(&iev))
69 event_queue.push_back(iev);
70 if (input->get_event(&iev))
71 event_queue.push_back(iev);
72 while (display->get_event(&iev)) {
73 event_queue.push_back(iev);
78 iev.type = F_DISPLAY_FLUSH;
79 iev.display.window = 0;
80 event_queue.push_back(iev);
83 if (event_queue.size()) {
84 while (event_queue.size()) { // process events
87 event_queue.erase(event_queue.begin());
94 bool F_Linux_Console_UI::exit_confirm(bool from_sighandler)
99 void F_Linux_Console_UI::refresh()
101 // refresh damaged windows
104 void F_Linux_Console_UI::sigcont()
106 debug("console continued");
111 void F_Linux_Console_UI::sigstop()
115 debug("console stopping");
118 void F_Linux_Console_UI::sigwinch()
120 exit_on_unimplemented("SIGWINCH");
123 #include <linux/vt.h>
124 #include <sys/ioctl.h>
126 bool F_Linux_Console_UI::probe()
128 if (strcmp(getenv("TERM"), "linux") && strcmp(getenv("TERM"), "linux"))
130 const char *tty = ttyname(fileno(stdout));
131 int tty_fd = open(tty, O_RDWR);
132 if (tty_fd < 0) { // can't open tty
133 debug("Can't open tty.");
137 if (ioctl(tty_fd, VT_GETMODE, &vtmode) < 0) {
139 debug("VT_GETMODE ioctl failed.");
142 if (!strstr(tty, "/dev/vc/")) {
143 debug("Looks like not a tty.");
146 char vcsa_n[32] = "/dev/vcsa";
147 strcat(vcsa_n, rindex(tty, '/') + 1);
148 vcsa = ::fopen(vcsa_n, "r+");
150 debug("Can't open /dev/vcsa.");
156 F_Linux_Console_UI::~F_Linux_Console_UI()