Revert "Added experimental feature NEW_KEYBOARD_HIT."

This reverts commit bc65112ce0.
This commit is contained in:
Bart House
2019-07-14 21:28:55 -07:00
parent e83fcd0353
commit 5870cb6a92
14 changed files with 3 additions and 199 deletions

View File

@@ -564,13 +564,9 @@ typedef unsigned char uchar;
%N first character of player name
DUMPLOG_FILE is not used if SYSCF is defined
*/
#endif /* DUMPLOG_FILE */
#endif
#endif /* DUMPLOG */
/* NEW_KEYBOARD_HIT adds new window proc to return whether keyboard has been hit
and character input is available */
/* #define NEW_KEYBOARD_HIT */
#endif
#define USE_ISAAC64 /* Use cross-plattform, bundled RNG */

View File

@@ -1147,9 +1147,6 @@ E void NDECL(gettty);
E void NDECL(setftty);
E void FDECL(settty, (const char *));
E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
E void FDECL(cmov, (int x, int y));
E void FDECL(nocmov, (int x, int y));
@@ -1555,9 +1552,6 @@ E void FDECL(mplayer_talk, (struct monst *));
#ifndef WIN32
E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
#endif
#ifndef TOS
E char NDECL(switchar);
@@ -1588,9 +1582,7 @@ E void FDECL(gotoxy, (int, int));
#endif
#ifdef TOS
E int FDECL(_copyfile, (char *, char *));
#ifndef NEW_KEYBOARD_HIT
E int NDECL(kbhit);
#endif
E void NDECL(set_colors);
E void NDECL(restore_colors);
#ifdef SUSPEND
@@ -1600,9 +1592,7 @@ E int NDECL(dosuspend);
#ifdef WIN32
E char *FDECL(get_username, (int *));
E void FDECL(nt_regularize, (char *));
#ifndef NEW_KEYBOARD_HIT
E int NDECL((*nt_kbhit));
#endif
E void FDECL(Delay, (int));
#endif /* WIN32 */
#endif /* MICRO || WIN32 */
@@ -1670,15 +1660,10 @@ E void FDECL(regex_free, (struct nhregex *));
#ifdef WIN32
E void NDECL(get_scr_size);
#ifndef NEW_KEYBOARD_HIT
E int NDECL(nttty_kbhit);
#endif
E void FDECL(nttty_open, (int));
E void NDECL(nttty_rubout);
E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
E int FDECL(ntposkey, (int *, int *, int *));
E void FDECL(set_output_mode, (int));
E void NDECL(synch_cursor);

View File

@@ -252,11 +252,8 @@ int _RTLENTRY _EXPFUNC read(int __handle, void _FAR *__buf, unsigned __len);
#ifndef CURSES_GRAPHICS
#include <conio.h> /* conflicting definitions with curses.h */
#endif
#ifndef NEW_KEYBOARD_HIT
#undef kbhit /* Use our special NT kbhit */
#define kbhit (*nt_kbhit)
#endif
#ifdef LAN_FEATURES
#define MAX_LAN_USERNAME 20

View File

@@ -311,9 +311,7 @@
#define HLOCK "perm" /* an empty file used for locking purposes */
#ifndef NEW_KEYBOARD_HIT
#define tgetch getchar
#endif
#ifndef NOSHELL
#define SHELL /* do not delete the '!' command */

View File

@@ -79,9 +79,6 @@ struct window_procs {
(int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (int, genericptr_t, int, int, int, unsigned long *));
boolean NDECL((*win_can_suspend));
#ifdef NEW_KEYBOARD_HIT
boolean NDECL((*win_keyboard_hit));
#endif
};
extern
@@ -163,9 +160,6 @@ extern
*/
#define status_enablefield (*windowprocs.win_status_enablefield)
#define status_update (*windowprocs.win_status_update)
#ifdef NEW_KEYBOARD_HIT
#define keyboard_hit (*windowprocs.win_keyboard_hit)
#endif
/*
* WINCAP
@@ -385,9 +379,6 @@ struct chain_procs {
(CARGS, int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int, int, unsigned long *));
boolean FDECL((*win_can_suspend), (CARGS));
#ifdef NEW_KEYBOARD_HIT
boolean FDECL((*keyboard_hit), (CARGS));
#endif
};
#endif /* WINCHAIN */
@@ -458,9 +449,6 @@ extern void FDECL(safe_status_enablefield,
(int, const char *, const char *, BOOLEAN_P));
extern void FDECL(safe_status_update, (int, genericptr_t, int, int, int, unsigned long *));
extern boolean NDECL(safe_can_suspend);
#ifdef NEW_KEYBOARD_HIT
extern boolean NDECL(safe_keyboard_hit);
#endif
extern void FDECL(stdio_raw_print, (const char *));
extern void FDECL(stdio_raw_print_bold, (const char *));
extern void NDECL(stdio_wait_synch);

View File

@@ -247,10 +247,6 @@ E void FDECL(genl_outrip, (winid, int, time_t));
E char *FDECL(tty_getmsghistory, (BOOLEAN_P));
E void FDECL(tty_putmsghistory, (const char *, BOOLEAN_P));
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tty_keyboard_hit);
#endif
#ifdef NO_TERMS
#ifdef MAC
#ifdef putchar

View File

@@ -374,11 +374,7 @@ boolean resuming;
if (multi >= 0 && occupation) {
#if defined(MICRO) || defined(WIN32)
abort_lev = 0;
#ifdef NEW_KEYBOARD_HIT
if (keyboard_hit()) {
#else
if (kbhit()) {
#endif
if ((ch = pgetchar()) == ABORT)
abort_lev++;
else

View File

@@ -523,9 +523,6 @@ static void NDECL(hup_void_ndecl);
static void FDECL(hup_void_fdecl_int, (int));
static void FDECL(hup_void_fdecl_winid, (winid));
static void FDECL(hup_void_fdecl_constchar_p, (const char *));
#ifdef NEW_KEYBOARD_HIT
static boolean NDECL(hup_keyboard_hit);
#endif
static struct window_procs hup_procs = {
"hup", 0L, 0L, hup_init_nhwindows,
@@ -573,9 +570,6 @@ static struct window_procs hup_procs = {
hup_void_ndecl, /* status_finish */
genl_status_enablefield, hup_status_update,
genl_can_suspend_no,
#ifdef NEW_KEYBOARD_HIT
hup_keyboard_hit
#endif
};
static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0;
@@ -630,14 +624,6 @@ hup_nhgetch(VOID_ARGS)
return '\033'; /* ESC */
}
#ifdef NEW_KEYBOARD_HIT
static boolean
hup_keyboard_hit(VOID_ARGS)
{
return FALSE;
}
#endif
/*ARGSUSED*/
static char
hup_yn_function(prompt, resp, deflt)

View File

@@ -398,12 +398,10 @@ int mode; // unused
{
DWORD cmode;
#ifndef NEW_KEYBOARD_HIT
/* Initialize the function pointer that points to
* the kbhit() equivalent, in this TTY case nttty_kbhit()
*/
nt_kbhit = nttty_kbhit;
#endif
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) {
/* Unable to set control handler */
@@ -438,19 +436,11 @@ int portdebug;
return ch;
}
#ifndef NEW_KEYBOARD_HIT
int
nttty_kbhit()
{
return keyboard_handler.pNHkbhit(console.hConIn, &ir);
}
#else
boolean
tkbhit()
{
return keyboard_handler.pNHkbhit(console.hConIn, &ir) != 0;
}
#endif
int
tgetch()

View File

@@ -56,7 +56,6 @@ extern void NDECL(backsp);
int NDECL(windows_console_custom_nhgetch);
extern void NDECL(safe_routines);
#ifndef NEW_KEYBOARD_HIT
/* The function pointer nt_kbhit contains a kbhit() equivalent
* which varies depending on which window port is active.
* For the tty port it is tty_kbhit() [from nttty.c]
@@ -66,7 +65,6 @@ extern void NDECL(safe_routines);
int def_kbhit(void);
int (*nt_kbhit)() = def_kbhit;
#endif
char
switchar()
@@ -160,13 +158,11 @@ max_filename()
return 0;
}
#ifndef NEW_KEYBOARD_HIT
int
def_kbhit()
{
return 0;
}
#endif
/*
* Strip out troublesome file system characters.
@@ -514,9 +510,7 @@ int code;
exit(code);
}
#ifndef NEW_KEYBOARD_HIT
#undef kbhit
#endif
#include <conio.h>
int
@@ -725,6 +719,7 @@ sys_random_seed(VOID_ARGS)
}
return ourseed;
}
#endif /* WIN32 */
/*winnt.c*/

View File

@@ -101,9 +101,6 @@ struct window_procs safe_procs = {
safe_status_update,
#endif
safe_can_suspend,
#ifdef NEW_KEYBOARD_HIT
safe_keyboard_hit
#endif
};
struct window_procs *
@@ -389,14 +386,6 @@ safe_can_suspend()
return FALSE;
}
#ifdef NEW_KEYBOARD_HIT
boolean
safe_keyboard_hit()
{
return FALSE;
}
#endif
void
safe_nhbell()
{

View File

@@ -36,12 +36,6 @@ extern void msmsg(const char *, ...);
#endif
#endif
#ifdef NEW_KEYBOARD_HIT
#if defined(UNIX)
#include <fcntl.h>
#endif
#endif
#ifdef TTY_TILES_ESCCODES
extern short glyph2tile[];
#define TILE_ANSI_COMMAND 'z'
@@ -139,9 +133,6 @@ struct window_procs tty_procs = {
genl_status_update,
#endif
genl_can_suspend_yes,
#ifdef NEW_KEYBOARD_HIT
tty_keyboard_hit
#endif
};
static int maxwin = 0; /* number of windows in use */
@@ -3488,7 +3479,6 @@ const char *str;
#endif
}
#ifndef NEW_KEYBOARD_HIT
int
tty_nhgetch()
{
@@ -3543,93 +3533,6 @@ tty_nhgetch()
#endif /* TTY_TILES_ESCCODES */
return i;
}
#else /* NEW_KEYBOARD_HIT */
#ifdef UNIX
static boolean stdin_non_blocking = FALSE;
int
tgetch()
{
static volatile int nesting = 0;
int i;
char nestbuf;
if (stdin_non_blocking) {
fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK);
stdin_non_blocking = FALSE;
}
/* kludge alert: Some Unix variants return funny values if getc()
* is called, interrupted, and then called again. There
* is non-reentrant code in the internal _filbuf() routine, called by
* getc().
*/
i = (++nesting == 1)
? getchar()
: (read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
? (int) nestbuf : EOF;
--nesting;
return i;
}
boolean
tkbhit()
{
int i;
if (!stdin_non_blocking) {
fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
stdin_non_blocking = TRUE;
}
i = getchar();
if (i != EOF) ungetc(i, stdin);
return (i != EOF);
}
#endif
int
tty_nhgetch()
{
int i;
HUPSKIP_RESULT('\033');
print_vt_code1(AVTC_INLINE_SYNC);
(void) fflush(stdout);
/* Note: if raw_print() and wait_synch() get called to report terminal
* initialization problems, then wins[] and ttyDisplay might not be
* available yet. Such problems will probably be fatal before we get
* here, but validate those pointers just in case...
*/
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
if (iflags.debug_fuzzer) {
i = randomkey();
} else {
i = tgetch();
}
if (!i)
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
else if (i == EOF)
i = '\033'; /* same for EOF */
if (ttyDisplay && ttyDisplay->toplin == 1)
ttyDisplay->toplin = 2;
#ifdef TTY_TILES_ESCCODES
{
/* hack to force output of the window select code */
int tmp = vt_tile_current_window;
vt_tile_current_window++;
print_vt_code2(AVTC_SELECT_WINDOW, tmp);
}
#endif /* TTY_TILES_ESCCODES */
return i;
}
boolean tty_keyboard_hit()
{
/* tgetch provider needs to also provide tkbhit() */
return tkbhit();
}
#endif /* NEW_KEYBOARD_HIT */
/*
* return a key, or 0, in which case a mouse button was pressed

View File

@@ -116,9 +116,6 @@ struct window_procs mswin_procs = {
mswin_status_init, mswin_status_finish, mswin_status_enablefield,
mswin_status_update,
genl_can_suspend_yes,
#ifdef NEW_KEYBOARD_HIT
mswin_keyboard_hit
#endif
};
/*
@@ -1405,15 +1402,6 @@ mswin_nhgetch()
return (key);
}
#ifdef NEW_KEYBOARD_HIT
/* boolean keyboard_hit() -- returns TRUE if input is available */
boolean
mswin_keyboard_hit()
{
return mswin_have_input() != 0;
}
#endif
/*
int nh_poskey(int *x, int *y, int *mod)
-- Returns a single character input from the user or a

View File

@@ -167,9 +167,6 @@ void mswin_raw_print(const char *str);
void mswin_raw_print_bold(const char *str);
void mswin_raw_print_flush();
int mswin_nhgetch(void);
#ifdef NEW_KEYBOARD_HIT
boolean mswin_keyboard_hit(void);
#endif
int mswin_nh_poskey(int *x, int *y, int *mod);
void mswin_nhbell(void);
int mswin_doprev_message(void);