Created
April 22, 2021 02:23
-
-
Save caiogallo/7f48a659ae911e0c37fac8e7661d6905 to your computer and use it in GitHub Desktop.
xbox one bluethooth controller on raspberry pi 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python3 | |
# apt install python-pip | |
# apt install python3-evdev | |
# pip install evdev | |
# | |
# list devices | |
# ls /dev/input/ | |
# | |
# https://diyprojects.io/python-library-evdev-raspberry-pi-use-gamepad-diy-projects-servomotor-games/#.Xa8ZR-gzaUl | |
# | |
from evdev import InputDevice, categorize, ecodes | |
gamepad = InputDevice('/dev/input/event2') | |
print(gamepad) | |
for event in gamepad.read_loop(): | |
if event.type == ecodes.EV_KEY: | |
print(event) | |
elif event.type == ecodes.EV_ABS: | |
absevent = categorize(event) | |
print(ecodes.bytype[absevent.event.type][absevent.event.code], absevent.event.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment