diff options
| -rw-r--r-- | game/client/const.hh | 5 | ||||
| -rw-r--r-- | game/client/keybind.cc | 24 | ||||
| -rw-r--r-- | game/client/settings.cc | 3 | ||||
| -rw-r--r-- | game/client/toggles.cc | 3 |
4 files changed, 28 insertions, 7 deletions
diff --git a/game/client/const.hh b/game/client/const.hh index 8c2c252..9bd8346 100644 --- a/game/client/const.hh +++ b/game/client/const.hh @@ -4,6 +4,11 @@ #include "shared/const.hh" +// This key is then going to be reserved for only +// the debug toggles and users won't be able to +// use this key for conventional gameplay things +constexpr static int DEBUG_KEY = GLFW_KEY_F3; + constexpr static int BASE_WIDTH = 320; constexpr static int BASE_HEIGHT = 240; diff --git a/game/client/keybind.cc b/game/client/keybind.cc index f631485..7df73ed 100644 --- a/game/client/keybind.cc +++ b/game/client/keybind.cc @@ -3,6 +3,8 @@ #include "core/constexpr.hh" +#include "client/const.hh" + constexpr static const char *UNKNOWN_KEY_NAME = "UNKNOWN"; static const std::pair<int, const char *> key_names[] = { @@ -147,14 +149,20 @@ ConfigKeyBind::ConfigKeyBind(void) ConfigKeyBind::ConfigKeyBind(int default_value) { - m_glfw_keycode = default_value; - m_name = get_key_name(default_value); + if(default_value == DEBUG_KEY) { + m_glfw_keycode = GLFW_KEY_UNKNOWN; + m_name = UNKNOWN_KEY_NAME; + } + else { + m_glfw_keycode = default_value; + m_name = get_key_name(default_value); + } } void ConfigKeyBind::set(const char *value) { for(const auto &it : key_names) { - if(!std::strcmp(it.second, value)) { + if((it.first != DEBUG_KEY) && !std::strcmp(it.second, value)) { m_glfw_keycode = it.first; m_name = it.second; return; @@ -172,8 +180,14 @@ const char *ConfigKeyBind::get(void) const void ConfigKeyBind::set_key(int keycode) { - m_glfw_keycode = keycode; - m_name = get_key_name(keycode); + if(keycode == DEBUG_KEY) { + m_glfw_keycode = GLFW_KEY_UNKNOWN; + m_name = UNKNOWN_KEY_NAME; + } + else { + m_glfw_keycode = keycode; + m_name = get_key_name(keycode); + } } int ConfigKeyBind::get_key(void) const diff --git a/game/client/settings.cc b/game/client/settings.cc index 8d0c81f..65679cb 100644 --- a/game/client/settings.cc +++ b/game/client/settings.cc @@ -4,6 +4,7 @@ #include "core/config.hh" #include "core/constexpr.hh" +#include "client/const.hh" #include "client/gamepad_axis.hh" #include "client/gamepad_button.hh" #include "client/gamepad.hh" @@ -529,7 +530,7 @@ static void refresh_input_wids(void) static void on_glfw_key(const GlfwKeyEvent &event) { - if(event.action == GLFW_PRESS) { + if((event.action == GLFW_PRESS) && (event.key != DEBUG_KEY)) { if(globals::gui_keybind_ptr || globals::gui_gamepad_axis_ptr || globals::gui_gamepad_button_ptr) { if(event.key == GLFW_KEY_ESCAPE) { ImGuiIO &io = ImGui::GetIO(); diff --git a/game/client/toggles.cc b/game/client/toggles.cc index 7d51832..7e20875 100644 --- a/game/client/toggles.cc +++ b/game/client/toggles.cc @@ -4,6 +4,7 @@ #include "core/config.hh" #include "client/chat.hh" +#include "client/const.hh" #include "client/gamepad.hh" #include "client/glfw.hh" #include "client/globals.hh" @@ -51,7 +52,7 @@ static void on_glfw_key(const GlfwKeyEvent &event) return; } - if(event.key == GLFW_KEY_F3) { + if(event.key == DEBUG_KEY) { if(event.action == GLFW_PRESS) { toggles::is_sequence_await = true; return; |
