2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
16 CKey::~CKey(void) = default;
18 CKey::CKey(uint32_t buttonCode
,
28 m_buttonCode
= buttonCode
;
29 m_leftTrigger
= leftTrigger
;
30 m_rightTrigger
= rightTrigger
;
31 m_leftThumbX
= leftThumbX
;
32 m_leftThumbY
= leftThumbY
;
33 m_rightThumbX
= rightThumbX
;
34 m_rightThumbY
= rightThumbY
;
38 CKey::CKey(uint32_t buttonCode
, unsigned int held
)
41 m_buttonCode
= buttonCode
;
45 CKey::CKey(uint32_t keycode
,
50 uint32_t lockingModifiers
,
54 if (vkey
) // FIXME: This needs cleaning up - should we always use the unicode key where available?
55 m_buttonCode
= vkey
| KEY_VKEY
;
57 m_buttonCode
= KEY_UNICODE
;
58 m_buttonCode
|= modifiers
;
63 m_modifiers
= modifiers
;
64 m_lockingModifiers
= lockingModifiers
;
68 CKey::CKey(const CKey
& key
)
82 m_fromService
= false;
83 m_buttonCode
= KEY_INVALID
;
89 m_lockingModifiers
= 0;
93 CKey
& CKey::operator=(const CKey
& key
)
97 m_leftTrigger
= key
.m_leftTrigger
;
98 m_rightTrigger
= key
.m_rightTrigger
;
99 m_leftThumbX
= key
.m_leftThumbX
;
100 m_leftThumbY
= key
.m_leftThumbY
;
101 m_rightThumbX
= key
.m_rightThumbX
;
102 m_rightThumbY
= key
.m_rightThumbY
;
103 m_repeat
= key
.m_repeat
;
104 m_fromService
= key
.m_fromService
;
105 m_buttonCode
= key
.m_buttonCode
;
106 m_keycode
= key
.m_keycode
;
108 m_unicode
= key
.m_unicode
;
109 m_ascii
= key
.m_ascii
;
110 m_modifiers
= key
.m_modifiers
;
111 m_lockingModifiers
= key
.m_lockingModifiers
;
116 uint8_t CKey::GetLeftTrigger() const
118 return m_leftTrigger
;
121 uint8_t CKey::GetRightTrigger() const
123 return m_rightTrigger
;
126 float CKey::GetLeftThumbX() const
131 float CKey::GetLeftThumbY() const
136 float CKey::GetRightThumbX() const
138 return m_rightThumbX
;
141 float CKey::GetRightThumbY() const
143 return m_rightThumbY
;
146 bool CKey::FromKeyboard() const
148 return (m_buttonCode
>= KEY_VKEY
&& m_buttonCode
!= KEY_INVALID
);
151 bool CKey::IsAnalogButton() const
153 if ((GetButtonCode() > 261 && GetButtonCode() < 270) ||
154 (GetButtonCode() > 279 && GetButtonCode() < 284))
160 bool CKey::IsIRRemote() const
162 if (GetButtonCode() < 256)
167 float CKey::GetRepeat() const
172 void CKey::SetFromService(bool fromService
)
174 if (fromService
&& (m_buttonCode
& KEY_VKEY
))
175 m_unicode
= m_buttonCode
- KEY_VKEY
;
177 m_fromService
= fromService
;