MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Keys.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::IO {
4
5enum class Keys : int16_t {
6 // Printable ASCII keys (single char, so we use the actual character names)
7 Space = 32,
8 Apostrophe = 39, // '
9 Comma = 44, // ,
10 Minus = 45, // -
11 Period = 46, // .
12 Slash = 47, // /
13
14 N0 = 48,
15 N1,
16 N2,
17 N3,
18 N4,
19 N5,
20 N6,
21 N7,
22 N8,
23 N9,
24
25 Semicolon = 59, // ;
26 Equal = 61, // =
27
28 A = 65,
29 B,
30 C,
31 D,
32 E,
33 F,
34 G,
35 H,
36 I,
37 J,
38 K,
39 L,
40 M,
41 N,
42 O,
43 P,
44 Q,
45 R,
46 S,
47 T,
48 U,
49 V,
50 W,
51 X,
52 Y,
53 Z,
54
55 LeftBracket = 91, // [
56 Backslash = 92, // \
57
58 RightBracket = 93, // ]
59 GraveAccent = 96, // `
60
61 // Function keys
62 Escape = 256,
63 Enter = 257,
64 Tab = 258,
65 Backspace = 259,
66 Insert = 260,
67 Delete = 261,
68
69 Right = 262,
70 Left = 263,
71 Down = 264,
72 Up = 265,
73
74 PageUp = 266,
75 PageDown = 267,
76 Home = 268,
77 End = 269,
78
79 CapsLock = 280,
80 ScrollLock = 281,
81 NumLock = 282,
82 PrintScreen = 283,
83 Pause = 284,
84
85 F1 = 290,
86 F2,
87 F3,
88 F4,
89 F5,
90 F6,
91 F7,
92 F8,
93 F9,
94 F10,
95 F11,
96 F12,
97 F13,
98 F14,
99 F15,
100 F16,
101 F17,
102 F18,
103 F19,
104 F20,
105 F21,
106 F22,
107 F23,
108 F24,
109 F25,
110
111 KP0 = 320,
112 KP1,
113 KP2,
114 KP3,
115 KP4,
116 KP5,
117 KP6,
118 KP7,
119 KP8,
120 KP9,
121
122 KPDecimal = 330,
123 KPDivide = 331,
124 KPMultiply = 332,
125 KPSubtract = 333,
126 KPAdd = 334,
127 KPEnter = 335,
128 KPEqual = 336,
129
130 LShift = 340,
131 LCtrl = 341,
132 LAlt = 342,
133 LSuper = 343,
134 RShift = 344,
135 RCtrl = 345,
136 RAlt = 346,
137 RSuper = 347,
138
139 Menu = 348,
140
141 Unknown = -1
142};
143
144/**
145 * @brief Converts a character to the corresponding Keys enum value.
146 * @param c The character to convert.
147 * @return An optional Keys value if the character matches a key, std::nullopt otherwise.
148 */
149MAYAFLUX_API std::optional<Keys> from_char(char c) noexcept;
150
151/**
152 * @brief Converts a string to the corresponding Keys enum value.
153 * @param str The string to convert.
154 * @return An optional Keys value if the string matches a key, std::nullopt otherwise.
155 */
156MAYAFLUX_API std::optional<Keys> from_string(std::string_view str) noexcept;
157
158/**
159 * @brief Converts a Keys enum value to its string representation.
160 * @param key The key to convert.
161 * @return The string view representing the key.
162 */
163MAYAFLUX_API std::string_view to_string(Keys key) noexcept;
164
165/**
166 * @brief Converts a Keys enum value to its lowercase string representation.
167 * @param key The key to convert.
168 * @return The lowercase string representing the key.
169 */
170MAYAFLUX_API std::string to_lowercase_string(Keys key) noexcept;
171
172/**
173 * @brief Checks if a key is a printable character.
174 * @param key The key to check.
175 * @return True if the key is printable, false otherwise.
176 */
177MAYAFLUX_API bool is_printable(Keys key) noexcept;
178
179/**
180 * @brief Checks if a key is a modifier key (e.g., Shift, Ctrl, Alt).
181 * @param key The key to check.
182 * @return True if the key is a modifier, false otherwise.
183 */
184MAYAFLUX_API bool is_modifier(Keys key) noexcept;
185
186/**
187 * @brief Checks if a key is a function key (e.g., F1-F25).
188 * @param key The key to check.
189 * @return True if the key is a function key, false otherwise.
190 */
191MAYAFLUX_API bool is_function_key(Keys key) noexcept;
192
193/**
194 * @brief Checks if a key is a keypad key.
195 * @param key The key to check.
196 * @return True if the key is a keypad key, false otherwise.
197 */
198MAYAFLUX_API bool is_keypad_key(Keys key) noexcept;
199
200/**
201 * @brief Returns a vector of all key names in lowercase.
202 * @return A vector of lowercase key names.
203 */
204MAYAFLUX_API std::vector<std::string> all_key_names_lowercase() noexcept;
205
206/**
207 * @brief Returns a container of all key names.
208 * @return A container of all key names.
209 */
210MAYAFLUX_API auto all_key_names() noexcept;
211
212/**
213 * @brief Returns a container of all Keys enum values.
214 * @return A container of all Keys values.
215 */
216MAYAFLUX_API auto all_keys() noexcept;
217
218/**
219 * @brief Returns the total number of keys.
220 * @return The number of keys.
221 */
222MAYAFLUX_API size_t key_count() noexcept;
223
224} // namespace MayaFlux::IO
bool is_modifier(Keys key) noexcept
Checks if a key is a modifier key (e.g., Shift, Ctrl, Alt).
Definition Keys.cpp:70
std::vector< std::string > all_key_names_lowercase() noexcept
Returns a vector of all key names in lowercase.
Definition Keys.cpp:87
size_t key_count() noexcept
Returns the total number of keys.
Definition Keys.cpp:102
bool is_printable(Keys key) noexcept
Checks if a key is a printable character.
Definition Keys.cpp:64
std::string to_lowercase_string(Keys key) noexcept
Converts a Keys enum value to its lowercase string representation.
Definition Keys.cpp:59
std::optional< Keys > from_char(char c) noexcept
Converts a character to the corresponding Keys enum value.
Definition Keys.cpp:21
bool is_function_key(Keys key) noexcept
Checks if a key is a function key (e.g., F1-F25).
Definition Keys.cpp:75
std::optional< Keys > from_string(std::string_view str) noexcept
Converts a string to the corresponding Keys enum value.
Definition Keys.cpp:41
auto all_key_names() noexcept
Returns a container of all key names.
Definition Keys.cpp:92
std::string_view to_string(Keys key) noexcept
Converts a Keys enum value to its string representation.
Definition Keys.cpp:54
auto all_keys() noexcept
Returns a container of all Keys enum values.
Definition Keys.cpp:97
bool is_keypad_key(Keys key) noexcept
Checks if a key is a keypad key.
Definition Keys.cpp:81