From 45dc27301ccc33c57ab154b9f947e008e8e91924 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sun, 11 Jul 2021 15:45:37 -0500 Subject: [PATCH] chore: enable/disable gamepad input at compile time --- src/emu.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/emu.rs b/src/emu.rs index e04785f..5d87195 100644 --- a/src/emu.rs +++ b/src/emu.rs @@ -11,6 +11,7 @@ pub const SM83_CYCLE_TIME: Duration = Duration::from_nanos(1_000_000_000 / SM83_ pub const CYCLES_IN_FRAME: Cycle = Cycle::new(456 * 154); // 456 Cycles times 154 scanlines pub(crate) const SM83_CLOCK_SPEED: u64 = 0x40_0000; // Hz which is 4.194304Mhz const DEFAULT_TITLE: &str = "DMG-01 Emulator"; +const GAMEPAD_ENABLED: bool = false; pub fn init(boot_path: Option<&str>, rom_path: &str) -> Result { let mut cpu = match boot_path { @@ -44,12 +45,13 @@ pub fn run( } pub fn run_unsynced(game_boy: &mut SM83, gamepad: &mut Gilrs, input: &WinitInputHelper) -> Cycle { - if let Some(event) = gamepad.next_event() { - joypad::handle_gamepad_input(game_boy.joypad_mut(), event); - } else { - joypad::handle_keyboard_input(game_boy.joypad_mut(), input); + if GAMEPAD_ENABLED { + if let Some(event) = gamepad.next_event() { + joypad::handle_gamepad_input(game_boy.joypad_mut(), event); + } } + joypad::handle_keyboard_input(game_boy.joypad_mut(), input); game_boy.step() }