diff options
Diffstat (limited to 'osdep/getch2.c')
-rw-r--r-- | osdep/getch2.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index 78e60b2373..f0aa19a2cc 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -24,7 +24,7 @@ #include "config.h" //#define HAVE_TERMCAP -#if !defined(__OS2__) && !defined(__MORPHOS__) +#if !defined(__MORPHOS__) #define CONFIG_IOCTL #endif @@ -159,11 +159,17 @@ void get_screen_size(void){ #endif } -void getch2(struct mp_fifo *fifo) +bool getch2(struct mp_fifo *fifo) { int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len); + /* Return false on EOF to stop running select() on the FD, as it'd + * trigger all the time. Note that it's possible to get temporary + * EOF on terminal if the user presses ctrl-d, but that shouldn't + * happen if the terminal state change done in getch2_enable() + * works. + */ if (retval < 1) - return; + return retval; getch2_len += retval; while (getch2_len > 0 && (getch2_len > 1 || getch2_buf[0] != 27)) { @@ -280,6 +286,7 @@ void getch2(struct mp_fifo *fifo) getch2_buf[i] = getch2_buf[len+i]; mplayer_put_key(fifo, code); } + return true; } static volatile int getch2_status=0; |