MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Win32/KeyMapping.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef MAYAFLUX_PLATFORM_WINDOWS
6
7#ifndef WIN32_LEAN_AND_MEAN
8#define WIN32_LEAN_AND_MEAN
9#endif
10#ifndef NOMINMAX
11#define NOMINMAX
12#endif
13#include <windows.h>
14
15namespace MayaFlux::Core {
16
17/**
18 * @brief Convert a Win32 virtual key code to IO::Keys.
19 *
20 * Printable letters (VK_A–VK_Z == 0x41–0x5A) and digits
21 * (VK_0–VK_9 == 0x30–0x39) share the same numeric values as the Keys
22 * enum and are cast directly. All other keys are dispatched through a
23 * lookup table.
24 *
25 * @param vk Win32 virtual key code (WPARAM from WM_KEYDOWN/WM_KEYUP).
26 * @return Corresponding IO::Keys value, or Keys::Unknown if unmapped.
27 */
28MAYAFLUX_API IO::Keys from_win32_key(WPARAM vk) noexcept;
29
30/**
31 * @brief Convert IO::Keys to the corresponding Win32 virtual key code.
32 *
33 * Returns 0 for Keys::Unknown or any key that has no Win32 equivalent.
34 *
35 * @param key IO::Keys value to convert.
36 * @return Win32 virtual key code, or 0 if unmapped.
37 */
38MAYAFLUX_API int to_win32_key(IO::Keys key) noexcept;
39
40/**
41 * @brief Convert a Win32 scancode to IO::Keys for numpad keys whose VK codes
42 * invert with NumLock state.
43 *
44 * Only handles scancodes 0x47–0x53 without the extended-key bit. Returns
45 * Keys::Unknown for all other inputs; caller falls back to from_win32_key().
46 *
47 * @param scancode Raw scancode from HIWORD(lParam) & 0x1FF (bit 8 = extended).
48 * @return Corresponding IO::Keys value, or Keys::Unknown if not handled.
49 */
50MAYAFLUX_API IO::Keys from_win32_scancode(uint32_t scancode) noexcept;
51
52/**
53 * @brief Check whether a Win32 virtual key code maps to a known IO::Keys value.
54 *
55 * @param vk Win32 virtual key code.
56 * @return True if the key is recognised, false otherwise.
57 */
58MAYAFLUX_API bool is_valid_win32_key(WPARAM vk) noexcept;
59
60} // namespace MayaFlux::Core
61
62#endif // MAYAFLUX_PLATFORM_WINDOWS