| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
/**************************************************************************** |
| 3 |
* * |
| 4 |
* Copyright (c) 2025 Kacper Donat <[email protected]> * |
| 5 |
* * |
| 6 |
* This file is part of FreeCAD. * |
| 7 |
* * |
| 8 |
* FreeCAD is free software: you can redistribute it and/or modify it * |
| 9 |
* under the terms of the GNU Lesser General Public License as * |
| 10 |
* published by the Free Software Foundation, either version 2.1 of the * |
| 11 |
* License, or (at your option) any later version. * |
| 12 |
* * |
| 13 |
* FreeCAD is distributed in the hope that it will be useful, but * |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 16 |
* Lesser General Public License for more details. * |
| 17 |
* * |
| 18 |
* You should have received a copy of the GNU Lesser General Public * |
| 19 |
* License along with FreeCAD. If not, see * |
| 20 |
* <https://www.gnu.org/licenses/>. * |
| 21 |
* * |
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
#include "InputHint.h" |
| 25 |
#include "InputHintPy.h" |
| 26 |
|
| 27 |
void Gui::registerUserInputEnumInPython(PyObject* module) |
| 28 |
{ |
| 29 |
using enum Gui::InputHint::UserInput; |
| 30 |
|
| 31 |
// clang-format off |
| 32 |
// this structure is repetition of each and every UserInput enum case |
| 33 |
// it can be regenerated by copying and pasting all entries and performing one substitution: |
| 34 |
// regex search: `(\w+) = .+?,` substitution: `{"$1", $1},` |
| 35 |
const std::map<const char*, InputHint::UserInput> userInputEntries { |
| 36 |
// Modifier |
| 37 |
{"ModifierShift", ModifierShift}, |
| 38 |
{"ModifierCtrl", ModifierCtrl}, |
| 39 |
{"ModifierAlt", ModifierAlt}, |
| 40 |
{"ModifierMeta", ModifierMeta}, |
| 41 |
|
| 42 |
// Keyboard Keys |
| 43 |
{"KeySpace", KeySpace}, |
| 44 |
{"KeyExclam", KeyExclam}, |
| 45 |
{"KeyQuoteDbl", KeyQuoteDbl}, |
| 46 |
{"KeyNumberSign", KeyNumberSign}, |
| 47 |
{"KeyDollar", KeyDollar}, |
| 48 |
{"KeyPercent", KeyPercent}, |
| 49 |
{"KeyAmpersand", KeyAmpersand}, |
| 50 |
{"KeyApostrophe", KeyApostrophe}, |
| 51 |
{"KeyParenLeft", KeyParenLeft}, |
| 52 |
{"KeyParenRight", KeyParenRight}, |
| 53 |
{"KeyAsterisk", KeyAsterisk}, |
| 54 |
{"KeyPlus", KeyPlus}, |
| 55 |
{"KeyComma", KeyComma}, |
| 56 |
{"KeyMinus", KeyMinus}, |
| 57 |
{"KeyPeriod", KeyPeriod}, |
| 58 |
{"KeySlash", KeySlash}, |
| 59 |
{"Key0", Key0}, |
| 60 |
{"Key1", Key1}, |
| 61 |
{"Key2", Key2}, |
| 62 |
{"Key3", Key3}, |
| 63 |
{"Key4", Key4}, |
| 64 |
{"Key5", Key5}, |
| 65 |
{"Key6", Key6}, |
| 66 |
{"Key7", Key7}, |
| 67 |
{"Key8", Key8}, |
| 68 |
{"Key9", Key9}, |
| 69 |
{"KeyColon", KeyColon}, |
| 70 |
{"KeySemicolon", KeySemicolon}, |
| 71 |
{"KeyLess", KeyLess}, |
| 72 |
{"KeyEqual", KeyEqual}, |
| 73 |
{"KeyGreater", KeyGreater}, |
| 74 |
{"KeyQuestion", KeyQuestion}, |
| 75 |
{"KeyAt", KeyAt}, |
| 76 |
{"KeyA", KeyA}, |
| 77 |
{"KeyB", KeyB}, |
| 78 |
{"KeyC", KeyC}, |
| 79 |
{"KeyD", KeyD}, |
| 80 |
{"KeyE", KeyE}, |
| 81 |
{"KeyF", KeyF}, |
| 82 |
{"KeyG", KeyG}, |
| 83 |
{"KeyH", KeyH}, |
| 84 |
{"KeyI", KeyI}, |
| 85 |
{"KeyJ", KeyJ}, |
| 86 |
{"KeyK", KeyK}, |
| 87 |
{"KeyL", KeyL}, |
| 88 |
{"KeyM", KeyM}, |
| 89 |
{"KeyN", KeyN}, |
| 90 |
{"KeyO", KeyO}, |
| 91 |
{"KeyP", KeyP}, |
| 92 |
{"KeyQ", KeyQ}, |
| 93 |
{"KeyR", KeyR}, |
| 94 |
{"KeyS", KeyS}, |
| 95 |
{"KeyT", KeyT}, |
| 96 |
{"KeyU", KeyU}, |
| 97 |
{"KeyV", KeyV}, |
| 98 |
{"KeyW", KeyW}, |
| 99 |
{"KeyX", KeyX}, |
| 100 |
{"KeyY", KeyY}, |
| 101 |
{"KeyZ", KeyZ}, |
| 102 |
{"KeyBracketLeft", KeyBracketLeft}, |
| 103 |
{"KeyBackslash", KeyBackslash}, |
| 104 |
{"KeyBracketRight", KeyBracketRight}, |
| 105 |
{"KeyAsciiCircum", KeyAsciiCircum}, |
| 106 |
{"KeyUnderscore", KeyUnderscore}, |
| 107 |
{"KeyQuoteLeft", KeyQuoteLeft}, |
| 108 |
{"KeyBraceLeft", KeyBraceLeft}, |
| 109 |
{"KeyBar", KeyBar}, |
| 110 |
{"KeyBraceRight", KeyBraceRight}, |
| 111 |
{"KeyAsciiTilde", KeyAsciiTilde}, |
| 112 |
|
| 113 |
// misc keys |
| 114 |
{"KeyEscape", KeyEscape}, |
| 115 |
{"KeyTab", KeyTab}, |
| 116 |
{"KeyBacktab", KeyBacktab}, |
| 117 |
{"KeyBackspace", KeyBackspace}, |
| 118 |
{"KeyReturn", KeyReturn}, |
| 119 |
{"KeyEnter", KeyEnter}, |
| 120 |
{"KeyInsert", KeyInsert}, |
| 121 |
{"KeyDelete", KeyDelete}, |
| 122 |
{"KeyPause", KeyPause}, |
| 123 |
{"KeyPrintScr", KeyPrintScr}, |
| 124 |
{"KeySysReq", KeySysReq}, |
| 125 |
{"KeyClear", KeyClear}, |
| 126 |
|
| 127 |
// cursor movement |
| 128 |
{"KeyHome", KeyHome}, |
| 129 |
{"KeyEnd", KeyEnd}, |
| 130 |
{"KeyLeft", KeyLeft}, |
| 131 |
{"KeyUp", KeyUp}, |
| 132 |
{"KeyRight", KeyRight}, |
| 133 |
{"KeyDown", KeyDown}, |
| 134 |
{"KeyPageUp", KeyPageUp}, |
| 135 |
{"KeyPageDown", KeyPageDown}, |
| 136 |
|
| 137 |
// modifiers |
| 138 |
{"KeyShift", KeyShift}, |
| 139 |
{"KeyControl", KeyControl}, |
| 140 |
{"KeyMeta", KeyMeta}, |
| 141 |
{"KeyAlt", KeyAlt}, |
| 142 |
{"KeyCapsLock", KeyCapsLock}, |
| 143 |
{"KeyNumLock", KeyNumLock}, |
| 144 |
{"KeyScrollLock", KeyScrollLock}, |
| 145 |
|
| 146 |
// function keys |
| 147 |
{"KeyF1", KeyF1}, |
| 148 |
{"KeyF2", KeyF2}, |
| 149 |
{"KeyF3", KeyF3}, |
| 150 |
{"KeyF4", KeyF4}, |
| 151 |
{"KeyF5", KeyF5}, |
| 152 |
{"KeyF6", KeyF6}, |
| 153 |
{"KeyF7", KeyF7}, |
| 154 |
{"KeyF8", KeyF8}, |
| 155 |
{"KeyF9", KeyF9}, |
| 156 |
{"KeyF10", KeyF10}, |
| 157 |
{"KeyF11", KeyF11}, |
| 158 |
{"KeyF12", KeyF12}, |
| 159 |
{"KeyF13", KeyF13}, |
| 160 |
{"KeyF14", KeyF14}, |
| 161 |
{"KeyF15", KeyF15}, |
| 162 |
{"KeyF16", KeyF16}, |
| 163 |
{"KeyF17", KeyF17}, |
| 164 |
{"KeyF18", KeyF18}, |
| 165 |
{"KeyF19", KeyF19}, |
| 166 |
{"KeyF20", KeyF20}, |
| 167 |
{"KeyF21", KeyF21}, |
| 168 |
{"KeyF22", KeyF22}, |
| 169 |
{"KeyF23", KeyF23}, |
| 170 |
{"KeyF24", KeyF24}, |
| 171 |
{"KeyF25", KeyF25}, |
| 172 |
{"KeyF26", KeyF26}, |
| 173 |
{"KeyF27", KeyF27}, |
| 174 |
{"KeyF28", KeyF28}, |
| 175 |
{"KeyF29", KeyF29}, |
| 176 |
{"KeyF30", KeyF30}, |
| 177 |
{"KeyF31", KeyF31}, |
| 178 |
{"KeyF32", KeyF32}, |
| 179 |
{"KeyF33", KeyF33}, |
| 180 |
{"KeyF34", KeyF34}, |
| 181 |
{"KeyF35", KeyF35}, |
| 182 |
|
| 183 |
// Mouse Keys |
| 184 |
{"MouseMove", MouseMove}, |
| 185 |
{"MouseLeft", MouseLeft}, |
| 186 |
{"MouseRight", MouseRight}, |
| 187 |
{"MouseMiddle", MouseMiddle}, |
| 188 |
{"MouseScroll", MouseScroll}, |
| 189 |
{"MouseScrollUp", MouseScrollUp}, |
| 190 |
{"MouseScrollDown", MouseScrollDown}, |
| 191 |
}; |
| 192 |
// clang-format on |
| 193 |
|
| 194 |
Base::PyRegisterEnum(module, "UserInput", userInputEntries); |
| 195 |
} |