Add key rebinding

This is a modified version of Jason Dorje Short's key rebinding
patch, and allows also binding special keys, such as the ones
used in getloc and getpos.

One of the ways to play NetHack on nethack.alt.org is via a HTML
terminal in browser. Unfortunately this means several ctrl-key
combinations cannot be entered, because the browser intercepts
those. Similar thing applies to some international keyboard layouts
on Windows. With this patch, the user can just rebind the command
to a key that works best for them.

I've tested this on Linux TTY, X11, and Windows TTY and GUI.
This commit is contained in:
Pasi Kallinen
2016-10-05 17:19:06 +03:00
parent d0783facdc
commit 680c8a542c
15 changed files with 1696 additions and 422 deletions

View File

@@ -424,9 +424,54 @@ extern NEARDATA struct instance_flags iflags;
#ifdef NHSTDC
/* forward declaration sufficient to declare pointers */
struct func_tab; /* from func_tab.h */
struct ext_func_tab; /* from func_tab.h */
#endif
/* special key functions */
enum nh_keyfunc {
NHKF_ESC = 0,
NHKF_DOAGAIN,
NHKF_REQMENU,
/* run ... clicklook need to be in a continuous block */
NHKF_RUN,
NHKF_RUN2,
NHKF_RUSH,
NHKF_FIGHT,
NHKF_FIGHT2,
NHKF_NOPICKUP,
NHKF_RUN_NOPICKUP,
NHKF_DOINV,
NHKF_TRAVEL,
NHKF_CLICKLOOK,
NHKF_REDRAW,
NHKF_REDRAW2,
NHKF_GETDIR_SELF,
NHKF_GETDIR_SELF2,
NHKF_GETDIR_HELP,
NHKF_COUNT,
NHKF_GETPOS_SELF,
NHKF_GETPOS_PICK,
NHKF_GETPOS_PICK_Q, /* quick */
NHKF_GETPOS_PICK_O, /* once */
NHKF_GETPOS_PICK_V, /* verbose */
NHKF_GETPOS_SHOWVALID,
NHKF_GETPOS_AUTODESC,
NHKF_GETPOS_MON_NEXT,
NHKF_GETPOS_MON_PREV,
NHKF_GETPOS_OBJ_NEXT,
NHKF_GETPOS_OBJ_PREV,
NHKF_GETPOS_DOOR_NEXT,
NHKF_GETPOS_DOOR_PREV,
NHKF_GETPOS_UNEX_NEXT,
NHKF_GETPOS_UNEX_PREV,
NHKF_GETPOS_HELP,
NUM_NHKF
};
/* commands[] is used to directly access cmdlist[] instead of looping
through it to find the entry for a given input character;
move_X is the character used for moving one step in direction X;
@@ -443,7 +488,8 @@ struct cmd {
char move_W, move_NW, move_N, move_NE, move_E, move_SE, move_S, move_SW;
const char *dirchars; /* current movement/direction characters */
const char *alphadirchars; /* same as dirchars if !numpad */
const struct func_tab *commands[256]; /* indexed by input character */
const struct ext_func_tab *commands[256]; /* indexed by input character */
char spkeys[NUM_NHKF];
};
extern NEARDATA struct cmd Cmd;