From 9819fad475d56297ff2d08ec8b3f6e3576c3cd82 Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:08:53 +0100 Subject: [PATCH] fix crash --- src/ui/input.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/input.rs b/src/ui/input.rs index 666257a..14f9450 100644 --- a/src/ui/input.rs +++ b/src/ui/input.rs @@ -280,18 +280,18 @@ pub fn change_paks( let key = profile.keys[CHANGE_PAK]; let mut pressed = false; - if controller_button.0 { + if controller_button.0 && controller.is_some() { pressed = controller .as_ref() .unwrap() .button(get_button_from_i32(controller_button.1)); - } else if joystick_button.0 { + } else if joystick_button.0 && joystick.is_some() { pressed = joystick .as_ref() .unwrap() .button(joystick_button.1) .unwrap(); - } else if joystick_hat.0 { + } else if joystick_hat.0 && joystick.is_some() { pressed = joystick.as_ref().unwrap().hat(joystick_hat.1).unwrap() == sdl2::joystick::HatState::from_raw(joystick_hat.2); } else if key.0 {