X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=hachu.c;h=ff5cc8f28dfc7d56817257ee7803dda00986cbb2;hb=023af02b0b3c0643b612183f8670807b081125f4;hp=478a20bad4a7569653357986dee094e2366a624d;hpb=2f6a663d11eb98f2beb54781103f30623ac2a656;p=hachu.git diff --git a/hachu.c b/hachu.c index 478a20b..ff5cc8f 100644 --- a/hachu.c +++ b/hachu.c @@ -29,8 +29,25 @@ #ifdef WIN32 # include + int InputWaiting() + { // checks for waiting input in pipe + static int pipe, init; + static HANDLE inp; + DWORD cnt; + + if(!init) inp = GetStdHandle(STD_INPUT_HANDLE); + if(!PeekNamedPipe(inp, NULL, 0, NULL, &cnt, NULL)) return 1; + return cnt; + } #else # include +# include + int InputWaiting() + { + int cnt; + if(ioctl(0, FIONREAD, &cnt)) return 1; + return cnt; + } int GetTickCount() // with thanks to Tord { struct timeval t; gettimeofday(&t, NULL);