mirror of
https://github.com/mpv-player/mpv
synced 2025-03-30 23:38:10 +00:00
add a read function for slave mode on mingw
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10929 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
4cafcfff45
commit
e27e245ffe
@ -13,6 +13,7 @@
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */
|
||||
extern int mp_input_win32_slave_cmd_func(int fd,char* dest,int size);
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
@ -1121,7 +1122,11 @@ if(keyb_fifo_get > 0)
|
||||
mp_input_add_key_fd(-1,0,mplayer_get_key,NULL);
|
||||
#endif
|
||||
if(slave_mode)
|
||||
#ifndef __MINGW32__
|
||||
mp_input_add_cmd_fd(0,1,NULL,NULL);
|
||||
#else
|
||||
mp_input_add_cmd_fd(0,0,mp_input_win32_slave_cmd_func,NULL);
|
||||
#endif
|
||||
else if(!use_stdin)
|
||||
#ifndef HAVE_NO_POSIX_SELECT
|
||||
mp_input_add_key_fd(0,1,NULL,NULL);
|
||||
|
@ -6,6 +6,25 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include "keycodes.h"
|
||||
#include "../input/input.h"
|
||||
|
||||
int mp_input_win32_slave_cmd_func(int fd,char* dest,int size){
|
||||
DWORD i,retval;
|
||||
int x=0;
|
||||
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(x)return x;
|
||||
return MP_INPUT_NOTHING;
|
||||
}
|
||||
|
||||
int screen_width=80;
|
||||
int screen_height=24;
|
||||
|
Loading…
Reference in New Issue
Block a user