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:
@@ -184,7 +184,10 @@ E void FDECL(set_occupation, (int (*)(void), const char *, int));
|
||||
E char NDECL(pgetchar);
|
||||
E void FDECL(pushch, (CHAR_P));
|
||||
E void FDECL(savech, (CHAR_P));
|
||||
E void NDECL(add_debug_extended_commands);
|
||||
E const char *FDECL(key2extcmddesc, (UCHAR_P));
|
||||
E boolean FDECL(bind_specialkey, (UCHAR_P, char *));
|
||||
E char FDECL(txt2key, (char *));
|
||||
E void FDECL(parseautocomplete, (char *, BOOLEAN_P));
|
||||
E void FDECL(reset_commands, (BOOLEAN_P));
|
||||
E void FDECL(rhack, (char *));
|
||||
E int NDECL(doextlist);
|
||||
@@ -193,6 +196,8 @@ E int NDECL(enter_explore_mode);
|
||||
E void FDECL(enlightenment, (int, int));
|
||||
E void FDECL(youhiding, (BOOLEAN_P, int));
|
||||
E void FDECL(show_conduct, (int));
|
||||
E void FDECL(bind_key, (UCHAR_P, char *));
|
||||
E void NDECL(dokeylist);
|
||||
E int FDECL(xytod, (SCHAR_P, SCHAR_P));
|
||||
E void FDECL(dtoxy, (coord *, int));
|
||||
E int FDECL(movecmd, (CHAR_P));
|
||||
@@ -211,6 +216,7 @@ E void NDECL(end_of_input);
|
||||
#endif
|
||||
E char NDECL(readchar);
|
||||
E void NDECL(sanity_check);
|
||||
E char* FDECL(key2txt, (UCHAR_P, char *));
|
||||
E char FDECL(yn_function, (const char *, const char *, CHAR_P));
|
||||
E boolean FDECL(paranoid_query, (BOOLEAN_P, const char *));
|
||||
|
||||
@@ -847,6 +853,7 @@ E char *FDECL(lcase, (char *));
|
||||
E char *FDECL(ucase, (char *));
|
||||
E char *FDECL(upstart, (char *));
|
||||
E char *FDECL(mungspaces, (char *));
|
||||
E char *FDECL(trimspaces, (char *));
|
||||
E char *FDECL(strip_newline, (char *));
|
||||
E char *FDECL(eos, (char *));
|
||||
E boolean FDECL(str_end_is, (const char *, const char *));
|
||||
@@ -1661,6 +1668,7 @@ E void FDECL(next_opt, (winid, const char *));
|
||||
E int FDECL(fruitadd, (char *, struct fruit *));
|
||||
E int FDECL(choose_classes_menu, (const char *, int, BOOLEAN_P,
|
||||
char *, char *));
|
||||
E void FDECL(parsebindings, (char *));
|
||||
E void FDECL(add_menu_cmd_alias, (CHAR_P, CHAR_P));
|
||||
E char FDECL(map_menu_cmd, (CHAR_P));
|
||||
E void FDECL(assign_warnings, (uchar *));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
#ifndef FUNC_TAB_H
|
||||
#define FUNC_TAB_H
|
||||
|
||||
struct func_tab {
|
||||
char f_char;
|
||||
boolean can_if_buried;
|
||||
int NDECL((*f_funct));
|
||||
const char *f_text;
|
||||
};
|
||||
/* extended command flags */
|
||||
#define IFBURIED 0x01 /* can do command when buried */
|
||||
#define AUTOCOMPLETE 0x02 /* command autocompletes */
|
||||
#define WIZMODECMD 0x04 /* wizard-mode command */
|
||||
#define GENERALCMD 0x08 /* general command, does not take game time */
|
||||
|
||||
struct ext_func_tab {
|
||||
uchar key;
|
||||
const char *ef_txt, *ef_desc;
|
||||
int NDECL((*ef_funct));
|
||||
boolean can_if_buried;
|
||||
int flags;
|
||||
const char *f_text;
|
||||
};
|
||||
|
||||
extern struct ext_func_tab extcmdlist[];
|
||||
|
||||
Reference in New Issue
Block a user