summaryrefslogtreecommitdiffstats
path: root/osdep/getch2-win.c
diff options
context:
space:
mode:
authoruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-08-25 04:28:08 +0000
committeruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-08-25 04:28:08 +0000
commitc51c1fc6681e20465de75436b5435947676fdabb (patch)
tree8e9bf1946a6436dd46e7d694134a5aadb0bf2b8a /osdep/getch2-win.c
parentdcd9ee6d5ab6c57fec3abd529e8de40a8cc609a0 (diff)
downloadmpv-c51c1fc6681e20465de75436b5435947676fdabb.tar.bz2
mpv-c51c1fc6681e20465de75436b5435947676fdabb.tar.xz
Make terminal input work more like VO key input
The Unix version of getch2() could either return an internally buffered key or do a second-level select() in addition to the input.c one and then read more data. Change getch2() to always add all read keys with mplayer_put_key() (like video output window keyboard input does) and remove the internal select() from the Unix version. Make input.c call mplayer_get_key() directly. The primary motivation for this change is to make combining multiple event sources under one select() easier. Now getch2() only needs to be called when the corresponding fd is readable, and it will be possible to handle events from X-based VOs with the same code. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24149 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep/getch2-win.c')
-rw-r--r--osdep/getch2-win.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index 002d39d4a6..260c7c3f76 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -9,6 +9,7 @@
#include <windows.h>
#include "keycodes.h"
#include "input/input.h"
+#include "mp_fifo.h"
// HACK, stdin is used as something else below
#undef stdin
@@ -34,13 +35,13 @@ void get_screen_size(){
static HANDLE stdin;
static int getch2_status=0;
-int getch2(int time){
+static int getch2_internal(void)
+{
INPUT_RECORD eventbuffer[128];
DWORD retval;
int i=0;
if(!getch2_status)return -1;
/*check if there are input events*/
- WaitForSingleObject(stdin, time);
if(!GetNumberOfConsoleInputEvents(stdin,&retval))
{
printf("getch2: can't get number of input events: %i\n",GetLastError());
@@ -118,6 +119,12 @@ int getch2(int time){
return -1;
}
+void getch2(void)
+{
+ int r = getch2_internal();
+ if (r >= 0)
+ mplayer_put_key(r);
+}
void getch2_enable(){
DWORD retval;