Debian Codegraph @

xbmc/input/keyboard/Key.h

raw
1 /*
2 * Copyright (C) 2005-2024 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include <stdint.h>
12 #include <string>
13
14 /*!
15 * \ingroup keyboard
16 */
17 class CKey
18 {
19 public:
20 CKey(void);
21 CKey(uint32_t buttonCode,
22 uint8_t leftTrigger = 0,
23 uint8_t rightTrigger = 0,
24 float leftThumbX = 0.0f,
25 float leftThumbY = 0.0f,
26 float rightThumbX = 0.0f,
27 float rightThumbY = 0.0f,
28 float repeat = 0.0f);
29 CKey(uint32_t buttonCode, unsigned int held);
30 CKey(uint32_t keycode,
31 uint8_t vkey,
32 wchar_t unicode,
33 char ascii,
34 uint32_t modifiers,
35 uint32_t lockingModifiers,
36 unsigned int held);
37 CKey(const CKey& key);
38 void Reset();
39
40 virtual ~CKey(void);
41 CKey& operator=(const CKey& key);
42 uint8_t GetLeftTrigger() const;
43 uint8_t GetRightTrigger() const;
44 float GetLeftThumbX() const;
45 float GetLeftThumbY() const;
46 float GetRightThumbX() const;
47 float GetRightThumbY() const;
48 float GetRepeat() const;
49 bool FromKeyboard() const;
50 bool IsAnalogButton() const;
51 bool IsIRRemote() const;
52 void SetFromService(bool fromService);
53 bool GetFromService() const { return m_fromService; }
54
55 inline uint32_t GetButtonCode() const { return m_buttonCode; }
56 inline uint32_t GetKeycode() const { return m_keycode; } // XBMCKey enum in XBMC_keysym.h
57 inline uint8_t GetVKey() const { return m_vkey; }
58 inline wchar_t GetUnicode() const { return m_unicode; }
59 inline char GetAscii() const { return m_ascii; }
60 inline uint32_t GetModifiers() const { return m_modifiers; }
61 inline uint32_t GetLockingModifiers() const { return m_lockingModifiers; }
62 inline unsigned int GetHeld() const { return m_held; }
63
64 enum Modifier
65 {
66 MODIFIER_CTRL = 0x00010000,
67 MODIFIER_SHIFT = 0x00020000,
68 MODIFIER_ALT = 0x00040000,
69 MODIFIER_RALT = 0x00080000,
70 MODIFIER_SUPER = 0x00100000,
71 MODIFIER_META = 0X00200000,
72 MODIFIER_LONG = 0X01000000,
73 MODIFIER_NUMLOCK = 0X02000000,
74 MODIFIER_CAPSLOCK = 0X04000000,
75 MODIFIER_SCROLLLOCK = 0X08000000,
76 };
77
78 private:
79 uint32_t m_buttonCode;
80 uint32_t m_keycode;
81 uint8_t m_vkey;
82 wchar_t m_unicode;
83 char m_ascii;
84 uint32_t m_modifiers;
85 uint32_t m_lockingModifiers;
86 unsigned int m_held;
87
88 uint8_t m_leftTrigger;
89 uint8_t m_rightTrigger;
90 float m_leftThumbX;
91 float m_leftThumbY;
92 float m_rightThumbX;
93 float m_rightThumbY;
94 float m_repeat; // time since last keypress
95 bool m_fromService;
96 };