1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-20 14:56:55 +00:00

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
This commit is contained in:
faust3 2004-08-13 13:32:43 +00:00
parent 7c5eecdb16
commit c8ac1bb62c

View File

@ -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;
}