~aleteoryx/muditaos

ref: a4a5a09c307af62cfbaaba11aa97cbcc118f0a7f muditaos/module-bsp/hal/key_input/KeyEventDefinitions.hpp -rw-r--r-- 1.3 KiB
a4a5a09c — Wojtek Rzepecki [BH-826] Add key input abstraction layer 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <magic_enum.hpp>

namespace bsp
{

    enum class KeyCodes
    {
        Undefined     = 0,
        NumericKey1   = 31,
        NumericKey2   = 32,
        NumericKey3   = 33,
        NumericKey4   = 41,
        NumericKey5   = 42,
        NumericKey6   = 43,
        NumericKey7   = 51,
        NumericKey8   = 52,
        NumericKey9   = 53,
        NumericKey0   = 62,
        NumericKeyAst = 61,
        NumericKeyPnd = 63,

        JoystickLeft  = 11,
        JoystickRight = 13,
        JoystickUp    = 2,
        JoystickDown  = 22,
        JoystickEnter = 12,

        FnLeft  = 21, // 1,
        FnRight = 23, // 3,

        VolUp   = 4,
        VolDown = 14,

        Torch = 24,

        SSwitchUp   = 34,
        SSwitchDown = 54,
        SSwitchMid  = 44,

        HeadsetOk      = 71,
        HeadsetVolUp   = 72,
        HeadsetVolDown = 73
    };

    enum class KeyEvents
    {
        Released,
        Pressed,
        Moved,
    };

    struct KeyEvent
    {
        KeyCodes code;
        KeyEvents event;
    };
} // namespace bsp

inline const char *c_str(bsp::KeyCodes code)
{
    return magic_enum::enum_name(code).data();
}