I'm very new to evdev and am currently trying to use an xbox controller to control a small robot. I am successful with each of the buttons, but I can not seem to figure out how to get valid readings from the joysticks.
This code only works for button response.
edit: Whenever an ABXY button is pressed, EV_ABS events occur also. I am not sure how to distinguish between these values and actual values of the joystick. Additionally, the event codes from the joystick movements are inconsistent. Here is the code I'm currently running:
from evdev import InputDevice, categorize, ecodes
dev = InputDevice('/dev/input/event1')
print(dev)
for event in dev.read_loop():
if event.type == ecodes.EV_KEY:
print("button is pressed")
elif event.type == ecodes.EV_ABS:
print(event)
Any advice is appreciated! Thanks!