summaryrefslogtreecommitdiffstats
path: root/osdep/getch2-win.c
diff options
context:
space:
mode:
authorfaust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-08-13 13:32:43 +0000
committerfaust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-08-13 13:32:43 +0000
commitc8ac1bb62c004dfc930b4245baf964e192932f92 (patch)
treece0738968c851df1c4faa43cc472464f0044b582 /osdep/getch2-win.c
parent7c5eecdb1644cf6af65e30bcfcd2822c4f505d5b (diff)
downloadmpv-c8ac1bb62c004dfc930b4245baf964e192932f92.tar.bz2
mpv-c8ac1bb62c004dfc930b4245baf964e192932f92.tar.xz
fix slave mode for mingw, patch by Anton Ragnarsson <anton.ragnarsson.1093 at student.uu.se> some cleanup by be
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13016 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep/getch2-win.c')
-rw-r--r--osdep/getch2-win.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index 023ec95a6d..241321a420 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -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;
}