-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeys.h
More file actions
28 lines (26 loc) · 651 Bytes
/
Copy pathkeys.h
File metadata and controls
28 lines (26 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <termios.h>
#include <stropts.h>
#define false 0
#define true 1
int bytesWaiting;
int STDIN = 0;
bool initialized = false;
int _kbhit() {
//static const int STDIN = 0;
//static bool initialized = false;
if (! initialized) {
// Use termios to turn off line buffering
termios term;
tcgetattr(STDIN, &term);
term.c_lflag &= ~ICANON;
tcsetattr(STDIN, TCSANOW, &term);
setbuf(stdin, NULL);
initialized = true;
}
initialized = false;
ioctl(STDIN, FIONREAD, &bytesWaiting);
return bytesWaiting;
}