You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Merge pull request #21954 from isaacremnant/fix_inputs
Fix is_action_pressed for InputEventActions
This commit is contained in:
@@ -199,6 +199,10 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
|
|||||||
|
|
||||||
Ref<InputEventAction> input_event_action = p_event;
|
Ref<InputEventAction> input_event_action = p_event;
|
||||||
if (input_event_action.is_valid()) {
|
if (input_event_action.is_valid()) {
|
||||||
|
if (p_pressed != NULL)
|
||||||
|
*p_pressed = input_event_action->is_pressed();
|
||||||
|
if (p_strength != NULL)
|
||||||
|
*p_strength = (*p_pressed) ? 1.0f : 0.0f;
|
||||||
return input_event_action->get_action() == p_action;
|
return input_event_action->get_action() == p_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -962,6 +962,22 @@ bool InputEventAction::is_action(const StringName &p_action) const {
|
|||||||
return action == p_action;
|
return action == p_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
|
||||||
|
|
||||||
|
Ref<InputEventAction> act = p_event;
|
||||||
|
if (act.is_null())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool match = action == act->action;
|
||||||
|
if (match) {
|
||||||
|
if (p_pressed != NULL)
|
||||||
|
*p_pressed = act->pressed;
|
||||||
|
if (p_strength != NULL)
|
||||||
|
*p_strength = (*p_pressed) ? 1.0f : 0.0f;
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
String InputEventAction::as_text() const {
|
String InputEventAction::as_text() const {
|
||||||
|
|
||||||
return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
|
return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
|
||||||
|
|||||||
@@ -481,6 +481,8 @@ public:
|
|||||||
|
|
||||||
virtual bool is_action(const StringName &p_action) const;
|
virtual bool is_action(const StringName &p_action) 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 shortcut_match(const Ref<InputEvent> &p_event) const;
|
||||||
virtual bool is_action_type() const { return true; }
|
virtual bool is_action_type() const { return true; }
|
||||||
virtual String as_text() const;
|
virtual String as_text() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user