Fixed UI navigation using joy axis inputs

Fixes #31879
This commit is contained in:
PouleyKetchoupp 2019-09-02 04:36:32 +02:00
parent aa06f515e0
commit 01c9ad1cdf

View file

@ -2289,32 +2289,34 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (from && p_event->is_pressed()) {
Control *next = NULL;
if (p_event->is_action_pressed("ui_focus_next")) {
Input *input = Input::get_singleton();
if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
next = from->find_next_valid_focus();
}
if (p_event->is_action_pressed("ui_focus_prev")) {
if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) {
next = from->find_prev_valid_focus();
}
if (!mods && p_event->is_action_pressed("ui_up")) {
if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) {
next = from->_get_focus_neighbour(MARGIN_TOP);
}
if (!mods && p_event->is_action_pressed("ui_left")) {
if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) {
next = from->_get_focus_neighbour(MARGIN_LEFT);
}
if (!mods && p_event->is_action_pressed("ui_right")) {
if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) {
next = from->_get_focus_neighbour(MARGIN_RIGHT);
}
if (!mods && p_event->is_action_pressed("ui_down")) {
if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) {
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
}