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 {