summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2023-06-28 19:13:38 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2023-06-28 19:13:38 +0200
commit8a51f59b47c832f38c260322d0115ef70d660bad (patch)
tree67b93bd743a7fd6cc2cdba26f0b0c7ba15e3914b
parent364f01a375903b90fc9b0af001a0808249aabac3 (diff)
downloadnihav-player-8a51f59b47c832f38c260322d0115ef70d660bad.tar.gz
make player exit on shift+Q instead of Q
-rw-r--r--videoplayer/src/main.rs11
1 files changed, 8 insertions, 3 deletions
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);