xbox controller

This commit is contained in:
apirrone 2025-01-11 18:12:31 +01:00
parent 8042e9b119
commit a3234557b6
2 changed files with 37 additions and 1 deletions

View file

@ -69,7 +69,30 @@ TODO
### Setup xbox one controller over bluetooth
TODO
Turn your xbox one controller on and set it in pairing mode by long pressing the sync button on the top of the controller.
Run the following commands on the rasp :
```bash
bluetoothctl
scan on
```
Wait for the controller to appear in the list, then run :
```bash
pair <controller_mac_address>
trust <controller_mac_address>
connect <controller_mac_address>
```
The led on the controller should stop blinking and stay on.
You can test that it's working by running
```bash
python3 scripts/test_xbox_controller.py
```
## Install the runtime

View file

@ -0,0 +1,13 @@
import pygame
pygame.init()
_p1 = pygame.joystick.Joystick(0)
_p1.init()
print(f"Loaded joystick with {_p1.get_numaxes()} axes.")
while True:
for event in pygame.event.get():
print(_p1.get_axis(0), _p1.get_axis(1), _p1.get_axis(2), _p1.get_axis(3))
pygame.event.pump() # process event queue