MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Wayland/KeyMapping.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef MAYAFLUX_PLATFORM_LINUX
4
6
7#include <xkbcommon/xkbcommon.h>
8
9namespace MayaFlux::Core {
10
11/**
12 * @brief Convert an xkbcommon keysym to IO::Keys.
13 *
14 * Printable ASCII keysyms (XKB_KEY_space through XKB_KEY_asciitilde) share
15 * numeric values with the Keys enum and are cast directly. All other
16 * keysyms are dispatched through a lookup table covering navigation, editing,
17 * lock, function, keypad, and modifier keys.
18 *
19 * @param sym xkb_keysym_t from xkb_state_key_get_one_sym().
20 * @return Corresponding IO::Keys value, or Keys::Unknown if unmapped.
21 */
22MAYAFLUX_API IO::Keys from_xkb_keysym(xkb_keysym_t sym) noexcept;
23
24/**
25 * @brief Convert IO::Keys to an xkbcommon keysym.
26 *
27 * Returns a layout-independent keysym for the given key. This is only
28 * meaningful for keys with stable Unicode/X11 keysym assignments (printable
29 * ASCII, function keys, navigation). Layout-sensitive printable keys will
30 * return the QWERTY/US keysym regardless of the active layout.
31 *
32 * @param key IO::Keys value to convert.
33 * @return Corresponding xkb_keysym_t, or XKB_KEY_NoSymbol if unmapped.
34 */
35MAYAFLUX_API xkb_keysym_t to_xkb_keysym(IO::Keys key) noexcept;
36
37/**
38 * @brief Check whether an xkbcommon keysym maps to a known IO::Keys value.
39 *
40 * @param sym xkb_keysym_t to validate.
41 * @return True if sym is not XKB_KEY_NoSymbol and has a known mapping.
42 */
43MAYAFLUX_API bool is_valid_xkb_keysym(xkb_keysym_t sym) noexcept;
44
45/**
46 * @brief Convert a raw evdev scancode to IO::Keys for keys where keysym
47 * is modifier-state-dependent and physical identity must be preserved.
48 *
49 * Currently handles numpad keys whose keysyms invert with Num Lock state.
50 * Returns Keys::Unknown for all other scancodes; caller falls back to
51 * from_xkb_keysym().
52 *
53 * @param scancode Raw evdev key code from wl_keyboard::key event.
54 * @return Corresponding IO::Keys value, or Keys::Unknown if not handled.
55 */
56MAYAFLUX_API IO::Keys from_evdev_scancode(uint32_t scancode) noexcept;
57
58} // namespace MayaFlux::Core
59
60#endif // MAYAFLUX_PLATFORM_LINUX