namespace
| 213 | |
| 214 | } // namespace |
| 215 | DirectWindow::DirectWindow(Platform *platform, const Window::Properties &properties) : |
| 216 | Window(properties), |
| 217 | platform{platform} |
| 218 | { |
| 219 | // Setup tty for reading keyboard from console |
| 220 | if ((tty_fd = open("/dev/tty", O_RDWR | O_NDELAY)) > 0) |
| 221 | { |
| 222 | tcgetattr(tty_fd, &termio_prev); |
| 223 | tcgetattr(tty_fd, &termio); |
| 224 | cfmakeraw(&termio); |
| 225 | termio.c_lflag |= ISIG; |
| 226 | termio.c_oflag |= OPOST | ONLCR; |
| 227 | termio.c_cc[VMIN] = 1; |
| 228 | termio.c_cc[VTIME] = 0; |
| 229 | |
| 230 | if (tcsetattr(tty_fd, TCSANOW, &termio) == -1) |
| 231 | LOGW("Failed to set attribs for '/dev/tty'"); |
| 232 | } |
| 233 | |
| 234 | platform->set_focus(true); |
| 235 | } |
| 236 | |
| 237 | DirectWindow::~DirectWindow() |
| 238 | { |