MayaFlux 0.3.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 Enumeration for mouse buttons.
146 */
147enum class MouseButtons : int8_t {
148 Left = 0,
149 Right = 1,
150 Middle = 2,
151 Button4 = 3,
152 Button5 = 4,
153 Button6 = 5,
154 Button7 = 6,
155 Button8 = 7,
156 Unknown = -1
157};
158
159/**
160 * @brief Converts a character to the corresponding Keys enum value.
161 * @param c The character to convert.
162 * @return An optional Keys value if the character matches a key, std::nullopt otherwise.
163 */
164MAYAFLUX_API std::optional<Keys> from_char(char c) noexcept;
165
166/**
167 * @brief Converts a string to the corresponding Keys enum value.
168 * @param str The string to convert.
169 * @return An optional Keys value if the string matches a key, std::nullopt otherwise.
170 */
171MAYAFLUX_API std::optional<Keys> from_string(std::string_view str) noexcept;
172
173/**
174 * @brief Converts a Keys enum value to its string representation.
175 * @param key The key to convert.
176 * @return The string view representing the key.
177 */
178MAYAFLUX_API std::string_view to_string(Keys key) noexcept;
179
180/**
181 * @brief Converts a Keys enum value to its lowercase string representation.
182 * @param key The key to convert.
183 * @return The lowercase string representing the key.
184 */
185MAYAFLUX_API std::string to_lowercase_string(Keys key) noexcept;
186
187/**
188 * @brief Checks if a key is a printable character.
189 * @param key The key to check.
190 * @return True if the key is printable, false otherwise.
191 */
192MAYAFLUX_API bool is_printable(Keys key) noexcept;
193
194/**
195 * @brief Checks if a key is a modifier key (e.g., Shift, Ctrl, Alt).
196 * @param key The key to check.
197 * @return True if the key is a modifier, false otherwise.
198 */
199MAYAFLUX_API bool is_modifier(Keys key) noexcept;
200
201/**
202 * @brief Checks if a key is a function key (e.g., F1-F25).
203 * @param key The key to check.
204 * @return True if the key is a function key, false otherwise.
205 */
206MAYAFLUX_API bool is_function_key(Keys key) noexcept;
207
208/**
209 * @brief Checks if a key is a keypad key.
210 * @param key The key to check.
211 * @return True if the key is a keypad key, false otherwise.
212 */
213MAYAFLUX_API bool is_keypad_key(Keys key) noexcept;
214
215/**
216 * @brief Returns a vector of all key names in lowercase.
217 * @return A vector of lowercase key names.
218 */
219MAYAFLUX_API std::vector<std::string> all_key_names_lowercase() noexcept;
220
221/**
222 * @brief Returns a container of all key names.
223 * @return A container of all key names.
224 */
225MAYAFLUX_API auto all_key_names() noexcept;
226
227/**
228 * @brief Returns a container of all Keys enum values.
229 * @return A container of all Keys values.
230 */
231MAYAFLUX_API auto all_keys() noexcept;
232
233/**
234 * @brief Returns the total number of keys.
235 * @return The number of keys.
236 */
237MAYAFLUX_API size_t key_count() noexcept;
238
239} // 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:71
std::vector< std::string > all_key_names_lowercase() noexcept
Returns a vector of all key names in lowercase.
Definition Keys.cpp:88
MouseButtons
Enumeration for mouse buttons.
Definition Keys.hpp:147
size_t key_count() noexcept
Returns the total number of keys.
Definition Keys.cpp:103
bool is_printable(Keys key) noexcept
Checks if a key is a printable character.
Definition Keys.cpp:65
std::string to_lowercase_string(Keys key) noexcept
Converts a Keys enum value to its lowercase string representation.
Definition Keys.cpp:60
std::optional< Keys > from_char(char c) noexcept
Converts a character to the corresponding Keys enum value.
Definition Keys.cpp:22
bool is_function_key(Keys key) noexcept
Checks if a key is a function key (e.g., F1-F25).
Definition Keys.cpp:76
std::optional< Keys > from_string(std::string_view str) noexcept
Converts a string to the corresponding Keys enum value.
Definition Keys.cpp:42
auto all_key_names() noexcept
Returns a container of all key names.
Definition Keys.cpp:93
std::string_view to_string(Keys key) noexcept
Converts a Keys enum value to its string representation.
Definition Keys.cpp:55
auto all_keys() noexcept
Returns a container of all Keys enum values.
Definition Keys.cpp:98
bool is_keypad_key(Keys key) noexcept
Checks if a key is a keypad key.
Definition Keys.cpp:82