|
@@ -88,7 +88,7 @@ String InputEvent::as_text() const {
|
|
|
return String();
|
|
|
}
|
|
|
|
|
|
-bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -288,25 +288,21 @@ String InputEventKey::as_text() const {
|
|
|
return kc;
|
|
|
}
|
|
|
|
|
|
-bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
Ref<InputEventKey> key = p_event;
|
|
|
if (key.is_null()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- bool match = false;
|
|
|
- if (get_scancode() == 0) {
|
|
|
- uint32_t code = get_physical_scancode_with_modifiers();
|
|
|
- uint32_t event_code = key->get_physical_scancode_with_modifiers();
|
|
|
-
|
|
|
- match = get_physical_scancode() == key->get_physical_scancode() && (!key->is_pressed() || (code & event_code) == code);
|
|
|
+ bool match;
|
|
|
+ if (scancode != 0) {
|
|
|
+ match = scancode == key->scancode;
|
|
|
} else {
|
|
|
- uint32_t code = get_scancode_with_modifiers();
|
|
|
- uint32_t event_code = key->get_scancode_with_modifiers();
|
|
|
-
|
|
|
- match = get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);
|
|
|
+ match = physical_scancode == key->physical_scancode;
|
|
|
+ }
|
|
|
+ if (p_exact_match) {
|
|
|
+ match &= get_modifiers_mask() == key->get_modifiers_mask();
|
|
|
}
|
|
|
-
|
|
|
if (match) {
|
|
|
bool pressed = key->is_pressed();
|
|
|
if (p_pressed != nullptr) {
|
|
@@ -466,13 +462,16 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
|
|
|
return mb;
|
|
|
}
|
|
|
|
|
|
-bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
Ref<InputEventMouseButton> mb = p_event;
|
|
|
if (mb.is_null()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
bool match = mb->button_index == button_index;
|
|
|
+ if (p_exact_match) {
|
|
|
+ match &= get_modifiers_mask() == mb->get_modifiers_mask();
|
|
|
+ }
|
|
|
if (match) {
|
|
|
bool pressed = mb->is_pressed();
|
|
|
if (p_pressed != nullptr) {
|
|
@@ -730,13 +729,17 @@ bool InputEventJoypadMotion::is_pressed() const {
|
|
|
return Math::abs(axis_value) >= 0.5f;
|
|
|
}
|
|
|
|
|
|
-bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
Ref<InputEventJoypadMotion> jm = p_event;
|
|
|
if (jm.is_null()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- bool match = (axis == jm->axis); // Matches even if not in the same direction, but returns a "not pressed" event.
|
|
|
+ // Matches even if not in the same direction, but returns a "not pressed" event.
|
|
|
+ bool match = (axis == jm->axis);
|
|
|
+ if (p_exact_match) {
|
|
|
+ match &= (axis_value < 0) == (jm->axis_value < 0);
|
|
|
+ }
|
|
|
if (match) {
|
|
|
float jm_abs_axis_value = Math::abs(jm->get_axis_value());
|
|
|
bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0);
|
|
@@ -819,7 +822,7 @@ float InputEventJoypadButton::get_pressure() const {
|
|
|
return pressure;
|
|
|
}
|
|
|
|
|
|
-bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
Ref<InputEventJoypadButton> jb = p_event;
|
|
|
if (jb.is_null()) {
|
|
|
return false;
|
|
@@ -1059,7 +1062,7 @@ bool InputEventAction::is_action(const StringName &p_action) const {
|
|
|
return action == p_action;
|
|
|
}
|
|
|
|
|
|
-bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
+bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
|
|
|
Ref<InputEventAction> act = p_event;
|
|
|
if (act.is_null()) {
|
|
|
return false;
|