cosmic-player/src/key_bind.rs

36 lines
1.1 KiB
Rust
Raw Normal View History

use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
use std::collections::HashMap;
2024-01-24 14:31:39 -07:00
2024-10-09 11:15:04 -06:00
use crate::Action;
2024-01-24 14:31:39 -07:00
pub use cosmic::widget::menu::key_bind::{KeyBind, Modifier};
2024-01-24 14:31:39 -07:00
//TODO: load from config
pub fn key_binds() -> HashMap<KeyBind, Action> {
let mut key_binds = HashMap::new();
macro_rules! bind {
2024-02-09 09:15:29 -07:00
([$($modifier:ident),* $(,)?], $key:expr, $action:ident) => {{
2024-01-24 14:31:39 -07:00
key_binds.insert(
KeyBind {
2024-01-24 21:06:07 -07:00
modifiers: vec![$(Modifier::$modifier),*],
2024-02-09 09:15:29 -07:00
key: $key,
2024-01-24 14:31:39 -07:00
},
Action::$action,
);
}};
}
//TODO: key bindings
bind!([], Key::Character("f".into()), Fullscreen);
bind!([Alt], Key::Named(Named::Enter), Fullscreen);
2026-03-20 16:17:24 -04:00
bind!([], Key::Character(" ".into()), PlayPause);
2024-02-09 09:15:29 -07:00
bind!([], Key::Named(Named::ArrowLeft), SeekBackward);
bind!([], Key::Named(Named::ArrowRight), SeekForward);
bind!([], Key::Character(".".into()), NextFrame);
bind!([], Key::Character(",".into()), PreviousFrame);
bind!([], Key::Character("a".into()), AbRepeat);
2024-01-24 14:31:39 -07:00
key_binds
}