aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authorrenniej <renniej@svn>2010-07-20 13:29:19 +0000
committerrenniej <renniej@svn>2010-07-20 13:29:19 +0000
commit4b1936c33385083a16da50ff297d8a0a2ccf3ce7 (patch)
tree455961caee4fb7825feaebd17dddb436dc10ef8a /guilib
parentae1d173f861a253d0ae3f1779a7c76c1c5faaa51 (diff)
See http://trac.xbmc.org/ticket/9665#comment:5
Key handling code has been simplified and streamlined. git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@32004 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/Key.cpp88
-rw-r--r--guilib/Key.h33
2 files changed, 24 insertions, 97 deletions
diff --git a/guilib/Key.cpp b/guilib/Key.cpp
index 45466bf07f..9add9f6513 100644
--- a/guilib/Key.cpp
+++ b/guilib/Key.cpp
@@ -36,42 +36,14 @@ CKey::CKey(void)
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_Modifiers = 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;
- 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 = 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(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)
+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, uint32_t modifiers, unsigned int held)
{
m_leftTrigger = leftTrigger;
m_rightTrigger = rightTrigger;
@@ -85,11 +57,7 @@ CKey::CKey(uint32_t buttonCode, uint8_t leftTrigger, uint8_t rightTrigger, float
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_Modifiers = modifiers;
m_held = held;
}
@@ -112,11 +80,7 @@ void CKey::Reset()
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_Modifiers = 0;
m_held = 0;
}
@@ -135,11 +99,7 @@ const CKey& CKey::operator=(const CKey& key)
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_Modifiers = key.m_Modifiers;
m_held = key.m_held;
return *this;
}
@@ -210,38 +170,14 @@ void CKey::SetFromHttpApi(bool bFromHttpApi)
m_fromHttpApi = bFromHttpApi;
}
-void CKey::SetButtonCode(uint32_t buttoncode)
-{
- m_buttonCode = buttoncode;
-}
-
-void CKey::SetVKey(uint8_t vkey)
-{
- m_VKey = vkey;
-}
-
-void CKey::SetAscii(char ascii)
-{
- m_cAscii = ascii;
-}
-
-void CKey::SetUnicode(wchar_t unicode)
+void CKey::SetKeystroke(uint32_t buttonCode, uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held)
{
- 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;
+ m_buttonCode = buttonCode;
+ m_VKey = vkey;
+ m_wUnicode = unicode;
+ m_cAscii = ascii;
+ m_Modifiers = modifiers;
+ 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 01212ae358..8f82adc19e 100644
--- a/guilib/Key.h
+++ b/guilib/Key.h
@@ -502,8 +502,7 @@ 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, 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(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, uint32_t modifiers = 0, unsigned int held = 0);
CKey(const CKey& key);
virtual ~CKey(void);
@@ -522,29 +521,25 @@ public:
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);
+ void SetKeystroke(uint32_t buttonCode, uint8_t vkey = 0, wchar_t unicode = 0, char ascii = 0, uint32_t modifiers = 0, unsigned int held = 0);
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 bool GetCtrl() const { return m_Modifiers & MODIFIER_CTRL ? 1 : 0; };
+ inline bool GetShift() const { return m_Modifiers & MODIFIER_SHIFT ? 1 : 0; };
+ inline bool GetAlt() const { return m_Modifiers & MODIFIER_ALT ? 1 : 0; };
+ inline bool GetRAlt() const { return m_Modifiers & MODIFIER_RALT ? 1 : 0; };
+ inline bool GetSuper() const { return m_Modifiers & MODIFIER_SUPER ? 1 : 0; };
inline unsigned int GetHeld() const { return m_held; };
enum Modifier {
- MODIFIER_CTRL = 0x00010000,
+ MODIFIER_CTRL = 0x00010000,
MODIFIER_SHIFT = 0x00020000,
- MODIFIER_ALT = 0x00040000,
- MODIFIER_SUPER = 0x00080000
+ MODIFIER_ALT = 0x00040000,
+ MODIFIER_RALT = 0x00080000,
+ MODIFIER_SUPER = 0x00100000
};
private:
@@ -552,11 +547,7 @@ private:
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;
+ uint32_t m_Modifiers;
unsigned int m_held;
uint8_t m_leftTrigger;