@@ -50,9 +50,6 @@ async def main():
5050 # Possible joystick events: JOYAXISMOTION, JOYBALLMOTION, JOYBUTTONDOWN,
5151 # JOYBUTTONUP, JOYHATMOTION, JOYDEVICEADDED, JOYDEVICEREMOVED
5252 for event in pygame .event .get ():
53- if event .type == pygame .QUIT :
54- done = True # Flag that we are done so we exit this loop.
55-
5653 if event .type == pygame .JOYBUTTONDOWN :
5754 print ("Joystick button pressed." )
5855 if event .button == 0 :
@@ -64,20 +61,22 @@ async def main():
6461 )
6562 )
6663
67- if event .type == pygame .JOYBUTTONUP :
64+ elif event .type == pygame .JOYBUTTONUP :
6865 print ("Joystick button released." )
6966
7067 # Handle hotplugging
71- if event .type == pygame .JOYDEVICEADDED :
68+ elif event .type == pygame .JOYDEVICEADDED :
7269 # This event will be generated when the program starts for every
7370 # joystick, filling up the list without needing to create them manually.
7471 joy = pygame .joystick .Joystick (event .device_index )
7572 joysticks [joy .get_instance_id ()] = joy
7673 print ("Joystick {} connected" .format (joy .get_instance_id ()))
7774
78- if event .type == pygame .JOYDEVICEREMOVED :
75+ elif event .type == pygame .JOYDEVICEREMOVED :
7976 del joysticks [event .instance_id ]
8077 print ("Joystick {} disconnected" .format (event .instance_id ))
78+ elif event .type == pygame .QUIT :
79+ done = True # Flag that we are done so we exit this loop.
8180
8281 # Drawing step
8382 # First, clear the screen to white. Don't put other drawing commands
0 commit comments