From a2249a4b0d38c0524a04bf30fccf9c3ea04c6766 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Mon, 12 May 2003 02:25:08 +0000 Subject: [PATCH] Some altkeyhandler tweaking --- src/options.c | 3 +++ sys/winnt/defaults.nh | 9 +++++++++ sys/winnt/nttty.c | 27 +++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/options.c b/src/options.c index 25771d082..17075865b 100644 --- a/src/options.c +++ b/src/options.c @@ -2663,6 +2663,9 @@ char *buf; defopt); else if (!strcmp(optname,"align")) Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj)); + else if (!strcmp(optname,"altkeyhandler")) + Sprintf(buf, "%s", iflags.altkeyhandler[0] ? + iflags.altkeyhandler : "default"); else if (!strcmp(optname, "boulder")) Sprintf(buf, "%c", iflags.bouldersym ? iflags.bouldersym : oc_syms[(int)objects[BOULDER].oc_class]); diff --git a/sys/winnt/defaults.nh b/sys/winnt/defaults.nh index 2173b4a68..3151e368e 100644 --- a/sys/winnt/defaults.nh +++ b/sys/winnt/defaults.nh @@ -13,6 +13,15 @@ # for tty window-port. OPTIONS=IBMGraphics +# Keyboard handling +# Different keyboard handlers can be loaded. +# Default is nhdefkey.dll but you can override that. +# Ray Chason's keyboard handler +# OPTIONS=altkeyhandler:nhraykey.dll +# +# NetHack 3.4.0 keyboard handling +# OPTIONS=altkeyhandler:nh340key.dll + # *** Personal Preferences *** # Some options to set personal preferences. Uncomment and change these to # suit your personal preference. If several people are to use the same diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index 2afdd6ee4..70374b378 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -825,18 +825,28 @@ register char *op; void load_keyboard_handler() { - char suffx[] = ".dll"; + char suffx[] = ".dll"; + char *truncspot; #define MAX_DLLNAME 25 char kh[MAX_ALTKEYHANDLER]; if (iflags.altkeyhandler[0]) { if (hLibrary) { /* already one loaded apparently */ FreeLibrary(hLibrary); hLibrary = (HANDLE)0; + pNHkbhit = (NHKBHIT)0; + pCheckInput = (CHECKINPUT)0; + pSourceWhere = (SOURCEWHERE)0; + pSourceAuthor = (SOURCEAUTHOR)0; + pKeyHandlerName = (KEYHANDLERNAME)0; + pProcessKeystroke = (PROCESS_KEYSTROKE)0; } + if ((truncspot = strstri(iflags.altkeyhandler, suffx)) != 0) + *truncspot = '\0'; (void) strncpy(kh, iflags.altkeyhandler, (MAX_ALTKEYHANDLER - sizeof suffx) - 1); kh[(MAX_ALTKEYHANDLER - sizeof suffx) - 1] = '\0'; Strcat(kh, suffx); + Strcpy(iflags.altkeyhandler, kh); hLibrary = LoadLibrary(kh); if (hLibrary) { pProcessKeystroke = @@ -853,12 +863,21 @@ load_keyboard_handler() (KEYHANDLERNAME) GetProcAddress (hLibrary, TEXT ("KeyHandlerName")); } } - if (!pProcessKeystroke || !pNHkbhit) { + if (!pProcessKeystroke || !pNHkbhit || !pCheckInput) { if (hLibrary) { FreeLibrary(hLibrary); hLibrary = (HANDLE)0; + pNHkbhit = (NHKBHIT)0; + pCheckInput = (CHECKINPUT)0; + pSourceWhere = (SOURCEWHERE)0; + pSourceAuthor = (SOURCEAUTHOR)0; + pKeyHandlerName = (KEYHANDLERNAME)0; + pProcessKeystroke = (PROCESS_KEYSTROKE)0; } - hLibrary = LoadLibrary("nhdefkey.dll"); + (void)strncpy(kh, "nhdefkey.dll", (MAX_ALTKEYHANDLER - sizeof suffx) - 1); + kh[(MAX_ALTKEYHANDLER - sizeof suffx) - 1] = '\0'; + Strcpy(iflags.altkeyhandler, kh); + hLibrary = LoadLibrary(kh); if (hLibrary) { pProcessKeystroke = (PROCESS_KEYSTROKE) GetProcAddress (hLibrary, TEXT ("ProcessKeystroke")); @@ -874,7 +893,7 @@ load_keyboard_handler() (KEYHANDLERNAME) GetProcAddress (hLibrary, TEXT ("KeyHandlerName")); } } - if (!pProcessKeystroke || !pNHkbhit) { + if (!pProcessKeystroke || !pNHkbhit || !pCheckInput) { if (!hLibrary) raw_printf("\nNetHack was unable to load keystroke handler.\n"); else { -- 2.40.0