clear keyboard state vectors on resume

if any keys were pressed in the middle of a suspend...

probably, the user didn't care to have them still pressed on resume!
This commit is contained in:
bunnie 2021-07-13 23:10:10 +08:00
parent 78394b869a
commit 7cd8b4107a
2 changed files with 17 additions and 0 deletions

View file

@ -36,6 +36,10 @@ impl RowColVec {
iter: 0
}
}
pub fn clear(&mut self) {
self.storage = [None; MAX_KEYS];
self.iter = 0;
}
pub fn len(&self) -> usize {
return MAX_KEYS
}

View file

@ -293,6 +293,19 @@ mod implementation {
}
pub fn resume(&mut self) {
self.susres.resume();
// clear the keyboard state vectors -- actually, if a key was being pressed at the time of suspend
// it's not really relevant anymore; let's throw everything away and start from a clean slate.
self.new_state.clear();
self.last_state.clear();
self.shift_down = false;
self.shift_up = false;
self.alt_down = false;
self.alt_up = false;
self.repeating_key = None;
self.chord_captured = false;
self.chord_active = 0;
self.chord = [[false; KBD_COLS]; KBD_ROWS];
}
pub fn set_map(&mut self, map: KeyMap) {