X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Funix%2Finput.c;h=6cb91d81380b355eedde4ff4651923aae0b26282;hb=4577dd26b3ecbf7ccc5ff55efa991334136866e1;hp=50eb23e898adc88a65c6d9efc12e10f1bf2c98e6;hpb=2ba6401e39bcfaaccaa45e6b7ef780a7a15b0c48;p=oftp diff --git a/src/unix/input.c b/src/unix/input.c index 50eb23e..6cb91d8 100644 --- a/src/unix/input.c +++ b/src/unix/input.c @@ -1,8 +1,11 @@ +#include +#include #include #include "input.h" int init_input(void) { + nodelay(stdscr, TRUE); return 0; } @@ -10,9 +13,25 @@ void cleanup_input(void) { } -int wait_input(union event *ev) +int poll_input(union event *ev) { ev->type = EV_KEY; ev->key.key = getch(); return 1; } + +int have_input(void) +{ + fd_set rdset; + struct timeval tv = {0, 0}; + + FD_ZERO(&rdset); + FD_SET(0, &rdset); + + while(select(1, &rdset, 0, 0, &tv) == -1 && errno == EINTR); + + if(FD_ISSET(0, &rdset)) { + return 1; + } + return 0; +}