diff options
Diffstat (limited to 'src/desktop/input.rs')
-rw-r--r-- | src/desktop/input.rs | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/desktop/input.rs b/src/desktop/input.rs index d7c10c8..55bbfb3 100644 --- a/src/desktop/input.rs +++ b/src/desktop/input.rs @@ -130,46 +130,47 @@ impl Keyboard { impl Input for Keyboard { fn update_events(&mut self, _cycles: u128) -> Option<u128> { - let mut res = 0xf; - let keys = self.keys.borrow(); + if let Ok(keys) = self.keys.lock() { + let mut res = 0xf; - if keys.contains(&KeyCode::KeyA) { - res &= 0b1110; - } + if (*keys).contains(&KeyCode::KeyA) { + res &= 0b1110; + } - if keys.contains(&KeyCode::KeyB) { - res &= 0b1101; - } + if (*keys).contains(&KeyCode::KeyB) { + res &= 0b1101; + } - if keys.contains(&KeyCode::Backspace) { - res &= 0b1011; - } + if (*keys).contains(&KeyCode::Backspace) { + res &= 0b1011; + } - if keys.contains(&KeyCode::Enter) { - res &= 0b0111; - } + if (*keys).contains(&KeyCode::Enter) { + res &= 0b0111; + } - self.action_reg = res; + self.action_reg = res; - let mut res = 0xf; + let mut res = 0xf; - if keys.contains(&KeyCode::ArrowRight) { - res &= 0b1110; - } + if (*keys).contains(&KeyCode::ArrowRight) { + res &= 0b1110; + } - if keys.contains(&KeyCode::ArrowLeft) { - res &= 0b1101; - } + if (*keys).contains(&KeyCode::ArrowLeft) { + res &= 0b1101; + } - if keys.contains(&KeyCode::ArrowUp) { - res &= 0b1011; - } + if (*keys).contains(&KeyCode::ArrowUp) { + res &= 0b1011; + } - if keys.contains(&KeyCode::ArrowDown) { - res &= 0b0111; - } + if (*keys).contains(&KeyCode::ArrowDown) { + res &= 0b0111; + } - self.direction_reg = res; + self.direction_reg = res; + } None } |