From c1db2fc3513d6617380fde4f98a97a72481e6d69 Mon Sep 17 00:00:00 2001 From: faust3 Date: Sat, 19 Apr 2003 09:19:30 +0000 Subject: disable getch2 on windows when we can't read stdin (msys) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9937 b3059339-0415-0410-9bf9-f77b7e298cf2 --- osdep/getch2-win.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'osdep') diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c index e7ac725771..96f6878d2b 100644 --- a/osdep/getch2-win.c +++ b/osdep/getch2-win.c @@ -14,11 +14,13 @@ void get_screen_size(){ } static HANDLE stdin; +static int getch2_status=0; int getch2(int time){ INPUT_RECORD eventbuffer[128]; DWORD retval; int i=0; + if(!getch2_status)return -1; /*check if there are input events*/ if(!GetNumberOfConsoleInputEvents(stdin,&retval)) { @@ -95,11 +97,16 @@ int getch2(int time){ return -1; } -static int getch2_status=0; void getch2_enable(){ - stdin = GetStdHandle(STD_INPUT_HANDLE); - getch2_status=1; + int retval; + stdin = GetStdHandle(STD_INPUT_HANDLE); + if(!GetNumberOfConsoleInputEvents(stdin,&retval)) + { + printf("getch2: %i can't get number of input events [disabling console input]\n",GetLastError()); + getch2_status = 0; + } + else getch2_status=1; } void getch2_disable(){ -- cgit v1.2.3