-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62ead7e
commit e292c07
Showing
8 changed files
with
2 additions
and
93 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1 @@ | ||
#include "termDisplay.h" | ||
|
||
char basic_getch() | ||
{ | ||
char ch; | ||
|
||
struct termios old; | ||
struct termios new; | ||
|
||
tcgetattr(0, &old); | ||
new = old; | ||
new.c_lflag &= ~ICANON; | ||
new.c_lflag &= ~ECHO; | ||
tcsetattr(0, TCSANOW, &new); | ||
ch = (char)getchar(); | ||
tcsetattr(0, TCSANOW, &old); | ||
|
||
return ch; | ||
} | ||
|
||
// returns NULL if there was no character | ||
// max wait time is in milliseconds | ||
char getch(unsigned int max_wait_time) | ||
{ | ||
char ch = NULL; | ||
|
||
fd_set rfds; | ||
struct timeval tv; | ||
|
||
FD_ZERO(&rfds); | ||
FD_SET(0, &rfds); | ||
|
||
tv.tv_sec = 0; | ||
tv.tv_usec = max_wait_time *10; | ||
|
||
int has_input = select(1, &rfds, NULL, NULL, &tv); | ||
|
||
if (has_input == 1) | ||
{ | ||
ch = basic_getch(); | ||
} | ||
|
||
return ch; | ||
} | ||
#include "termDisplay.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters