add code support to make keypad behave better with swap_yz option
This is being committed commented out in include/ntconf.h.
This commit is contained in:
@@ -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
|
unix: fix double DLB definition in linux hints file
|
||||||
windows: fix --showpaths output for the data file which relies on being
|
windows: fix --showpaths output for the data file which relies on being
|
||||||
constructed programmatically to incorporate the version suffix
|
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
|
Platform- and/or Interface-Specific Fixes or Features
|
||||||
|
|||||||
@@ -34,7 +34,9 @@
|
|||||||
|
|
||||||
/*#define CHANGE_COLOR*/ /* allow palette changes */
|
/*#define CHANGE_COLOR*/ /* allow palette changes */
|
||||||
#define SELECTSAVED /* Provide menu of saved games to choose from at start */
|
#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.
|
* The remaining code shouldn't need modification.
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
|
|||||||
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
||||||
#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI)
|
#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.
|
* Keypad keys are translated to the normal values below.
|
||||||
* Shifted keypad keys are translated to the
|
* Shifted keypad keys are translated to the
|
||||||
@@ -110,6 +117,15 @@ int portdebug;
|
|||||||
int altseq = 0;
|
int altseq = 0;
|
||||||
const struct pad *kpad;
|
const struct pad *kpad;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numberpad & 0x10) {
|
||||||
|
numberpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
shiftstate = 0L;
|
shiftstate = 0L;
|
||||||
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
||||||
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
||||||
@@ -149,6 +165,14 @@ int portdebug;
|
|||||||
} else {
|
} else {
|
||||||
ch = kpad[scan - KEYPADLO].normal;
|
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 */
|
} else if (altseq > 0) { /* ALT sequence */
|
||||||
if (vk == 0xBF)
|
if (vk == 0xBF)
|
||||||
ch = M('?');
|
ch = M('?');
|
||||||
@@ -238,6 +262,15 @@ coord *cc;
|
|||||||
#endif
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numpad & 0x10) {
|
||||||
|
numpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (!done) {
|
while (!done) {
|
||||||
#if defined(SAFERHANGUP)
|
#if defined(SAFERHANGUP)
|
||||||
dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for
|
dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for
|
||||||
@@ -249,7 +282,14 @@ coord *cc;
|
|||||||
ReadConsoleInput(hConIn, ir, 1, count);
|
ReadConsoleInput(hConIn, ir, 1, count);
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (qwertz)
|
||||||
|
numpad |= 0x10;
|
||||||
|
#endif
|
||||||
ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
|
ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
numpad &= ~0x10;
|
||||||
|
#endif
|
||||||
done = valid;
|
done = valid;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
|
|||||||
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
||||||
#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI)
|
#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.
|
* Keypad keys are translated to the normal values below.
|
||||||
* Shifted keypad keys are translated to the
|
* Shifted keypad keys are translated to the
|
||||||
@@ -120,6 +127,14 @@ int portdebug;
|
|||||||
int altseq = 0;
|
int altseq = 0;
|
||||||
const struct pad *kpad;
|
const struct pad *kpad;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numberpad & 0x10) {
|
||||||
|
numberpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
shiftstate = 0L;
|
shiftstate = 0L;
|
||||||
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
||||||
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
||||||
@@ -163,6 +178,14 @@ int portdebug;
|
|||||||
} else {
|
} else {
|
||||||
ch = kpad[scan - KEYPADLO].normal;
|
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 */
|
} else if (altseq > 0) { /* ALT sequence */
|
||||||
if (vk == 0xBF)
|
if (vk == 0xBF)
|
||||||
ch = M('?');
|
ch = M('?');
|
||||||
@@ -271,6 +294,15 @@ coord *cc;
|
|||||||
#endif
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numpad & 0x10) {
|
||||||
|
numpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (!done) {
|
while (!done) {
|
||||||
#if defined(SAFERHANGUP)
|
#if defined(SAFERHANGUP)
|
||||||
dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for
|
dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for
|
||||||
@@ -289,7 +321,14 @@ coord *cc;
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (ir->EventType == KEY_EVENT
|
if (ir->EventType == KEY_EVENT
|
||||||
&& ir->Event.KeyEvent.bKeyDown) {
|
&& ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (qwertz)
|
||||||
|
numpad |= 0x10;
|
||||||
|
#endif
|
||||||
ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
|
ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
numpad &= ~0x10;
|
||||||
|
#endif
|
||||||
if (valid)
|
if (valid)
|
||||||
return ch;
|
return ch;
|
||||||
} else if (ir->EventType == MOUSE_EVENT) {
|
} else if (ir->EventType == MOUSE_EVENT) {
|
||||||
|
|||||||
@@ -212,6 +212,13 @@ DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
|
|||||||
#define isnumkeypad(x) \
|
#define isnumkeypad(x) \
|
||||||
(KEYPADLO <= (x) && (x) <= 0x51 && (x) != 0x4A && (x) != 0x4E)
|
(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.
|
* Keypad keys are translated to the normal values below.
|
||||||
* Shifted keypad keys are translated to the
|
* Shifted keypad keys are translated to the
|
||||||
@@ -301,6 +308,14 @@ int portdebug;
|
|||||||
const struct pad *kpad;
|
const struct pad *kpad;
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numberpad & 0x10) {
|
||||||
|
numberpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
shiftstate = 0L;
|
shiftstate = 0L;
|
||||||
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
|
||||||
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
scan = ir->Event.KeyEvent.wVirtualScanCode;
|
||||||
@@ -347,6 +362,14 @@ int portdebug;
|
|||||||
} else {
|
} else {
|
||||||
ch = kpad[scan - KEYPADLO].normal;
|
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 */
|
} else if (altseq > 0) { /* ALT sequence */
|
||||||
ReadConsoleInput(hConIn, ir, 1, &count);
|
ReadConsoleInput(hConIn, ir, 1, &count);
|
||||||
if (vk == 0xBF)
|
if (vk == 0xBF)
|
||||||
@@ -471,6 +494,15 @@ coord *cc;
|
|||||||
#endif
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
|
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (numpad & 0x10) {
|
||||||
|
numpad &= ~0x10;
|
||||||
|
qwertz = TRUE;
|
||||||
|
} else {
|
||||||
|
qwertz = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (!done) {
|
while (!done) {
|
||||||
*count = 0;
|
*count = 0;
|
||||||
dwWait = WaitForSingleObject(hConIn, INFINITE);
|
dwWait = WaitForSingleObject(hConIn, INFINITE);
|
||||||
@@ -490,12 +522,19 @@ coord *cc;
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (ir->EventType == KEY_EVENT
|
if (ir->EventType == KEY_EVENT
|
||||||
&& ir->Event.KeyEvent.bKeyDown) {
|
&& ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (qwertz)
|
||||||
|
numpad |= 0x10;
|
||||||
|
#endif
|
||||||
ch = ProcessKeystroke(hConIn, ir, &valid, numpad,
|
ch = ProcessKeystroke(hConIn, ir, &valid, numpad,
|
||||||
#ifdef PORTDEBUG
|
#ifdef PORTDEBUG
|
||||||
1);
|
1);
|
||||||
#else
|
#else
|
||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
numpad &= ~0x10;
|
||||||
|
#endif
|
||||||
if (valid)
|
if (valid)
|
||||||
return ch;
|
return ch;
|
||||||
} else {
|
} else {
|
||||||
@@ -549,6 +588,7 @@ INPUT_RECORD *ir;
|
|||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
unsigned long shiftstate;
|
unsigned long shiftstate;
|
||||||
int altseq = 0, keycode, vk;
|
int altseq = 0, keycode, vk;
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define NEED_VARARGS /* Uses ... */
|
#define NEED_VARARGS /* Uses ... */
|
||||||
#include "win32api.h"
|
#include "win32api.h"
|
||||||
@@ -428,8 +427,17 @@ boolean *valid;
|
|||||||
boolean numberpad;
|
boolean numberpad;
|
||||||
int portdebug;
|
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);
|
console.hConIn, ir, valid, numberpad, portdebug);
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
numberpad &= ~0x10;
|
||||||
|
#endif
|
||||||
/* check for override */
|
/* check for override */
|
||||||
if (ch && ch < MAX_OVERRIDES && key_overrides[ch])
|
if (ch && ch < MAX_OVERRIDES && key_overrides[ch])
|
||||||
ch = key_overrides[ch];
|
ch = key_overrides[ch];
|
||||||
@@ -448,13 +456,20 @@ tgetch()
|
|||||||
int mod;
|
int mod;
|
||||||
coord cc;
|
coord cc;
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
boolean numpad = iflags.num_pad;
|
||||||
|
|
||||||
really_move_cursor();
|
really_move_cursor();
|
||||||
if (iflags.debug_fuzzer)
|
if (iflags.debug_fuzzer)
|
||||||
return randomkey();
|
return randomkey();
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (Cmd.swap_yz)
|
||||||
|
numpad |= 0x10;
|
||||||
|
#endif
|
||||||
|
|
||||||
return (program_state.done_hup)
|
return (program_state.done_hup)
|
||||||
? '\033'
|
? '\033'
|
||||||
: keyboard_handler.pCheckInput(
|
: keyboard_handler.pCheckInput(
|
||||||
console.hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
|
console.hConIn, &ir, &count, numpad, 0, &mod, &cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -464,13 +479,22 @@ int *x, *y, *mod;
|
|||||||
int ch;
|
int ch;
|
||||||
coord cc;
|
coord cc;
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
boolean numpad = iflags.num_pad;
|
||||||
|
|
||||||
really_move_cursor();
|
really_move_cursor();
|
||||||
if (iflags.debug_fuzzer)
|
if (iflags.debug_fuzzer)
|
||||||
return randomkey();
|
return randomkey();
|
||||||
|
#ifdef QWERTZ_SUPPORT
|
||||||
|
if (Cmd.swap_yz)
|
||||||
|
numpad |= 0x10;
|
||||||
|
#endif
|
||||||
ch = (program_state.done_hup)
|
ch = (program_state.done_hup)
|
||||||
? '\033'
|
? '\033'
|
||||||
: keyboard_handler.pCheckInput(
|
: 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) {
|
if (!ch) {
|
||||||
*x = cc.x;
|
*x = cc.x;
|
||||||
*y = cc.y;
|
*y = cc.y;
|
||||||
@@ -1901,12 +1925,17 @@ void nethack_enter_nttty()
|
|||||||
HKL keyboard_layout = GetKeyboardLayout(0);
|
HKL keyboard_layout = GetKeyboardLayout(0);
|
||||||
DWORD primary_language = (UINT_PTR) keyboard_layout & 0x3f;
|
DWORD primary_language = (UINT_PTR) keyboard_layout & 0x3f;
|
||||||
|
|
||||||
if (primary_language == LANG_ENGLISH) {
|
/* This was overriding the handler that had already
|
||||||
if (!load_keyboard_handler("nhdefkey"))
|
been loaded during options parsing. Needs to
|
||||||
error("Unable to load nhdefkey.dll");
|
check first */
|
||||||
} else {
|
if (!iflags.altkeyhandler[0]) {
|
||||||
if (!load_keyboard_handler("nhraykey"))
|
if (primary_language == LANG_ENGLISH) {
|
||||||
error("Unable to load nhraykey.dll");
|
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 */
|
#endif /* TTY_GRAPHICS */
|
||||||
|
|||||||
Reference in New Issue
Block a user