With a little project in hands I thought it would be a good excuse to learn python. With the gamepad I have here (Logitech F310), the values of axis X and axis Y for the joysticks vary between 0-255, with 127 or 128 when they are "idle" at the center.
With this code (from http://www.lafavre.us/robotics/IoT_LogitechF310.pdf)
from evdev import InputDevice, categorize, ecodes, KeyEvent
gamepad = InputDevice('/dev/input/event3')
for event in gamepad.read_loop():
if event.type == ecodes.EV_ABS:
absevent = categorize(event)
if ecodes.bytype[absevent.event.type][absevent.event.code] == 'ABS_RZ':
if absevent.event.value > 128:
print 'reverse'
print absevent.event.value
elif absevent.event.value < 127:
print 'forward'
print absevent.event.value
if ecodes.bytype[absevent.event.type][absevent.event.code] == 'ABS_Z':
if absevent.event.value > 128 :
print 'right'
print absevent.event.value
elif absevent.event.value < 127:
print 'left'
print absevent.event.value
I'm able to get the positions for up, down, right, left; what I've failed to accomplish so far is, how to retrieve the values of X and Y when the joystick it's in between the X axis and the Y axis, which are narrow intervals (4 to be precise).