From 4b13bb6b6e1741ec0ad5f682bdb1746a73665e33 Mon Sep 17 00:00:00 2001 From: skymike03 Date: Sun, 6 Jul 2025 20:54:16 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20lecture=20s=C3=A9curis=C3=A9e=20po?= =?UTF-8?q?ur=20controls.json=20dans=20controls.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controls.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controls.py b/controls.py index aa3e72d..1cdfbe4 100644 --- a/controls.py +++ b/controls.py @@ -1,5 +1,6 @@ import pygame import config +from config import CONTROLS_CONFIG_PATH import asyncio import math from display import draw_validation_transition @@ -17,6 +18,15 @@ JOYHAT_DEBOUNCE = 200 # Délai anti-rebond pour JOYHATMOTION (ms) JOYAXIS_DEBOUNCE = 50 # Délai anti-rebond pour JOYAXISMOTION (ms) REPEAT_ACTION_DEBOUNCE = 50 # Délai anti-rebond pour répétitions up/down/left/right (ms) +def load_controls_config(path=CONTROLS_CONFIG_PATH): + """Charge la configuration des contrôles depuis un fichier JSON.""" + try: + with open(path, "r") as f: + return json.load(f) + except (FileNotFoundError, json.JSONDecodeError) as e: + logging.error(f"Erreur lors de la lecture de {path} : {e}") + return {} + def is_input_matched(event, action_name): """Vérifie si l'événement correspond à l'action configurée.""" if not config.controls_config.get(action_name):