W341-2 Finnish and international keyboard arrangements

This commit is contained in:
nethack.allison
2003-03-02 12:58:29 +00:00
parent be0ad1b8ab
commit eab7064510
4 changed files with 70 additions and 6 deletions

View File

@@ -132,6 +132,7 @@ extern void NDECL(win32_abort);
#ifdef WIN32CON
extern void FDECL(nttty_preference_update, (const char *));
extern void NDECL(toggle_mouse_support);
extern void FDECL(map_subkeyvalue, (char *));
#endif
#include <fcntl.h>

View File

@@ -316,6 +316,9 @@ static struct Comp_Opt
40, DISP_IN_GAME },
{ "videoshades", "gray shades to map to black/gray/white",
32, DISP_IN_GAME },
#endif
#ifdef WIN32CON
{"subkeyvalue", "override keystroke value", 7, SET_IN_FILE},
#endif
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
80, DISP_IN_GAME },
@@ -981,6 +984,7 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, "colour", 5, FALSE))
Strcpy(opts, "color"); /* fortunately this isn't longer */
if (!match_optname(opts, "subkeyvalue", 11, TRUE)) /* allow multiple */
duplicate_opt_detection(opts, 1); /* 1 means compound opts */
/* special boolean options */
@@ -1889,6 +1893,17 @@ goodfruit:
} else if (negated) bad_negation(fullname, TRUE);
return;
}
fullname = "subkeyvalue";
if (match_optname(opts, fullname, 5, TRUE)) {
if (negated) bad_negation(fullname, FALSE);
else {
#if defined(WIN32CON)
op = string_for_opt(opts, 0);
map_subkeyvalue(op);
#endif
}
return;
}
/* WINCAP
* tile_width:nn */
fullname = "tile_width";
@@ -1930,7 +1945,6 @@ goodfruit:
} else if (negated) bad_negation(fullname, TRUE);
return;
}
fullname = "windowtype";
if (match_optname(opts, fullname, 3, TRUE)) {
if (negated) {

View File

@@ -106,6 +106,15 @@ OPTIONS=hilite_pet,!toptenwin
# The location that a record of game aborts and self-diagnosed game problems
# is kept (default=HACKDIR, writeable)
#TROUBLEDIR=c:\nethack\trouble
# Finnish keyboards might need these modifications uncommented.
# For \, @, $, [, |
#OPTIONS=subkeyvalue:171/92
#OPTIONS=subkeyvalue:178/64
#OPTIONS=subkeyvalue:180/36
#OPTIONS=subkeyvalue:184/91
#OPTIONS=subkeyvalue:188/124
#
# *** CHARACTER GRAPHICS ***
#
@@ -165,4 +174,3 @@ OPTIONS=hilite_pet,!toptenwin
# 047 045 092 058 058 092 045 047 \
# 047 045 092 058 032 058 092 045 047

View File

@@ -61,6 +61,9 @@ int ttycolors[CLR_MAX];
static void NDECL(init_ttycolor);
# endif
#define MAX_OVERRIDES 256
unsigned char key_overrides[MAX_OVERRIDES];
#define DEFTEXTCOLOR ttycolors[7]
#ifdef TEXTCOLOR
#define DEFGLYPHBGRND (0)
@@ -331,9 +334,9 @@ INPUT_RECORD *ir;
boolean *valid;
int portdebug;
{
int metaflags = 0, k;
int metaflags = 0, k = 0;
int keycode, vk;
unsigned char ch, pre_ch;
unsigned char ch, pre_ch, mk = 0;
unsigned short int scan;
unsigned long shiftstate;
int altseq = 0;
@@ -406,13 +409,20 @@ int portdebug;
*valid = FALSE;
}
}
/* check for override */
if (ch && ch < MAX_OVERRIDES && key_overrides[ch]) {
mk = ch;
ch = key_overrides[ch];
*valid = TRUE;
}
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 (ESC to end)\n",
ch, scan, vk, pre_ch, shiftstate);
"PORTDEBUG: ch=%u, sc=%u, vk=%d, pre=%d, sh=0x%X, ta=%d, mk=%d (ESC to end)\n",
ch, scan, vk, pre_ch, shiftstate, k, mk);
xputs(buf);
}
#endif
@@ -936,4 +946,35 @@ win32con_debug_keystrokes()
(void)doredraw();
}
#endif
void
map_subkeyvalue(op)
register char *op;
{
char digits[] = "0123456789";
int length, i, idx, val;
char *kp;
idx = -1;
val = -1;
kp = index(op, '/');
if (kp) {
*kp = '\0';
kp++;
length = strlen(kp);
if (length < 1 || length > 3) return;
for (i = 0; i < length; i++)
if (!index(digits, kp[i])) return;
val = atoi(kp);
length = strlen(op);
if (length < 1 || length > 3) return;
for (i = 0; i < length; i++)
if (!index(digits, op[i])) return;
idx = atoi(op);
}
if (idx >= MAX_OVERRIDES || idx < 0 || val >= MAX_OVERRIDES || val < 1)
return;
key_overrides[idx] = val;
}
#endif /* WIN32CON */