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.
This commit is contained in:
William McBrine
2006-11-12 16:18:09 +00:00
parent ac5dcbeb70
commit cdfd9046bf

View File

@@ -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;
}