pyPad360 v1.0 Available

Now that I’ve finished the project that I was using this for I thought I’d post the final version we used. It’s available here: files.awhetter.co.uk/pypad360-v3-beta.py

It no longer uses pygame but uses pysdl2 instead. It also supports rumbling!
Message strings are no longer appended with the controller number, it’s sent as an argument with the message instead. So they are now of the form “A_DOWN” and “LSTICK_H” instead of “C1_A_DOWN” or “C1_LSTICK_HORZ”.
We were using these like this:

self.accept("LSTICK_H", self.move, [PyPad360.LSTICK_H])

def move(self, axis_num, controller_num)
   amount = self.controllers.axes_states[axis_num]
   # Do move stuff

All of the axis values are normalised to between -1 and 1, and are kept track of in self.axes_states. The LSTICK_H, LSTICK_V, etc class variables relate to the index that that axis is in axes_states. So self.axes_states[self.LSTICK_H] will get you the axes state of the horizontal movement of the left stick.

The controllers are rumbled using messenger.send(“rumble-controller”, [controllerId, strength, duration]), where controllerId is the number of the controller to rumble, strength is a number between 0 and 1, and duration is the amount of time to rumble for in milliseconds. (strength and duration documentation is here: wiki.libsdl.org/CategoryForceFeedback)

It doesn’t support hot plugging controllers but it should be possible because an unexpected event type (e.type) occurs when one is plugged in. No checks are done on array indexes but they probably should be. Annoyingly the button and axis mappings for the default kernel driver in Linux and for xboxdrv differ so I’d recommend allowing the user to change those. Also this is untested on Mac.