1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #pragma once 21 22 #include <com/sun/star/awt/Key.hpp> 23 #include <com/sun/star/awt/KeyGroup.hpp> 24 #include <o3tl/typed_flags_set.hxx> 25 26 constexpr sal_uInt16 KEY_CODE_MASK = 0x0FFF; 27 28 // Modifier keys 29 constexpr sal_uInt16 KEY_SHIFT = 0x1000; 30 constexpr sal_uInt16 KEY_MOD1 = 0x2000; 31 constexpr sal_uInt16 KEY_MOD2 = 0x4000; 32 constexpr sal_uInt16 KEY_MOD3 = 0x8000; 33 constexpr sal_uInt16 KEY_MODIFIERS_MASK = 0xF000; 34 35 // Key groups 36 constexpr sal_uInt16 KEYGROUP_NUM = css::awt::KeyGroup::NUM; 37 constexpr sal_uInt16 KEYGROUP_ALPHA = css::awt::KeyGroup::ALPHA; 38 constexpr sal_uInt16 KEYGROUP_FKEYS = css::awt::KeyGroup::FKEYS; 39 constexpr sal_uInt16 KEYGROUP_CURSOR = css::awt::KeyGroup::CURSOR; 40 constexpr sal_uInt16 KEYGROUP_MISC = css::awt::KeyGroup::MISC; 41 constexpr sal_uInt16 KEYGROUP_TYPE = css::awt::KeyGroup::TYPE; 42 43 // Key codes 44 constexpr sal_uInt16 KEY_0 = css::awt::Key::NUM0; 45 constexpr sal_uInt16 KEY_1 = css::awt::Key::NUM1; 46 constexpr sal_uInt16 KEY_2 = css::awt::Key::NUM2; 47 constexpr sal_uInt16 KEY_3 = css::awt::Key::NUM3; 48 constexpr sal_uInt16 KEY_4 = css::awt::Key::NUM4; 49 constexpr sal_uInt16 KEY_5 = css::awt::Key::NUM5; 50 constexpr sal_uInt16 KEY_6 = css::awt::Key::NUM6; 51 constexpr sal_uInt16 KEY_7 = css::awt::Key::NUM7; 52 constexpr sal_uInt16 KEY_8 = css::awt::Key::NUM8; 53 constexpr sal_uInt16 KEY_9 = css::awt::Key::NUM9; 54 55 constexpr sal_uInt16 KEY_A = css::awt::Key::A; 56 constexpr sal_uInt16 KEY_B = css::awt::Key::B; 57 constexpr sal_uInt16 KEY_C = css::awt::Key::C; 58 constexpr sal_uInt16 KEY_D = css::awt::Key::D; 59 constexpr sal_uInt16 KEY_E = css::awt::Key::E; 60 constexpr sal_uInt16 KEY_F = css::awt::Key::F; 61 constexpr sal_uInt16 KEY_G = css::awt::Key::G; 62 constexpr sal_uInt16 KEY_H = css::awt::Key::H; 63 constexpr sal_uInt16 KEY_I = css::awt::Key::I; 64 constexpr sal_uInt16 KEY_J = css::awt::Key::J; 65 constexpr sal_uInt16 KEY_K = css::awt::Key::K; 66 constexpr sal_uInt16 KEY_L = css::awt::Key::L; 67 constexpr sal_uInt16 KEY_M = css::awt::Key::M; 68 constexpr sal_uInt16 KEY_N = css::awt::Key::N; 69 constexpr sal_uInt16 KEY_O = css::awt::Key::O; 70 constexpr sal_uInt16 KEY_P = css::awt::Key::P; 71 constexpr sal_uInt16 KEY_Q = css::awt::Key::Q; 72 constexpr sal_uInt16 KEY_R = css::awt::Key::R; 73 constexpr sal_uInt16 KEY_S = css::awt::Key::S; 74 constexpr sal_uInt16 KEY_T = css::awt::Key::T; 75 constexpr sal_uInt16 KEY_U = css::awt::Key::U; 76 constexpr sal_uInt16 KEY_V = css::awt::Key::V; 77 constexpr sal_uInt16 KEY_W = css::awt::Key::W; 78 constexpr sal_uInt16 KEY_X = css::awt::Key::X; 79 constexpr sal_uInt16 KEY_Y = css::awt::Key::Y; 80 constexpr sal_uInt16 KEY_Z = css::awt::Key::Z; 81 82 constexpr sal_uInt16 KEY_F1 = css::awt::Key::F1; 83 constexpr sal_uInt16 KEY_F2 = css::awt::Key::F2; 84 constexpr sal_uInt16 KEY_F3 = css::awt::Key::F3; 85 constexpr sal_uInt16 KEY_F4 = css::awt::Key::F4; 86 constexpr sal_uInt16 KEY_F5 = css::awt::Key::F5; 87 constexpr sal_uInt16 KEY_F6 = css::awt::Key::F6; 88 constexpr sal_uInt16 KEY_F7 = css::awt::Key::F7; 89 constexpr sal_uInt16 KEY_F8 = css::awt::Key::F8; 90 constexpr sal_uInt16 KEY_F9 = css::awt::Key::F9; 91 constexpr sal_uInt16 KEY_F10 = css::awt::Key::F10; 92 constexpr sal_uInt16 KEY_F11 = css::awt::Key::F11; 93 constexpr sal_uInt16 KEY_F12 = css::awt::Key::F12; 94 constexpr sal_uInt16 KEY_F13 = css::awt::Key::F13; 95 constexpr sal_uInt16 KEY_F14 = css::awt::Key::F14; 96 constexpr sal_uInt16 KEY_F15 = css::awt::Key::F15; 97 constexpr sal_uInt16 KEY_F16 = css::awt::Key::F16; 98 constexpr sal_uInt16 KEY_F17 = css::awt::Key::F17; 99 constexpr sal_uInt16 KEY_F18 = css::awt::Key::F18; 100 constexpr sal_uInt16 KEY_F19 = css::awt::Key::F19; 101 constexpr sal_uInt16 KEY_F20 = css::awt::Key::F20; 102 constexpr sal_uInt16 KEY_F21 = css::awt::Key::F21; 103 constexpr sal_uInt16 KEY_F22 = css::awt::Key::F22; 104 constexpr sal_uInt16 KEY_F23 = css::awt::Key::F23; 105 constexpr sal_uInt16 KEY_F24 = css::awt::Key::F24; 106 constexpr sal_uInt16 KEY_F25 = css::awt::Key::F25; 107 constexpr sal_uInt16 KEY_F26 = css::awt::Key::F26; 108 109 constexpr sal_uInt16 KEY_DOWN = css::awt::Key::DOWN; 110 constexpr sal_uInt16 KEY_UP = css::awt::Key::UP; 111 constexpr sal_uInt16 KEY_LEFT = css::awt::Key::LEFT; 112 constexpr sal_uInt16 KEY_RIGHT = css::awt::Key::RIGHT; 113 constexpr sal_uInt16 KEY_HOME = css::awt::Key::HOME; 114 constexpr sal_uInt16 KEY_END = css::awt::Key::END; 115 constexpr sal_uInt16 KEY_PAGEUP = css::awt::Key::PAGEUP; 116 constexpr sal_uInt16 KEY_PAGEDOWN = css::awt::Key::PAGEDOWN; 117 118 constexpr sal_uInt16 KEY_RETURN = css::awt::Key::RETURN; 119 constexpr sal_uInt16 KEY_ESCAPE = css::awt::Key::ESCAPE; 120 constexpr sal_uInt16 KEY_TAB = css::awt::Key::TAB; 121 constexpr sal_uInt16 KEY_BACKSPACE = css::awt::Key::BACKSPACE; 122 constexpr sal_uInt16 KEY_SPACE = css::awt::Key::SPACE; 123 constexpr sal_uInt16 KEY_INSERT = css::awt::Key::INSERT; 124 constexpr sal_uInt16 KEY_DELETE = css::awt::Key::DELETE; 125 126 constexpr sal_uInt16 KEY_ADD = css::awt::Key::ADD; 127 constexpr sal_uInt16 KEY_SUBTRACT = css::awt::Key::SUBTRACT; 128 constexpr sal_uInt16 KEY_MULTIPLY = css::awt::Key::MULTIPLY; 129 constexpr sal_uInt16 KEY_DIVIDE = css::awt::Key::DIVIDE; 130 constexpr sal_uInt16 KEY_POINT = css::awt::Key::POINT; 131 constexpr sal_uInt16 KEY_COMMA = css::awt::Key::COMMA; 132 constexpr sal_uInt16 KEY_LESS = css::awt::Key::LESS; 133 constexpr sal_uInt16 KEY_GREATER = css::awt::Key::GREATER; 134 constexpr sal_uInt16 KEY_EQUAL = css::awt::Key::EQUAL; 135 136 constexpr sal_uInt16 KEY_OPEN = css::awt::Key::OPEN; 137 constexpr sal_uInt16 KEY_CUT = css::awt::Key::CUT; 138 constexpr sal_uInt16 KEY_COPY = css::awt::Key::COPY; 139 constexpr sal_uInt16 KEY_PASTE = css::awt::Key::PASTE; 140 constexpr sal_uInt16 KEY_UNDO = css::awt::Key::UNDO; 141 constexpr sal_uInt16 KEY_REPEAT = css::awt::Key::REPEAT; 142 constexpr sal_uInt16 KEY_FIND = css::awt::Key::FIND; 143 constexpr sal_uInt16 KEY_PROPERTIES = css::awt::Key::PROPERTIES; 144 constexpr sal_uInt16 KEY_FRONT = css::awt::Key::FRONT; 145 constexpr sal_uInt16 KEY_CONTEXTMENU = css::awt::Key::CONTEXTMENU; 146 constexpr sal_uInt16 KEY_MENU = css::awt::Key::MENU; 147 constexpr sal_uInt16 KEY_HELP = css::awt::Key::HELP; 148 constexpr sal_uInt16 KEY_HANGUL_HANJA = css::awt::Key::HANGUL_HANJA; 149 constexpr sal_uInt16 KEY_DECIMAL = css::awt::Key::DECIMAL; 150 constexpr sal_uInt16 KEY_TILDE = css::awt::Key::TILDE; 151 constexpr sal_uInt16 KEY_QUOTELEFT = css::awt::Key::QUOTELEFT; 152 constexpr sal_uInt16 KEY_BRACKETLEFT = css::awt::Key::BRACKETLEFT; 153 constexpr sal_uInt16 KEY_BRACKETRIGHT = css::awt::Key::BRACKETRIGHT; 154 constexpr sal_uInt16 KEY_SEMICOLON = css::awt::Key::SEMICOLON; 155 constexpr sal_uInt16 KEY_QUOTERIGHT = css::awt::Key::QUOTERIGHT; 156 constexpr sal_uInt16 KEY_RIGHTCURLYBRACKET = css::awt::Key::RIGHTCURLYBRACKET; 157 constexpr sal_uInt16 KEY_NUMBERSIGN = css::awt::Key::NUMBERSIGN; 158 constexpr sal_uInt16 KEY_XF86FORWARD = css::awt::Key::XF86FORWARD; 159 constexpr sal_uInt16 KEY_XF86BACK = css::awt::Key::XF86BACK; 160 constexpr sal_uInt16 KEY_COLON = css::awt::Key::COLON; 161 162 constexpr sal_uInt16 KEY_CAPSLOCK = css::awt::Key::CAPSLOCK; 163 constexpr sal_uInt16 KEY_NUMLOCK = css::awt::Key::NUMLOCK; 164 constexpr sal_uInt16 KEY_SCROLLLOCK = css::awt::Key::SCROLLLOCK; 165 166 // extended Modifier-Keys (only used for modkey events) 167 enum class ModKeyFlags 168 { 169 NONE = 0x0000, 170 LeftShift = 0x0001, 171 RightShift = 0x0002, 172 LeftMod1 = 0x0004, 173 RightMod1 = 0x0008, 174 LeftMod2 = 0x0010, 175 RightMod2 = 0x0020, 176 LeftMod3 = 0x0040, 177 RightMod3 = 0x0080, 178 Mod1Msk = LeftMod1 | RightMod1, // should be Mod1Mask, but that conflicts with a X.h macro grrrr 179 Mod2Msk = LeftMod2 | RightMod2, 180 }; 181 namespace o3tl 182 { 183 template <> struct typed_flags<ModKeyFlags> : is_typed_flags<ModKeyFlags, 0x00ff> 184 { 185 }; 186 } 187 188 enum class KeyIndicatorState 189 { 190 NONE = 0x0000, 191 CAPSLOCK = 0x0001, 192 NUMLOCK = 0x0002, 193 SCROLLLOCK = 0x0004 194 }; 195 namespace o3tl 196 { 197 template <> struct typed_flags<KeyIndicatorState> : is_typed_flags<KeyIndicatorState, 0x0007> 198 { 199 }; 200 } 201 202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 203
