# HG changeset patch # User faust3 # Date 1092403963 0 # Node ID 00a4cf87e2ff73601b1a84678682a8bd40d07d56 # Parent 2f45d852b7c182f5b7c849b9c30981b356875200 fix slave mode for mingw, patch by Anton Ragnarsson some cleanup by be diff -r 2f45d852b7c1 -r 00a4cf87e2ff osdep/getch2-win.c --- a/osdep/getch2-win.c Fri Aug 13 12:28:59 2004 +0000 +++ b/osdep/getch2-win.c Fri Aug 13 13:32:43 2004 +0000 @@ -9,20 +9,14 @@ #include "../input/input.h" int mp_input_win32_slave_cmd_func(int fd,char* dest,int size){ - DWORD i,retval; - int x=0; + DWORD retval; HANDLE stdin = GetStdHandle(STD_INPUT_HANDLE); - INPUT_RECORD eventbuffer[250]; - if(!GetNumberOfConsoleInputEvents(stdin,&retval) || !retval)return MP_INPUT_NOTHING; - ReadConsoleInput(stdin,eventbuffer,250,&retval); - for(i = 0; i < retval; i++){ - if(eventbuffer[i].EventType==KEY_EVENT&&eventbuffer[i].Event.KeyEvent.bKeyDown== TRUE){ - if(eventbuffer[i].Event.KeyEvent.wVirtualKeyCode==VK_RETURN)dest[x]='\n'; - else dest[x]=eventbuffer[i].Event.KeyEvent.uChar.AsciiChar; - ++x; - } + if(!PeekNamedPipe(stdin, NULL, size, &retval, NULL, NULL) || !retval){ + return MP_INPUT_NOTHING; } - if(x)return x; + if(retval>size)retval=size; + ReadFile(stdin, dest, retval, &retval, NULL); + if(retval)return retval; return MP_INPUT_NOTHING; }