|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
use log::trace;
|
|
|
|
|
use skulpin::winit::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode};
|
|
|
|
|
// use skulpin::winit::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode};
|
|
|
|
|
use skulpin::sdl2::keyboard::{Keycode, Mod};
|
|
|
|
|
|
|
|
|
|
fn parse_keycode(keycode: VirtualKeyCode) -> Option<(&'static str, bool)> {
|
|
|
|
|
pub fn parse_keycode(keycode: Keycode) -> Option<(&'static str, bool)> {
|
|
|
|
|
macro_rules! unsupported_key {
|
|
|
|
|
($name: ident) => {{
|
|
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
@ -11,228 +12,263 @@ fn parse_keycode(keycode: VirtualKeyCode) -> Option<(&'static str, bool)> {
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Documentation: https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlkey.html
|
|
|
|
|
match keycode {
|
|
|
|
|
VirtualKeyCode::Key1 => Some(("1", false)),
|
|
|
|
|
VirtualKeyCode::Key2 => Some(("2", false)),
|
|
|
|
|
VirtualKeyCode::Key3 => Some(("3", false)),
|
|
|
|
|
VirtualKeyCode::Key4 => Some(("4", false)),
|
|
|
|
|
VirtualKeyCode::Key5 => Some(("5", false)),
|
|
|
|
|
VirtualKeyCode::Key6 => Some(("6", false)),
|
|
|
|
|
VirtualKeyCode::Key7 => Some(("7", false)),
|
|
|
|
|
VirtualKeyCode::Key8 => Some(("8", false)),
|
|
|
|
|
VirtualKeyCode::Key9 => Some(("9", false)),
|
|
|
|
|
VirtualKeyCode::Key0 => Some(("0", false)),
|
|
|
|
|
VirtualKeyCode::A => Some(("a", false)),
|
|
|
|
|
VirtualKeyCode::B => Some(("b", false)),
|
|
|
|
|
VirtualKeyCode::C => Some(("c", false)),
|
|
|
|
|
VirtualKeyCode::D => Some(("d", false)),
|
|
|
|
|
VirtualKeyCode::E => Some(("e", false)),
|
|
|
|
|
VirtualKeyCode::F => Some(("f", false)),
|
|
|
|
|
VirtualKeyCode::G => Some(("g", false)),
|
|
|
|
|
VirtualKeyCode::H => Some(("h", false)),
|
|
|
|
|
VirtualKeyCode::I => Some(("i", false)),
|
|
|
|
|
VirtualKeyCode::J => Some(("j", false)),
|
|
|
|
|
VirtualKeyCode::K => Some(("k", false)),
|
|
|
|
|
VirtualKeyCode::L => Some(("l", false)),
|
|
|
|
|
VirtualKeyCode::M => Some(("m", false)),
|
|
|
|
|
VirtualKeyCode::N => Some(("n", false)),
|
|
|
|
|
VirtualKeyCode::O => Some(("o", false)),
|
|
|
|
|
VirtualKeyCode::P => Some(("p", false)),
|
|
|
|
|
VirtualKeyCode::Q => Some(("q", false)),
|
|
|
|
|
VirtualKeyCode::R => Some(("r", false)),
|
|
|
|
|
VirtualKeyCode::S => Some(("s", false)),
|
|
|
|
|
VirtualKeyCode::T => Some(("t", false)),
|
|
|
|
|
VirtualKeyCode::U => Some(("u", false)),
|
|
|
|
|
VirtualKeyCode::V => Some(("v", false)),
|
|
|
|
|
VirtualKeyCode::W => Some(("w", false)),
|
|
|
|
|
VirtualKeyCode::X => Some(("x", false)),
|
|
|
|
|
VirtualKeyCode::Y => Some(("y", false)),
|
|
|
|
|
VirtualKeyCode::Z => Some(("z", false)),
|
|
|
|
|
VirtualKeyCode::Escape => Some(("ESC", true)),
|
|
|
|
|
VirtualKeyCode::F1 => Some(("F1", true)),
|
|
|
|
|
VirtualKeyCode::F2 => Some(("F2", true)),
|
|
|
|
|
VirtualKeyCode::F3 => Some(("F3", true)),
|
|
|
|
|
VirtualKeyCode::F4 => Some(("F4", true)),
|
|
|
|
|
VirtualKeyCode::F5 => Some(("F5", true)),
|
|
|
|
|
VirtualKeyCode::F6 => Some(("F6", true)),
|
|
|
|
|
VirtualKeyCode::F7 => Some(("F7", true)),
|
|
|
|
|
VirtualKeyCode::F8 => Some(("F8", true)),
|
|
|
|
|
VirtualKeyCode::F9 => Some(("F9", true)),
|
|
|
|
|
VirtualKeyCode::F10 => Some(("F10", true)),
|
|
|
|
|
VirtualKeyCode::F11 => Some(("F11", true)),
|
|
|
|
|
VirtualKeyCode::F12 => Some(("F12", true)),
|
|
|
|
|
VirtualKeyCode::F13 => Some(("F13", true)),
|
|
|
|
|
VirtualKeyCode::F14 => Some(("F14", true)),
|
|
|
|
|
VirtualKeyCode::F15 => Some(("F15", true)),
|
|
|
|
|
VirtualKeyCode::F16 => Some(("F16", true)),
|
|
|
|
|
VirtualKeyCode::F17 => Some(("F17", true)),
|
|
|
|
|
VirtualKeyCode::F18 => Some(("F18", true)),
|
|
|
|
|
VirtualKeyCode::F19 => Some(("F19", true)),
|
|
|
|
|
VirtualKeyCode::F20 => Some(("F20", true)),
|
|
|
|
|
VirtualKeyCode::F21 => Some(("F21", true)),
|
|
|
|
|
VirtualKeyCode::F22 => Some(("F22", true)),
|
|
|
|
|
VirtualKeyCode::F23 => Some(("F23", true)),
|
|
|
|
|
VirtualKeyCode::F24 => Some(("F24", true)),
|
|
|
|
|
VirtualKeyCode::Snapshot => unsupported_key!(Snapshot),
|
|
|
|
|
VirtualKeyCode::Scroll => unsupported_key!(Scroll),
|
|
|
|
|
VirtualKeyCode::Pause => unsupported_key!(Pause),
|
|
|
|
|
VirtualKeyCode::Insert => Some(("Insert", true)),
|
|
|
|
|
VirtualKeyCode::Home => Some(("Home", true)),
|
|
|
|
|
VirtualKeyCode::Delete => Some(("Delete", true)),
|
|
|
|
|
VirtualKeyCode::End => Some(("End", true)),
|
|
|
|
|
VirtualKeyCode::PageDown => Some(("PageDown", true)),
|
|
|
|
|
VirtualKeyCode::PageUp => Some(("PageUp", true)),
|
|
|
|
|
VirtualKeyCode::Left => Some(("Left", true)),
|
|
|
|
|
VirtualKeyCode::Up => Some(("Up", true)),
|
|
|
|
|
VirtualKeyCode::Right => Some(("Right", true)),
|
|
|
|
|
VirtualKeyCode::Down => Some(("Down", true)),
|
|
|
|
|
VirtualKeyCode::Back => Some(("BS", true)),
|
|
|
|
|
VirtualKeyCode::Return => Some(("Enter", true)),
|
|
|
|
|
VirtualKeyCode::Space => Some(("Space", true)),
|
|
|
|
|
VirtualKeyCode::Compose => unsupported_key!(Compose),
|
|
|
|
|
VirtualKeyCode::Caret => Some(("^", false)),
|
|
|
|
|
VirtualKeyCode::Numlock => unsupported_key!(Numlock),
|
|
|
|
|
VirtualKeyCode::Numpad0 => Some(("0", false)),
|
|
|
|
|
VirtualKeyCode::Numpad1 => Some(("1", false)),
|
|
|
|
|
VirtualKeyCode::Numpad2 => Some(("2", false)),
|
|
|
|
|
VirtualKeyCode::Numpad3 => Some(("3", false)),
|
|
|
|
|
VirtualKeyCode::Numpad4 => Some(("4", false)),
|
|
|
|
|
VirtualKeyCode::Numpad5 => Some(("5", false)),
|
|
|
|
|
VirtualKeyCode::Numpad6 => Some(("6", false)),
|
|
|
|
|
VirtualKeyCode::Numpad7 => Some(("7", false)),
|
|
|
|
|
VirtualKeyCode::Numpad8 => Some(("8", false)),
|
|
|
|
|
VirtualKeyCode::Numpad9 => Some(("9", false)),
|
|
|
|
|
// These next two are for Brazillian keyboards according to
|
|
|
|
|
// https://hg.mozilla.org/integration/mozilla-inbound/rev/28039c359ce8#l2.31
|
|
|
|
|
// Mapping both to the same thing as firefox
|
|
|
|
|
VirtualKeyCode::AbntC1 => Some(("/", false)),
|
|
|
|
|
VirtualKeyCode::AbntC2 => Some((".", false)),
|
|
|
|
|
VirtualKeyCode::Add => Some(("+", true)),
|
|
|
|
|
VirtualKeyCode::Apostrophe => Some(("'", false)),
|
|
|
|
|
VirtualKeyCode::Apps => unsupported_key!(Apps),
|
|
|
|
|
VirtualKeyCode::At => Some(("@", false)),
|
|
|
|
|
VirtualKeyCode::Ax => unsupported_key!(Ax),
|
|
|
|
|
VirtualKeyCode::Backslash => Some(("Bslash", true)),
|
|
|
|
|
VirtualKeyCode::Calculator => unsupported_key!(Calculator),
|
|
|
|
|
VirtualKeyCode::Capital => unsupported_key!(Capital),
|
|
|
|
|
VirtualKeyCode::Colon => Some((":", false)),
|
|
|
|
|
VirtualKeyCode::Comma => Some((",", false)),
|
|
|
|
|
VirtualKeyCode::Convert => unsupported_key!(Convert),
|
|
|
|
|
VirtualKeyCode::Decimal => Some((".", false)),
|
|
|
|
|
VirtualKeyCode::Divide => Some(("/", false)),
|
|
|
|
|
VirtualKeyCode::Equals => Some(("=", false)),
|
|
|
|
|
VirtualKeyCode::Grave => Some(("`", false)),
|
|
|
|
|
VirtualKeyCode::Kana => unsupported_key!(Kana),
|
|
|
|
|
VirtualKeyCode::Kanji => unsupported_key!(Kanji),
|
|
|
|
|
VirtualKeyCode::LAlt => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::LBracket => Some(("[", false)),
|
|
|
|
|
VirtualKeyCode::LControl => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::LShift => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::LWin => unsupported_key!(LWin),
|
|
|
|
|
VirtualKeyCode::Mail => unsupported_key!(Mail),
|
|
|
|
|
VirtualKeyCode::MediaSelect => unsupported_key!(MediaSelect),
|
|
|
|
|
VirtualKeyCode::MediaStop => unsupported_key!(MediaStop),
|
|
|
|
|
VirtualKeyCode::Minus => Some(("-", false)),
|
|
|
|
|
VirtualKeyCode::Multiply => Some(("*", false)),
|
|
|
|
|
VirtualKeyCode::Mute => unsupported_key!(Mute),
|
|
|
|
|
VirtualKeyCode::MyComputer => unsupported_key!(MyComputer),
|
|
|
|
|
VirtualKeyCode::NavigateForward => unsupported_key!(NavigateForward),
|
|
|
|
|
VirtualKeyCode::NavigateBackward => unsupported_key!(NavigateBackward),
|
|
|
|
|
VirtualKeyCode::NextTrack => unsupported_key!(NextTrack),
|
|
|
|
|
VirtualKeyCode::NoConvert => unsupported_key!(NoConvert),
|
|
|
|
|
VirtualKeyCode::NumpadComma => Some((",", false)),
|
|
|
|
|
VirtualKeyCode::NumpadEnter => Some(("Enter", true)),
|
|
|
|
|
VirtualKeyCode::NumpadEquals => Some(("=", false)),
|
|
|
|
|
VirtualKeyCode::OEM102 => unsupported_key!(OEM102),
|
|
|
|
|
VirtualKeyCode::Period => Some((".", false)),
|
|
|
|
|
VirtualKeyCode::PlayPause => unsupported_key!(PlayPause),
|
|
|
|
|
VirtualKeyCode::Power => unsupported_key!(Power),
|
|
|
|
|
VirtualKeyCode::PrevTrack => unsupported_key!(PrevTrack),
|
|
|
|
|
VirtualKeyCode::RAlt => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::RBracket => Some(("]", false)),
|
|
|
|
|
VirtualKeyCode::RControl => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::RShift => None, // Regular modifier key
|
|
|
|
|
VirtualKeyCode::RWin => unsupported_key!(RWin),
|
|
|
|
|
VirtualKeyCode::Semicolon => Some((";", false)),
|
|
|
|
|
VirtualKeyCode::Slash => Some(("/", false)),
|
|
|
|
|
VirtualKeyCode::Sleep => unsupported_key!(Sleep),
|
|
|
|
|
VirtualKeyCode::Stop => unsupported_key!(Stop),
|
|
|
|
|
VirtualKeyCode::Subtract => Some(("-", false)),
|
|
|
|
|
VirtualKeyCode::Sysrq => unsupported_key!(Sysrq),
|
|
|
|
|
VirtualKeyCode::Tab => Some(("Tab", true)),
|
|
|
|
|
VirtualKeyCode::Underline => unsupported_key!(Underline),
|
|
|
|
|
VirtualKeyCode::Unlabeled => unsupported_key!(Unlabeled),
|
|
|
|
|
VirtualKeyCode::VolumeDown => unsupported_key!(VolumeDown),
|
|
|
|
|
VirtualKeyCode::VolumeUp => unsupported_key!(VolumeUp),
|
|
|
|
|
VirtualKeyCode::Wake => unsupported_key!(Wake),
|
|
|
|
|
VirtualKeyCode::WebBack => unsupported_key!(WebBack),
|
|
|
|
|
VirtualKeyCode::WebFavorites => unsupported_key!(WebFavorites),
|
|
|
|
|
VirtualKeyCode::WebForward => unsupported_key!(WebForward),
|
|
|
|
|
VirtualKeyCode::WebHome => unsupported_key!(WebHome),
|
|
|
|
|
VirtualKeyCode::WebRefresh => unsupported_key!(WebRefresh),
|
|
|
|
|
VirtualKeyCode::WebSearch => unsupported_key!(WebSearch),
|
|
|
|
|
VirtualKeyCode::WebStop => unsupported_key!(WebStop),
|
|
|
|
|
VirtualKeyCode::Yen => Some(("¥", false)),
|
|
|
|
|
VirtualKeyCode::Copy => unsupported_key!(Copy),
|
|
|
|
|
VirtualKeyCode::Paste => unsupported_key!(Paste),
|
|
|
|
|
VirtualKeyCode::Cut => unsupported_key!(Cut),
|
|
|
|
|
Keycode::Backspace => Some(("BS", true)),
|
|
|
|
|
Keycode::Tab => Some(("Tab", true)),
|
|
|
|
|
Keycode::Return => Some(("Enter", true)),
|
|
|
|
|
Keycode::Escape => Some(("Esc", true)),
|
|
|
|
|
Keycode::Space => Some((" ", false)),
|
|
|
|
|
Keycode::Exclaim => Some(("!", false)),
|
|
|
|
|
Keycode::Quotedbl => Some(("\"", false)),
|
|
|
|
|
Keycode::Hash => Some(("#", false)),
|
|
|
|
|
Keycode::Dollar => Some(("$", false)),
|
|
|
|
|
Keycode::Percent => Some(("%", false)),
|
|
|
|
|
Keycode::Ampersand => Some(("&", false)),
|
|
|
|
|
Keycode::Quote => Some(("'", false)),
|
|
|
|
|
Keycode::LeftParen => Some(("(", false)),
|
|
|
|
|
Keycode::RightParen => Some((")", false)),
|
|
|
|
|
Keycode::Asterisk => Some(("*", false)),
|
|
|
|
|
Keycode::Plus => Some(("+", false)),
|
|
|
|
|
Keycode::Comma => Some((",", false)),
|
|
|
|
|
Keycode::Minus => Some(("-", false)),
|
|
|
|
|
Keycode::Period => Some((".", false)),
|
|
|
|
|
Keycode::Slash => Some(("/", false)),
|
|
|
|
|
Keycode::Num0 => Some(("0", false)),
|
|
|
|
|
Keycode::Num1 => Some(("1", false)),
|
|
|
|
|
Keycode::Num2 => Some(("2", false)),
|
|
|
|
|
Keycode::Num3 => Some(("3", false)),
|
|
|
|
|
Keycode::Num4 => Some(("4", false)),
|
|
|
|
|
Keycode::Num5 => Some(("5", false)),
|
|
|
|
|
Keycode::Num6 => Some(("6", false)),
|
|
|
|
|
Keycode::Num7 => Some(("7", false)),
|
|
|
|
|
Keycode::Num8 => Some(("8", false)),
|
|
|
|
|
Keycode::Num9 => Some(("9", false)),
|
|
|
|
|
Keycode::Colon => Some((":", false)),
|
|
|
|
|
Keycode::Semicolon => Some((";", false)),
|
|
|
|
|
Keycode::Less => Some(("lt", true)),
|
|
|
|
|
Keycode::Equals => Some(("=", false)),
|
|
|
|
|
Keycode::Greater => Some(("gt", true)),
|
|
|
|
|
Keycode::Question => Some(("?", false)),
|
|
|
|
|
Keycode::At => Some(("@", false)),
|
|
|
|
|
Keycode::LeftBracket => Some(("[", false)),
|
|
|
|
|
Keycode::Backslash => Some(("\\", false)),
|
|
|
|
|
Keycode::RightBracket => Some(("]", false)),
|
|
|
|
|
Keycode::Caret => Some(("^", false)),
|
|
|
|
|
Keycode::Underscore => Some(("_", false)),
|
|
|
|
|
Keycode::Backquote => Some(("`", false)),
|
|
|
|
|
Keycode::A => Some(("a", false)),
|
|
|
|
|
Keycode::B => Some(("b", false)),
|
|
|
|
|
Keycode::C => Some(("c", false)),
|
|
|
|
|
Keycode::D => Some(("d", false)),
|
|
|
|
|
Keycode::E => Some(("e", false)),
|
|
|
|
|
Keycode::F => Some(("f", false)),
|
|
|
|
|
Keycode::G => Some(("g", false)),
|
|
|
|
|
Keycode::H => Some(("h", false)),
|
|
|
|
|
Keycode::I => Some(("i", false)),
|
|
|
|
|
Keycode::J => Some(("j", false)),
|
|
|
|
|
Keycode::K => Some(("k", false)),
|
|
|
|
|
Keycode::L => Some(("l", false)),
|
|
|
|
|
Keycode::M => Some(("m", false)),
|
|
|
|
|
Keycode::N => Some(("n", false)),
|
|
|
|
|
Keycode::O => Some(("o", false)),
|
|
|
|
|
Keycode::P => Some(("p", false)),
|
|
|
|
|
Keycode::Q => Some(("q", false)),
|
|
|
|
|
Keycode::R => Some(("r", false)),
|
|
|
|
|
Keycode::S => Some(("s", false)),
|
|
|
|
|
Keycode::T => Some(("t", false)),
|
|
|
|
|
Keycode::U => Some(("u", false)),
|
|
|
|
|
Keycode::V => Some(("v", false)),
|
|
|
|
|
Keycode::W => Some(("w", false)),
|
|
|
|
|
Keycode::X => Some(("x", false)),
|
|
|
|
|
Keycode::Y => Some(("y", false)),
|
|
|
|
|
Keycode::Z => Some(("z", false)),
|
|
|
|
|
Keycode::Delete => Some(("Delete", true)),
|
|
|
|
|
Keycode::CapsLock => unsupported_key!(CapsLock),
|
|
|
|
|
Keycode::F1 => Some(("F1", true)),
|
|
|
|
|
Keycode::F2 => Some(("F2", true)),
|
|
|
|
|
Keycode::F3 => Some(("F3", true)),
|
|
|
|
|
Keycode::F4 => Some(("F4", true)),
|
|
|
|
|
Keycode::F5 => Some(("F5", true)),
|
|
|
|
|
Keycode::F6 => Some(("F6", true)),
|
|
|
|
|
Keycode::F7 => Some(("F7", true)),
|
|
|
|
|
Keycode::F8 => Some(("F8", true)),
|
|
|
|
|
Keycode::F9 => Some(("F9", true)),
|
|
|
|
|
Keycode::F10 => Some(("F10", true)),
|
|
|
|
|
Keycode::F11 => Some(("F11", true)),
|
|
|
|
|
Keycode::F12 => Some(("F12", true)),
|
|
|
|
|
Keycode::PrintScreen => unsupported_key!(PrintScreen),
|
|
|
|
|
Keycode::ScrollLock => unsupported_key!(ScrollLock),
|
|
|
|
|
Keycode::Pause => unsupported_key!(Pause),
|
|
|
|
|
Keycode::Insert => Some(("Insert", true)),
|
|
|
|
|
Keycode::Home => Some(("Home", true)),
|
|
|
|
|
Keycode::PageUp => Some(("PageUp", true)),
|
|
|
|
|
Keycode::End => Some(("End", true)),
|
|
|
|
|
Keycode::PageDown => Some(("PageDown", true)),
|
|
|
|
|
Keycode::Right => Some(("Right", true)),
|
|
|
|
|
Keycode::Left => Some(("Left", true)),
|
|
|
|
|
Keycode::Down => Some(("Down", true)),
|
|
|
|
|
Keycode::Up => Some(("Up", true)),
|
|
|
|
|
Keycode::NumLockClear => unsupported_key!(NumLockClear),
|
|
|
|
|
Keycode::KpDivide => Some(("/", true)),
|
|
|
|
|
Keycode::KpMultiply => Some(("*", true)),
|
|
|
|
|
Keycode::KpMinus => Some(("-", true)),
|
|
|
|
|
Keycode::KpPlus => Some(("+", true)),
|
|
|
|
|
Keycode::KpEnter => Some(("Enter", true)),
|
|
|
|
|
Keycode::Kp0 => Some(("0", false)),
|
|
|
|
|
Keycode::Kp1 => Some(("1", false)),
|
|
|
|
|
Keycode::Kp2 => Some(("2", false)),
|
|
|
|
|
Keycode::Kp3 => Some(("3", false)),
|
|
|
|
|
Keycode::Kp4 => Some(("4", false)),
|
|
|
|
|
Keycode::Kp5 => Some(("5", false)),
|
|
|
|
|
Keycode::Kp6 => Some(("6", false)),
|
|
|
|
|
Keycode::Kp7 => Some(("7", false)),
|
|
|
|
|
Keycode::Kp8 => Some(("8", false)),
|
|
|
|
|
Keycode::Kp9 => Some(("9", false)),
|
|
|
|
|
Keycode::KpPeriod => Some((".", false)),
|
|
|
|
|
Keycode::Application => unsupported_key!(Application),
|
|
|
|
|
Keycode::Power => unsupported_key!(Power),
|
|
|
|
|
Keycode::KpEquals => Some(("=", false)),
|
|
|
|
|
Keycode::F13 => Some(("F13", true)),
|
|
|
|
|
Keycode::F14 => Some(("F14", true)),
|
|
|
|
|
Keycode::F15 => Some(("F15", true)),
|
|
|
|
|
Keycode::F16 => Some(("F16", true)),
|
|
|
|
|
Keycode::F17 => Some(("F17", true)),
|
|
|
|
|
Keycode::F18 => Some(("F18", true)),
|
|
|
|
|
Keycode::F19 => Some(("F19", true)),
|
|
|
|
|
Keycode::F20 => Some(("F20", true)),
|
|
|
|
|
Keycode::F21 => Some(("F21", true)),
|
|
|
|
|
Keycode::F22 => Some(("F22", true)),
|
|
|
|
|
Keycode::F23 => Some(("F23", true)),
|
|
|
|
|
Keycode::F24 => Some(("F24", true)),
|
|
|
|
|
Keycode::Execute => unsupported_key!(Execute),
|
|
|
|
|
Keycode::Help => unsupported_key!(Help),
|
|
|
|
|
Keycode::Menu => unsupported_key!(Menu),
|
|
|
|
|
Keycode::Select => unsupported_key!(Select),
|
|
|
|
|
Keycode::Stop => unsupported_key!(Stop),
|
|
|
|
|
Keycode::Again => unsupported_key!(Again),
|
|
|
|
|
Keycode::Undo => unsupported_key!(Undo),
|
|
|
|
|
Keycode::Cut => unsupported_key!(Cut),
|
|
|
|
|
Keycode::Copy => unsupported_key!(Copy),
|
|
|
|
|
Keycode::Paste => unsupported_key!(Paste),
|
|
|
|
|
Keycode::Find => unsupported_key!(Find),
|
|
|
|
|
Keycode::Mute => unsupported_key!(Mute),
|
|
|
|
|
Keycode::VolumeUp => unsupported_key!(VolumeUp),
|
|
|
|
|
Keycode::VolumeDown => unsupported_key!(VolumeDown),
|
|
|
|
|
Keycode::KpComma => unsupported_key!(KpComma),
|
|
|
|
|
Keycode::KpEqualsAS400 => unsupported_key!(KpEqualsAS400),
|
|
|
|
|
Keycode::AltErase => unsupported_key!(AltErase),
|
|
|
|
|
Keycode::Sysreq => unsupported_key!(Sysreq),
|
|
|
|
|
Keycode::Cancel => unsupported_key!(Cancel),
|
|
|
|
|
Keycode::Clear => unsupported_key!(Clear),
|
|
|
|
|
Keycode::Prior => unsupported_key!(Prior),
|
|
|
|
|
Keycode::Return2 => unsupported_key!(Return2),
|
|
|
|
|
Keycode::Separator => unsupported_key!(Separator),
|
|
|
|
|
Keycode::Out => unsupported_key!(Out),
|
|
|
|
|
Keycode::Oper => unsupported_key!(Oper),
|
|
|
|
|
Keycode::ClearAgain => unsupported_key!(ClearAgain),
|
|
|
|
|
Keycode::CrSel => unsupported_key!(CrSel),
|
|
|
|
|
Keycode::ExSel => unsupported_key!(ExSel),
|
|
|
|
|
Keycode::Kp00 => unsupported_key!(Kp00),
|
|
|
|
|
Keycode::Kp000 => unsupported_key!(Kp000),
|
|
|
|
|
Keycode::ThousandsSeparator => unsupported_key!(ThousandsSeparator),
|
|
|
|
|
Keycode::DecimalSeparator => unsupported_key!(DecimalSeparator),
|
|
|
|
|
Keycode::CurrencyUnit => unsupported_key!(CurrencyUnit),
|
|
|
|
|
Keycode::CurrencySubUnit => unsupported_key!(CurrencySubUnit),
|
|
|
|
|
Keycode::KpLeftParen => Some(("(", false)),
|
|
|
|
|
Keycode::KpRightParen => Some((")", false)),
|
|
|
|
|
Keycode::KpLeftBrace => Some(("[", false)),
|
|
|
|
|
Keycode::KpRightBrace => Some(("]", false)),
|
|
|
|
|
Keycode::KpTab => Some(("TAB", true)),
|
|
|
|
|
Keycode::KpBackspace => Some(("BS", true)),
|
|
|
|
|
Keycode::KpA => Some(("A", false)),
|
|
|
|
|
Keycode::KpB => Some(("B", false)),
|
|
|
|
|
Keycode::KpC => Some(("C", false)),
|
|
|
|
|
Keycode::KpD => Some(("D", false)),
|
|
|
|
|
Keycode::KpE => Some(("E", false)),
|
|
|
|
|
Keycode::KpF => Some(("F", false)),
|
|
|
|
|
Keycode::KpXor => unsupported_key!(KpXor),
|
|
|
|
|
Keycode::KpPower => Some(("^", false)),
|
|
|
|
|
Keycode::KpPercent => Some(("%", false)),
|
|
|
|
|
Keycode::KpLess => Some(("lt", true)),
|
|
|
|
|
Keycode::KpGreater => Some(("gt", true)),
|
|
|
|
|
Keycode::KpAmpersand => Some(("&", false)),
|
|
|
|
|
Keycode::KpDblAmpersand => unsupported_key!(KpDblAmpersand),
|
|
|
|
|
Keycode::KpVerticalBar => Some(("|", false)),
|
|
|
|
|
Keycode::KpDblVerticalBar => unsupported_key!(KpDblVerticalBar),
|
|
|
|
|
Keycode::KpColon => Some((":", false)),
|
|
|
|
|
Keycode::KpHash => Some(("#", false)),
|
|
|
|
|
Keycode::KpSpace => Some((" ", false)),
|
|
|
|
|
Keycode::KpAt => Some(("@", false)),
|
|
|
|
|
Keycode::KpExclam => Some(("!", false)),
|
|
|
|
|
Keycode::KpMemStore => unsupported_key!(KpMemStore),
|
|
|
|
|
Keycode::KpMemRecall => unsupported_key!(KpMemRecall),
|
|
|
|
|
Keycode::KpMemClear => unsupported_key!(KpMemClear),
|
|
|
|
|
Keycode::KpMemAdd => unsupported_key!(KpMemAdd),
|
|
|
|
|
Keycode::KpMemSubtract => unsupported_key!(KpMemSubtract),
|
|
|
|
|
Keycode::KpMemMultiply => unsupported_key!(KpMemMultiply),
|
|
|
|
|
Keycode::KpMemDivide => unsupported_key!(KpMemDivide),
|
|
|
|
|
Keycode::KpPlusMinus => unsupported_key!(KpPlusMinus),
|
|
|
|
|
Keycode::KpClear => unsupported_key!(KpClear),
|
|
|
|
|
Keycode::KpClearEntry => unsupported_key!(KpClearEntry),
|
|
|
|
|
Keycode::KpBinary => unsupported_key!(KpBinary),
|
|
|
|
|
Keycode::KpOctal => unsupported_key!(KpOctal),
|
|
|
|
|
Keycode::KpDecimal => unsupported_key!(KpDecimal),
|
|
|
|
|
Keycode::KpHexadecimal => unsupported_key!(KpHexadecimal),
|
|
|
|
|
Keycode::LCtrl => None,
|
|
|
|
|
Keycode::LShift => None,
|
|
|
|
|
Keycode::LAlt => None,
|
|
|
|
|
Keycode::LGui => None,
|
|
|
|
|
Keycode::RCtrl => None,
|
|
|
|
|
Keycode::RShift => None,
|
|
|
|
|
Keycode::RAlt => None,
|
|
|
|
|
Keycode::RGui => None,
|
|
|
|
|
Keycode::Mode => unsupported_key!(Mode),
|
|
|
|
|
Keycode::AudioNext => unsupported_key!(AudioNext),
|
|
|
|
|
Keycode::AudioPrev => unsupported_key!(AudioPrev),
|
|
|
|
|
Keycode::AudioStop => unsupported_key!(AudioStop),
|
|
|
|
|
Keycode::AudioPlay => unsupported_key!(AudioPlay),
|
|
|
|
|
Keycode::AudioMute => unsupported_key!(AudioMute),
|
|
|
|
|
Keycode::MediaSelect => unsupported_key!(MediaSelect),
|
|
|
|
|
Keycode::Www => unsupported_key!(Www),
|
|
|
|
|
Keycode::Mail => unsupported_key!(Mail),
|
|
|
|
|
Keycode::Calculator => unsupported_key!(Calculator),
|
|
|
|
|
Keycode::Computer => unsupported_key!(Computer),
|
|
|
|
|
Keycode::AcSearch => unsupported_key!(AcSearch),
|
|
|
|
|
Keycode::AcHome => unsupported_key!(AcHome),
|
|
|
|
|
Keycode::AcBack => unsupported_key!(AcBack),
|
|
|
|
|
Keycode::AcForward => unsupported_key!(AcForward),
|
|
|
|
|
Keycode::AcStop => unsupported_key!(AcStop),
|
|
|
|
|
Keycode::AcRefresh => unsupported_key!(AcRefresh),
|
|
|
|
|
Keycode::AcBookmarks => unsupported_key!(AcBookmarks),
|
|
|
|
|
Keycode::BrightnessDown => unsupported_key!(BrightnessDown),
|
|
|
|
|
Keycode::BrightnessUp => unsupported_key!(BrightnessUp),
|
|
|
|
|
Keycode::DisplaySwitch => unsupported_key!(DisplaySwitch),
|
|
|
|
|
Keycode::KbdIllumToggle =>unsupported_key!(KbdIllumToggle),
|
|
|
|
|
Keycode::KbdIllumDown => unsupported_key!(KbdIllumDown),
|
|
|
|
|
Keycode::KbdIllumUp => unsupported_key!(KbdIllumUp),
|
|
|
|
|
Keycode::Eject => unsupported_key!(Eject),
|
|
|
|
|
Keycode::Sleep => unsupported_key!(Sleep)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn append_modifiers(modifiers: ModifiersState, keycode_text: &str, special: bool) -> String {
|
|
|
|
|
pub fn append_modifiers(modifiers: Mod, keycode_text: &str, special: bool) -> String {
|
|
|
|
|
let mut result = keycode_text.to_string();
|
|
|
|
|
let mut special = special;
|
|
|
|
|
|
|
|
|
|
if modifiers.shift() {
|
|
|
|
|
result = match result.as_ref() {
|
|
|
|
|
"1" => "!".to_string(),
|
|
|
|
|
"2" => "@".to_string(),
|
|
|
|
|
"3" => "#".to_string(),
|
|
|
|
|
"4" => "$".to_string(),
|
|
|
|
|
"5" => "%".to_string(),
|
|
|
|
|
"6" => "^".to_string(),
|
|
|
|
|
"7" => "&".to_string(),
|
|
|
|
|
"8" => "*".to_string(),
|
|
|
|
|
"9" => "(".to_string(),
|
|
|
|
|
"0" => ")".to_string(),
|
|
|
|
|
"'" => "\"".to_string(),
|
|
|
|
|
"Bslash" => {
|
|
|
|
|
special = false;
|
|
|
|
|
"|".to_string()
|
|
|
|
|
},
|
|
|
|
|
"," => {
|
|
|
|
|
special = true;
|
|
|
|
|
"lt".to_string()
|
|
|
|
|
},
|
|
|
|
|
"=" => "+".to_string(),
|
|
|
|
|
"`" => "~".to_string(),
|
|
|
|
|
"[" => "{".to_string(),
|
|
|
|
|
"-" => "_".to_string(),
|
|
|
|
|
"." => ">".to_string(),
|
|
|
|
|
"]" => "}".to_string(),
|
|
|
|
|
";" => ":".to_string(),
|
|
|
|
|
"/" => "?".to_string(),
|
|
|
|
|
other => {
|
|
|
|
|
special = true;
|
|
|
|
|
format!("S-{}", other)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result == "<" {
|
|
|
|
|
if modifiers.contains(Mod::LSHIFTMOD) || modifiers.contains(Mod::RSHIFTMOD) {
|
|
|
|
|
special = true;
|
|
|
|
|
result = "lt".to_string();
|
|
|
|
|
result = format!("S-{}", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if modifiers.ctrl() {
|
|
|
|
|
if modifiers.contains(Mod::LCTRLMOD) || modifiers.contains(Mod::RCTRLMOD) {
|
|
|
|
|
special = true;
|
|
|
|
|
result = format!("C-{}", result);
|
|
|
|
|
}
|
|
|
|
|
if modifiers.alt() {
|
|
|
|
|
if modifiers.contains(Mod::LALTMOD) || modifiers.contains(Mod::RALTMOD) {
|
|
|
|
|
special = true;
|
|
|
|
|
result = format!("M-{}", result);
|
|
|
|
|
}
|
|
|
|
|
if modifiers.logo() {
|
|
|
|
|
if modifiers.contains(Mod::LGUIMOD) || modifiers.contains(Mod::RGUIMOD) {
|
|
|
|
|
special = true;
|
|
|
|
|
result = format!("D-{}", result);
|
|
|
|
|
}
|
|
|
|
@ -243,21 +279,3 @@ pub fn append_modifiers(modifiers: ModifiersState, keycode_text: &str, special:
|
|
|
|
|
|
|
|
|
|
result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn construct_keybinding_string(input: KeyboardInput) -> Option<String> {
|
|
|
|
|
match input {
|
|
|
|
|
KeyboardInput {
|
|
|
|
|
state: ElementState::Pressed,
|
|
|
|
|
virtual_keycode: Some(keycode),
|
|
|
|
|
modifiers,
|
|
|
|
|
..
|
|
|
|
|
} => {
|
|
|
|
|
if let Some((keycode_text, special)) = parse_keycode(keycode) {
|
|
|
|
|
Some(append_modifiers(modifiers, keycode_text, special))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
_ => None
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|