Skip to content
Snippets Groups Projects
Commit 5e0fe384 authored by Annika Österdiekhoff's avatar Annika Österdiekhoff
Browse files

fix error when only one controller is connected

parent 2bed7e6c
No related branches found
No related tags found
1 merge request!45Resolve "Controller Support"
Pipeline #46229 passed
......@@ -274,7 +274,7 @@ class PyGameGUI:
for key_set in self.key_sets:
current_player_name = str(key_set.current_player)
# if a joystick is connected for current player
if joysticks[key_set.joystick]:
if key_set.joystick in joysticks:
# Usually axis run in pairs, up/down for one, and left/right for the other. Triggers count as axes.
# You may want to take into account some tolerance to handle jitter, and
# joystick drift may keep the joystick from centering at 0 or using the full range of position values.
......@@ -341,7 +341,7 @@ class PyGameGUI:
for key_set in self.key_sets:
current_player_name = str(key_set.current_player)
# if a joystick is connected for current player
if joysticks[key_set.joystick]:
if key_set.joystick in joysticks:
# pickup = Button A <-> 0
if joysticks[key_set.joystick].get_button(0) and event.type == pygame.JOYBUTTONDOWN:
action = Action(current_player_name, ActionType.PUT, "pickup")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment