mirror of
https://github.com/apirrone/Open_Duck_Mini_Runtime.git
synced 2025-09-03 11:43:58 +00:00
xbox controller
This commit is contained in:
parent
8042e9b119
commit
a3234557b6
2 changed files with 37 additions and 1 deletions
25
README.md
25
README.md
|
@ -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
|
||||
|
|
13
scripts/test_xbox_controller.py
Normal file
13
scripts/test_xbox_controller.py
Normal 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
|
Loading…
Reference in a new issue