summaryrefslogtreecommitdiff
path: root/src/conio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conio.c')
-rw-r--r--src/conio.c16
1 files changed, 16 insertions, 0 deletions
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 <termios.h>
+#include <unistd.h>
+#include <stdio.h>
+
+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;
+}