From 5e0fe384483db49dadd6da4e8dd6e1d63f8219ab Mon Sep 17 00:00:00 2001 From: annika <annika.oesterdiekhoff@uni-bielefeld.de> Date: Thu, 15 Feb 2024 12:07:45 +0100 Subject: [PATCH] fix error when only one controller is connected --- overcooked_simulator/gui_2d_vis/overcooked_gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overcooked_simulator/gui_2d_vis/overcooked_gui.py b/overcooked_simulator/gui_2d_vis/overcooked_gui.py index 796e94e4..87a0b5c3 100644 --- a/overcooked_simulator/gui_2d_vis/overcooked_gui.py +++ b/overcooked_simulator/gui_2d_vis/overcooked_gui.py @@ -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") -- GitLab