Skip to content

Commit bda1f96

Browse files
EljeynaCastro-Fidel
authored andcommittedAug 15, 2024
Fix buttons
1 parent 87d8344 commit bda1f96

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed
 

‎ingame/models/Gamepad.py

+4-27
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def __init__(self):
2121
self.joystick: Union[Joystick, None] = None
2222

2323
self.terminated: bool = False
24-
self.last_rb_clicked: bool = False
25-
self.last_lb_clicked: bool = False
2624

2725
self.last_left_clicked: bool = False
2826
self.last_right_clicked: bool = False
@@ -34,9 +32,6 @@ def __init__(self):
3432
self.last_dpad_up_clicked: bool = False
3533
self.last_dpad_down_clicked: bool = False
3634

37-
self.last_apply_clicked: bool = False
38-
self.last_back_clicked: bool = False
39-
4035
self.lb_clicked: () = lambda: None
4136
self.rb_clicked: () = lambda: None
4237
self.l_clicked: () = lambda: None
@@ -82,36 +77,18 @@ def cycle(self):
8277
self.joystick = joysticks[self.joystick.get_instance_id()]
8378

8479
# LB
85-
if event.button == self.LB_BUTTON and not self.last_lb_clicked:
86-
self.last_lb_clicked = not self.last_lb_clicked
80+
if event.button == self.LB_BUTTON:
8781
self.lb_clicked()
8882
# RB
89-
if event.button == self.RB_BUTTON and not self.last_rb_clicked:
90-
self.last_rb_clicked = not self.last_rb_clicked
83+
if event.button == self.RB_BUTTON:
9184
self.rb_clicked()
9285
# APPLY
93-
if event.button == self.APPLY_BUTTON and not self.last_apply_clicked:
94-
self.last_apply_clicked = not self.last_apply_clicked
86+
if event.button == self.APPLY_BUTTON:
9587
self.apply_clicked()
9688
# BACK
97-
if event.button == self.BACK_BUTTON and not self.last_back_clicked:
98-
self.last_back_clicked = not self.last_back_clicked
89+
if event.button == self.BACK_BUTTON:
9990
self.back_clicked()
10091

101-
if event.type == pygame.JOYBUTTONUP:
102-
# LB
103-
if event.button == self.LB_BUTTON and self.last_lb_clicked:
104-
self.last_lb_clicked = not self.last_lb_clicked
105-
# RB
106-
if event.button == self.RB_BUTTON and not self.last_rb_clicked:
107-
self.last_rb_clicked = not self.last_rb_clicked
108-
# APPLY
109-
if event.button == self.APPLY_BUTTON and not self.last_apply_clicked:
110-
self.last_apply_clicked = not self.last_apply_clicked
111-
# BACK
112-
if event.button == self.BACK_BUTTON and not self.last_back_clicked:
113-
self.last_back_clicked = not self.last_back_clicked
114-
11592
if event.type == pygame.JOYAXISMOTION:
11693
self.joystick = joysticks[event.instance_id]
11794
left_right_axis = self.joystick.get_axis(self.LEFT_RIGHT_AXIS)

0 commit comments

Comments
 (0)