| 1 | #![allow(dead_code)] |
| 2 | |
| 3 | pub type Keysym = u32; |
| 4 | pub const XK_ESCAPE: Keysym = 0xff1b; |
| 5 | pub const XK_RETURN: Keysym = 0xff0d; |
| 6 | pub const XK_SPACE: Keysym = 0x0020; |
| 7 | pub const XK_TAB: Keysym = 0xff09; |
| 8 | pub const XK_BACKSPACE: Keysym = 0xff08; |
| 9 | pub const XK_DELETE: Keysym = 0xffff; |
| 10 | pub const XK_F1: Keysym = 0xffbe; |
| 11 | pub const XK_F2: Keysym = 0xffbf; |
| 12 | pub const XK_F3: Keysym = 0xffc0; |
| 13 | pub const XK_F4: Keysym = 0xffc1; |
| 14 | pub const XK_F5: Keysym = 0xffc2; |
| 15 | pub const XK_F6: Keysym = 0xffc3; |
| 16 | pub const XK_F7: Keysym = 0xffc4; |
| 17 | pub const XK_F8: Keysym = 0xffc5; |
| 18 | pub const XK_F9: Keysym = 0xffc6; |
| 19 | pub const XK_F10: Keysym = 0xffc7; |
| 20 | pub const XK_F11: Keysym = 0xffc8; |
| 21 | pub const XK_F12: Keysym = 0xffc9; |
| 22 | pub const XK_A: Keysym = 0x0061; |
| 23 | pub const XK_B: Keysym = 0x0062; |
| 24 | pub const XK_C: Keysym = 0x0063; |
| 25 | pub const XK_D: Keysym = 0x0064; |
| 26 | pub const XK_E: Keysym = 0x0065; |
| 27 | pub const XK_F: Keysym = 0x0066; |
| 28 | pub const XK_G: Keysym = 0x0067; |
| 29 | pub const XK_H: Keysym = 0x0068; |
| 30 | pub const XK_I: Keysym = 0x0069; |
| 31 | pub const XK_J: Keysym = 0x006a; |
| 32 | pub const XK_K: Keysym = 0x006b; |
| 33 | pub const XK_L: Keysym = 0x006c; |
| 34 | pub const XK_M: Keysym = 0x006d; |
| 35 | pub const XK_N: Keysym = 0x006e; |
| 36 | pub const XK_O: Keysym = 0x006f; |
| 37 | pub const XK_P: Keysym = 0x0070; |
| 38 | pub const XK_Q: Keysym = 0x0071; |
| 39 | pub const XK_R: Keysym = 0x0072; |
| 40 | pub const XK_S: Keysym = 0x0073; |
| 41 | pub const XK_T: Keysym = 0x0074; |
| 42 | pub const XK_U: Keysym = 0x0075; |
| 43 | pub const XK_V: Keysym = 0x0076; |
| 44 | pub const XK_W: Keysym = 0x0077; |
| 45 | pub const XK_X: Keysym = 0x0078; |
| 46 | pub const XK_Y: Keysym = 0x0079; |
| 47 | pub const XK_Z: Keysym = 0x007a; |
| 48 | pub const XK_0: Keysym = 0x0030; |
| 49 | pub const XK_1: Keysym = 0x0031; |
| 50 | pub const XK_2: Keysym = 0x0032; |
| 51 | pub const XK_3: Keysym = 0x0033; |
| 52 | pub const XK_4: Keysym = 0x0034; |
| 53 | pub const XK_5: Keysym = 0x0035; |
| 54 | pub const XK_6: Keysym = 0x0036; |
| 55 | pub const XK_7: Keysym = 0x0037; |
| 56 | pub const XK_8: Keysym = 0x0038; |
| 57 | pub const XK_9: Keysym = 0x0039; |
| 58 | pub const XK_LEFT: Keysym = 0xff51; |
| 59 | pub const XK_UP: Keysym = 0xff52; |
| 60 | pub const XK_RIGHT: Keysym = 0xff53; |
| 61 | pub const XK_DOWN: Keysym = 0xff54; |
| 62 | pub const XK_HOME: Keysym = 0xff50; |
| 63 | pub const XK_END: Keysym = 0xff57; |
| 64 | pub const XK_PAGE_UP: Keysym = 0xff55; |
| 65 | pub const XK_PAGE_DOWN: Keysym = 0xff56; |
| 66 | pub const XK_INSERT: Keysym = 0xff63; |
| 67 | pub const XK_MINUS: Keysym = 0x002d; |
| 68 | pub const XK_EQUAL: Keysym = 0x003d; |
| 69 | pub const XK_LEFT_BRACKET: Keysym = 0x005b; |
| 70 | pub const XK_RIGHT_BRACKET: Keysym = 0x005d; |
| 71 | pub const XK_SEMICOLON: Keysym = 0x003b; |
| 72 | pub const XK_APOSTROPHE: Keysym = 0x0027; |
| 73 | pub const XK_GRAVE: Keysym = 0x0060; |
| 74 | pub const XK_BACKSLASH: Keysym = 0x005c; |
| 75 | pub const XK_COMMA: Keysym = 0x002c; |
| 76 | pub const XK_PERIOD: Keysym = 0x002e; |
| 77 | pub const XK_SLASH: Keysym = 0x002f; |
| 78 | pub const XK_PRINT: Keysym = 0xff61; |
| 79 | |
| 80 | pub const XF86_AUDIO_RAISE_VOLUME: Keysym = 0x1008ff13; |
| 81 | pub const XF86_AUDIO_LOWER_VOLUME: Keysym = 0x1008ff11; |
| 82 | pub const XF86_AUDIO_MUTE: Keysym = 0x1008ff12; |
| 83 | pub const XF86_MON_BRIGHTNESS_UP: Keysym = 0x1008ff02; |
| 84 | pub const XF86_MON_BRIGHTNESS_DOWN: Keysym = 0x1008ff03; |
| 85 | |
| 86 | pub fn format_keysym(keysym: Keysym) -> String { |
| 87 | match keysym { |
| 88 | XK_RETURN => "Return".to_string(), |
| 89 | XK_ESCAPE => "Esc".to_string(), |
| 90 | XK_SPACE => "Space".to_string(), |
| 91 | XK_TAB => "Tab".to_string(), |
| 92 | XK_BACKSPACE => "Backspace".to_string(), |
| 93 | XK_DELETE => "Del".to_string(), |
| 94 | XK_LEFT => "Left".to_string(), |
| 95 | XK_RIGHT => "Right".to_string(), |
| 96 | XK_UP => "Up".to_string(), |
| 97 | XK_DOWN => "Down".to_string(), |
| 98 | XK_HOME => "Home".to_string(), |
| 99 | XK_END => "End".to_string(), |
| 100 | XK_PAGE_UP => "PgUp".to_string(), |
| 101 | XK_PAGE_DOWN => "PgDn".to_string(), |
| 102 | XK_INSERT => "Ins".to_string(), |
| 103 | XK_F1 => "F1".to_string(), |
| 104 | XK_F2 => "F2".to_string(), |
| 105 | XK_F3 => "F3".to_string(), |
| 106 | XK_F4 => "F4".to_string(), |
| 107 | XK_F5 => "F5".to_string(), |
| 108 | XK_F6 => "F6".to_string(), |
| 109 | XK_F7 => "F7".to_string(), |
| 110 | XK_F8 => "F8".to_string(), |
| 111 | XK_F9 => "F9".to_string(), |
| 112 | XK_F10 => "F10".to_string(), |
| 113 | XK_F11 => "F11".to_string(), |
| 114 | XK_F12 => "F12".to_string(), |
| 115 | XK_SLASH => "/".to_string(), |
| 116 | XK_COMMA => ",".to_string(), |
| 117 | XK_PERIOD => ".".to_string(), |
| 118 | XK_MINUS => "-".to_string(), |
| 119 | XK_EQUAL => "=".to_string(), |
| 120 | XK_GRAVE => "`".to_string(), |
| 121 | XK_LEFT_BRACKET => "[".to_string(), |
| 122 | XK_RIGHT_BRACKET => "]".to_string(), |
| 123 | XK_SEMICOLON => ";".to_string(), |
| 124 | XK_APOSTROPHE => "'".to_string(), |
| 125 | XK_BACKSLASH => "\\".to_string(), |
| 126 | XK_PRINT => "Print".to_string(), |
| 127 | XF86_AUDIO_RAISE_VOLUME => "Vol+".to_string(), |
| 128 | XF86_AUDIO_LOWER_VOLUME => "Vol-".to_string(), |
| 129 | XF86_AUDIO_MUTE => "Mute".to_string(), |
| 130 | XF86_MON_BRIGHTNESS_UP => "Bright+".to_string(), |
| 131 | XF86_MON_BRIGHTNESS_DOWN => "Bright-".to_string(), |
| 132 | XK_A..=XK_Z => { |
| 133 | let ch = (keysym - XK_A + b'A' as u32) as u8 as char; |
| 134 | ch.to_string() |
| 135 | } |
| 136 | XK_0..=XK_9 => { |
| 137 | let ch = (keysym - XK_0 + b'0' as u32) as u8 as char; |
| 138 | ch.to_string() |
| 139 | } |
| 140 | _ => format!("0x{:x}", keysym), |
| 141 | } |
| 142 | } |