Files
terminal_tetris/c-src/terminal_linux.c
2026-03-02 08:09:02 +13:00

28 lines
634 B
C

#include "../include/terminal.h"
#include <termios.h>
#include <unistd.h>
static struct termios orig_termios;
void exit_raw_mode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enter_raw_mode() {
tcgetattr(STDIN_FILENO, &orig_termios);
// atexit(exit_raw_mode); // zig is handling this step
struct termios raw = orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
raw.c_cc[VMIN] = 0;
// raw.c_cc[VTIME] = 1;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}