diff --git a/MAC-START.md b/MAC-START.md index df7efcf..593e862 100644 --- a/MAC-START.md +++ b/MAC-START.md @@ -150,6 +150,15 @@ Spiel läuft dann mit der Tastatur weiter. * **Kabel (empfohlen):** Xbox-One-/Series-Controller per USB-C bzw. micro-USB anstecken. Läuft ohne Treiber, ohne Pairing, und der Controller braucht keine Batterien. + *Blinkt* der Controller am Kabel nur, ist es meist ein reines **Ladekabel** + ohne Datenleitungen – dann ein Datenkabel verwenden. Prüfen, ob der Mac ihn + überhaupt sieht: + + ```bash + system_profiler SPUSBDataType | grep -i -A 6 xbox + ``` + + Bleibt die Ausgabe leer, liegt es an Kabel oder Port, nicht am Spiel. * **Bluetooth:** Systemeinstellungen → Bluetooth → Controller koppeln. Geht, ist am Stand aber störanfälliger (Akku, Reconnects). * **Microsofts Xbox-Funk-Dongle** funktioniert auf macOS **nicht**. diff --git a/README.md b/README.md index d94e56e..13f4e76 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ loader_game/ menu.py Stufenauswahl intro.py Anleitungsbild (Tutorial) + Startsequenz (Ampel, Reissverschluss) game.py Zustandsmaschine einer Runde -tests/test_logic.py 62 Tests (ohne Fenster) +tests/test_logic.py 63 Tests (ohne Fenster) tools/controller_check.py Diagnose: zeigt jede Controller-Eingabe docs/ANALYSE.md Analyse Altstand + Fehlerliste old_version/ eingefrorener Altstand (nicht versioniert) diff --git a/docs/ANALYSE.md b/docs/ANALYSE.md index bcb3c3f..1273b17 100644 --- a/docs/ANALYSE.md +++ b/docs/ANALYSE.md @@ -166,3 +166,22 @@ Behoben in `input_map.py`: Spiel-Aktion. * Tests für die Tastenbelegung (Tasten 0–3, D-Pad als Hat, Stick mit Deadzone), 62 Tests insgesamt. + +## 12. Controller-Diagnose vom MacBook (v1.7) + +Die Ausgabe von `tools/controller_check.py` auf dem MacBook (Xbox Series X +Controller, Bluetooth, pygame 2.6.1 / SDL 2.28.4): + +* Der Controller meldet sich **erst nach dem Start** an (`Gefundene Controller: + keiner`, dann `Controller-Wechsel: …`) – Hotplug greift. +* Tasten 0 (A) und 2 (X) kommen als `JOYBUTTONDOWN` an. +* **Das D-Pad kommt nicht als Hat, sondern als Tasten 11–14** + (11 = hoch, 12 = runter, 13 = links, 14 = rechts). +* Der linke Stick kommt als Achsen 0/1, aufwärts = negativ. + +Daraus: `BUTTON_ACTIONS` um 11–14 erweitert, damit D-Pad im Menü und im Spiel +funktioniert. Test ergänzt (63 Tests). + +Ausserdem in `MAC-START.md` notiert: blinkt der Controller am USB-Kabel nur, +ist in der Regel ein reines Ladekabel ohne Datenleitungen schuld – Prüfbefehl +`system_profiler SPUSBDataType | grep -i -A 6 xbox`. diff --git a/loader_game/input_map.py b/loader_game/input_map.py index cbe4173..e154f27 100644 --- a/loader_game/input_map.py +++ b/loader_game/input_map.py @@ -37,12 +37,18 @@ KEY_ACTIONS: dict[int, Action] = { pygame.K_ESCAPE: Action.BACK, } -#: Controller-Tasten (Xbox-Layout: 0=A, 1=B, 2=X, 3=Y) +#: Controller-Tasten. Xbox-Layout: 0=A, 1=B, 2=X, 3=Y. +#: Das D-Pad meldet macOS bei Xbox-Controllern nicht als Hat, sondern als +#: Tasten 11-14 (Reihenfolge hoch, runter, links, rechts). BUTTON_ACTIONS: dict[int, Action] = { 0: Action.PRIMARY, 1: Action.BACK, 2: Action.LEFT, 3: Action.UP, + 11: Action.UP, + 12: Action.DOWN, + 13: Action.LEFT, + 14: Action.RIGHT, } #: D-Pad, das als Hat gemeldet wird diff --git a/tests/test_logic.py b/tests/test_logic.py index 741c52d..deec805 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -539,6 +539,21 @@ class ControllerMappingTests(unittest.TestCase): [], ) + def test_dpad_as_buttons(self) -> None: + # macOS meldet das D-Pad von Xbox-Controllern als Tasten 11-14. + for button, expected in ( + (11, Action.UP), + (12, Action.DOWN), + (13, Action.LEFT), + (14, Action.RIGHT), + ): + self.assertEqual( + input_map.actions_from_event( + self.event(type=pygame.JOYBUTTONDOWN, button=button, joy=0) + ), + [expected], + ) + def test_dpad_as_hat(self) -> None: for value, expected in ( ((-1, 0), Action.LEFT),