forked from Mirrors/RGSX
fix: update controller mappings and improve loading screen handling
This commit is contained in:
@@ -85,36 +85,12 @@ def _run_windows_gamelist_update():
|
|||||||
|
|
||||||
_run_windows_gamelist_update()
|
_run_windows_gamelist_update()
|
||||||
|
|
||||||
# Vérifier et appliquer les mises à jour AVANT tout chargement des contrôles
|
# Pré-boot: Désactivé — pas de test Internet ni de mise à jour avant l'init
|
||||||
try:
|
try:
|
||||||
# Internet rapide (synchrone) avant init graphique complète
|
logger.debug("Pré-boot: vérification des mises à jour désactivée")
|
||||||
if test_internet():
|
config.update_checked = False
|
||||||
logger.debug("Pré-boot: connexion Internet OK, vérification des mises à jour")
|
except Exception:
|
||||||
# Initialiser un mini-contexte de chargement pour feedback si l'écran est prêt
|
pass
|
||||||
config.menu_state = "loading"
|
|
||||||
config.current_loading_system = _("loading_check_updates")
|
|
||||||
config.loading_progress = 5.0
|
|
||||||
config.needs_redraw = True
|
|
||||||
# Lancer la vérification en mode synchrone via boucle temporaire
|
|
||||||
# Utilise une boucle d'événements courte pour permettre pygame d'initialiser
|
|
||||||
try:
|
|
||||||
# Créer une boucle asyncio ad-hoc si non présente
|
|
||||||
loop = asyncio.new_event_loop()
|
|
||||||
asyncio.set_event_loop(loop)
|
|
||||||
success, _msg = loop.run_until_complete(check_for_updates())
|
|
||||||
logger.debug(f"Pré-boot: check_for_updates terminé success={success}")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Pré-boot: échec check_for_updates: {e}")
|
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
loop.close()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
config.update_checked = True
|
|
||||||
else:
|
|
||||||
logger.debug("Pré-boot: pas d'Internet, pas de vérification des mises à jour")
|
|
||||||
except Exception as e:
|
|
||||||
logger.exception(f"Pré-boot update check a échoué: {e}")
|
|
||||||
|
|
||||||
|
|
||||||
# Initialisation de Pygame
|
# Initialisation de Pygame
|
||||||
@@ -187,6 +163,18 @@ config.init_font()
|
|||||||
config.screen_width, config.screen_height = pygame.display.get_surface().get_size()
|
config.screen_width, config.screen_height = pygame.display.get_surface().get_size()
|
||||||
logger.debug(f"Résolution d'écran : {config.screen_width}x{config.screen_height}")
|
logger.debug(f"Résolution d'écran : {config.screen_width}x{config.screen_height}")
|
||||||
|
|
||||||
|
# Afficher un premier écran de chargement immédiatement pour éviter un écran noir
|
||||||
|
try:
|
||||||
|
if config.menu_state not in ("loading", "error", "pause_menu"):
|
||||||
|
config.menu_state = "loading"
|
||||||
|
config.current_loading_system = _("loading_startup") if _ else "Chargement..."
|
||||||
|
config.loading_progress = 1.0
|
||||||
|
draw_loading_screen(screen)
|
||||||
|
pygame.display.flip()
|
||||||
|
pygame.event.pump()
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Impossible d'afficher l'écran de chargement initial: {e}")
|
||||||
|
|
||||||
# Détection des joysticks après init_display (plus stable sur Batocera)
|
# Détection des joysticks après init_display (plus stable sur Batocera)
|
||||||
try:
|
try:
|
||||||
if platform.system() != "Windows":
|
if platform.system() != "Windows":
|
||||||
@@ -229,11 +217,15 @@ else:
|
|||||||
config.nintendo_controller = True
|
config.nintendo_controller = True
|
||||||
logger.debug(f"Controller detected : {name}")
|
logger.debug(f"Controller detected : {name}")
|
||||||
print(f"Controller detected : {name}")
|
print(f"Controller detected : {name}")
|
||||||
|
elif "trimui" in lname:
|
||||||
|
config.trimui_controller = True
|
||||||
|
logger.debug(f"Controller detected : {name}")
|
||||||
|
print(f"Controller detected : {name}")
|
||||||
elif "logitech" in lname:
|
elif "logitech" in lname:
|
||||||
config.logitech_controller = True
|
config.logitech_controller = True
|
||||||
logger.debug(f"Controller detected : {name}")
|
logger.debug(f"Controller detected : {name}")
|
||||||
print(f"Controller detected : {name}")
|
print(f"Controller detected : {name}")
|
||||||
elif "8bitdo" in name or "8-bitdo" in lname:
|
elif "8bitdo" in lname or "8-bitdo" in lname:
|
||||||
config.eightbitdo_controller = True
|
config.eightbitdo_controller = True
|
||||||
logger.debug(f"Controller detected : {name}")
|
logger.debug(f"Controller detected : {name}")
|
||||||
print(f"Controller detected : {name}")
|
print(f"Controller detected : {name}")
|
||||||
@@ -242,9 +234,15 @@ else:
|
|||||||
logger.debug(f"Controller detected : {name}")
|
logger.debug(f"Controller detected : {name}")
|
||||||
print(f"Controller detected : {name}")
|
print(f"Controller detected : {name}")
|
||||||
# Note: virtual keyboard display now depends on controller presence (config.joystick)
|
# Note: virtual keyboard display now depends on controller presence (config.joystick)
|
||||||
print(f"Generic controller detected : {name}")
|
|
||||||
logger.debug(f"Flags contrôleur: xbox={config.xbox_controller}, ps={config.playstation_controller}, nintendo={config.nintendo_controller}, eightbitdo={config.eightbitdo_controller}, steam={config.steam_controller}, trimui={config.trimui_controller}, logitech={config.logitech_controller}, generic={config.generic_controller}")
|
logger.debug(f"Flags contrôleur: xbox={config.xbox_controller}, ps={config.playstation_controller}, nintendo={config.nintendo_controller}, eightbitdo={config.eightbitdo_controller}, steam={config.steam_controller}, trimui={config.trimui_controller}, logitech={config.logitech_controller}, generic={config.generic_controller}")
|
||||||
|
|
||||||
|
# Si aucune marque spécifique détectée mais un joystick est présent, marquer comme générique
|
||||||
|
if not any([config.xbox_controller, config.playstation_controller, config.nintendo_controller,
|
||||||
|
config.eightbitdo_controller, config.steam_controller, config.trimui_controller,
|
||||||
|
config.logitech_controller]):
|
||||||
|
config.generic_controller = True
|
||||||
|
logger.debug("Aucun contrôleur spécifique détecté, utilisation du profil générique")
|
||||||
|
|
||||||
|
|
||||||
# Vérification des dossiers pour le débogage
|
# Vérification des dossiers pour le débogage
|
||||||
logger.debug(f"SYSTEM_FOLDER: {config.SYSTEM_FOLDER}")
|
logger.debug(f"SYSTEM_FOLDER: {config.SYSTEM_FOLDER}")
|
||||||
@@ -265,16 +263,19 @@ config.repeat_key = None
|
|||||||
config.repeat_start_time = 0
|
config.repeat_start_time = 0
|
||||||
config.repeat_last_action = 0
|
config.repeat_last_action = 0
|
||||||
|
|
||||||
# Initialisation du mixer Pygame
|
# Charger la configuration de la musique AVANT d'initialiser l'audio
|
||||||
pygame.mixer.pre_init(44100, -16, 2, 4096)
|
|
||||||
try:
|
|
||||||
pygame.mixer.init()
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"Échec init mixer: {e}")
|
|
||||||
|
|
||||||
# Charger la configuration de la musique AVANT de lancer la musique
|
|
||||||
load_music_config()
|
load_music_config()
|
||||||
|
|
||||||
|
# Initialisation du mixer Pygame (déférée/évitable si musique désactivée)
|
||||||
|
if getattr(config, 'music_enabled', True):
|
||||||
|
pygame.mixer.pre_init(44100, -16, 2, 4096)
|
||||||
|
try:
|
||||||
|
pygame.mixer.init()
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Échec init mixer: {e}")
|
||||||
|
else:
|
||||||
|
logger.debug("Musique désactivée, on saute l'initialisation du mixer")
|
||||||
|
|
||||||
# Dossier musique Batocera
|
# Dossier musique Batocera
|
||||||
music_folder = os.path.join(config.APP_FOLDER, "assets", "music")
|
music_folder = os.path.join(config.APP_FOLDER, "assets", "music")
|
||||||
music_files = [f for f in os.listdir(music_folder) if f.lower().endswith(('.ogg', '.mp3'))]
|
music_files = [f for f in os.listdir(music_folder) if f.lower().endswith(('.ogg', '.mp3'))]
|
||||||
@@ -317,6 +318,31 @@ else:
|
|||||||
config.menu_state = "loading"
|
config.menu_state = "loading"
|
||||||
logger.debug("Configuration des contrôles trouvée, chargement normal")
|
logger.debug("Configuration des contrôles trouvée, chargement normal")
|
||||||
|
|
||||||
|
# Log de diagnostic: résumé des mappages actifs (type/valeur par action)
|
||||||
|
try:
|
||||||
|
if config.controls_config:
|
||||||
|
summary = {}
|
||||||
|
for action, mapping in config.controls_config.items():
|
||||||
|
mtype = mapping.get("type")
|
||||||
|
val = None
|
||||||
|
if mtype == "key":
|
||||||
|
val = mapping.get("key")
|
||||||
|
elif mtype == "button":
|
||||||
|
val = mapping.get("button")
|
||||||
|
elif mtype == "axis":
|
||||||
|
val = (mapping.get("axis"), mapping.get("direction"))
|
||||||
|
elif mtype == "hat":
|
||||||
|
v = mapping.get("value")
|
||||||
|
if isinstance(v, list):
|
||||||
|
v = tuple(v)
|
||||||
|
val = v
|
||||||
|
elif mtype == "mouse":
|
||||||
|
val = mapping.get("button")
|
||||||
|
summary[action] = {"type": mtype, "value": val, "display": mapping.get("display")}
|
||||||
|
logger.debug(f"Contrôles actifs: {summary}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Impossible de journaliser le résumé des contrôles: {e}")
|
||||||
|
|
||||||
# Initialisation du gamepad
|
# Initialisation du gamepad
|
||||||
joystick = None
|
joystick = None
|
||||||
if pygame.joystick.get_count() > 0:
|
if pygame.joystick.get_count() > 0:
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
"confirm": {
|
"confirm": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 0,
|
"button": 0,
|
||||||
"display": "B"
|
"display": "A"
|
||||||
},
|
},
|
||||||
"cancel": {
|
"cancel": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 1,
|
"button": 1,
|
||||||
"display": "A"
|
"display": "B"
|
||||||
},
|
},
|
||||||
"up": {
|
"up": {
|
||||||
"type": "hat",
|
"type": "hat",
|
||||||
@@ -44,22 +44,22 @@
|
|||||||
"start": {
|
"start": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 9,
|
"button": 9,
|
||||||
"display": "Start"
|
"display": "START"
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 8,
|
"button": 8,
|
||||||
"display": "Select"
|
"display": "SELECT"
|
||||||
},
|
},
|
||||||
"page_up": {
|
"page_up": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 7,
|
"button": 6,
|
||||||
"display": "R2"
|
"display": "L2"
|
||||||
},
|
},
|
||||||
"page_down": {
|
"page_down": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 6,
|
"button": 7,
|
||||||
"display": "L2"
|
"display": "R2"
|
||||||
},
|
},
|
||||||
"history": {
|
"history": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
@@ -73,12 +73,12 @@
|
|||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 5,
|
"button": 4,
|
||||||
"display": "L1"
|
"display": "L1"
|
||||||
},
|
},
|
||||||
"space": {
|
"space": {
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"button": 4,
|
"button": 5,
|
||||||
"display": "R1"
|
"display": "R1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,9 +381,13 @@ def get_control_display(action, default):
|
|||||||
|
|
||||||
elif control_type == 'button':
|
elif control_type == 'button':
|
||||||
button_id = control_config.get('button')
|
button_id = control_config.get('button')
|
||||||
|
# Étendre le mapping pour couvrir plus de manettes (incl. Trimui)
|
||||||
button_names = {
|
button_names = {
|
||||||
0: "A", 1: "B", 2: "X", 3: "Y",
|
0: "A", 1: "B", 2: "X", 3: "Y",
|
||||||
4: "LB", 5: "RB", 6: "Select", 7: "Start"
|
4: "LB", 5: "RB",
|
||||||
|
6: "Select", 7: "Start",
|
||||||
|
8: "Select", 9: "Start",
|
||||||
|
10: "L3", 11: "R3",
|
||||||
}
|
}
|
||||||
return button_names.get(button_id, f"Btn{button_id}")
|
return button_names.get(button_id, f"Btn{button_id}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user