summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-02-16 14:17:26 +0100
committerGitHub <noreply@github.com>2019-02-16 14:17:26 +0100
commit29359c169b68e3ff42f7837650edcd05166d8d72 (patch)
tree7eeebbc92134022f27782fcb92dd7eac788a9f12
parent2e6c98058fe60811f8345eeafb4a5954f7c81fed (diff)
parentb54910eb05296380a0bb9b97df3af8eedac11250 (diff)
Merge pull request #25924 from Calinou/add-gamepad-button-shortcut
Make Button shortcuts triggerable by gamepads
-rw-r--r--core/os/input_event.cpp14
-rw-r--r--core/os/input_event.h1
2 files changed, 12 insertions, 3 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 1e0e83c8d2..24ec8a1963 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -749,6 +749,15 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *
return match;
}
+bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const {
+
+ Ref<InputEventJoypadButton> button = p_event;
+ if (button.is_null())
+ return false;
+
+ return button_index == button->button_index;
+}
+
String InputEventJoypadButton::as_text() const {
return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
@@ -950,11 +959,10 @@ bool InputEventAction::is_pressed() const {
}
bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
- Ref<InputEventKey> event = p_event;
- if (event.is_null())
+ if (p_event.is_null())
return false;
- return event->is_action(action);
+ return p_event->is_action(action);
}
bool InputEventAction::is_action(const StringName &p_action) const {
diff --git a/core/os/input_event.h b/core/os/input_event.h
index db31055b5f..a6a7012298 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -400,6 +400,7 @@ public:
float get_pressure() const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
+ virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
virtual String as_text() const;