You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Prevent axis-based actions from getting stuck
This commit is contained in:
@@ -701,19 +701,40 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
|
|||||||
|
|
||||||
if (!p_event->is_echo()) {
|
if (!p_event->is_echo()) {
|
||||||
if (p_event->is_action_pressed(E.key)) {
|
if (p_event->is_action_pressed(E.key)) {
|
||||||
|
if (jm.is_valid()) {
|
||||||
|
// If axis is already pressed, don't increase the pressed counter.
|
||||||
|
if (!action.axis_pressed) {
|
||||||
action.pressed++;
|
action.pressed++;
|
||||||
|
action.axis_pressed = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
action.pressed++;
|
||||||
|
}
|
||||||
|
|
||||||
is_pressed = true;
|
is_pressed = true;
|
||||||
if (action.pressed == 1) {
|
if (action.pressed == 1) {
|
||||||
action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames();
|
action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames();
|
||||||
action.pressed_process_frame = Engine::get_singleton()->get_process_frames();
|
action.pressed_process_frame = Engine::get_singleton()->get_process_frames();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
bool is_released = true;
|
||||||
|
if (jm.is_valid()) {
|
||||||
|
// Same as above. Don't release axis when not pressed.
|
||||||
|
if (action.axis_pressed) {
|
||||||
|
action.axis_pressed = false;
|
||||||
|
} else {
|
||||||
|
is_released = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_released) {
|
||||||
if (action.pressed == 1) {
|
if (action.pressed == 1) {
|
||||||
action.released_physics_frame = Engine::get_singleton()->get_physics_frames();
|
action.released_physics_frame = Engine::get_singleton()->get_physics_frames();
|
||||||
action.released_process_frame = Engine::get_singleton()->get_process_frames();
|
action.released_process_frame = Engine::get_singleton()->get_process_frames();
|
||||||
}
|
}
|
||||||
action.pressed = MAX(action.pressed - 1, 0);
|
action.pressed = MAX(action.pressed - 1, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
action.exact = InputMap::get_singleton()->event_is_action(p_event, E.key, true);
|
action.exact = InputMap::get_singleton()->event_is_action(p_event, E.key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ private:
|
|||||||
uint64_t released_physics_frame = UINT64_MAX;
|
uint64_t released_physics_frame = UINT64_MAX;
|
||||||
uint64_t released_process_frame = UINT64_MAX;
|
uint64_t released_process_frame = UINT64_MAX;
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
|
bool axis_pressed = false;
|
||||||
bool exact = true;
|
bool exact = true;
|
||||||
float strength = 0.0f;
|
float strength = 0.0f;
|
||||||
float raw_strength = 0.0f;
|
float raw_strength = 0.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user