From 79fa249aa729e03b17991c3991f5bb090ffb6b61 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sat, 4 Mar 2023 17:17:13 -0800 Subject: restructured project --- src/conio.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/conio.c (limited to 'src/conio.c') diff --git a/src/conio.c b/src/conio.c new file mode 100644 index 0000000..50b7e0f --- /dev/null +++ b/src/conio.c @@ -0,0 +1,16 @@ +#include "./conio.h" +#include +#include +#include + +int getch(void) { + struct termios oldattr, newattr; + int ch; + tcgetattr(STDIN_FILENO, &oldattr); + newattr = oldattr; + newattr.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newattr); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &oldattr); + return ch; +} -- cgit v1.3.1