I am trying to read from a PS3 controller in python on Ubuntu and I am not very lucky. I started with the ps3joy driver from Willow Garage (http://www.ros.org/wiki/ps3joy), which supposedly publishes all the important bits of the PS3 controller for something that I have never heard of the name "uinput". Apparently, this is a linux function that allows userpace drivers to provide system events .... Why does the WG driver require root access, given that it is supposedly a user space driver located outside of me, but that is not my question.
In any case, the current state when I try to make it work is that I have a driver, and I checked that it responds to button presses on the controller, but I don’t know how to pull any of this data, so I can use it.
My first assumption was to use pygame to (hopefully) read from / dev / uinput (which I'm sure where the driver sends the data):
from pygame import joystick
if not joystick.get_init():
joystick.init()
js = joystick.Joystick(0)
js.init()
print js.get_numbuttons()
for i in range(js.get_numaxes()):
print js.get_axis(i)
but it didn’t work. The most important part of the problem is that it does the same if I don't have a WG driver at all.
I am sure that this is something simple, that I just do not read the right information, but googling did not help me find the right information, and I get tired and desperate.
source
share