3 Commits

Author SHA1 Message Date
3d2d5a6243 chore(input_manager): clean mapping of actions to evdev button codes
All checks were successful
Code and build check / Check code (push) Successful in 1m25s
Code and build check / Build with uv (push) Successful in 45s
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-06-06 13:36:16 +05:00
565dc49f36 fix(input_manager): prevent game launch when AddGameDialog is open
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-06-06 13:23:55 +05:00
c460737bed fix(input_manager): Prioritize tab switching over game card navigation on left arrow key press
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-06-06 13:09:52 +05:00

View File

@@ -37,8 +37,8 @@ BUTTONS = {
'confirm': {ecodes.BTN_A},
'back': {ecodes.BTN_B},
'add_game': {ecodes.BTN_Y},
'prev_tab': {ecodes.BTN_TL, ecodes.BTN_TL2},
'next_tab': {ecodes.BTN_TR, ecodes.BTN_TR2},
'prev_tab': {ecodes.BTN_TL, ecodes.BTN_TRIGGER_HAPPY7},
'next_tab': {ecodes.BTN_TR, ecodes.BTN_TRIGGER_HAPPY5},
'confirm_stick': {ecodes.BTN_THUMBL, ecodes.BTN_THUMBR},
'context_menu': {ecodes.BTN_START},
'menu': {ecodes.BTN_SELECT, ecodes.BTN_MODE},
@@ -153,7 +153,7 @@ class InputManager(QObject):
return
# Game launch on detail page
if (button_code in BUTTONS['confirm'] or button_code in BUTTONS['confirm_stick']) and self._parent.currentDetailPage is not None:
if (button_code in BUTTONS['confirm'] or button_code in BUTTONS['confirm_stick']) and self._parent.currentDetailPage is not None and self._parent.current_add_game_dialog is None:
if self._parent.current_exec_line:
self._parent.toggleGame(self._parent.current_exec_line, None)
return
@@ -390,6 +390,20 @@ class InputManager(QObject):
focused._show_context_menu(pos)
return True
# Tab switching with Left/Right keys (non-GameCard focus or no focus)
idx = self._parent.stackedWidget.currentIndex()
total = len(self._parent.tabButtons)
if key == Qt.Key.Key_Left and (not isinstance(focused, GameCard) or focused is None):
new = (idx - 1) % total
self._parent.switchTab(new)
self._parent.tabButtons[new].setFocus()
return True
if key == Qt.Key.Key_Right and (not isinstance(focused, GameCard) or focused is None):
new = (idx + 1) % total
self._parent.switchTab(new)
self._parent.tabButtons[new].setFocus()
return True
# Library tab navigation
if self._parent.stackedWidget.currentIndex() == 0:
game_cards = self._parent.gamesListWidget.findChildren(GameCard)
@@ -497,20 +511,6 @@ class InputManager(QObject):
self._parent.tabButtons[0].setFocus()
return True
# Tab switching with Left/Right keys (non-GameCard focus)
idx = self._parent.stackedWidget.currentIndex()
total = len(self._parent.tabButtons)
if key == Qt.Key.Key_Left and not isinstance(focused, GameCard):
new = (idx - 1) % total
self._parent.switchTab(new)
self._parent.tabButtons[new].setFocus()
return True
if key == Qt.Key.Key_Right and not isinstance(focused, GameCard):
new = (idx + 1) % total
self._parent.switchTab(new)
self._parent.tabButtons[new].setFocus()
return True
# Navigate down into tab content
if key == Qt.Key.Key_Down:
if isinstance(focused, NavLabel):
@@ -520,11 +520,6 @@ class InputManager(QObject):
if focusables:
focusables[0].setFocus()
return True
else:
if focused is not None:
focused.focusNextChild()
return True
# Navigate up through tab content
if key == Qt.Key.Key_Up:
if isinstance(focused, NavLabel):
@@ -557,7 +552,6 @@ class InputManager(QObject):
return super().eventFilter(obj, event)
def init_gamepad(self) -> None:
self.check_gamepad()
threading.Thread(target=self.run_udev_monitor, daemon=True).start()