summaryrefslogtreecommitdiffstats
path: root/core/input
diff options
context:
space:
mode:
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input_event.cpp2
-rw-r--r--core/input/input_map.cpp4
-rw-r--r--core/input/input_map.h4
3 files changed, 6 insertions, 4 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index d125bad252..4733aaf220 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -1097,7 +1097,7 @@ JoyAxis InputEventJoypadMotion::get_axis() const {
void InputEventJoypadMotion::set_axis_value(float p_value) {
axis_value = p_value;
- pressed = Math::abs(axis_value) >= 0.5f;
+ pressed = Math::abs(axis_value) >= InputMap::DEFAULT_DEADZONE;
emit_changed();
}
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 6378f18545..954df36f3e 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -42,7 +42,7 @@ InputMap *InputMap::singleton = nullptr;
void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
- ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.2f));
+ ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(DEFAULT_DEADZONE));
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone);
@@ -305,7 +305,7 @@ void InputMap::load_from_project_settings() {
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
Dictionary action = GLOBAL_GET(pi.name);
- float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.2f;
+ float deadzone = action.has("deadzone") ? (float)action["deadzone"] : DEFAULT_DEADZONE;
Array events = action["events"];
add_action(name, deadzone);
diff --git a/core/input/input_map.h b/core/input/input_map.h
index 45798490f7..2b2a025332 100644
--- a/core/input/input_map.h
+++ b/core/input/input_map.h
@@ -49,6 +49,8 @@ public:
List<Ref<InputEvent>> inputs;
};
+ static constexpr float DEFAULT_DEADZONE = 0.2f;
+
private:
static InputMap *singleton;
@@ -74,7 +76,7 @@ public:
bool has_action(const StringName &p_action) const;
List<StringName> get_actions() const;
- void add_action(const StringName &p_action, float p_deadzone = 0.2);
+ void add_action(const StringName &p_action, float p_deadzone = DEFAULT_DEADZONE);
void erase_action(const StringName &p_action);
float action_get_deadzone(const StringName &p_action);