diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-07-21 15:11:10 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-07-21 15:11:10 +0200 |
commit | 3b07afd3b57af31044d46077ce3ad9f0d262e87f (patch) | |
tree | 63ac0e5d3a91f4f2394b61c54b1eb2df0f47ca04 /turtetris_master | |
parent | d56374f9720a790ae2ab51da5fbc6a503f970f98 (diff) | |
download | turris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.tar.gz turris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.tar.bz2 turris-tetris-3b07afd3b57af31044d46077ce3ad9f0d262e87f.zip |
Don't repeat on start and select keys
Diffstat (limited to 'turtetris_master')
-rw-r--r-- | turtetris_master/usb_input.py | 9 |
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 |