github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/internal/xkbcommon/keycodes.go (about) 1 //go:build linux && !android 2 3 package xkbcommon 4 5 import "github.com/rajveermalviya/gamen/events" 6 7 /* 8 9 #include <xkbcommon/xkbcommon.h> 10 11 */ 12 import "C" 13 14 func KeySymToVirtualKey(sym KeySym) events.VirtualKey { 15 switch sym { 16 case C.XKB_KEY_Cancel: 17 return events.VirtualKeyCancel 18 case C.XKB_KEY_BackSpace: 19 return events.VirtualKeyBackSpace 20 case C.XKB_KEY_Tab, 21 C.XKB_KEY_ISO_Left_Tab: 22 return events.VirtualKeyTab 23 case C.XKB_KEY_Clear, C.XKB_KEY_KP_Begin: 24 return events.VirtualKeyClear 25 case C.XKB_KEY_Return, C.XKB_KEY_KP_Enter: 26 return events.VirtualKeyReturn 27 case C.XKB_KEY_Shift_L: 28 return events.VirtualKeyLShift 29 case C.XKB_KEY_Shift_R: 30 return events.VirtualKeyRShift 31 case C.XKB_KEY_Control_L: 32 return events.VirtualKeyLControl 33 case C.XKB_KEY_Control_R: 34 return events.VirtualKeyRControl 35 case C.XKB_KEY_Alt_L: 36 return events.VirtualKeyLAlt 37 case C.XKB_KEY_Alt_R: 38 return events.VirtualKeyRAlt 39 case C.XKB_KEY_Super_L, 40 C.XKB_KEY_Hyper_L: 41 return events.VirtualKeyLWin 42 case C.XKB_KEY_Super_R, 43 C.XKB_KEY_Hyper_R: 44 return events.VirtualKeyRWin 45 case C.XKB_KEY_ISO_Level3_Shift, 46 C.XKB_KEY_ISO_Level5_Shift, 47 C.XKB_KEY_ISO_Group_Shift: 48 return events.VirtualKeyAltgr 49 case C.XKB_KEY_Pause: 50 return events.VirtualKeyPause 51 case C.XKB_KEY_Caps_Lock: 52 return events.VirtualKeyCapsLock 53 case C.XKB_KEY_Kana_Lock, 54 C.XKB_KEY_Kana_Shift: 55 return events.VirtualKeyKana 56 // case 0: 57 // return events.VirtualKeyJunja 58 // case 0: 59 // return events.VirtualKeyFinal 60 case C.XKB_KEY_Kanji: 61 return events.VirtualKeyKanji 62 case C.XKB_KEY_Escape: 63 return events.VirtualKeyEscape 64 case C.XKB_KEY_Henkan: 65 return events.VirtualKeyConvert 66 case C.XKB_KEY_Muhenkan: 67 return events.VirtualKeyNonconvert 68 // case 0: 69 // return events.VirtualKeyAccept 70 // case 0: 71 // return events.VirtualKeyModechange 72 case C.XKB_KEY_Page_Up, C.XKB_KEY_KP_Page_Up: 73 return events.VirtualKeyPageUp 74 case C.XKB_KEY_Page_Down, C.XKB_KEY_KP_Page_Down: 75 return events.VirtualKeyPageDown 76 case C.XKB_KEY_End, C.XKB_KEY_KP_End: 77 return events.VirtualKeyEnd 78 case C.XKB_KEY_Home, C.XKB_KEY_KP_Home: 79 return events.VirtualKeyHome 80 case C.XKB_KEY_Left, C.XKB_KEY_KP_Left: 81 return events.VirtualKeyLeft 82 case C.XKB_KEY_Up, C.XKB_KEY_KP_Up: 83 return events.VirtualKeyUp 84 case C.XKB_KEY_Right, C.XKB_KEY_KP_Right: 85 return events.VirtualKeyRight 86 case C.XKB_KEY_Down, C.XKB_KEY_KP_Down: 87 return events.VirtualKeyDown 88 89 case C.XKB_KEY_Select: 90 return events.VirtualKeySelect 91 case C.XKB_KEY_Print: 92 return events.VirtualKeyPrint 93 case C.XKB_KEY_Execute: 94 return events.VirtualKeyExecute 95 case C.XKB_KEY_Insert, C.XKB_KEY_KP_Insert: 96 return events.VirtualKeyInsert 97 case C.XKB_KEY_Delete, C.XKB_KEY_KP_Delete: 98 return events.VirtualKeyDelete 99 case C.XKB_KEY_Help: 100 return events.VirtualKeyHelp 101 case C.XKB_KEY_Num_Lock: 102 return events.VirtualKeyNumLock 103 case C.XKB_KEY_Scroll_Lock: 104 return events.VirtualKeyScrollLock 105 case C.XKB_KEY_F1: 106 return events.VirtualKeyF1 107 case C.XKB_KEY_F2: 108 return events.VirtualKeyF2 109 case C.XKB_KEY_F3: 110 return events.VirtualKeyF3 111 case C.XKB_KEY_F4: 112 return events.VirtualKeyF4 113 case C.XKB_KEY_F5: 114 return events.VirtualKeyF5 115 case C.XKB_KEY_F6: 116 return events.VirtualKeyF6 117 case C.XKB_KEY_F7: 118 return events.VirtualKeyF7 119 case C.XKB_KEY_F8: 120 return events.VirtualKeyF8 121 case C.XKB_KEY_F9: 122 return events.VirtualKeyF9 123 case C.XKB_KEY_F10: 124 return events.VirtualKeyF10 125 case C.XKB_KEY_F11: 126 return events.VirtualKeyF11 127 case C.XKB_KEY_F12: 128 return events.VirtualKeyF12 129 case C.XKB_KEY_F13: 130 return events.VirtualKeyF13 131 case C.XKB_KEY_F14: 132 return events.VirtualKeyF14 133 case C.XKB_KEY_F15: 134 return events.VirtualKeyF15 135 case C.XKB_KEY_F16: 136 return events.VirtualKeyF16 137 case C.XKB_KEY_F17: 138 return events.VirtualKeyF17 139 case C.XKB_KEY_F18: 140 return events.VirtualKeyF18 141 case C.XKB_KEY_F19: 142 return events.VirtualKeyF19 143 case C.XKB_KEY_F20: 144 return events.VirtualKeyF20 145 case C.XKB_KEY_F21: 146 return events.VirtualKeyF21 147 case C.XKB_KEY_F22: 148 return events.VirtualKeyF22 149 case C.XKB_KEY_F23: 150 return events.VirtualKeyF23 151 case C.XKB_KEY_F24: 152 return events.VirtualKeyF24 153 154 case C.XKB_KEY_Menu: 155 return events.VirtualKeyContextMenu 156 // case 0: 157 // return events.VirtualKeySleep 158 159 case C.XKB_KEY_space, C.XKB_KEY_KP_Space: 160 return events.VirtualKeySpace 161 162 case C.XKB_KEY_0: 163 return events.VirtualKey0 164 case C.XKB_KEY_1: 165 return events.VirtualKey1 166 case C.XKB_KEY_2: 167 return events.VirtualKey2 168 case C.XKB_KEY_3: 169 return events.VirtualKey3 170 case C.XKB_KEY_4: 171 return events.VirtualKey4 172 case C.XKB_KEY_5: 173 return events.VirtualKey5 174 case C.XKB_KEY_6: 175 return events.VirtualKey6 176 case C.XKB_KEY_7: 177 return events.VirtualKey7 178 case C.XKB_KEY_8: 179 return events.VirtualKey8 180 case C.XKB_KEY_9: 181 return events.VirtualKey9 182 183 case C.XKB_KEY_semicolon: 184 return events.VirtualKeySemicolon 185 case C.XKB_KEY_equal: 186 return events.VirtualKeyEquals 187 case C.XKB_KEY_A, C.XKB_KEY_a: 188 return events.VirtualKeyA 189 case C.XKB_KEY_B, C.XKB_KEY_b: 190 return events.VirtualKeyB 191 case C.XKB_KEY_C, C.XKB_KEY_c: 192 return events.VirtualKeyC 193 case C.XKB_KEY_D, C.XKB_KEY_d: 194 return events.VirtualKeyD 195 case C.XKB_KEY_E, C.XKB_KEY_e: 196 return events.VirtualKeyE 197 case C.XKB_KEY_F, C.XKB_KEY_f: 198 return events.VirtualKeyF 199 case C.XKB_KEY_G, C.XKB_KEY_g: 200 return events.VirtualKeyG 201 case C.XKB_KEY_H, C.XKB_KEY_h: 202 return events.VirtualKeyH 203 case C.XKB_KEY_I, C.XKB_KEY_i: 204 return events.VirtualKeyI 205 case C.XKB_KEY_J, C.XKB_KEY_j: 206 return events.VirtualKeyJ 207 case C.XKB_KEY_K, C.XKB_KEY_k: 208 return events.VirtualKeyK 209 case C.XKB_KEY_L, C.XKB_KEY_l: 210 return events.VirtualKeyL 211 case C.XKB_KEY_M, C.XKB_KEY_m: 212 return events.VirtualKeyM 213 case C.XKB_KEY_N, C.XKB_KEY_n: 214 return events.VirtualKeyN 215 case C.XKB_KEY_O, C.XKB_KEY_o: 216 return events.VirtualKeyO 217 case C.XKB_KEY_P, C.XKB_KEY_p: 218 return events.VirtualKeyP 219 case C.XKB_KEY_Q, C.XKB_KEY_q: 220 return events.VirtualKeyQ 221 case C.XKB_KEY_R, C.XKB_KEY_r: 222 return events.VirtualKeyR 223 case C.XKB_KEY_S, C.XKB_KEY_s: 224 return events.VirtualKeyS 225 case C.XKB_KEY_T, C.XKB_KEY_t: 226 return events.VirtualKeyT 227 case C.XKB_KEY_U, C.XKB_KEY_u: 228 return events.VirtualKeyU 229 case C.XKB_KEY_V, C.XKB_KEY_v: 230 return events.VirtualKeyV 231 case C.XKB_KEY_W, C.XKB_KEY_w: 232 return events.VirtualKeyW 233 case C.XKB_KEY_X, C.XKB_KEY_x: 234 return events.VirtualKeyX 235 case C.XKB_KEY_Y, C.XKB_KEY_y: 236 return events.VirtualKeyY 237 case C.XKB_KEY_Z, C.XKB_KEY_z: 238 return events.VirtualKeyZ 239 240 case C.XKB_KEY_KP_0: 241 return events.VirtualKeyNumpad0 242 case C.XKB_KEY_KP_1: 243 return events.VirtualKeyNumpad1 244 case C.XKB_KEY_KP_2: 245 return events.VirtualKeyNumpad2 246 case C.XKB_KEY_KP_3: 247 return events.VirtualKeyNumpad3 248 case C.XKB_KEY_KP_4: 249 return events.VirtualKeyNumpad4 250 case C.XKB_KEY_KP_5: 251 return events.VirtualKeyNumpad5 252 case C.XKB_KEY_KP_6: 253 return events.VirtualKeyNumpad6 254 case C.XKB_KEY_KP_7: 255 return events.VirtualKeyNumpad7 256 case C.XKB_KEY_KP_8: 257 return events.VirtualKeyNumpad8 258 case C.XKB_KEY_KP_9: 259 return events.VirtualKeyNumpad9 260 261 case C.XKB_KEY_KP_Multiply: 262 return events.VirtualKeyMultiply 263 case C.XKB_KEY_KP_Add: 264 return events.VirtualKeyAdd 265 case C.XKB_KEY_KP_Subtract: 266 return events.VirtualKeySubtract 267 case C.XKB_KEY_KP_Decimal: 268 return events.VirtualKeyDecimal 269 case C.XKB_KEY_KP_Divide: 270 return events.VirtualKeyDivide 271 272 case C.XKB_KEY_minus: 273 return events.VirtualKeyHyphenMinus 274 case C.XKB_KEY_XF86AudioMute: 275 return events.VirtualKeyVolumeMute 276 case C.XKB_KEY_XF86AudioLowerVolume: 277 return events.VirtualKeyVolumeDown 278 case C.XKB_KEY_XF86AudioRaiseVolume: 279 return events.VirtualKeyVolumeUp 280 case C.XKB_KEY_comma: 281 return events.VirtualKeyComma 282 case C.XKB_KEY_period: 283 return events.VirtualKeyPeriod 284 case C.XKB_KEY_slash: 285 return events.VirtualKeySlash 286 case C.XKB_KEY_grave: 287 return events.VirtualKeyBackQuote 288 case C.XKB_KEY_bracketleft: 289 return events.VirtualKeyOpenBracket 290 case C.XKB_KEY_backslash: 291 return events.VirtualKeyBackSlash 292 case C.XKB_KEY_bracketright: 293 return events.VirtualKeyCloseBracket 294 case C.XKB_KEY_apostrophe: 295 return events.VirtualKeyQuote 296 } 297 298 return events.VirtualKey(sym) 299 }