From d52c2d61d02184e86802f8badcf164ca6dfba168 Mon Sep 17 00:00:00 2001 From: Edward Barber Date: Mon, 11 Jul 2022 20:04:39 -0700 Subject: [PATCH] Fix vjoy activation condition handling Check if current comparison condition is valid for the type of VJoy condition under `_modify_vjoy`. Only reset comparison condition if it is not valid for the current input type. Previously comparison condition would reset with any call to `_modify_vjoy`. --- gremlin/ui/activation_condition.py | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gremlin/ui/activation_condition.py b/gremlin/ui/activation_condition.py index 8e5adfb9..f2dff8a7 100644 --- a/gremlin/ui/activation_condition.py +++ b/gremlin/ui/activation_condition.py @@ -624,12 +624,38 @@ def _modify_vjoy(self, data): self.condition_data.vjoy_id = data["device_id"] self.condition_data.input_type = data["input_type"] self.condition_data.input_id = data["input_id"] + + valid_axis_condition = [ + "inside", + "outside" + ] + valid_button_condition = [ + "pressed", + "released" + ] + valid_hat_condition = [ + "center", + "north", + "north-east", + "east", + "south-east", + "south", + "south-west", + "west", + "north-west" + ] - if data["input_type"] == InputType.JoystickAxis: + if (data["input_type"] == InputType.JoystickAxis and + self.condition_data.comparison not in valid_axis_condition + ): self.condition_data.comparison = "inside" - elif data["input_type"] == InputType.JoystickButton: + elif (data["input_type"] == InputType.JoystickButton and + self.condition_data.comparison not in valid_button_condition + ): self.condition_data.comparison = "pressed" - elif data["input_type"] == InputType.JoystickHat: + elif (data["input_type"] == InputType.JoystickHat and + self.condition_data.comparison not in valid_hat_condition + ): self.condition_data.comparison = \ util.hat_tuple_to_direction((0, 0)) self._create_ui()