summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 00:24:01 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 00:24:01 +0000
commit6961b9ef7098440a7e1e31dc9908e3b3b30c23fb (patch)
treee14fb95aad6cc2a09643903aeac1ce489dd4dab4 /osdep
parentaa4388fea4da75c798523fa55392ed7b5a0210a2 (diff)
downloadmpv-6961b9ef7098440a7e1e31dc9908e3b3b30c23fb.tar.bz2
mpv-6961b9ef7098440a7e1e31dc9908e3b3b30c23fb.tar.xz
Add support for reading key events from MinGW xterm.
Unfortunately keys only arrive after enter was pressed and SetNamedPipeHandleState does not seem to help. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30784 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep')
-rw-r--r--osdep/getch2-win.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index dd6268b06a..7218e81a5a 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -25,6 +25,7 @@
#include "config.h"
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <windows.h>
#include "keycodes.h"
@@ -64,7 +65,15 @@ static int getch2_internal(void)
INPUT_RECORD eventbuffer[128];
DWORD retval;
int i=0;
- if(!getch2_status)return -1;
+ if(!getch2_status){
+ // supports e.g. MinGW xterm, unfortunately keys are only received after
+ // enter was pressed.
+ uint8_t c;
+ if (!PeekNamedPipe(in, NULL, 1, &retval, NULL, NULL) || !retval)
+ return -1;
+ ReadFile(in, &c, 1, &retval, NULL);
+ return retval == 1 ? c : -1;
+ }
/*check if there are input events*/
if(!GetNumberOfConsoleInputEvents(in,&retval))
{