diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 375c2497c..baf32548d 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -325,6 +325,8 @@ taking off a fedora or dented pot (no-delay helmets) left the helmet stuck unix: fix double DLB definition in linux hints file windows: fix --showpaths output for the data file which relies on being constructed programmatically to incorporate the version suffix +windows+tty: add code to make keypad support for swap_yz behave (currently + commented out in include/ntconf.h) Platform- and/or Interface-Specific Fixes or Features diff --git a/include/ntconf.h b/include/ntconf.h index a135ee420..ecdf7bc81 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -34,7 +34,9 @@ /*#define CHANGE_COLOR*/ /* allow palette changes */ #define SELECTSAVED /* Provide menu of saved games to choose from at start */ - + +/* #define QWERTZ_SUPPORT */ /* when swap_yz is True, numpad 7 is 'z' not 'y' */ + /* * ----------------------------------------------------------------- * The remaining code shouldn't need modification. diff --git a/sys/winnt/nh340key.c b/sys/winnt/nh340key.c index 78600ec67..a4faa80c1 100644 --- a/sys/winnt/nh340key.c +++ b/sys/winnt/nh340key.c @@ -52,6 +52,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) #define PADKEYS (KEYPADHI - KEYPADLO + 1) #define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) +#ifdef QWERTZ_SUPPORT +/* when 'numberpad' is 0 and Cmd.swap_yz is True + (signaled by setting 0x10 on boolean numpad argument) + treat keypress of numpad 7 as 'z' rather than 'y' */ +static boolean qwertz = FALSE; +#endif + /* * Keypad keys are translated to the normal values below. * Shifted keypad keys are translated to the @@ -110,6 +117,15 @@ int portdebug; int altseq = 0; const struct pad *kpad; +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + shiftstate = 0L; ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; scan = ir->Event.KeyEvent.wVirtualScanCode; @@ -149,6 +165,14 @@ int portdebug; } else { ch = kpad[scan - KEYPADLO].normal; } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ } else if (altseq > 0) { /* ALT sequence */ if (vk == 0xBF) ch = M('?'); @@ -238,6 +262,15 @@ coord *cc; #endif int ch; boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif while (!done) { #if defined(SAFERHANGUP) dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for @@ -249,7 +282,14 @@ coord *cc; ReadConsoleInput(hConIn, ir, 1, count); if (mode == 0) { if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif done = valid; } } else { diff --git a/sys/winnt/nhdefkey.c b/sys/winnt/nhdefkey.c index f6d110adb..e40cf6a1e 100644 --- a/sys/winnt/nhdefkey.c +++ b/sys/winnt/nhdefkey.c @@ -60,6 +60,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) #define PADKEYS (KEYPADHI - KEYPADLO + 1) #define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) +#ifdef QWERTZ_SUPPORT +/* when 'numberpad' is 0 and Cmd.swap_yz is True + (signaled by setting 0x10 on boolean numpad argument) + treat keypress of numpad 7 as 'z' rather than 'y' */ +static boolean qwertz = FALSE; +#endif + /* * Keypad keys are translated to the normal values below. * Shifted keypad keys are translated to the @@ -120,6 +127,14 @@ int portdebug; int altseq = 0; const struct pad *kpad; +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif shiftstate = 0L; ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; scan = ir->Event.KeyEvent.wVirtualScanCode; @@ -163,6 +178,14 @@ int portdebug; } else { ch = kpad[scan - KEYPADLO].normal; } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ } else if (altseq > 0) { /* ALT sequence */ if (vk == 0xBF) ch = M('?'); @@ -271,6 +294,15 @@ coord *cc; #endif int ch; boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif while (!done) { #if defined(SAFERHANGUP) dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for @@ -289,7 +321,14 @@ coord *cc; if (count > 0) { if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif if (valid) return ch; } else if (ir->EventType == MOUSE_EVENT) { diff --git a/sys/winnt/nhraykey.c b/sys/winnt/nhraykey.c index aafe9c44c..7ce4e0e50 100644 --- a/sys/winnt/nhraykey.c +++ b/sys/winnt/nhraykey.c @@ -212,6 +212,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) #define isnumkeypad(x) \ (KEYPADLO <= (x) && (x) <= 0x51 && (x) != 0x4A && (x) != 0x4E) +#ifdef QWERTZ_SUPPORT +/* when 'numberpad' is 0 and Cmd.swap_yz is True + (signaled by setting 0x10 on boolean numpad argument) + treat keypress of numpad 7 as 'z' rather than 'y' */ +static boolean qwertz = FALSE; +#endif + /* * Keypad keys are translated to the normal values below. * Shifted keypad keys are translated to the @@ -301,6 +308,14 @@ int portdebug; const struct pad *kpad; DWORD count; +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif shiftstate = 0L; ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; scan = ir->Event.KeyEvent.wVirtualScanCode; @@ -347,6 +362,14 @@ int portdebug; } else { ch = kpad[scan - KEYPADLO].normal; } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ } else if (altseq > 0) { /* ALT sequence */ ReadConsoleInput(hConIn, ir, 1, &count); if (vk == 0xBF) @@ -471,6 +494,15 @@ coord *cc; #endif int ch; boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif while (!done) { *count = 0; dwWait = WaitForSingleObject(hConIn, INFINITE); @@ -490,12 +522,19 @@ coord *cc; if (count > 0) { if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif ch = ProcessKeystroke(hConIn, ir, &valid, numpad, #ifdef PORTDEBUG 1); #else 0); #endif +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif if (valid) return ch; } else { @@ -549,6 +588,7 @@ INPUT_RECORD *ir; unsigned char ch; unsigned long shiftstate; int altseq = 0, keycode, vk; + done = 0; retval = 0; while (!done) { diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index 88aea5aad..9c96ae8a4 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -13,7 +13,6 @@ * */ - #ifdef WIN32 #define NEED_VARARGS /* Uses ... */ #include "win32api.h" @@ -428,8 +427,17 @@ boolean *valid; boolean numberpad; int portdebug; { - int ch = keyboard_handler.pProcessKeystroke( + int ch; + +#ifdef QWERTZ_SUPPORT + if (Cmd.swap_yz) + numberpad |= 0x10; +#endif + ch = keyboard_handler.pProcessKeystroke( console.hConIn, ir, valid, numberpad, portdebug); +#ifdef QWERTZ_SUPPORT + numberpad &= ~0x10; +#endif /* check for override */ if (ch && ch < MAX_OVERRIDES && key_overrides[ch]) ch = key_overrides[ch]; @@ -448,13 +456,20 @@ tgetch() int mod; coord cc; DWORD count; + boolean numpad = iflags.num_pad; + really_move_cursor(); if (iflags.debug_fuzzer) return randomkey(); +#ifdef QWERTZ_SUPPORT + if (Cmd.swap_yz) + numpad |= 0x10; +#endif + return (program_state.done_hup) ? '\033' : keyboard_handler.pCheckInput( - console.hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc); + console.hConIn, &ir, &count, numpad, 0, &mod, &cc); } int @@ -464,13 +479,22 @@ int *x, *y, *mod; int ch; coord cc; DWORD count; + boolean numpad = iflags.num_pad; + really_move_cursor(); if (iflags.debug_fuzzer) return randomkey(); +#ifdef QWERTZ_SUPPORT + if (Cmd.swap_yz) + numpad |= 0x10; +#endif ch = (program_state.done_hup) ? '\033' : keyboard_handler.pCheckInput( - console.hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc); + console.hConIn, &ir, &count, numpad, 1, mod, &cc); +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif if (!ch) { *x = cc.x; *y = cc.y; @@ -1901,12 +1925,17 @@ void nethack_enter_nttty() HKL keyboard_layout = GetKeyboardLayout(0); DWORD primary_language = (UINT_PTR) keyboard_layout & 0x3f; - if (primary_language == LANG_ENGLISH) { - if (!load_keyboard_handler("nhdefkey")) - error("Unable to load nhdefkey.dll"); - } else { - if (!load_keyboard_handler("nhraykey")) - error("Unable to load nhraykey.dll"); + /* This was overriding the handler that had already + been loaded during options parsing. Needs to + check first */ + if (!iflags.altkeyhandler[0]) { + if (primary_language == LANG_ENGLISH) { + if (!load_keyboard_handler("nhdefkey")) + error("Unable to load nhdefkey.dll"); + } else { + if (!load_keyboard_handler("nhraykey")) + error("Unable to load nhraykey.dll"); + } } } #endif /* TTY_GRAPHICS */