From cdfd9046bfe78a458a7ad9f216951fc1295a8f34 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 12 Nov 2006 16:18:09 +0000 Subject: [PATCH] New logic for the inner core of wgetch: PDC_check_bios_key() is always called, the loop always recycles if no key (unless nodelay), and napms() is always called if no key (unless nodelay). By stipulating that PDC_check_bios_key() will always be called before PDC_get_bios_key(), I can simplify the implementation of mouse support for DOS and OS/2. Also, the demos no longer hog the CPU under Windows when built with Watcom DOS. (No help for Borland yet; it will need a new delay routine.) The downside: Even in delay mode, the keyboard won't respond more often than every 1/20th of a second. I don't think this will really be a problem, but it needs a lot of testing to be sure. --- pdcurses/getch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdcurses/getch.c b/pdcurses/getch.c index b0f5510b..a333c471 100644 --- a/pdcurses/getch.c +++ b/pdcurses/getch.c @@ -16,7 +16,7 @@ #define _INBUFSIZ 512 /* size of terminal input buffer */ #define NUNGETCH 256 /* max # chars to ungetch() */ -RCSID("$Id: getch.c,v 1.51 2006/11/05 07:13:40 wmcbrine Exp $"); +RCSID("$Id: getch.c,v 1.52 2006/11/12 16:18:09 wmcbrine Exp $"); static int c_pindex = 0; /* putter index */ static int c_gindex = 1; /* getter index */ @@ -163,8 +163,7 @@ int wgetch(WINDOW *win) for (;;) /* loop for any buffering */ { - if ((SP->delaytenths || win->_delayms || win->_nodelay) - && !PDC_check_bios_key()) + if (!PDC_check_bios_key()) { key = -1; } @@ -188,11 +187,12 @@ int wgetch(WINDOW *win) return ERR; waitcount--; - napms(50); /* sleep for 1/20th second */ } else if (win->_nodelay) return ERR; + + napms(50); /* sleep for 1/20th second */ continue; }