From 3e5fbd50de561ffc9e84fba6c4b2d0a2e13b118a Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 17 Jul 2008 17:12:41 +0000 Subject: Do "keypress -> command_type" via keybindings. Solves bug 2018200, where you couldn't do macros with the old 3.4 keymap since the 3.4 keys were done via macros and macros can't recursively invoke macros. Has the little snag that it doesn't exactly reproduce the 3.4 "fire ammo" command since 3.4 automatically goes to the inventory list but 4.0 doesn't. TODO: * Get levelmap commands to use keybindings instead of hardcoded mappings. * Let function keys and alt keys be bound to commands. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6587 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/macro.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crawl-ref/source/macro.h') diff --git a/crawl-ref/source/macro.h b/crawl-ref/source/macro.h index 35b2514a51..16c13f358c 100644 --- a/crawl-ref/source/macro.h +++ b/crawl-ref/source/macro.h @@ -29,6 +29,10 @@ enum KeymapContext { KC_TARGETING, // Only during 'x' and other targeting modes KC_CONFIRM, // When being asked y/n/q questions +#ifdef USE_TILE + KC_TILE, // For context_for_command() +#endif + KC_CONTEXT_COUNT, // Must always be the last real context KC_NONE // Don't apply any keymaps (for menus) }; @@ -85,4 +89,17 @@ void insert_macro_into_buff(const keyseq& keys); int get_macro_buf_size(); +/////////////////////////////////////////////////////////////// +// Keybinding stuff + +void init_keybindings(); + +command_type name_to_command(std::string name); +std::string command_to_name(command_type cmd); + +command_type key_to_command(int key, KeymapContext context); +int command_to_key(command_type cmd); +KeymapContext context_for_command(command_type cmd); + +void bind_command_to_key(command_type cmd, int key); #endif -- cgit v1.2.3-54-g00ecf