summaryrefslogtreecommitdiffstats
path: root/game/client/keybind.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-15 17:12:47 +0500
committeruntodesu <kirill@untode.su>2025-03-15 17:12:47 +0500
commit3a6cfe786a9e78188923849e3f65e2218b1af80c (patch)
tree7d8e54c334d7053ce3af0334593338680ac78da6 /game/client/keybind.cc
parente53cca0ec8b4186cf79b6f927d74483f1301d5f6 (diff)
downloadvoxelius-3a6cfe786a9e78188923849e3f65e2218b1af80c.tar.bz2
voxelius-3a6cfe786a9e78188923849e3f65e2218b1af80c.zip
Hard-code DEBUG_KEY and make it un-bindable
Diffstat (limited to 'game/client/keybind.cc')
-rw-r--r--game/client/keybind.cc24
1 files changed, 19 insertions, 5 deletions
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