onJoyAxisMotion()

Method that is called when any of the analog parts of a connected joystick is moved. Modern joysticks usually have three analog axis, a hat (digital joystick) and anything from four buttons upwards. This event handler method is fired in the world. Joysticks are automatically initialized when Slut starts.

class Atlantis(World):
    def onJoyAxisMotion(self, event):
    	pass
  • event.joy ... joystick number, an integer, starting with 0 for the first joystick
  • event.axis ... active axis on particular joystick, an integer, starting with 0 for the first axis
  • event.value ... current value on particular axis, a float from -1.0 to 1.0 with 0.0 being the center

Relevant examples: joystick.py

In Context

class Atlantis(World):
    def onSetup(self):
        self.name = "Joy"

    def onJoyAxisMotion(self, event):
    	print 'Joystick has been moved.'
    	print 'Joystick that has fired the event:', event.joy
    	print 'Axis that has fired the event:', event.axis
    	print 'Current position of that axis:', event.value
Initiated by Stephan Hechenberger
Thanks to CADRE's 103