diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-03 12:02:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 12:02:18 +0200 |
commit | a1fe20a57e80fb6594106804fd8d4ba97d49dc06 (patch) | |
tree | 6f3700e6e7caf5cd9999b1ead8192926d8264c07 | |
parent | 40a9cc66a983611dbfac4c3b00964c730f9f3d15 (diff) | |
parent | 01c9ad1cdff598c1686ef3f03e302e4b9779dafb (diff) |
Merge pull request #31880 from nekomatata/joystick-ui-navigation
Fixed UI navigation using joy axis inputs
-rw-r--r-- | scene/main/viewport.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 93eea2ad0b..b5c82ce4e3 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -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); } |