Skip to content

Commit

Permalink
Fix activation_condition logic
Browse files Browse the repository at this point in the history
    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`.
  • Loading branch information
edwardwbarber committed Jul 12, 2022
1 parent 643814e commit 7a6e28a
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions gremlin/ui/activation_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7a6e28a

Please sign in to comment.