From: Kostya Shishkov Date: Wed, 28 Jun 2023 17:13:38 +0000 (+0200) Subject: make player exit on shift+Q instead of Q X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=8a51f59b47c832f38c260322d0115ef70d660bad;p=nihav-player.git make player exit on shift+Q instead of Q --- diff --git a/videoplayer/src/main.rs b/videoplayer/src/main.rs index 33d386f..6becffd 100644 --- a/videoplayer/src/main.rs +++ b/videoplayer/src/main.rs @@ -12,7 +12,7 @@ use std::thread; use std::sync::atomic::{AtomicU8, Ordering}; use sdl2::event::{Event, WindowEvent}; -use sdl2::keyboard::Keycode; +use sdl2::keyboard::{Keycode, Mod}; use sdl2::mouse::MouseButton; use sdl2::render::{Canvas, Texture, TextureCreator}; use sdl2::pixels::PixelFormatEnum; @@ -476,9 +476,14 @@ impl Player { if let Event::MouseButtonDown {mouse_btn: MouseButton::Right, ..} = event { self.toggle_pause(); } - if let Event::KeyDown {keycode: Some(keycode), ..} = event { + if let Event::KeyDown {keycode: Some(keycode), keymod, ..} = event { match keycode { - Keycode::Escape | Keycode::Q => { + Keycode::Escape => { + self.end = true; + println!(); + return Ok(true); + }, + Keycode::Q if matches!(keymod, Mod::RSHIFTMOD | Mod::LSHIFTMOD) => { self.end = true; println!(); return Ok(true);