#![allow(dead_code)] pub type Keysym = u32; pub const XK_ESCAPE: Keysym = 0xff1b; pub const XK_RETURN: Keysym = 0xff0d; pub const XK_SPACE: Keysym = 0x0020; pub const XK_TAB: Keysym = 0xff09; pub const XK_BACKSPACE: Keysym = 0xff08; pub const XK_DELETE: Keysym = 0xffff; pub const XK_F1: Keysym = 0xffbe; pub const XK_F2: Keysym = 0xffbf; pub const XK_F3: Keysym = 0xffc0; pub const XK_F4: Keysym = 0xffc1; pub const XK_F5: Keysym = 0xffc2; pub const XK_F6: Keysym = 0xffc3; pub const XK_F7: Keysym = 0xffc4; pub const XK_F8: Keysym = 0xffc5; pub const XK_F9: Keysym = 0xffc6; pub const XK_F10: Keysym = 0xffc7; pub const XK_F11: Keysym = 0xffc8; pub const XK_F12: Keysym = 0xffc9; pub const XK_A: Keysym = 0x0061; pub const XK_B: Keysym = 0x0062; pub const XK_C: Keysym = 0x0063; pub const XK_D: Keysym = 0x0064; pub const XK_E: Keysym = 0x0065; pub const XK_F: Keysym = 0x0066; pub const XK_G: Keysym = 0x0067; pub const XK_H: Keysym = 0x0068; pub const XK_I: Keysym = 0x0069; pub const XK_J: Keysym = 0x006a; pub const XK_K: Keysym = 0x006b; pub const XK_L: Keysym = 0x006c; pub const XK_M: Keysym = 0x006d; pub const XK_N: Keysym = 0x006e; pub const XK_O: Keysym = 0x006f; pub const XK_P: Keysym = 0x0070; pub const XK_Q: Keysym = 0x0071; pub const XK_R: Keysym = 0x0072; pub const XK_S: Keysym = 0x0073; pub const XK_T: Keysym = 0x0074; pub const XK_U: Keysym = 0x0075; pub const XK_V: Keysym = 0x0076; pub const XK_W: Keysym = 0x0077; pub const XK_X: Keysym = 0x0078; pub const XK_Y: Keysym = 0x0079; pub const XK_Z: Keysym = 0x007a; pub const XK_0: Keysym = 0x0030; pub const XK_1: Keysym = 0x0031; pub const XK_2: Keysym = 0x0032; pub const XK_3: Keysym = 0x0033; pub const XK_4: Keysym = 0x0034; pub const XK_5: Keysym = 0x0035; pub const XK_6: Keysym = 0x0036; pub const XK_7: Keysym = 0x0037; pub const XK_8: Keysym = 0x0038; pub const XK_9: Keysym = 0x0039; pub const XK_LEFT: Keysym = 0xff51; pub const XK_UP: Keysym = 0xff52; pub const XK_RIGHT: Keysym = 0xff53; pub const XK_DOWN: Keysym = 0xff54; pub const XK_HOME: Keysym = 0xff50; pub const XK_END: Keysym = 0xff57; pub const XK_PAGE_UP: Keysym = 0xff55; pub const XK_PAGE_DOWN: Keysym = 0xff56; pub const XK_INSERT: Keysym = 0xff63; pub const XK_MINUS: Keysym = 0x002d; pub const XK_EQUAL: Keysym = 0x003d; pub const XK_LEFT_BRACKET: Keysym = 0x005b; pub const XK_RIGHT_BRACKET: Keysym = 0x005d; pub const XK_SEMICOLON: Keysym = 0x003b; pub const XK_APOSTROPHE: Keysym = 0x0027; pub const XK_GRAVE: Keysym = 0x0060; pub const XK_BACKSLASH: Keysym = 0x005c; pub const XK_COMMA: Keysym = 0x002c; pub const XK_PERIOD: Keysym = 0x002e; pub const XK_SLASH: Keysym = 0x002f; pub const XK_PRINT: Keysym = 0xff61; pub const XK_AMPERSAND: Keysym = 0x26; pub const XK_AGRAVE: Keysym = 0xe0; pub const XK_CCEDILLA: Keysym = 0xe7; pub const XK_EGRAVE: Keysym = 0xe8; pub const XK_EACUTE: Keysym = 0xe9; pub const XK_PARENLEFT: Keysym = 0x28; pub const XK_PARENRIGHT: Keysym = 0x29; pub const XK_QUOTEDBL: Keysym = 0x22; pub const XK_UNDERSCORE: Keysym = 0x5f; pub const XK_HYPHEN: Keysym = 0xad; pub const XF86_AUDIO_MEDIA: Keysym = 0x1008ff32; pub const XF86_AUDIO_NEXT: Keysym = 0x1008ff17; pub const XF86_AUDIO_PAUSE: Keysym = 0x1008ff31; pub const XF86_AUDIO_PLAY: Keysym = 0x1008ff14; pub const XF86_AUDIO_PREV: Keysym = 0x1008ff16; pub const XF86_AUDIO_RAISE_VOLUME: Keysym = 0x1008ff13; pub const XF86_AUDIO_LOWER_VOLUME: Keysym = 0x1008ff11; pub const XF86_AUDIO_MUTE: Keysym = 0x1008ff12; pub const XF86_AUDIO_MIC_MUTE: Keysym = 0x1008ffb2; pub const XF86_AUDIO_RECORD: Keysym = 0x1008ff1c; pub const XF86_AUDIO_REWIND: Keysym = 0x1008ff3e; pub const XF86_AUDIO_STOP: Keysym = 0x1008ff15; pub const XF86_BACK: Keysym = 0x1008ff26; pub const XF86_CALCULATOR: Keysym = 0x1008ff1d; pub const XF86_CLOSE: Keysym = 0x1008ff56; pub const XF86_COPY: Keysym = 0x1008ff57; pub const XF86_CUT: Keysym = 0x1008ff58; pub const XF86_DOS: Keysym = 0x1008ff5a; pub const XF86_DISPLAY: Keysym = 0x1008ff59; pub const XF86_DOCUMENTS: Keysym = 0x1008ff5b; pub const XF86_EJECT: Keysym = 0x1008ff2c; pub const XF86_EXPLORER: Keysym = 0x1008ff5d; pub const XF86_FAVORITES: Keysym = 0x1008ff30; pub const XF86_FINANCE: Keysym = 0x1008ff3c; pub const XF86_FORWARD: Keysym = 0x1008ff27; pub const XF86_GAME: Keysym = 0x1008ff5e; pub const XF86_GO: Keysym = 0x1008ff5f; pub const XF86_HOME_PAGE: Keysym = 0x1008ff18; pub const XF86_MAIL: Keysym = 0x1008ff19; pub const XF86_MAIL_FORWARD: Keysym = 0x1008ff90; pub const XF86_MENU_KB: Keysym = 0x1008ff65; pub const XF86_MESSENGER: Keysym = 0x1008ff8e; pub const XF86_MON_BRIGHTNESS_UP: Keysym = 0x1008ff02; pub const XF86_MON_BRIGHTNESS_DOWN: Keysym = 0x1008ff03; pub const XF86_MY_COMPUTER: Keysym = 0x1008ff33; pub const XF86_NEW: Keysym = 0x1008ff68; pub const XF86_NEXT_VMODE: Keysym = 0x1008fe22; pub const XF86_PREV_VMODE: Keysym = 0x1008fe23; pub const XF86_OPEN: Keysym = 0x1008ff6b; pub const XF86_PASTE: Keysym = 0x1008ff6d; pub const XF86_PHONE: Keysym = 0x1008ff6e; pub const XF86_POWER_OFF: Keysym = 0x1008ff2a; pub const XF86_RELOAD: Keysym = 0x1008ff73; pub const XF86_REPLY: Keysym = 0x1008ff72; pub const XF86_ROTATE_WINDOWS: Keysym = 0x1008ff74; pub const XF86_SAVE: Keysym = 0x1008ff77; pub const XF86_SCREEN_SAVER: Keysym = 0x1008ff2d; pub const XF86_SCROLL_DOWN: Keysym = 0x1008ff79; pub const XF86_SCROLL_UP: Keysym = 0x1008ff78; pub const XF86_SEARCH: Keysym = 0x1008ff1b; pub const XF86_SEND: Keysym = 0x1008ff7b; pub const XF86_SHOP: Keysym = 0x1008ff36; pub const XF86_SLEEP: Keysym = 0x1008ff2f; pub const XF86_TASK_PANE: Keysym = 0x1008ff7f; pub const XF86_TOOLS: Keysym = 0x1008ff81; pub const XF86_WWW: Keysym = 0x1008ff2e; pub const XF86_WAKE_UP: Keysym = 0x1008ff2b; pub const XF86_WEBCAM: Keysym = 0x1008ff8f; pub const XF86_XFER: Keysym = 0x1008ff8a; pub fn keysym_from_str(s: &str) -> Option { match s { "Return" => Some(XK_RETURN), "Escape" => Some(XK_ESCAPE), "Space" => Some(XK_SPACE), "Tab" => Some(XK_TAB), "Backspace" => Some(XK_BACKSPACE), "Delete" => Some(XK_DELETE), "F1" => Some(XK_F1), "F2" => Some(XK_F2), "F3" => Some(XK_F3), "F4" => Some(XK_F4), "F5" => Some(XK_F5), "F6" => Some(XK_F6), "F7" => Some(XK_F7), "F8" => Some(XK_F8), "F9" => Some(XK_F9), "F10" => Some(XK_F10), "F11" => Some(XK_F11), "F12" => Some(XK_F12), "A" => Some(XK_A), "B" => Some(XK_B), "C" => Some(XK_C), "D" => Some(XK_D), "E" => Some(XK_E), "F" => Some(XK_F), "G" => Some(XK_G), "H" => Some(XK_H), "I" => Some(XK_I), "J" => Some(XK_J), "K" => Some(XK_K), "L" => Some(XK_L), "M" => Some(XK_M), "N" => Some(XK_N), "O" => Some(XK_O), "P" => Some(XK_P), "Q" => Some(XK_Q), "R" => Some(XK_R), "S" => Some(XK_S), "T" => Some(XK_T), "U" => Some(XK_U), "V" => Some(XK_V), "W" => Some(XK_W), "X" => Some(XK_X), "Y" => Some(XK_Y), "Z" => Some(XK_Z), "0" => Some(XK_0), "1" => Some(XK_1), "2" => Some(XK_2), "3" => Some(XK_3), "4" => Some(XK_4), "5" => Some(XK_5), "6" => Some(XK_6), "7" => Some(XK_7), "8" => Some(XK_8), "9" => Some(XK_9), "Left" => Some(XK_LEFT), "Right" => Some(XK_RIGHT), "Up" => Some(XK_UP), "Down" => Some(XK_DOWN), "Home" => Some(XK_HOME), "End" => Some(XK_END), "PageUp" => Some(XK_PAGE_UP), "PageDown" => Some(XK_PAGE_DOWN), "Insert" => Some(XK_INSERT), "Minus" => Some(XK_MINUS), "Equal" => Some(XK_EQUAL), "BracketLeft" => Some(XK_LEFT_BRACKET), "BracketRight" => Some(XK_RIGHT_BRACKET), "Semicolon" => Some(XK_SEMICOLON), "Apostrophe" => Some(XK_APOSTROPHE), "Grave" => Some(XK_GRAVE), "Backslash" => Some(XK_BACKSLASH), "Comma" => Some(XK_COMMA), "Period" => Some(XK_PERIOD), "Slash" => Some(XK_SLASH), "Print" => Some(XK_PRINT), "Ampersand" => Some(XK_AMPERSAND), "Agrave" => Some(XK_AGRAVE), "Ccedilla" => Some(XK_CCEDILLA), "Egrave" => Some(XK_EGRAVE), "Eacute" => Some(XK_EACUTE), "ParenLeft" => Some(XK_PARENLEFT), "ParenRight" => Some(XK_PARENRIGHT), "QuoteDouble" => Some(XK_QUOTEDBL), "Underscore" => Some(XK_UNDERSCORE), "Hyphen" => Some(XK_HYPHEN), "AudioMedia" | "XF86AudioMedia" => Some(XF86_AUDIO_MEDIA), "XF86AudioNext" => Some(XF86_AUDIO_NEXT), "XF86AudioPause" => Some(XF86_AUDIO_PAUSE), "XF86AudioPlay" => Some(XF86_AUDIO_PLAY), "XF86AudioPrev" => Some(XF86_AUDIO_PREV), "XF86AudioRaiseVolume" => Some(XF86_AUDIO_RAISE_VOLUME), "AudioLowerVolume" | "XF86AudioLowerVolume" => Some(XF86_AUDIO_LOWER_VOLUME), "AudioMute" | "XF86AudioMute" => Some(XF86_AUDIO_MUTE), "XF86AudioMicMute" => Some(XF86_AUDIO_MIC_MUTE), "XF86AudioRecord" => Some(XF86_AUDIO_RECORD), "XF86AudioRewind" => Some(XF86_AUDIO_REWIND), "XF86AudioStop" => Some(XF86_AUDIO_STOP), "XF86Back" => Some(XF86_BACK), "XF86Calculator" => Some(XF86_CALCULATOR), "XF86Close" => Some(XF86_CLOSE), "XF86Copy" => Some(XF86_COPY), "XF86Cut" => Some(XF86_CUT), "XF86DOS" => Some(XF86_DOS), "XF86Display" => Some(XF86_DISPLAY), "XF86Documents" => Some(XF86_DOCUMENTS), "XF86Eject" => Some(XF86_EJECT), "XF86Explorer" => Some(XF86_EXPLORER), "XF86Favorites" => Some(XF86_FAVORITES), "XF86Finance" => Some(XF86_FINANCE), "XF86Forward" => Some(XF86_FORWARD), "XF86Game" => Some(XF86_GAME), "XF86Go" => Some(XF86_GO), "XF86HomePage" => Some(XF86_HOME_PAGE), "XF86Mail" => Some(XF86_MAIL), "XF86MailForward" => Some(XF86_MAIL_FORWARD), "XF86MenuKB" => Some(XF86_MENU_KB), "XF86Messenger" => Some(XF86_MESSENGER), "MonBrightnessUp" | "XF86MonBrightnessUp" => Some(XF86_MON_BRIGHTNESS_UP), "MonBrightnessDown" | "XF86MonBrightnessDown" => Some(XF86_MON_BRIGHTNESS_DOWN), "XF86MyComputer" => Some(XF86_MY_COMPUTER), "XF86New" => Some(XF86_NEW), "XF86Next_VMode" => Some(XF86_NEXT_VMODE), "XF86Prev_VMode" => Some(XF86_PREV_VMODE), "XF86Open" => Some(XF86_OPEN), "XF86Paste" => Some(XF86_PASTE), "XF86Phone" => Some(XF86_PHONE), "XF86PowerOff" => Some(XF86_POWER_OFF), "XF86Reload" => Some(XF86_RELOAD), "XF86Reply" => Some(XF86_REPLY), "XF86RotateWindows" => Some(XF86_ROTATE_WINDOWS), "XF86Save" => Some(XF86_SAVE), "XF86ScreenSaver" => Some(XF86_SCREEN_SAVER), "XF86ScrollDown" => Some(XF86_SCROLL_DOWN), "XF86ScrollUp" => Some(XF86_SCROLL_UP), "XF86Search" => Some(XF86_SEARCH), "XF86Send" => Some(XF86_SEND), "XF86Shop" => Some(XF86_SHOP), "XF86Sleep" => Some(XF86_SLEEP), "XF86TaskPane" => Some(XF86_TASK_PANE), "XF86Tools" => Some(XF86_TOOLS), "XF86WWW" => Some(XF86_WWW), "XF86WakeUp" => Some(XF86_WAKE_UP), "XF86WebCam" => Some(XF86_WEBCAM), "XF86Xfer" => Some(XF86_XFER), _ => None, } } pub fn format_keysym(keysym: Keysym) -> String { match keysym { XK_RETURN => "Return".to_string(), XK_ESCAPE => "Esc".to_string(), XK_SPACE => "Space".to_string(), XK_TAB => "Tab".to_string(), XK_BACKSPACE => "Backspace".to_string(), XK_DELETE => "Del".to_string(), XK_LEFT => "Left".to_string(), XK_RIGHT => "Right".to_string(), XK_UP => "Up".to_string(), XK_DOWN => "Down".to_string(), XK_HOME => "Home".to_string(), XK_END => "End".to_string(), XK_PAGE_UP => "PgUp".to_string(), XK_PAGE_DOWN => "PgDn".to_string(), XK_INSERT => "Ins".to_string(), XK_F1 => "F1".to_string(), XK_F2 => "F2".to_string(), XK_F3 => "F3".to_string(), XK_F4 => "F4".to_string(), XK_F5 => "F5".to_string(), XK_F6 => "F6".to_string(), XK_F7 => "F7".to_string(), XK_F8 => "F8".to_string(), XK_F9 => "F9".to_string(), XK_F10 => "F10".to_string(), XK_F11 => "F11".to_string(), XK_F12 => "F12".to_string(), XK_SLASH => "/".to_string(), XK_COMMA => ",".to_string(), XK_PERIOD => ".".to_string(), XK_MINUS => "-".to_string(), XK_EQUAL => "=".to_string(), XK_GRAVE => "`".to_string(), XK_LEFT_BRACKET => "[".to_string(), XK_RIGHT_BRACKET => "]".to_string(), XK_SEMICOLON => ";".to_string(), XK_APOSTROPHE => "'".to_string(), XK_BACKSLASH => "\\".to_string(), XK_PRINT => "Print".to_string(), XK_AMPERSAND => "&".to_string(), XK_AGRAVE => "à".to_string(), XK_CCEDILLA => "ç".to_string(), XK_EGRAVE => "è".to_string(), XK_EACUTE => "é".to_string(), XK_PARENLEFT => "(".to_string(), XK_PARENRIGHT => ")".to_string(), XK_QUOTEDBL => "\"".to_string(), XK_UNDERSCORE => "_".to_string(), XK_HYPHEN => "-".to_string(), XF86_AUDIO_MEDIA => "Media".to_string(), XF86_AUDIO_NEXT => "Next".to_string(), XF86_AUDIO_PAUSE => "Pause".to_string(), XF86_AUDIO_PLAY => "Play".to_string(), XF86_AUDIO_PREV => "Prev".to_string(), XF86_AUDIO_RAISE_VOLUME => "Vol+".to_string(), XF86_AUDIO_LOWER_VOLUME => "Vol-".to_string(), XF86_AUDIO_MUTE => "Mute".to_string(), XF86_AUDIO_MIC_MUTE => "MicMute".to_string(), XF86_AUDIO_RECORD => "Record".to_string(), XF86_AUDIO_REWIND => "Rewind".to_string(), XF86_AUDIO_STOP => "Stop".to_string(), XF86_BACK => "Back".to_string(), XF86_CALCULATOR => "Calculator".to_string(), XF86_CLOSE => "Close".to_string(), XF86_COPY => "Copy".to_string(), XF86_CUT => "Cut".to_string(), XF86_DOS => "DOS".to_string(), XF86_DISPLAY => "Display".to_string(), XF86_DOCUMENTS => "Documents".to_string(), XF86_EJECT => "Eject".to_string(), XF86_EXPLORER => "Explorer".to_string(), XF86_FAVORITES => "Favorites".to_string(), XF86_FINANCE => "Finance".to_string(), XF86_FORWARD => "Forward".to_string(), XF86_GAME => "Game".to_string(), XF86_GO => "Go".to_string(), XF86_HOME_PAGE => "HomePage".to_string(), XF86_MAIL => "Mail".to_string(), XF86_MAIL_FORWARD => "MailForward".to_string(), XF86_MENU_KB => "MenuKB".to_string(), XF86_MESSENGER => "Messenger".to_string(), XF86_MON_BRIGHTNESS_UP => "Bright+".to_string(), XF86_MON_BRIGHTNESS_DOWN => "Bright-".to_string(), XF86_MY_COMPUTER => "MyComputer".to_string(), XF86_NEW => "New".to_string(), XF86_NEXT_VMODE => "NextVMode".to_string(), XF86_PREV_VMODE => "PrevVMode".to_string(), XF86_OPEN => "Open".to_string(), XF86_PASTE => "Paste".to_string(), XF86_PHONE => "Phone".to_string(), XF86_POWER_OFF => "PowerOff".to_string(), XF86_RELOAD => "Reload".to_string(), XF86_REPLY => "Reply".to_string(), XF86_ROTATE_WINDOWS => "RotateWindows".to_string(), XF86_SAVE => "Save".to_string(), XF86_SCREEN_SAVER => "ScreenSaver".to_string(), XF86_SCROLL_DOWN => "ScrollDown".to_string(), XF86_SCROLL_UP => "ScrollUp".to_string(), XF86_SEARCH => "Search".to_string(), XF86_SEND => "Send".to_string(), XF86_SHOP => "Shop".to_string(), XF86_SLEEP => "Sleep".to_string(), XF86_TASK_PANE => "TaskPane".to_string(), XF86_TOOLS => "Tools".to_string(), XF86_WWW => "WWW".to_string(), XF86_WAKE_UP => "WakeUp".to_string(), XF86_WEBCAM => "WebCam".to_string(), XF86_XFER => "Xfer".to_string(), XK_A..=XK_Z => { let ch = (keysym - XK_A + b'A' as u32) as u8 as char; ch.to_string() } XK_0..=XK_9 => { let ch = (keysym - XK_0 + b'0' as u32) as u8 as char; ch.to_string() } _ => format!("0x{:x}", keysym), } }