From 13c3e7497331bb9b3e0779b28f79b225484bd7d6 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 12 May 2020 08:07:37 +0300 Subject: [PATCH] sdl2: Allow toggling frame limiter with right stick Former-commit-id: 1207b84dbd6162986e5ce790e13e1e2c0b125ebf Former-commit-id: c7fe6ef3e5ec66fc63e5193e294bfb9d7f469afe --- platform/rustboyadvance-sdl2/src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/rustboyadvance-sdl2/src/main.rs b/platform/rustboyadvance-sdl2/src/main.rs index 0171fe0..02d172f 100644 --- a/platform/rustboyadvance-sdl2/src/main.rs +++ b/platform/rustboyadvance-sdl2/src/main.rs @@ -2,6 +2,7 @@ use sdl2; use sdl2::event::{Event, WindowEvent}; use sdl2::image::{InitFlag, LoadTexture}; use sdl2::keyboard::Scancode; +use sdl2::controller::Button; use sdl2::messagebox::*; use sdl2::pixels::Color; use sdl2::rect::Rect; @@ -330,9 +331,10 @@ fn main() -> Result<(), Box> { Scancode::Space => frame_limiter = true, k => input.borrow_mut().on_keyboard_key_up(k), }, - Event::ControllerButtonDown { button, .. } => { - input.borrow_mut().on_controller_button_down(button); - } + Event::ControllerButtonDown { button, .. } => match button { + Button::RightStick => frame_limiter = !frame_limiter, + b => input.borrow_mut().on_controller_button_down(b), + }, Event::ControllerButtonUp { button, .. } => { input.borrow_mut().on_controller_button_up(button); }