15#ifndef LINUX_HELPERS_H
16#define LINUX_HELPERS_H
22static inline int32_t getch()
24 static struct termios oldt, newt;
25 tcgetattr(STDIN_FILENO, &oldt);
27 newt.c_lflag &= ~(ICANON | ECHO);
28 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
29 int32_t
retVal = getchar();
30 tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
34static inline int32_t kbhit()
39 term2.c_lflag &= ~ICANON;
40 tcsetattr(0, TCSANOW, &term2);
42 ioctl(0, FIONREAD, &byteswaiting);
43 tcsetattr(0, TCSANOW, &term);
44 return byteswaiting > 0;
47static void inline Sleep(int32_t msecs) { usleep(msecs * 1000); }