|
|
@ -1,7 +1,8 @@
|
|
|
|
use log::trace;
|
|
|
|
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 {
|
|
|
|
macro_rules! unsupported_key {
|
|
|
|
($name: ident) => {{
|
|
|
|
($name: ident) => {{
|
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
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 {
|
|
|
|
match keycode {
|
|
|
|
VirtualKeyCode::Key1 => Some(("1", false)),
|
|
|
|
Keycode::Backspace => Some(("BS", true)),
|
|
|
|
VirtualKeyCode::Key2 => Some(("2", false)),
|
|
|
|
Keycode::Tab => Some(("Tab", true)),
|
|
|
|
VirtualKeyCode::Key3 => Some(("3", false)),
|
|
|
|
Keycode::Return => Some(("Enter", true)),
|
|
|
|
VirtualKeyCode::Key4 => Some(("4", false)),
|
|
|
|
Keycode::Escape => Some(("Esc", true)),
|
|
|
|
VirtualKeyCode::Key5 => Some(("5", false)),
|
|
|
|
Keycode::Space => Some((" ", false)),
|
|
|
|
VirtualKeyCode::Key6 => Some(("6", false)),
|
|
|
|
Keycode::Exclaim => Some(("!", false)),
|
|
|
|
VirtualKeyCode::Key7 => Some(("7", false)),
|
|
|
|
Keycode::Quotedbl => Some(("\"", false)),
|
|
|
|
VirtualKeyCode::Key8 => Some(("8", false)),
|
|
|
|
Keycode::Hash => Some(("#", false)),
|
|
|
|
VirtualKeyCode::Key9 => Some(("9", false)),
|
|
|
|
Keycode::Dollar => Some(("$", false)),
|
|
|
|
VirtualKeyCode::Key0 => Some(("0", false)),
|
|
|
|
Keycode::Percent => Some(("%", false)),
|
|
|
|
VirtualKeyCode::A => Some(("a", false)),
|
|
|
|
Keycode::Ampersand => Some(("&", false)),
|
|
|
|
VirtualKeyCode::B => Some(("b", false)),
|
|
|
|
Keycode::Quote => Some(("'", false)),
|
|
|
|
VirtualKeyCode::C => Some(("c", false)),
|
|
|
|
Keycode::LeftParen => Some(("(", false)),
|
|
|
|
VirtualKeyCode::D => Some(("d", false)),
|
|
|
|
Keycode::RightParen => Some((")", false)),
|
|
|
|
VirtualKeyCode::E => Some(("e", false)),
|
|
|
|
Keycode::Asterisk => Some(("*", false)),
|
|
|
|
VirtualKeyCode::F => Some(("f", false)),
|
|
|
|
Keycode::Plus => Some(("+", false)),
|
|
|
|
VirtualKeyCode::G => Some(("g", false)),
|
|
|
|
Keycode::Comma => Some((",", false)),
|
|
|
|
VirtualKeyCode::H => Some(("h", false)),
|
|
|
|
Keycode::Minus => Some(("-", false)),
|
|
|
|
VirtualKeyCode::I => Some(("i", false)),
|
|
|
|
Keycode::Period => Some((".", false)),
|
|
|
|
VirtualKeyCode::J => Some(("j", false)),
|
|
|
|
Keycode::Slash => Some(("/", false)),
|
|
|
|
VirtualKeyCode::K => Some(("k", false)),
|
|
|
|
Keycode::Num0 => Some(("0", false)),
|
|
|
|
VirtualKeyCode::L => Some(("l", false)),
|
|
|
|
Keycode::Num1 => Some(("1", false)),
|
|
|
|
VirtualKeyCode::M => Some(("m", false)),
|
|
|
|
Keycode::Num2 => Some(("2", false)),
|
|
|
|
VirtualKeyCode::N => Some(("n", false)),
|
|
|
|
Keycode::Num3 => Some(("3", false)),
|
|
|
|
VirtualKeyCode::O => Some(("o", false)),
|
|
|
|
Keycode::Num4 => Some(("4", false)),
|
|
|
|
VirtualKeyCode::P => Some(("p", false)),
|
|
|
|
Keycode::Num5 => Some(("5", false)),
|
|
|
|
VirtualKeyCode::Q => Some(("q", false)),
|
|
|
|
Keycode::Num6 => Some(("6", false)),
|
|
|
|
VirtualKeyCode::R => Some(("r", false)),
|
|
|
|
Keycode::Num7 => Some(("7", false)),
|
|
|
|
VirtualKeyCode::S => Some(("s", false)),
|
|
|
|
Keycode::Num8 => Some(("8", false)),
|
|
|
|
VirtualKeyCode::T => Some(("t", false)),
|
|
|
|
Keycode::Num9 => Some(("9", false)),
|
|
|
|
VirtualKeyCode::U => Some(("u", false)),
|
|
|
|
Keycode::Colon => Some((":", false)),
|
|
|
|
VirtualKeyCode::V => Some(("v", false)),
|
|
|
|
Keycode::Semicolon => Some((";", false)),
|
|
|
|
VirtualKeyCode::W => Some(("w", false)),
|
|
|
|
Keycode::Less => Some(("lt", true)),
|
|
|
|
VirtualKeyCode::X => Some(("x", false)),
|
|
|
|
Keycode::Equals => Some(("=", false)),
|
|
|
|
VirtualKeyCode::Y => Some(("y", false)),
|
|
|
|
Keycode::Greater => Some(("gt", true)),
|
|
|
|
VirtualKeyCode::Z => Some(("z", false)),
|
|
|
|
Keycode::Question => Some(("?", false)),
|
|
|
|
VirtualKeyCode::Escape => Some(("ESC", true)),
|
|
|
|
Keycode::At => Some(("@", false)),
|
|
|
|
VirtualKeyCode::F1 => Some(("F1", true)),
|
|
|
|
Keycode::LeftBracket => Some(("[", false)),
|
|
|
|
VirtualKeyCode::F2 => Some(("F2", true)),
|
|
|
|
Keycode::Backslash => Some(("\\", false)),
|
|
|
|
VirtualKeyCode::F3 => Some(("F3", true)),
|
|
|
|
Keycode::RightBracket => Some(("]", false)),
|
|
|
|
VirtualKeyCode::F4 => Some(("F4", true)),
|
|
|
|
Keycode::Caret => Some(("^", false)),
|
|
|
|
VirtualKeyCode::F5 => Some(("F5", true)),
|
|
|
|
Keycode::Underscore => Some(("_", false)),
|
|
|
|
VirtualKeyCode::F6 => Some(("F6", true)),
|
|
|
|
Keycode::Backquote => Some(("`", false)),
|
|
|
|
VirtualKeyCode::F7 => Some(("F7", true)),
|
|
|
|
Keycode::A => Some(("a", false)),
|
|
|
|
VirtualKeyCode::F8 => Some(("F8", true)),
|
|
|
|
Keycode::B => Some(("b", false)),
|
|
|
|
VirtualKeyCode::F9 => Some(("F9", true)),
|
|
|
|
Keycode::C => Some(("c", false)),
|
|
|
|
VirtualKeyCode::F10 => Some(("F10", true)),
|
|
|
|
Keycode::D => Some(("d", false)),
|
|
|
|
VirtualKeyCode::F11 => Some(("F11", true)),
|
|
|
|
Keycode::E => Some(("e", false)),
|
|
|
|
VirtualKeyCode::F12 => Some(("F12", true)),
|
|
|
|
Keycode::F => Some(("f", false)),
|
|
|
|
VirtualKeyCode::F13 => Some(("F13", true)),
|
|
|
|
Keycode::G => Some(("g", false)),
|
|
|
|
VirtualKeyCode::F14 => Some(("F14", true)),
|
|
|
|
Keycode::H => Some(("h", false)),
|
|
|
|
VirtualKeyCode::F15 => Some(("F15", true)),
|
|
|
|
Keycode::I => Some(("i", false)),
|
|
|
|
VirtualKeyCode::F16 => Some(("F16", true)),
|
|
|
|
Keycode::J => Some(("j", false)),
|
|
|
|
VirtualKeyCode::F17 => Some(("F17", true)),
|
|
|
|
Keycode::K => Some(("k", false)),
|
|
|
|
VirtualKeyCode::F18 => Some(("F18", true)),
|
|
|
|
Keycode::L => Some(("l", false)),
|
|
|
|
VirtualKeyCode::F19 => Some(("F19", true)),
|
|
|
|
Keycode::M => Some(("m", false)),
|
|
|
|
VirtualKeyCode::F20 => Some(("F20", true)),
|
|
|
|
Keycode::N => Some(("n", false)),
|
|
|
|
VirtualKeyCode::F21 => Some(("F21", true)),
|
|
|
|
Keycode::O => Some(("o", false)),
|
|
|
|
VirtualKeyCode::F22 => Some(("F22", true)),
|
|
|
|
Keycode::P => Some(("p", false)),
|
|
|
|
VirtualKeyCode::F23 => Some(("F23", true)),
|
|
|
|
Keycode::Q => Some(("q", false)),
|
|
|
|
VirtualKeyCode::F24 => Some(("F24", true)),
|
|
|
|
Keycode::R => Some(("r", false)),
|
|
|
|
VirtualKeyCode::Snapshot => unsupported_key!(Snapshot),
|
|
|
|
Keycode::S => Some(("s", false)),
|
|
|
|
VirtualKeyCode::Scroll => unsupported_key!(Scroll),
|
|
|
|
Keycode::T => Some(("t", false)),
|
|
|
|
VirtualKeyCode::Pause => unsupported_key!(Pause),
|
|
|
|
Keycode::U => Some(("u", false)),
|
|
|
|
VirtualKeyCode::Insert => Some(("Insert", true)),
|
|
|
|
Keycode::V => Some(("v", false)),
|
|
|
|
VirtualKeyCode::Home => Some(("Home", true)),
|
|
|
|
Keycode::W => Some(("w", false)),
|
|
|
|
VirtualKeyCode::Delete => Some(("Delete", true)),
|
|
|
|
Keycode::X => Some(("x", false)),
|
|
|
|
VirtualKeyCode::End => Some(("End", true)),
|
|
|
|
Keycode::Y => Some(("y", false)),
|
|
|
|
VirtualKeyCode::PageDown => Some(("PageDown", true)),
|
|
|
|
Keycode::Z => Some(("z", false)),
|
|
|
|
VirtualKeyCode::PageUp => Some(("PageUp", true)),
|
|
|
|
Keycode::Delete => Some(("Delete", true)),
|
|
|
|
VirtualKeyCode::Left => Some(("Left", true)),
|
|
|
|
Keycode::CapsLock => unsupported_key!(CapsLock),
|
|
|
|
VirtualKeyCode::Up => Some(("Up", true)),
|
|
|
|
Keycode::F1 => Some(("F1", true)),
|
|
|
|
VirtualKeyCode::Right => Some(("Right", true)),
|
|
|
|
Keycode::F2 => Some(("F2", true)),
|
|
|
|
VirtualKeyCode::Down => Some(("Down", true)),
|
|
|
|
Keycode::F3 => Some(("F3", true)),
|
|
|
|
VirtualKeyCode::Back => Some(("BS", true)),
|
|
|
|
Keycode::F4 => Some(("F4", true)),
|
|
|
|
VirtualKeyCode::Return => Some(("Enter", true)),
|
|
|
|
Keycode::F5 => Some(("F5", true)),
|
|
|
|
VirtualKeyCode::Space => Some(("Space", true)),
|
|
|
|
Keycode::F6 => Some(("F6", true)),
|
|
|
|
VirtualKeyCode::Compose => unsupported_key!(Compose),
|
|
|
|
Keycode::F7 => Some(("F7", true)),
|
|
|
|
VirtualKeyCode::Caret => Some(("^", false)),
|
|
|
|
Keycode::F8 => Some(("F8", true)),
|
|
|
|
VirtualKeyCode::Numlock => unsupported_key!(Numlock),
|
|
|
|
Keycode::F9 => Some(("F9", true)),
|
|
|
|
VirtualKeyCode::Numpad0 => Some(("0", false)),
|
|
|
|
Keycode::F10 => Some(("F10", true)),
|
|
|
|
VirtualKeyCode::Numpad1 => Some(("1", false)),
|
|
|
|
Keycode::F11 => Some(("F11", true)),
|
|
|
|
VirtualKeyCode::Numpad2 => Some(("2", false)),
|
|
|
|
Keycode::F12 => Some(("F12", true)),
|
|
|
|
VirtualKeyCode::Numpad3 => Some(("3", false)),
|
|
|
|
Keycode::PrintScreen => unsupported_key!(PrintScreen),
|
|
|
|
VirtualKeyCode::Numpad4 => Some(("4", false)),
|
|
|
|
Keycode::ScrollLock => unsupported_key!(ScrollLock),
|
|
|
|
VirtualKeyCode::Numpad5 => Some(("5", false)),
|
|
|
|
Keycode::Pause => unsupported_key!(Pause),
|
|
|
|
VirtualKeyCode::Numpad6 => Some(("6", false)),
|
|
|
|
Keycode::Insert => Some(("Insert", true)),
|
|
|
|
VirtualKeyCode::Numpad7 => Some(("7", false)),
|
|
|
|
Keycode::Home => Some(("Home", true)),
|
|
|
|
VirtualKeyCode::Numpad8 => Some(("8", false)),
|
|
|
|
Keycode::PageUp => Some(("PageUp", true)),
|
|
|
|
VirtualKeyCode::Numpad9 => Some(("9", false)),
|
|
|
|
Keycode::End => Some(("End", true)),
|
|
|
|
// These next two are for Brazillian keyboards according to
|
|
|
|
Keycode::PageDown => Some(("PageDown", true)),
|
|
|
|
// https://hg.mozilla.org/integration/mozilla-inbound/rev/28039c359ce8#l2.31
|
|
|
|
Keycode::Right => Some(("Right", true)),
|
|
|
|
// Mapping both to the same thing as firefox
|
|
|
|
Keycode::Left => Some(("Left", true)),
|
|
|
|
VirtualKeyCode::AbntC1 => Some(("/", false)),
|
|
|
|
Keycode::Down => Some(("Down", true)),
|
|
|
|
VirtualKeyCode::AbntC2 => Some((".", false)),
|
|
|
|
Keycode::Up => Some(("Up", true)),
|
|
|
|
VirtualKeyCode::Add => Some(("+", true)),
|
|
|
|
Keycode::NumLockClear => unsupported_key!(NumLockClear),
|
|
|
|
VirtualKeyCode::Apostrophe => Some(("'", false)),
|
|
|
|
Keycode::KpDivide => Some(("/", true)),
|
|
|
|
VirtualKeyCode::Apps => unsupported_key!(Apps),
|
|
|
|
Keycode::KpMultiply => Some(("*", true)),
|
|
|
|
VirtualKeyCode::At => Some(("@", false)),
|
|
|
|
Keycode::KpMinus => Some(("-", true)),
|
|
|
|
VirtualKeyCode::Ax => unsupported_key!(Ax),
|
|
|
|
Keycode::KpPlus => Some(("+", true)),
|
|
|
|
VirtualKeyCode::Backslash => Some(("Bslash", true)),
|
|
|
|
Keycode::KpEnter => Some(("Enter", true)),
|
|
|
|
VirtualKeyCode::Calculator => unsupported_key!(Calculator),
|
|
|
|
Keycode::Kp0 => Some(("0", false)),
|
|
|
|
VirtualKeyCode::Capital => unsupported_key!(Capital),
|
|
|
|
Keycode::Kp1 => Some(("1", false)),
|
|
|
|
VirtualKeyCode::Colon => Some((":", false)),
|
|
|
|
Keycode::Kp2 => Some(("2", false)),
|
|
|
|
VirtualKeyCode::Comma => Some((",", false)),
|
|
|
|
Keycode::Kp3 => Some(("3", false)),
|
|
|
|
VirtualKeyCode::Convert => unsupported_key!(Convert),
|
|
|
|
Keycode::Kp4 => Some(("4", false)),
|
|
|
|
VirtualKeyCode::Decimal => Some((".", false)),
|
|
|
|
Keycode::Kp5 => Some(("5", false)),
|
|
|
|
VirtualKeyCode::Divide => Some(("/", false)),
|
|
|
|
Keycode::Kp6 => Some(("6", false)),
|
|
|
|
VirtualKeyCode::Equals => Some(("=", false)),
|
|
|
|
Keycode::Kp7 => Some(("7", false)),
|
|
|
|
VirtualKeyCode::Grave => Some(("`", false)),
|
|
|
|
Keycode::Kp8 => Some(("8", false)),
|
|
|
|
VirtualKeyCode::Kana => unsupported_key!(Kana),
|
|
|
|
Keycode::Kp9 => Some(("9", false)),
|
|
|
|
VirtualKeyCode::Kanji => unsupported_key!(Kanji),
|
|
|
|
Keycode::KpPeriod => Some((".", false)),
|
|
|
|
VirtualKeyCode::LAlt => None, // Regular modifier key
|
|
|
|
Keycode::Application => unsupported_key!(Application),
|
|
|
|
VirtualKeyCode::LBracket => Some(("[", false)),
|
|
|
|
Keycode::Power => unsupported_key!(Power),
|
|
|
|
VirtualKeyCode::LControl => None, // Regular modifier key
|
|
|
|
Keycode::KpEquals => Some(("=", false)),
|
|
|
|
VirtualKeyCode::LShift => None, // Regular modifier key
|
|
|
|
Keycode::F13 => Some(("F13", true)),
|
|
|
|
VirtualKeyCode::LWin => unsupported_key!(LWin),
|
|
|
|
Keycode::F14 => Some(("F14", true)),
|
|
|
|
VirtualKeyCode::Mail => unsupported_key!(Mail),
|
|
|
|
Keycode::F15 => Some(("F15", true)),
|
|
|
|
VirtualKeyCode::MediaSelect => unsupported_key!(MediaSelect),
|
|
|
|
Keycode::F16 => Some(("F16", true)),
|
|
|
|
VirtualKeyCode::MediaStop => unsupported_key!(MediaStop),
|
|
|
|
Keycode::F17 => Some(("F17", true)),
|
|
|
|
VirtualKeyCode::Minus => Some(("-", false)),
|
|
|
|
Keycode::F18 => Some(("F18", true)),
|
|
|
|
VirtualKeyCode::Multiply => Some(("*", false)),
|
|
|
|
Keycode::F19 => Some(("F19", true)),
|
|
|
|
VirtualKeyCode::Mute => unsupported_key!(Mute),
|
|
|
|
Keycode::F20 => Some(("F20", true)),
|
|
|
|
VirtualKeyCode::MyComputer => unsupported_key!(MyComputer),
|
|
|
|
Keycode::F21 => Some(("F21", true)),
|
|
|
|
VirtualKeyCode::NavigateForward => unsupported_key!(NavigateForward),
|
|
|
|
Keycode::F22 => Some(("F22", true)),
|
|
|
|
VirtualKeyCode::NavigateBackward => unsupported_key!(NavigateBackward),
|
|
|
|
Keycode::F23 => Some(("F23", true)),
|
|
|
|
VirtualKeyCode::NextTrack => unsupported_key!(NextTrack),
|
|
|
|
Keycode::F24 => Some(("F24", true)),
|
|
|
|
VirtualKeyCode::NoConvert => unsupported_key!(NoConvert),
|
|
|
|
Keycode::Execute => unsupported_key!(Execute),
|
|
|
|
VirtualKeyCode::NumpadComma => Some((",", false)),
|
|
|
|
Keycode::Help => unsupported_key!(Help),
|
|
|
|
VirtualKeyCode::NumpadEnter => Some(("Enter", true)),
|
|
|
|
Keycode::Menu => unsupported_key!(Menu),
|
|
|
|
VirtualKeyCode::NumpadEquals => Some(("=", false)),
|
|
|
|
Keycode::Select => unsupported_key!(Select),
|
|
|
|
VirtualKeyCode::OEM102 => unsupported_key!(OEM102),
|
|
|
|
Keycode::Stop => unsupported_key!(Stop),
|
|
|
|
VirtualKeyCode::Period => Some((".", false)),
|
|
|
|
Keycode::Again => unsupported_key!(Again),
|
|
|
|
VirtualKeyCode::PlayPause => unsupported_key!(PlayPause),
|
|
|
|
Keycode::Undo => unsupported_key!(Undo),
|
|
|
|
VirtualKeyCode::Power => unsupported_key!(Power),
|
|
|
|
Keycode::Cut => unsupported_key!(Cut),
|
|
|
|
VirtualKeyCode::PrevTrack => unsupported_key!(PrevTrack),
|
|
|
|
Keycode::Copy => unsupported_key!(Copy),
|
|
|
|
VirtualKeyCode::RAlt => None, // Regular modifier key
|
|
|
|
Keycode::Paste => unsupported_key!(Paste),
|
|
|
|
VirtualKeyCode::RBracket => Some(("]", false)),
|
|
|
|
Keycode::Find => unsupported_key!(Find),
|
|
|
|
VirtualKeyCode::RControl => None, // Regular modifier key
|
|
|
|
Keycode::Mute => unsupported_key!(Mute),
|
|
|
|
VirtualKeyCode::RShift => None, // Regular modifier key
|
|
|
|
Keycode::VolumeUp => unsupported_key!(VolumeUp),
|
|
|
|
VirtualKeyCode::RWin => unsupported_key!(RWin),
|
|
|
|
Keycode::VolumeDown => unsupported_key!(VolumeDown),
|
|
|
|
VirtualKeyCode::Semicolon => Some((";", false)),
|
|
|
|
Keycode::KpComma => unsupported_key!(KpComma),
|
|
|
|
VirtualKeyCode::Slash => Some(("/", false)),
|
|
|
|
Keycode::KpEqualsAS400 => unsupported_key!(KpEqualsAS400),
|
|
|
|
VirtualKeyCode::Sleep => unsupported_key!(Sleep),
|
|
|
|
Keycode::AltErase => unsupported_key!(AltErase),
|
|
|
|
VirtualKeyCode::Stop => unsupported_key!(Stop),
|
|
|
|
Keycode::Sysreq => unsupported_key!(Sysreq),
|
|
|
|
VirtualKeyCode::Subtract => Some(("-", false)),
|
|
|
|
Keycode::Cancel => unsupported_key!(Cancel),
|
|
|
|
VirtualKeyCode::Sysrq => unsupported_key!(Sysrq),
|
|
|
|
Keycode::Clear => unsupported_key!(Clear),
|
|
|
|
VirtualKeyCode::Tab => Some(("Tab", true)),
|
|
|
|
Keycode::Prior => unsupported_key!(Prior),
|
|
|
|
VirtualKeyCode::Underline => unsupported_key!(Underline),
|
|
|
|
Keycode::Return2 => unsupported_key!(Return2),
|
|
|
|
VirtualKeyCode::Unlabeled => unsupported_key!(Unlabeled),
|
|
|
|
Keycode::Separator => unsupported_key!(Separator),
|
|
|
|
VirtualKeyCode::VolumeDown => unsupported_key!(VolumeDown),
|
|
|
|
Keycode::Out => unsupported_key!(Out),
|
|
|
|
VirtualKeyCode::VolumeUp => unsupported_key!(VolumeUp),
|
|
|
|
Keycode::Oper => unsupported_key!(Oper),
|
|
|
|
VirtualKeyCode::Wake => unsupported_key!(Wake),
|
|
|
|
Keycode::ClearAgain => unsupported_key!(ClearAgain),
|
|
|
|
VirtualKeyCode::WebBack => unsupported_key!(WebBack),
|
|
|
|
Keycode::CrSel => unsupported_key!(CrSel),
|
|
|
|
VirtualKeyCode::WebFavorites => unsupported_key!(WebFavorites),
|
|
|
|
Keycode::ExSel => unsupported_key!(ExSel),
|
|
|
|
VirtualKeyCode::WebForward => unsupported_key!(WebForward),
|
|
|
|
Keycode::Kp00 => unsupported_key!(Kp00),
|
|
|
|
VirtualKeyCode::WebHome => unsupported_key!(WebHome),
|
|
|
|
Keycode::Kp000 => unsupported_key!(Kp000),
|
|
|
|
VirtualKeyCode::WebRefresh => unsupported_key!(WebRefresh),
|
|
|
|
Keycode::ThousandsSeparator => unsupported_key!(ThousandsSeparator),
|
|
|
|
VirtualKeyCode::WebSearch => unsupported_key!(WebSearch),
|
|
|
|
Keycode::DecimalSeparator => unsupported_key!(DecimalSeparator),
|
|
|
|
VirtualKeyCode::WebStop => unsupported_key!(WebStop),
|
|
|
|
Keycode::CurrencyUnit => unsupported_key!(CurrencyUnit),
|
|
|
|
VirtualKeyCode::Yen => Some(("¥", false)),
|
|
|
|
Keycode::CurrencySubUnit => unsupported_key!(CurrencySubUnit),
|
|
|
|
VirtualKeyCode::Copy => unsupported_key!(Copy),
|
|
|
|
Keycode::KpLeftParen => Some(("(", false)),
|
|
|
|
VirtualKeyCode::Paste => unsupported_key!(Paste),
|
|
|
|
Keycode::KpRightParen => Some((")", false)),
|
|
|
|
VirtualKeyCode::Cut => unsupported_key!(Cut),
|
|
|
|
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 result = keycode_text.to_string();
|
|
|
|
let mut special = special;
|
|
|
|
let mut special = special;
|
|
|
|
|
|
|
|
|
|
|
|
if modifiers.shift() {
|
|
|
|
if modifiers.contains(Mod::LSHIFTMOD) || modifiers.contains(Mod::RSHIFTMOD) {
|
|
|
|
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;
|
|
|
|
special = true;
|
|
|
|
"lt".to_string()
|
|
|
|
result = format!("S-{}", result);
|
|
|
|
},
|
|
|
|
|
|
|
|
"=" => "+".to_string(),
|
|
|
|
|
|
|
|
"`" => "~".to_string(),
|
|
|
|
|
|
|
|
"[" => "{".to_string(),
|
|
|
|
|
|
|
|
"-" => "_".to_string(),
|
|
|
|
|
|
|
|
"." => ">".to_string(),
|
|
|
|
|
|
|
|
"]" => "}".to_string(),
|
|
|
|
|
|
|
|
";" => ":".to_string(),
|
|
|
|
|
|
|
|
"/" => "?".to_string(),
|
|
|
|
|
|
|
|
other => {
|
|
|
|
|
|
|
|
special = true;
|
|
|
|
|
|
|
|
format!("S-{}", other)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if result == "<" {
|
|
|
|
|
|
|
|
special = true;
|
|
|
|
|
|
|
|
result = "lt".to_string();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if modifiers.contains(Mod::LCTRLMOD) || modifiers.contains(Mod::RCTRLMOD) {
|
|
|
|
if modifiers.ctrl() {
|
|
|
|
|
|
|
|
special = true;
|
|
|
|
special = true;
|
|
|
|
result = format!("C-{}", result);
|
|
|
|
result = format!("C-{}", result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if modifiers.alt() {
|
|
|
|
if modifiers.contains(Mod::LALTMOD) || modifiers.contains(Mod::RALTMOD) {
|
|
|
|
special = true;
|
|
|
|
special = true;
|
|
|
|
result = format!("M-{}", result);
|
|
|
|
result = format!("M-{}", result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if modifiers.logo() {
|
|
|
|
if modifiers.contains(Mod::LGUIMOD) || modifiers.contains(Mod::RGUIMOD) {
|
|
|
|
special = true;
|
|
|
|
special = true;
|
|
|
|
result = format!("D-{}", result);
|
|
|
|
result = format!("D-{}", result);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -243,21 +279,3 @@ pub fn append_modifiers(modifiers: ModifiersState, keycode_text: &str, special:
|
|
|
|
|
|
|
|
|
|
|
|
result
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|