You need to sign in or sign up before continuing.
Commit e6e8dcde authored by Georgiy Yankovskiy's avatar Georgiy Yankovskiy

Gamepad polling terminate

parent 7fd78120
...@@ -34,45 +34,48 @@ class Gamepad: ...@@ -34,45 +34,48 @@ class Gamepad:
self.thread.start() self.thread.start()
def cycle(self): def cycle(self):
while not self.terminated: try:
# pygame.event.pump() while not self.terminated:
pygame.event.wait() # pygame.event.pump()
pygame.event.wait()
lb_button = self.joystick.get_button(self.LB_BUTTON) lb_button = self.joystick.get_button(self.LB_BUTTON)
rb_button = self.joystick.get_button(self.RB_BUTTON) rb_button = self.joystick.get_button(self.RB_BUTTON)
# LB # LB
if lb_button and not self.last_lb_clicked: if lb_button and not self.last_lb_clicked:
self.last_lb_clicked = not self.last_lb_clicked self.last_lb_clicked = not self.last_lb_clicked
self.lb_clicked() self.lb_clicked()
if not lb_button and self.last_lb_clicked: if not lb_button and self.last_lb_clicked:
self.last_lb_clicked = not self.last_lb_clicked self.last_lb_clicked = not self.last_lb_clicked
# RB # RB
if rb_button and not self.last_rb_clicked: if rb_button and not self.last_rb_clicked:
self.last_rb_clicked = not self.last_rb_clicked self.last_rb_clicked = not self.last_rb_clicked
self.rb_clicked() self.rb_clicked()
if not rb_button and self.last_rb_clicked: if not rb_button and self.last_rb_clicked:
self.last_rb_clicked = not self.last_rb_clicked self.last_rb_clicked = not self.last_rb_clicked
# print(f"Button {self.LB_BUTTON}: {lb_button}") # print(f"Button {self.LB_BUTTON}: {lb_button}")
# print(f"Button {self.RB_BUTTON}: {rb_button}") # print(f"Button {self.RB_BUTTON}: {rb_button}")
# for i in range(self.joystick.get_numaxes()): # for i in range(self.joystick.get_numaxes()):
# axis = self.joystick.get_axis(i) # axis = self.joystick.get_axis(i)
# print(f"Axis {i}: {axis}") # print(f"Axis {i}: {axis}")
# #
# for i in range(self.joystick.get_numbuttons()): # for i in range(self.joystick.get_numbuttons()):
# button = self.joystick.get_button(i) # button = self.joystick.get_button(i)
# print(f"Button {i}: {button}") # print(f"Button {i}: {button}")
except pygame.error:
pass
def terminate(self): def terminate(self):
# TODO self.terminated = True
# self.thread. pygame.quit()
pass pass
pass pass
...@@ -26,6 +26,10 @@ Window { ...@@ -26,6 +26,10 @@ Window {
} }
} }
Component.onDestruction: {
console.log("Desctructing window");
}
id: window id: window
width: 640 width: 640
height: 480 height: 480
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment