From 350fe185784d6d0350ed8b675630440ff425a6ca Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 23 Sep 2008 17:54:13 +0000 Subject: Add heretic key controls to config file list. Add key binding code to heretic/d_main.c and change g_game.c to use the common definitions. Subversion-branch: /branches/raven-branch Subversion-revision: 1265 --- src/heretic/ct_chat.h | 8 ++++++++ src/heretic/d_main.c | 33 +++++++++++++++++++++++++++++++ src/heretic/g_game.c | 16 +-------------- src/m_config.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/m_controls.c | 31 +++++++++++++++++++++++++++++ src/m_controls.h | 11 +++++++++++ 6 files changed, 138 insertions(+), 15 deletions(-) diff --git a/src/heretic/ct_chat.h b/src/heretic/ct_chat.h index 326f65cb..eee7e6ce 100644 --- a/src/heretic/ct_chat.h +++ b/src/heretic/ct_chat.h @@ -24,6 +24,9 @@ // Chat mode stuff // +#ifndef HERETIC_CT_CHAT_H +#define HERETIC_CT_CHAT_H + #define CT_PLR_GREEN 1 #define CT_PLR_YELLOW 2 #define CT_PLR_RED 3 @@ -35,3 +38,8 @@ #define CT_KEY_RED 'r' #define CT_KEY_BLUE 'b' #define CT_KEY_ALL 't' + +extern char *chat_macros[10]; + +#endif /* #ifndef HERETIC_CT_CHAT_H */ + diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c index 6107ba16..6797ace1 100644 --- a/src/heretic/d_main.c +++ b/src/heretic/d_main.c @@ -26,9 +26,13 @@ #include #include +#include "ct_chat.h" #include "doomdef.h" +#include "i_system.h" #include "i_video.h" #include "m_argv.h" +#include "m_config.h" +#include "m_controls.h" #include "p_local.h" #include "s_sound.h" #include "v_video.h" @@ -702,6 +706,35 @@ void CleanExit(void) } #endif +// +// Add configuration file variable bindings. +// + +void D_BindVariables(void) +{ + extern int screenblocks; + extern int snd_Channels; + int i; + + I_BindVariables(); + M_BindBaseControls(); + M_BindHereticControls(); + + M_BindVariable("mouse_sensitivity", &mouseSensitivity); + M_BindVariable("sfx_volume", &snd_MaxVolume); + M_BindVariable("music_volume", &snd_MusicVolume); + M_BindVariable("screenblocks", &screenblocks); + M_BindVariable("snd_channels", &snd_Channels); + + for (i=0; i<10; ++i) + { + char buf[12]; + + sprintf(buf, "chatmacro%i", i); + M_BindVariable(buf, &chat_macros[i]); + } +} + //--------------------------------------------------------------------------- // // PROC D_DoomMain diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 59be2f87..83279a2e 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -29,6 +29,7 @@ #include "doomkeys.h" #include "i_timer.h" #include "i_system.h" +#include "m_controls.h" #include "m_misc.h" #include "m_random.h" #include "p_local.h" @@ -134,21 +135,6 @@ byte *savebuffer, *save_p; // // controls (have defaults) // -int key_right, key_left, key_up, key_down; -int key_strafeleft, key_straferight; -int key_fire, key_use, key_strafe, key_speed; -int key_flyup, key_flydown, key_flycenter; -int key_lookup, key_lookdown, key_lookcenter; -int key_invleft, key_invright, key_useartifact; - -int mousebfire; -int mousebstrafe; -int mousebforward; - -int joybfire; -int joybstrafe; -int joybuse; -int joybspeed; diff --git a/src/m_config.c b/src/m_config.c index 513c3a2c..a4451569 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -173,6 +173,60 @@ static default_t doom_defaults_list[] = CONFIG_VARIABLE_KEY(key_straferight), + //! + // Keyboard key to fly upward. + // + + CONFIG_VARIABLE_KEY(key_flyup), + + //! + // Keyboard key to fly downwards. + // + + CONFIG_VARIABLE_KEY(key_flydown), + + //! + // Keyboard key to center flying. + // + + CONFIG_VARIABLE_KEY(key_flycenter), + + //! + // Keyboard key to look up. + // + + CONFIG_VARIABLE_KEY(key_lookup), + + //! + // Keyboard key to look down. + // + + CONFIG_VARIABLE_KEY(key_lookdown), + + //! + // Keyboard key to center the view. + // + + CONFIG_VARIABLE_KEY(key_lookcenter), + + //! + // Keyboard key to scroll left in the inventory. + // + + CONFIG_VARIABLE_KEY(key_invleft), + + //! + // Keyboard key to scroll right in the inventory. + // + + CONFIG_VARIABLE_KEY(key_invright), + + //! + // Keyboard key to use the current item in the inventory. + // + + CONFIG_VARIABLE_KEY(key_useartifact), + //! // Keyboard key to fire the currently selected weapon. // diff --git a/src/m_controls.c b/src/m_controls.c index 9b81d9c3..1d57c4cc 100644 --- a/src/m_controls.c +++ b/src/m_controls.c @@ -41,7 +41,23 @@ int key_fire = KEY_RCTRL; int key_use = ' '; int key_strafe = KEY_RALT; int key_speed = KEY_RSHIFT; + +// +// Heretic keyboard controls +// +int key_flyup = KEY_PGUP; +int key_flydown = KEY_INS; +int key_flycenter = KEY_HOME; + +int key_lookup = KEY_PGDN; +int key_lookdown = KEY_DEL; +int key_lookcenter = KEY_END; + +int key_invleft = '['; +int key_invright = ']'; +int key_useartifact = KEY_ENTER; + // // Mouse controls // @@ -116,3 +132,18 @@ void M_BindBaseControls(void) M_BindVariable("novert", &novert); } +void M_BindHereticControls(void) +{ + M_BindVariable("key_flyup", &key_flyup); + M_BindVariable("key_flydown", &key_flydown); + M_BindVariable("key_flycenter", &key_flycenter); + + M_BindVariable("key_lookup", &key_lookup); + M_BindVariable("key_lookdown", &key_lookdown); + M_BindVariable("key_lookcenter", &key_lookcenter); + + M_BindVariable("key_invleft", &key_invleft); + M_BindVariable("key_invright", &key_invright); + M_BindVariable("key_useartifact", &key_useartifact); +} + diff --git a/src/m_controls.h b/src/m_controls.h index 93cc6f5b..18e07db8 100644 --- a/src/m_controls.h +++ b/src/m_controls.h @@ -35,6 +35,16 @@ extern int key_fire; extern int key_use; extern int key_strafe; extern int key_speed; + +extern int key_flyup; +extern int key_flydown; +extern int key_flycenter; +extern int key_lookup; +extern int key_lookdown; +extern int key_lookcenter; +extern int key_invleft; +extern int key_invright; +extern int key_useartifact; extern int mousebfire; extern int mousebstrafe; @@ -56,6 +66,7 @@ extern int dclick_use; extern int novert; void M_BindBaseControls(void); +void M_BindHereticControls(void); #endif /* #ifndef __M_CONTROLS_H__ */ -- cgit v1.2.3