Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

new Windows binary available

0 views
Skip to first unread message

Michael Allison

unread,
Mar 1, 2003, 9:12:56 PM3/1/03
to
There is a new replacement Windows binary available
called nh341wn3.zip. It may assist those of you
having difficulty with international keyboards by
allowing you to alter the key value information
being returned by the operating system, before it
gets to NetHack.

See the "news" file, and the included "defaults.nh"
for a little more information/samples.

There are no gameplay updates included.

d_mike

unread,
Mar 2, 2003, 1:41:51 PM3/2/03
to
"Michael Allison" wrote:
> There is a new replacement Windows binary available
> called nh341wn3.zip. It may assist those of you
> having difficulty with international keyboards by
> allowing you to alter the key value information
> being returned by the operating system, before it
> gets to NetHack.
> ...

Yes, it works with SE/FI kbd layouts, in a way ...

It's still not perfect because of the way the keys/commands
are mapped at the moment.

On these layouts you use the right alt for '@' which is
located on the number '2' key - which in turn is mapped
as the extended command #twoweapon (M-2). The same goes
for M-? which clashes with right alt + '\'.

One simple fix, and perhaps a bit more generic than remapping
keycodes, would be to only use the left alt as Meta key?

// dmike


d_mike

unread,
Mar 2, 2003, 3:46:34 PM3/2/03
to
> ...

To answer myself ... Had a minute over ...

I just checked the "simple fix", and I guess it's a bit easier
than remapping keycodes via the options file, and it should work
at least as good as that solution. This "fix" will disable the
right alt as a Meta key but return the correct <right alt> + <x>
key.

M-? is still a problem with SE/FI layouts since they have "+"
(normal), "?" (shifted) and "\" (right alt) on the same key. You
would have to press <shift> + <left alt> + <+/?/\> keys at the
same time to invoke M-?. It's not a huge problem to fix, but since
I don't use M-? ...

You can try it (no diff available on this machine ...), 3.4.1
source:

sys\winnt\nttty.c

line 351-353 from

KeyState[VK_CAPITAL] = (shiftstate & CAPSLOCK_ON) ? 0x81 : 0;

if (shiftstate & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) {

to

KeyState[VK_CAPITAL] = (shiftstate & CAPSLOCK_ON) ? 0x81 : 0;
KeyState[VK_MENU] = (shiftstate & RIGHT_ALT_PRESSED) ? 0x81 : 0;

if (shiftstate & (LEFT_ALT_PRESSED)) {

Not perfect, but a quick 2-liner - if you can stand loosing the
right alt as a Meta key.

// dmike


d_mike

unread,
Mar 3, 2003, 6:34:39 PM3/3/03
to

"d_mike" <delg...@RemoveThis.hotmail.com> wrote (once again):
> ...

Had two minutes over tonight, full moon you know :)

Still no diff app on this machine but this patch should fix most, if not
all international keyboard related problems as far as I know (except
Kanjii or double byte setups perhaps. But since the app is often
compiled without double byte or even Unicode support (you would have to
change compiler directives for that) I guess it's pretty much safe.) ...

What you get is full compatiblity with right alt and Meta, including
Shift+Meta combinations.

What you loose is ... Right alt as a Meta key. That's a combination
which is technically not possible on international keyboard layouts so
why try to "fix" something that can't physically be done?

NOTE: If you use the keypad for navigation - you *MUST* activate it
as "keypad" and not "numberpad", i.e. Numlock = OFF. It will *not*
respect the configuration settings, as it's easier to control that
with numlock on/off instead of editing the configuration file.

This is one new function and a rewritten process_keystroke in
sys\winnt\nttty.c. It's still not great, a rewrite of the code is
neccessary for that, but this works good enough.

Swap process_keystroke(...) for this one:
====================================================
int process_keystroke(ir, valid, portdebug)
INPUT_RECORD *ir;
boolean *valid;
int portdebug;
{
unsigned char ch, pre_ch, ascCnt, ascBuf[8], mods;
unsigned short int vk, vs;
unsigned long ss;

*valid = FALSE;
mods = 0;

ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
vk = ir->Event.KeyEvent.wVirtualKeyCode;
vs = ir->Event.KeyEvent.wVirtualScanCode;
ss = ir->Event.KeyEvent.dwControlKeyState & ~(NUMLOCK_ON|SCROLLLOCK_ON);

/* Set keyboard pressed states for ToAscii() */
KeyState[VK_SHIFT] = (ss & SHIFT_PRESSED) ? 0x81 : 0;
KeyState[VK_CONTROL] = (ss & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) ? 0x81
: 0;
KeyState[VK_CAPITAL] = (ss & CAPSLOCK_ON) ? 0x81 : 0;
KeyState[VK_MENU] = (ss & RIGHT_ALT_PRESSED) ? 0x81 : 0;

/* Remap arrow keys and numpad keys - IF THEY ARE ACTIVATED AND NOT
"NUMBERS" */
ch = myMapArrowVK(ch, &vk, &vs);

/* For reasons only known to M$ developers, RIGHT_ALT also generates a
LEFT_CTRL.
** So a RIGHT_ALT is a (RIGHT_ALT+LEFT_CTRL). We make them mutually
exclusive here ...
** Not entirely correct, but close ...
** It's not possible to distinguish a RIGHT_ALT from a
RIGHT_ALT+LEFT_CONTROL since
** they generate the same KeyEvent.dwControlKeyState
*/
if (ss & RIGHT_ALT_PRESSED)
ss &= ~(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED);

if (ch != 0) {
if (ss & LEFT_ALT_PRESSED)
mods |= M(0);

/* Convert to ascii and include modifiers */
ascCnt = ToAscii(vk, vs, KeyState, (LPWORD)&ascBuf, 0);
switch(ascCnt) {
case 0:
ch = 0;
break;
case 1:
ch = ascBuf[0] | mods;
*valid = TRUE;
break;
case 2:
ch = ascBuf[1] | mods;
*valid = TRUE;
break;
default:
ch = 0;
break;
}
}

if (ch == '\r')
ch = '\n';

#ifdef PORT_DEBUG
if (portdebug) {
char buf[BUFSZ];
Sprintf(buf,
"PORTDEBUG: ch=%u, scan=%u, vk=%d, pre=%d, shiftstate=0x%X, mods=0x%X (ESC
to end)\n",
ch, vs, vk, pre_ch, ss, mods);
xputs(buf);
}
#endif

return ch;
}
========================================================


And add this function above process_keystroke(...)
========================================================
int
myMapArrowVK(unsigned char ch, unsigned short int *vk, unsigned short int
*vs)
{
unsigned char result;

switch (*vk) {
case VK_CLEAR:
result = '.';
break;
case VK_LEFT:
result = 'h';
break;
case VK_RIGHT:
result = 'l';
break;
case VK_UP:
result = 'k';
break;
case VK_DOWN:
result = 'j';
break;
case VK_END:
result = 'b';
break;
case VK_NEXT:
result = 'n';
break;
case VK_HOME:
result = 'y';
break;
case VK_PRIOR:
result = 'u';
break;
default:
result = 0;
break;

}

if (result != 0) {
*vk = VkKeyScan(result);
*vs = MapVirtualKey(*vk, 0);
} else
result = ch;

return result;
}
========================================================

That should be compatible with most keyboards and even
fix multiple Meta-Control-Shift combos plus some diacriticals.

// dmike


Sascha Wostmann

unread,
Mar 4, 2003, 12:56:11 PM3/4/03
to
Michael Allison :

here's the settings for (at least my) german keyboard:

> # For \, @, $, [, |
> OPTIONS=subkeyvalue:223/92
> OPTIONS=subkeyvalue:241/64
> #OPTIONS=subkeyvalue:180/36
> OPTIONS=subkeyvalue:184/91
> OPTIONS=subkeyvalue:188/124

You don't need to replace the '$' key, because there's no problem with
shifted keys, just the AltGR-Keys have problems.

To find out what values to enter, follow these instructions:
- comment out all the OPTIONS-Lines above in your defaults.nh
- prepare a list with all the AltGR-Keys in the first column
and two more columns
- start nethack in wizard mode (see guidebook)
- start the portdebug-mode
- press the key you want to remap
in the output, for example
> PORTDEBUG: ch=171, sc=27, vk=187, pre=126, sh=0x21, ta=0, mk=0
- write down the value for "ch=" in the second column (171)
- write down the value for "pre=" in the third column (126)
- repeat for all AltGR-Keys

Now edit your defaults.nh and enter the two values ch/pre, for example
OPTIONS=subkeyvalue:171/126

best regards,
Sascha
--
www.nethack.de
(download mirror for version 3.4.1)

0 new messages