2

How can I use an analog joystick in Python on Linux? I come from a C++ background, where I used joystick.h to read events from /dev/input/js[x]. Is there a python wrapper around this I can use, perhaps? I don't really want to have to use a huge library like pyGame or SDL?

bsg75
  • 21
  • 1
  • 3
  • I don't know if it's the same interface, but this might be what you're looking for. http://sourceforge.net/projects/joy2xev/ – Haz Aug 19 '13 at 21:20

3 Answers3

3

This gist worked for me on Ubuntu 15.04 without modification.

Robin Macharg
  • 1,468
  • 14
  • 22
2

There is evdev, It's only for Linux, and it seems to be able to do much more than just handling joystick. I've never tried it, though.

I spent some time looking for a library to only read joystick in a cross-platform way, but didn't find any, and I've ended up with pygame (only initializing joystick and event modules) in my projects.

cube
  • 3,867
  • 7
  • 32
  • 52
0

Now (2016+) there's a new sufficiently multiplatform Python module called "inputs" that you can find on GitHub or install from Pipy

It can read joysticks, controllers, keyboards and mices and seems to offer a good support for all their features, including vibration where available.

RobM
  • 1,005
  • 11
  • 13