summaryrefslogtreecommitdiff
path: root/core/os/input_event.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-06-02 21:11:10 +0200
committerGitHub <noreply@github.com>2019-06-02 21:11:10 +0200
commit688933ea18fa1da136927da9a3615945379f0fd1 (patch)
tree6ca764f3fbb663294cf5c5adb15b29741511ec46 /core/os/input_event.cpp
parent512f8c7e62a67dcb0540b63bbae2b523283d004d (diff)
parentf24783283201a7508720c5bbc2548ef0563c8b99 (diff)
Merge pull request #29383 from groud/strength_for_inputeventaction
Add configurable strength value to InputEventAction
Diffstat (limited to 'core/os/input_event.cpp')
-rw-r--r--core/os/input_event.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index a072017353..9c5066da3d 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -1010,6 +1010,14 @@ bool InputEventAction::is_pressed() const {
return pressed;
}
+void InputEventAction::set_strength(float p_strength) {
+ strength = CLAMP(p_strength, 0.0f, 1.0f);
+}
+
+float InputEventAction::get_strength() const {
+ return strength;
+}
+
bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
if (p_event.is_null())
return false;
@@ -1051,14 +1059,19 @@ void InputEventAction::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed);
//ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed);
+ ClassDB::bind_method(D_METHOD("set_strength", "strength"), &InputEventAction::set_strength);
+ ClassDB::bind_method(D_METHOD("get_strength"), &InputEventAction::get_strength);
+
// ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
}
InputEventAction::InputEventAction() {
pressed = false;
+ strength = 1.0f;
}
/////////////////////////////