From a9886a773a967b79712da4b3f770a0d501839a4e Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 22 Feb 2023 10:09:40 +1100 Subject: [PATCH] joypad clear buttons fn --- src/processor/memory/mmio/joypad.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/processor/memory/mmio/joypad.rs b/src/processor/memory/mmio/joypad.rs index 3438faf..b39538c 100644 --- a/src/processor/memory/mmio/joypad.rs +++ b/src/processor/memory/mmio/joypad.rs @@ -63,18 +63,7 @@ impl Joypad { gamepads: ConnectedGamepadsIterator, ) -> bool { let old = *self; - *self = Joypad { - sel_action: self.sel_action, - sel_direction: self.sel_direction, - down: false, - up: false, - left: false, - right: false, - start: false, - select: false, - b: false, - a: false, - }; + self.clear_buttons(); for (_, pad) in gamepads { self.down |= pad.is_pressed(Button::DPadDown); self.up |= pad.is_pressed(Button::DPadUp); @@ -95,6 +84,17 @@ impl Joypad { self.b |= keys.contains(&Key::Semicolon); *self != old } + + fn clear_buttons(&mut self) { + self.down = false; + self.up = false; + self.left = false; + self.right = false; + self.start = false; + self.select = false; + self.a = false; + self.b = false; + } } impl Default for Joypad {