From 3b07afd3b57af31044d46077ce3ad9f0d262e87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 21 Jul 2017 15:11:10 +0200 Subject: Don't repeat on start and select keys --- turtetris_master/usb_input.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/turtetris_master/usb_input.py b/turtetris_master/usb_input.py index c452f7f..d81c970 100644 --- a/turtetris_master/usb_input.py +++ b/turtetris_master/usb_input.py @@ -45,8 +45,10 @@ class Gamepad: assert self.ep is not None self.state = {} - for key in ['left', 'right', 'up', 'down', 'select', 'start']: + for key in ['left', 'right', 'up', 'down']: self.state[key] = 0 + for key in ['select', 'start']: + self.state[key] = False def check(self): "Check the input state" @@ -61,7 +63,7 @@ class Gamepad: "start": bool(data[6] & 0x20), } changed = {} - for key in ['left', 'right', 'up', 'down', 'select', 'start']: + for key in ['left', 'right', 'up', 'down']: changed[key] = False if new_state[key]: if self.state[key] == 0 or self.state[key] > 14: @@ -70,4 +72,7 @@ class Gamepad: self.state[key] += 1 else: self.state[key] = 0 + for key in ['select', 'start']: + changed[key] = new_state[key] and not self.state[key] + self.state[key] = new_state[key] return changed -- cgit v1.2.3