Mercurial > mplayer.hg
changeset 9936:6d9531a5d95b
disable getch2 on windows when we can't read stdin (msys)
author | faust3 |
---|---|
date | Sat, 19 Apr 2003 09:19:30 +0000 |
parents | cb685216dc73 |
children | 8098165634f7 |
files | osdep/getch2-win.c |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/osdep/getch2-win.c Sat Apr 19 02:55:26 2003 +0000 +++ b/osdep/getch2-win.c Sat Apr 19 09:19:30 2003 +0000 @@ -14,11 +14,13 @@ } 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 @@ 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(){