aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-07-21 15:11:10 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-07-21 15:11:10 +0200
commit3b07afd3b57af31044d46077ce3ad9f0d262e87f (patch)
tree63ac0e5d3a91f4f2394b61c54b1eb2df0f47ca04
parentd56374f9720a790ae2ab51da5fbc6a503f970f98 (diff)
downloadturris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.tar.gz
turris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.tar.bz2
turris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.zip
Don't repeat on start and select keys
-rw-r--r--turtetris_master/usb_input.py9
1 files 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