aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2018-01-10 12:09:21 -0800
committerGarrett Brown <themagnificentmrb@gmail.com>2018-01-15 14:36:30 -0800
commitd7adf87d1e535fbbf8dab9935ebe439e7aec6a62 (patch)
treedefbeccca049ec99958e134dad775b30c50e0ffd
parentf8cf1e6362546d0e390fde4af1aa8de44cdd409f (diff)
Keyboard: Add keycode property to CKey
Required for upcoming changes to the Game API.
-rw-r--r--xbmc/input/Key.cpp5
-rw-r--r--xbmc/input/Key.h4
-rw-r--r--xbmc/input/KeyboardStat.cpp6
3 files changed, 12 insertions, 3 deletions
diff --git a/xbmc/input/Key.cpp b/xbmc/input/Key.cpp
index 3d1b90e3ca..c049fbcf3c 100644
--- a/xbmc/input/Key.cpp
+++ b/xbmc/input/Key.cpp
@@ -48,7 +48,7 @@ CKey::CKey(uint32_t buttonCode, unsigned int held)
m_held = held;
}
-CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
+CKey::CKey(uint32_t keycode, uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
{
Reset();
if (vkey) // FIXME: This needs cleaning up - should we always use the unicode key where available?
@@ -56,6 +56,7 @@ CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsign
else
m_buttonCode = KEY_UNICODE;
m_buttonCode |= modifiers;
+ m_keycode = keycode;
m_vkey = vkey;
m_unicode = unicode;
m_ascii = ascii;
@@ -79,6 +80,7 @@ void CKey::Reset()
m_repeat = 0.0f;
m_fromService = false;
m_buttonCode = KEY_INVALID;
+ m_keycode = 0;
m_vkey = 0;
m_unicode = 0;
m_ascii = 0;
@@ -98,6 +100,7 @@ CKey& CKey::operator=(const CKey& key)
m_repeat = key.m_repeat;
m_fromService = key.m_fromService;
m_buttonCode = key.m_buttonCode;
+ m_keycode = key.m_keycode;
m_vkey = key.m_vkey;
m_unicode = key.m_unicode;
m_ascii = key.m_ascii;
diff --git a/xbmc/input/Key.h b/xbmc/input/Key.h
index 916b689553..bb5ad3bb13 100644
--- a/xbmc/input/Key.h
+++ b/xbmc/input/Key.h
@@ -149,7 +149,7 @@ public:
CKey(void);
CKey(uint32_t buttonCode, uint8_t leftTrigger = 0, uint8_t rightTrigger = 0, float leftThumbX = 0.0f, float leftThumbY = 0.0f, float rightThumbX = 0.0f, float rightThumbY = 0.0f, float repeat = 0.0f);
CKey(uint32_t buttonCode, unsigned int held);
- CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held);
+ CKey(uint32_t keycode, uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held);
CKey(const CKey& key);
void Reset();
@@ -169,6 +169,7 @@ public:
bool GetFromService() const { return m_fromService; }
inline uint32_t GetButtonCode() const { return m_buttonCode; }
+ inline uint32_t GetKeycode() const { return m_keycode; } // XBMCKey enum in XBMC_keysym.h
inline uint8_t GetVKey() const { return m_vkey; }
inline wchar_t GetUnicode() const { return m_unicode; }
inline char GetAscii() const { return m_ascii; }
@@ -187,6 +188,7 @@ public:
private:
uint32_t m_buttonCode;
+ uint32_t m_keycode;
uint8_t m_vkey;
wchar_t m_unicode;
char m_ascii;
diff --git a/xbmc/input/KeyboardStat.cpp b/xbmc/input/KeyboardStat.cpp
index 22417de05d..ecaad6fad1 100644
--- a/xbmc/input/KeyboardStat.cpp
+++ b/xbmc/input/KeyboardStat.cpp
@@ -74,6 +74,7 @@ bool CKeyboardStat::LookupSymAndUnicodePeripherals(XBMC_keysym &keysym, uint8_t
CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
{
+ uint32_t keycode;
uint8_t vkey;
wchar_t unicode;
char ascii;
@@ -98,6 +99,7 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
// The keysym.unicode is usually valid, even if it is zero. A zero
// unicode just means this is a non-printing keypress. The ascii and
// vkey will be set below.
+ keycode = keysym.sym;
unicode = keysym.unicode;
ascii = 0;
vkey = 0;
@@ -121,6 +123,8 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
// will match keys like \ that are on different keys on regional keyboards.
else if (KeyTableLookupUnicode(keysym.unicode, &keytable))
{
+ if (keycode == 0)
+ keycode = keytable.sym;
vkey = keytable.vkey;
ascii = keytable.ascii;
}
@@ -175,7 +179,7 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const
// Create and return a CKey
- CKey key(vkey, unicode, ascii, modifiers, held);
+ CKey key(keycode, vkey, unicode, ascii, modifiers, held);
return key;
}