fix: disable gamepad handling on game start thanks to @Vector_null
All checks were successful
Code and build check / Check code (push) Successful in 1m41s
Code and build check / Build with uv (push) Successful in 49s

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
2025-06-15 14:00:06 +05:00
parent f765b5e840
commit 3cc40154b0
2 changed files with 24 additions and 0 deletions

View File

@ -72,6 +72,7 @@ class InputManager(QObject):
):
super().__init__(cast(QObject, main_window))
self._parent = main_window
self._gamepad_handling_enabled = True
# Ensure attributes exist on main_window
self._parent.currentDetailPage = getattr(self._parent, 'currentDetailPage', None)
self._parent.current_exec_line = getattr(self._parent, 'current_exec_line', None)
@ -132,6 +133,16 @@ class InputManager(QObject):
except Exception as e:
logger.error(f"Error in handle_fullscreen_slot: {e}", exc_info=True)
def disable_gamepad_handling(self) -> None:
"""Отключает обработку событий геймпада."""
self._gamepad_handling_enabled = False
self.stop_rumble()
self.dpad_timer.stop()
def enable_gamepad_handling(self) -> None:
"""Включает обработку событий геймпада."""
self._gamepad_handling_enabled = True
def trigger_rumble(self, duration_ms: int = 200, strong_magnitude: int = 0x8000, weak_magnitude: int = 0x8000) -> None:
"""Trigger a rumble effect on the gamepad if supported."""
if not read_rumble_config():
@ -176,6 +187,8 @@ class InputManager(QObject):
@Slot(int)
def handle_button_slot(self, button_code: int) -> None:
if not self._gamepad_handling_enabled:
return
try:
# Ignore gamepad events if a game is launched
if getattr(self._parent, '_gameLaunched', False):
@ -318,6 +331,8 @@ class InputManager(QObject):
@Slot(int, int, float)
def handle_dpad_slot(self, code: int, value: int, current_time: float) -> None:
if not self._gamepad_handling_enabled:
return
try:
# Ignore gamepad events if a game is launched
if getattr(self._parent, '_gameLaunched', False):

View File

@ -1726,6 +1726,8 @@ class MainWindow(QMainWindow):
elif not child_running:
# Игра завершилась сбрасываем флаг, сбрасываем кнопку и останавливаем таймер
self._gameLaunched = False
if hasattr(self, 'input_manager'):
self.input_manager.enable_gamepad_handling()
self.resetPlayButton()
#self._uninhibit_screensaver()
if hasattr(self, 'checkProcessTimer') and self.checkProcessTimer is not None:
@ -1782,6 +1784,9 @@ class MainWindow(QMainWindow):
# Если игра уже запущена для этого exe останавливаем её по нажатию кнопки
if self.game_processes and self.target_exe == current_exe:
if hasattr(self, 'input_manager'):
self.input_manager.enable_gamepad_handling()
for proc in self.game_processes:
try:
parent = psutil.Process(proc.pid)
@ -1821,6 +1826,10 @@ class MainWindow(QMainWindow):
self.target_exe = current_exe
exe_name = os.path.splitext(current_exe)[0]
env_vars = os.environ.copy()
if hasattr(self, 'input_manager'):
self.input_manager.disable_gamepad_handling()
if entry_exec_split[0] == "env" and len(entry_exec_split) > 1 and 'data/scripts/start.sh' in entry_exec_split[1]:
env_vars['START_FROM_STEAM'] = '1'
elif entry_exec_split[0] == "flatpak":