onJoyBottonUp(), onJoyBottonDown()

Method that is called when a Button of any connected joystick has been pressed. 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 onJoyButtonDown(self, event):
    	pass

class Atlantis(World):
    def onJoyButtonUp(self, event):
    	pass
  • event.joy ... joystick number, an integer, starting with 0 for the first joystick
  • event.button ... button that has been pressed or released, an integer, starting with 0 for the first button of the hat.

Relevant examples: joystick.py

In Context

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

    def onJoyButtonDown(self, event):
    	print 'Joystick button has been pressed.'
    	print 'Joystick that has fired the event:', event.joy
    	print 'Button that was pressed:', event.button
    	
    def onJoyButtonUp(self, event):
    	print 'Joystick button has been released.'
    	print 'Joystick that has fired the event:', event.joy
    	print 'Button that was released:', event.button
Initiated by Stephan Hechenberger
Thanks to CADRE's 103