1 /* 2 * barrier -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2002 Chris Schoeneman 5 * 6 * This package is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * found in the file LICENSE that should have accompanied this file. 9 * 10 * This package is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "common/basic_types.h" 22 23 //! Key ID 24 /*! 25 Type to hold a key symbol identifier. The encoding is UTF-32, using 26 U+E000 through U+EFFF for the various control keys (e.g. arrow 27 keys, function keys, modifier keys, etc). 28 */ 29 typedef UInt32 KeyID; 30 31 //! Key Code 32 /*! 33 Type to hold a physical key identifier. That is, it identifies a 34 physical key on the keyboard. KeyButton 0 is reserved to be an 35 invalid key; platforms that use 0 as a physical key identifier 36 will have to remap that value to some arbitrary unused id. 37 */ 38 typedef UInt16 KeyButton; 39 40 //! Modifier key mask 41 /*! 42 Type to hold a bitmask of key modifiers (e.g. shift keys). 43 */ 44 typedef UInt32 KeyModifierMask; 45 46 //! Modifier key ID 47 /*! 48 Type to hold the id of a key modifier (e.g. a shift key). 49 */ 50 typedef UInt32 KeyModifierID; 51 52 //! @name Modifier key masks 53 //@{ 54 static const KeyModifierMask KeyModifierShift = 0x0001; 55 static const KeyModifierMask KeyModifierControl = 0x0002; 56 static const KeyModifierMask KeyModifierAlt = 0x0004; 57 static const KeyModifierMask KeyModifierMeta = 0x0008; 58 static const KeyModifierMask KeyModifierSuper = 0x0010; 59 static const KeyModifierMask KeyModifierAltGr = 0x0020; 60 static const KeyModifierMask KeyModifierLevel5Lock = 0x0040; 61 static const KeyModifierMask KeyModifierCapsLock = 0x1000; 62 static const KeyModifierMask KeyModifierNumLock = 0x2000; 63 static const KeyModifierMask KeyModifierScrollLock = 0x4000; 64 //@} 65 66 //! @name Modifier key bits 67 //@{ 68 static const UInt32 kKeyModifierBitNone = 16; 69 static const UInt32 kKeyModifierBitShift = 0; 70 static const UInt32 kKeyModifierBitControl = 1; 71 static const UInt32 kKeyModifierBitAlt = 2; 72 static const UInt32 kKeyModifierBitMeta = 3; 73 static const UInt32 kKeyModifierBitSuper = 4; 74 static const UInt32 kKeyModifierBitAltGr = 5; 75 static const UInt32 kKeyModifierBitLevel5Lock = 6; 76 static const UInt32 kKeyModifierBitCapsLock = 12; 77 static const UInt32 kKeyModifierBitNumLock = 13; 78 static const UInt32 kKeyModifierBitScrollLock = 14; 79 static const SInt32 kKeyModifierNumBits = 16; 80 //@} 81 82 //! @name Modifier key identifiers 83 //@{ 84 static const KeyModifierID kKeyModifierIDNull = 0; 85 static const KeyModifierID kKeyModifierIDShift = 1; 86 static const KeyModifierID kKeyModifierIDControl = 2; 87 static const KeyModifierID kKeyModifierIDAlt = 3; 88 static const KeyModifierID kKeyModifierIDMeta = 4; 89 static const KeyModifierID kKeyModifierIDSuper = 5; 90 static const KeyModifierID kKeyModifierIDAltGr = 6; 91 static const KeyModifierID kKeyModifierIDLast = 7; 92 //@} 93 94 //! @name Key identifiers 95 //@{ 96 // all identifiers except kKeyNone and those in 0xE000 to 0xE0FF 97 // inclusive are equal to the corresponding X11 keysym - 0x1000. 98 99 // no key 100 static const KeyID kKeyNone = 0x0000; 101 102 // TTY functions 103 static const KeyID kKeyBackSpace = 0xEF08; /* back space, back char */ 104 static const KeyID kKeyTab = 0xEF09; 105 static const KeyID kKeyLinefeed = 0xEF0A; /* Linefeed, LF */ 106 static const KeyID kKeyClear = 0xEF0B; 107 static const KeyID kKeyReturn = 0xEF0D; /* Return, enter */ 108 static const KeyID kKeyPause = 0xEF13; /* Pause, hold */ 109 static const KeyID kKeyScrollLock = 0xEF14; 110 static const KeyID kKeySysReq = 0xEF15; 111 static const KeyID kKeyEscape = 0xEF1B; 112 static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */ 113 static const KeyID kKeyKana = 0xEF26; /* Kana */ 114 static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */ 115 static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */ 116 static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */ 117 static const KeyID kKeyHangul = 0xEF31; /* Hangul */ 118 static const KeyID kKeyHanja = 0xEF34; /* Hanja */ 119 static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */ 120 121 // cursor control 122 static const KeyID kKeyHome = 0xEF50; 123 static const KeyID kKeyLeft = 0xEF51; /* Move left, left arrow */ 124 static const KeyID kKeyUp = 0xEF52; /* Move up, up arrow */ 125 static const KeyID kKeyRight = 0xEF53; /* Move right, right arrow */ 126 static const KeyID kKeyDown = 0xEF54; /* Move down, down arrow */ 127 static const KeyID kKeyPageUp = 0xEF55; 128 static const KeyID kKeyPageDown = 0xEF56; 129 static const KeyID kKeyEnd = 0xEF57; /* EOL */ 130 static const KeyID kKeyBegin = 0xEF58; /* BOL */ 131 132 // misc functions 133 static const KeyID kKeySelect = 0xEF60; /* Select, mark */ 134 static const KeyID kKeyPrint = 0xEF61; 135 static const KeyID kKeyExecute = 0xEF62; /* Execute, run, do */ 136 static const KeyID kKeyInsert = 0xEF63; /* Insert, insert here */ 137 static const KeyID kKeyUndo = 0xEF65; /* Undo, oops */ 138 static const KeyID kKeyRedo = 0xEF66; /* redo, again */ 139 static const KeyID kKeyMenu = 0xEF67; 140 static const KeyID kKeyFind = 0xEF68; /* Find, search */ 141 static const KeyID kKeyCancel = 0xEF69; /* Cancel, stop, abort, exit */ 142 static const KeyID kKeyHelp = 0xEF6A; /* Help */ 143 static const KeyID kKeyBreak = 0xEF6B; 144 static const KeyID kKeyAltGr = 0xEF7E; /* Character set switch */ 145 static const KeyID kKeyNumLock = 0xEF7F; 146 147 // keypad 148 static const KeyID kKeyKP_Space = 0xEF80; /* space */ 149 static const KeyID kKeyKP_Tab = 0xEF89; 150 static const KeyID kKeyKP_Enter = 0xEF8D; /* enter */ 151 static const KeyID kKeyKP_F1 = 0xEF91; /* PF1, KP_A, ... */ 152 static const KeyID kKeyKP_F2 = 0xEF92; 153 static const KeyID kKeyKP_F3 = 0xEF93; 154 static const KeyID kKeyKP_F4 = 0xEF94; 155 static const KeyID kKeyKP_Home = 0xEF95; 156 static const KeyID kKeyKP_Left = 0xEF96; 157 static const KeyID kKeyKP_Up = 0xEF97; 158 static const KeyID kKeyKP_Right = 0xEF98; 159 static const KeyID kKeyKP_Down = 0xEF99; 160 static const KeyID kKeyKP_PageUp = 0xEF9A; 161 static const KeyID kKeyKP_PageDown = 0xEF9B; 162 static const KeyID kKeyKP_End = 0xEF9C; 163 static const KeyID kKeyKP_Begin = 0xEF9D; 164 static const KeyID kKeyKP_Insert = 0xEF9E; 165 static const KeyID kKeyKP_Delete = 0xEF9F; 166 static const KeyID kKeyKP_Equal = 0xEFBD; /* equals */ 167 static const KeyID kKeyKP_Multiply = 0xEFAA; 168 static const KeyID kKeyKP_Add = 0xEFAB; 169 static const KeyID kKeyKP_Separator= 0xEFAC; /* separator, often comma */ 170 static const KeyID kKeyKP_Subtract = 0xEFAD; 171 static const KeyID kKeyKP_Decimal = 0xEFAE; 172 static const KeyID kKeyKP_Divide = 0xEFAF; 173 static const KeyID kKeyKP_0 = 0xEFB0; 174 static const KeyID kKeyKP_1 = 0xEFB1; 175 static const KeyID kKeyKP_2 = 0xEFB2; 176 static const KeyID kKeyKP_3 = 0xEFB3; 177 static const KeyID kKeyKP_4 = 0xEFB4; 178 static const KeyID kKeyKP_5 = 0xEFB5; 179 static const KeyID kKeyKP_6 = 0xEFB6; 180 static const KeyID kKeyKP_7 = 0xEFB7; 181 static const KeyID kKeyKP_8 = 0xEFB8; 182 static const KeyID kKeyKP_9 = 0xEFB9; 183 184 // function keys 185 static const KeyID kKeyF1 = 0xEFBE; 186 static const KeyID kKeyF2 = 0xEFBF; 187 static const KeyID kKeyF3 = 0xEFC0; 188 static const KeyID kKeyF4 = 0xEFC1; 189 static const KeyID kKeyF5 = 0xEFC2; 190 static const KeyID kKeyF6 = 0xEFC3; 191 static const KeyID kKeyF7 = 0xEFC4; 192 static const KeyID kKeyF8 = 0xEFC5; 193 static const KeyID kKeyF9 = 0xEFC6; 194 static const KeyID kKeyF10 = 0xEFC7; 195 static const KeyID kKeyF11 = 0xEFC8; 196 static const KeyID kKeyF12 = 0xEFC9; 197 static const KeyID kKeyF13 = 0xEFCA; 198 static const KeyID kKeyF14 = 0xEFCB; 199 static const KeyID kKeyF15 = 0xEFCC; 200 static const KeyID kKeyF16 = 0xEFCD; 201 static const KeyID kKeyF17 = 0xEFCE; 202 static const KeyID kKeyF18 = 0xEFCF; 203 static const KeyID kKeyF19 = 0xEFD0; 204 static const KeyID kKeyF20 = 0xEFD1; 205 static const KeyID kKeyF21 = 0xEFD2; 206 static const KeyID kKeyF22 = 0xEFD3; 207 static const KeyID kKeyF23 = 0xEFD4; 208 static const KeyID kKeyF24 = 0xEFD5; 209 static const KeyID kKeyF25 = 0xEFD6; 210 static const KeyID kKeyF26 = 0xEFD7; 211 static const KeyID kKeyF27 = 0xEFD8; 212 static const KeyID kKeyF28 = 0xEFD9; 213 static const KeyID kKeyF29 = 0xEFDA; 214 static const KeyID kKeyF30 = 0xEFDB; 215 static const KeyID kKeyF31 = 0xEFDC; 216 static const KeyID kKeyF32 = 0xEFDD; 217 static const KeyID kKeyF33 = 0xEFDE; 218 static const KeyID kKeyF34 = 0xEFDF; 219 static const KeyID kKeyF35 = 0xEFE0; 220 221 // modifiers 222 static const KeyID kKeyShift_L = 0xEFE1; /* Left shift */ 223 static const KeyID kKeyShift_R = 0xEFE2; /* Right shift */ 224 static const KeyID kKeyControl_L = 0xEFE3; /* Left control */ 225 static const KeyID kKeyControl_R = 0xEFE4; /* Right control */ 226 static const KeyID kKeyCapsLock = 0xEFE5; /* Caps lock */ 227 static const KeyID kKeyShiftLock = 0xEFE6; /* Shift lock */ 228 static const KeyID kKeyMeta_L = 0xEFE7; /* Left meta */ 229 static const KeyID kKeyMeta_R = 0xEFE8; /* Right meta */ 230 static const KeyID kKeyAlt_L = 0xEFE9; /* Left alt */ 231 static const KeyID kKeyAlt_R = 0xEFEA; /* Right alt */ 232 static const KeyID kKeySuper_L = 0xEFEB; /* Left super */ 233 static const KeyID kKeySuper_R = 0xEFEC; /* Right super */ 234 static const KeyID kKeyHyper_L = 0xEFED; /* Left hyper */ 235 static const KeyID kKeyHyper_R = 0xEFEE; /* Right hyper */ 236 237 // multi-key character composition 238 static const KeyID kKeyCompose = 0xEF20; 239 static const KeyID kKeyDeadGrave = 0x0300; 240 static const KeyID kKeyDeadAcute = 0x0301; 241 static const KeyID kKeyDeadCircumflex = 0x0302; 242 static const KeyID kKeyDeadTilde = 0x0303; 243 static const KeyID kKeyDeadMacron = 0x0304; 244 static const KeyID kKeyDeadBreve = 0x0306; 245 static const KeyID kKeyDeadAbovedot = 0x0307; 246 static const KeyID kKeyDeadDiaeresis = 0x0308; 247 static const KeyID kKeyDeadAbovering = 0x030a; 248 static const KeyID kKeyDeadDoubleacute = 0x030b; 249 static const KeyID kKeyDeadCaron = 0x030c; 250 static const KeyID kKeyDeadCedilla = 0x0327; 251 static const KeyID kKeyDeadOgonek = 0x0328; 252 253 // more function and modifier keys 254 static const KeyID kKeyLeftTab = 0xEE20; 255 256 // update modifiers 257 static const KeyID kKeySetModifiers = 0xEE06; 258 static const KeyID kKeyClearModifiers = 0xEE07; 259 260 // group change 261 static const KeyID kKeyNextGroup = 0xEE08; 262 static const KeyID kKeyPrevGroup = 0xEE0A; 263 264 // extended keys 265 static const KeyID kKeyEject = 0xE001; 266 static const KeyID kKeySleep = 0xE05F; 267 static const KeyID kKeyWWWBack = 0xE0A6; 268 static const KeyID kKeyWWWForward = 0xE0A7; 269 static const KeyID kKeyWWWRefresh = 0xE0A8; 270 static const KeyID kKeyWWWStop = 0xE0A9; 271 static const KeyID kKeyWWWSearch = 0xE0AA; 272 static const KeyID kKeyWWWFavorites = 0xE0AB; 273 static const KeyID kKeyWWWHome = 0xE0AC; 274 static const KeyID kKeyAudioMute = 0xE0AD; 275 static const KeyID kKeyAudioDown = 0xE0AE; 276 static const KeyID kKeyAudioUp = 0xE0AF; 277 static const KeyID kKeyAudioNext = 0xE0B0; 278 static const KeyID kKeyAudioPrev = 0xE0B1; 279 static const KeyID kKeyAudioStop = 0xE0B2; 280 static const KeyID kKeyAudioPlay = 0xE0B3; 281 static const KeyID kKeyAppMail = 0xE0B4; 282 static const KeyID kKeyAppMedia = 0xE0B5; 283 static const KeyID kKeyAppUser1 = 0xE0B6; 284 static const KeyID kKeyAppUser2 = 0xE0B7; 285 static const KeyID kKeyBrightnessDown = 0xE0B8; 286 static const KeyID kKeyBrightnessUp = 0xE0B9; 287 static const KeyID kKeyMissionControl = 0xE0C0; 288 static const KeyID kKeyLaunchpad = 0xE0C1; 289 290 //@} 291 292 struct KeyNameMapEntry { 293 const char* m_name; 294 KeyID m_id; 295 }; 296 struct KeyModifierNameMapEntry { 297 const char* m_name; 298 KeyModifierMask m_mask; 299 }; 300 301 //! Key name to KeyID table 302 /*! 303 A table of key names to the corresponding KeyID. Only the keys listed 304 above plus non-alphanumeric ASCII characters are in the table. The end 305 of the table is the first pair with a NULL m_name. 306 */ 307 extern const struct KeyNameMapEntry kKeyNameMap[]; 308 309 //! Modifier key name to KeyModifierMask table 310 /*! 311 A table of modifier key names to the corresponding KeyModifierMask. 312 The end of the table is the first pair with a NULL m_name. 313 */ 314 extern const struct KeyModifierNameMapEntry kModifierNameMap[]; 315