In pygame 2 the X360 controller mapping has 6 Axes, 11 buttons and 1 hat. X-Box 360 Controller (name: "Xbox 360 Controller") Below are a couple of mappings for two popular game pads.Īxis and hat mappings are listed from -1 to +1. quit ()Ĭontroller mappings are drawn from the underlying SDL library which pygame uses and they differīetween pygame 1 and pygame 2. # If you forget this line, the program will 'hang' # on exit if running from IDLE. Press a button on your controller to start Buttons start red and turn black first time they are pressed. It's particularly helpful for determining of your controller suffers from joystick drift, and detecting dead buttons. unindent () # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT # Go ahead and update the screen with what we've drawn. This page tests game controllers connected to your computer, such as Xbox, PlayStation, or anything supporting USB. tprint ( screen, "Number of joysticks: ". Don't put other drawing commands # above this, or they will be erased with this command. JOYBUTTONUP : print ( "Joystick button released." ) # DRAWING STEP # First, clear the screen to white. JOYBUTTONDOWN : print ( "Joystick button pressed." ) elif event. ![]() done = True # Flag that we are done so we exit this loop. textPrint = TextPrint () # - Main Program Loop - while not done : # EVENT PROCESSING STEP # Possible joystick actions: JOYAXISMOTION, JOYBALLMOTION, JOYBUTTONDOWN, # JOYBUTTONUP, JOYHATMOTION for event in pygame. done = False # Used to manage how fast the screen updates. set_caption ( "My Game" ) # Loop until the user clicks the close button. init () # Set the width and height of the screen (width, height). line_height = 15 def indent ( self ): self. render ( textString, True, BLACK ) screen. Font ( None, 20 ) def tprint ( self, screen, textString ): textBitmap = self. ![]() class TextPrint ( object ): def _init_ ( self ): self. ![]() # It has nothing to do with the joysticks, just outputting the # information. Color ( 'white' ) # This is a simple class that will help us print to the screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |