D-Pad von Xbox-Controllern kommt auf macOS als Tasten 11-14 statt Hat - jetzt gemappt (hoch/runter/links/rechts). Hotplug bestaetigt. 63 Tests. MAC-START: Hinweis auf Ladekabel vs. Datenkabel.

This commit is contained in:
Project Bridge committed 2026-11-01 13:13:43 +00:00
1 parent 5237b0a39c
commit 4491fb1524
5 files changed
+51 -2

No files matched your search

+9
View File
@@ -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**.
+1 -1
View File
@@ -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)
+19
View File
@@ -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`.
+7 -1
View File
@@ -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
+15
View File
@@ -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),