You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Fix UI navigation with joysticks
This commit is contained in:
@@ -2427,28 +2427,57 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|||||||
if (from && p_event->is_pressed()) {
|
if (from && p_event->is_pressed()) {
|
||||||
Control *next = nullptr;
|
Control *next = nullptr;
|
||||||
|
|
||||||
if (p_event->is_action_pressed("ui_focus_next", true)) {
|
Ref<InputEventJoypadMotion> joypadmotion_event = p_event;
|
||||||
next = from->find_next_valid_focus();
|
if (joypadmotion_event.is_valid()) {
|
||||||
}
|
Input *input = Input::get_singleton();
|
||||||
|
|
||||||
if (p_event->is_action_pressed("ui_focus_prev", true)) {
|
if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
|
||||||
next = from->find_prev_valid_focus();
|
next = from->find_next_valid_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mods && p_event->is_action_pressed("ui_up", true)) {
|
if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) {
|
||||||
next = from->_get_focus_neighbour(MARGIN_TOP);
|
next = from->find_prev_valid_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mods && p_event->is_action_pressed("ui_left", true)) {
|
if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) {
|
||||||
next = from->_get_focus_neighbour(MARGIN_LEFT);
|
next = from->_get_focus_neighbour(MARGIN_TOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mods && p_event->is_action_pressed("ui_right", true)) {
|
if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) {
|
||||||
next = from->_get_focus_neighbour(MARGIN_RIGHT);
|
next = from->_get_focus_neighbour(MARGIN_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mods && p_event->is_action_pressed("ui_down", true)) {
|
if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) {
|
||||||
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
|
next = from->_get_focus_neighbour(MARGIN_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) {
|
||||||
|
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (p_event->is_action_pressed("ui_focus_next", true)) {
|
||||||
|
next = from->find_next_valid_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_event->is_action_pressed("ui_focus_prev", true)) {
|
||||||
|
next = from->find_prev_valid_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mods && p_event->is_action_pressed("ui_up", true)) {
|
||||||
|
next = from->_get_focus_neighbour(MARGIN_TOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mods && p_event->is_action_pressed("ui_left", true)) {
|
||||||
|
next = from->_get_focus_neighbour(MARGIN_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mods && p_event->is_action_pressed("ui_right", true)) {
|
||||||
|
next = from->_get_focus_neighbour(MARGIN_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mods && p_event->is_action_pressed("ui_down", true)) {
|
||||||
|
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user