aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authorrenniej <renniej@svn>2010-07-20 08:25:56 +0000
committerrenniej <renniej@svn>2010-07-20 08:25:56 +0000
commita73adafb41768a95fa71f526bb674c6e6bf25ce2 (patch)
tree7e2994cba543035aadc984e013a7af2409132f44 /guilib
parent3e7e7d63893cc6b52a8d12e8529883fe8cc6cf78 (diff)
http://trac.xbmc.org/ticket/9665
Modifications to key handling to tidy it up. Changes are tested and working but further changes to CKeyboardStat::HandleEvent and CKeyboardStat::Update will be made to make the key processing more transparent. git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31997 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/Key.cpp129
-rw-r--r--guilib/Key.h34
2 files changed, 134 insertions, 29 deletions
diff --git a/guilib/Key.cpp b/guilib/Key.cpp
index cebcae3237..45466bf07f 100644
--- a/guilib/Key.cpp
+++ b/guilib/Key.cpp
@@ -24,7 +24,6 @@
CKey::CKey(void)
{
- m_buttonCode = KEY_INVALID;
m_leftTrigger = 0;
m_rightTrigger = 0;
m_leftThumbX = 0.0f;
@@ -33,12 +32,22 @@ CKey::CKey(void)
m_rightThumbY = 0.0f;
m_repeat = 0.0f;
m_fromHttpApi = false;
+ m_buttonCode = KEY_INVALID;
+ m_VKey = 0;
+ m_wUnicode = 0;
+ m_cAscii = 0;
+ m_bShift = 0;
+ m_bCtrl = 0;
+ m_bAlt = 0;
+ m_bRAlt = 0;
+ m_bSuper = 0;
m_held = 0;
}
CKey::~CKey(void)
{}
+/* Commented out temporarily prior to permanent removal
CKey::CKey(uint32_t buttonCode, uint8_t leftTrigger, uint8_t rightTrigger, float leftThumbX, float leftThumbY, float rightThumbX, float rightThumbY, float repeat)
{
m_leftTrigger = leftTrigger;
@@ -47,43 +56,91 @@ CKey::CKey(uint32_t buttonCode, uint8_t leftTrigger, uint8_t rightTrigger, float
m_leftThumbY = leftThumbY;
m_rightThumbX = rightThumbX;
m_rightThumbY = rightThumbY;
- m_buttonCode = buttonCode;
m_repeat = repeat;
m_fromHttpApi = false;
+ m_buttonCode = buttonCode;
+ m_VKey = 0;
+ m_wUnicode = 0;
+ m_cAscii = 0;
+ m_bShift = 0;
+ m_bCtrl = 0;
+ m_bAlt = 0;
+ m_bRAlt = 0;
+ m_bSuper = 0;
m_held = 0;
}
+*/
-CKey::CKey(const CKey& key)
+CKey::CKey(uint32_t buttonCode, uint8_t leftTrigger, uint8_t rightTrigger, float leftThumbX, float leftThumbY, float rightThumbX, float rightThumbY, float repeat, uint8_t vkey, wchar_t unicode, char ascii, bool shift, bool ctrl, bool alt, bool ralt, bool super, unsigned int held)
{
- *this = key;
+ m_leftTrigger = leftTrigger;
+ m_rightTrigger = rightTrigger;
+ m_leftThumbX = leftThumbX;
+ m_leftThumbY = leftThumbY;
+ m_rightThumbX = rightThumbX;
+ m_rightThumbY = rightThumbY;
+ m_repeat = repeat;
+ m_fromHttpApi = false;
+ m_buttonCode = buttonCode;
+ m_VKey = vkey;
+ m_wUnicode = unicode;
+ m_cAscii = ascii;
+ m_bShift = shift;
+ m_bCtrl = ctrl;
+ m_bAlt = alt;
+ m_bRAlt = ralt;
+ m_bSuper = super;
+ m_held = held;
}
-uint32_t CKey::GetButtonCode() const // for backwards compatibility only
+CKey::CKey(const CKey& key)
{
- return m_buttonCode;
+ *this = key;
}
-wchar_t CKey::GetUnicode() const
+void CKey::Reset()
{
- if (m_buttonCode>=KEY_ASCII && m_buttonCode < KEY_UNICODE) // will need to change when Unicode is fully implemented
- return (wchar_t)(m_buttonCode - KEY_ASCII);
- else
- return 0;
+ m_leftTrigger = 0;
+ m_rightTrigger = 0;
+ m_leftThumbX = 0.0f;
+ m_leftThumbY = 0.0f;
+ m_rightThumbX = 0.0f;
+ m_rightThumbY = 0.0f;
+ m_repeat = 0.0f;
+ m_fromHttpApi = false;
+ m_buttonCode = KEY_INVALID;
+ m_VKey = 0;
+ m_wUnicode = 0;
+ m_cAscii = 0;
+ m_bShift = 0;
+ m_bCtrl = 0;
+ m_bAlt = 0;
+ m_bRAlt = 0;
+ m_bSuper = 0;
+ m_held = 0;
}
const CKey& CKey::operator=(const CKey& key)
{
if (&key == this) return * this;
- m_leftTrigger = key.m_leftTrigger;
+ m_leftTrigger = key.m_leftTrigger;
m_rightTrigger = key.m_rightTrigger;
- m_buttonCode = key.m_buttonCode;
- m_leftThumbX = key.m_leftThumbX;
- m_leftThumbY = key.m_leftThumbY;
- m_rightThumbX = key.m_rightThumbX;
- m_rightThumbY = key.m_rightThumbY;
- m_repeat = key.m_repeat;
- m_fromHttpApi = key.m_fromHttpApi;
- m_held = key.m_held;
+ m_leftThumbX = key.m_leftThumbX;
+ m_leftThumbY = key.m_leftThumbY;
+ m_rightThumbX = key.m_rightThumbX;
+ m_rightThumbY = key.m_rightThumbY;
+ m_repeat = key.m_repeat;
+ m_fromHttpApi = key.m_fromHttpApi;
+ m_buttonCode = key.m_buttonCode;
+ m_VKey = key.m_VKey;
+ m_wUnicode = key.m_wUnicode;
+ m_cAscii = key.m_cAscii;
+ m_bShift = key.m_bShift;
+ m_bCtrl = key.m_bCtrl;
+ m_bAlt = key.m_bAlt;
+ m_bRAlt = key.m_bRAlt;
+ m_bSuper = m_bSuper;
+ m_held = key.m_held;
return *this;
}
@@ -153,14 +210,38 @@ void CKey::SetFromHttpApi(bool bFromHttpApi)
m_fromHttpApi = bFromHttpApi;
}
-void CKey::SetHeld(unsigned int held)
+void CKey::SetButtonCode(uint32_t buttoncode)
{
- m_held = held;
+ m_buttonCode = buttoncode;
+}
+
+void CKey::SetVKey(uint8_t vkey)
+{
+ m_VKey = vkey;
}
-unsigned int CKey::GetHeld() const
+void CKey::SetAscii(char ascii)
{
- return m_held;
+ m_cAscii = ascii;
+}
+
+void CKey::SetUnicode(wchar_t unicode)
+{
+ m_wUnicode = unicode;
+}
+
+void CKey::SetModifiers(bool ctrl, bool shift, bool alt, bool ralt, bool super)
+{
+ m_bCtrl = ctrl;
+ m_bShift = shift;
+ m_bAlt = alt;
+ m_bRAlt = ralt;
+ m_bSuper = super;
+}
+
+void CKey::SetHeld(unsigned int held)
+{
+ m_held = held;
}
CAction::CAction(int actionID, float amount1 /* = 1.0f */, float amount2 /* = 0.0f */, const CStdString &name /* = "" */)
diff --git a/guilib/Key.h b/guilib/Key.h
index c30f162edd..01212ae358 100644
--- a/guilib/Key.h
+++ b/guilib/Key.h
@@ -502,13 +502,12 @@ class CKey
{
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, 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, 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, uint8_t vkey = 0, wchar_t unicode = 0, char ascii = 0, bool shift = 0, bool ctrl = 0, bool alt = 0, bool ralt = 0, bool super = 0, unsigned int held = 0);
CKey(const CKey& key);
virtual ~CKey(void);
const CKey& operator=(const CKey& key);
- uint32_t GetButtonCode() const; // for backwards compatibility only
- wchar_t GetUnicode() const; // http api does not really support unicode till now. It only simulates unicode when ascii codes are available:
uint8_t GetLeftTrigger() const;
uint8_t GetRightTrigger() const;
float GetLeftThumbX() const;
@@ -522,8 +521,24 @@ public:
void SetFromHttpApi(bool);
bool GetFromHttpApi() const;
+ void Reset();
+ void SetButtonCode(uint32_t buttoncode);
+ void SetVKey(uint8_t vkey);
+ void SetAscii(char ascii);
+ void SetUnicode(wchar_t unicode);
+ void SetModifiers(bool ctrl, bool shift, bool alt, bool ralt, bool super);
void SetHeld(unsigned int held);
- unsigned int GetHeld() const;
+
+ inline uint32_t GetButtonCode() const { return m_buttonCode;};
+ inline uint8_t GetVKey() const { return m_VKey;};
+ inline wchar_t GetUnicode() const { return m_wUnicode;};
+ inline char GetAscii() const { return m_cAscii;};
+ inline bool GetCtrl() const { return m_bCtrl; };
+ inline bool GetShift() const { return m_bShift; };
+ inline bool GetAlt() const { return m_bAlt; };
+ inline bool GetRAlt() const { return m_bRAlt; };
+ inline bool GetSuper() const { return m_bSuper; };
+ inline unsigned int GetHeld() const { return m_held; };
enum Modifier {
MODIFIER_CTRL = 0x00010000,
@@ -534,6 +549,16 @@ public:
private:
uint32_t m_buttonCode;
+ uint8_t m_VKey;
+ wchar_t m_wUnicode;
+ char m_cAscii;
+ bool m_bShift;
+ bool m_bCtrl;
+ bool m_bAlt;
+ bool m_bRAlt;
+ bool m_bSuper;
+ unsigned int m_held;
+
uint8_t m_leftTrigger;
uint8_t m_rightTrigger;
float m_leftThumbX;
@@ -542,7 +567,6 @@ private:
float m_rightThumbY;
float m_repeat; // time since last keypress
bool m_fromHttpApi;
- unsigned int m_held;
};
#endif