summaryrefslogtreecommitdiffstats
path: root/src/input/inputEvent.h
diff options
context:
space:
mode:
authorSebastien Braun2010-10-10 01:39:14 +0200
committerSebastien Braun2010-10-10 14:05:35 +0200
commitd45ad40dd76250d3f342d70159b3737be8562139 (patch)
tree3329c6b6632fbf760abd9a63ab358e11bd55cfa9 /src/input/inputEvent.h
parentCode cleanup for X11FakeKeyboardHandler.cpp (diff)
downloadpvs-d45ad40dd76250d3f342d70159b3737be8562139.tar.gz
pvs-d45ad40dd76250d3f342d70159b3737be8562139.tar.xz
pvs-d45ad40dd76250d3f342d70159b3737be8562139.zip
Code cleanup for inputEvent.h
- Use Qt's fixed-width integral types instead of stdint.h, which I forgot to include anyway - CamelCase identifiers - fix underscore position on instance variables
Diffstat (limited to 'src/input/inputEvent.h')
-rw-r--r--src/input/inputEvent.h118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/input/inputEvent.h b/src/input/inputEvent.h
index 82b059c..73b7129 100644
--- a/src/input/inputEvent.h
+++ b/src/input/inputEvent.h
@@ -39,19 +39,19 @@ private:
friend void eventToString(InputEvent const& evt, QString& str);
friend bool eventFromString(QString const& str, InputEvent& evt);
- uint16_t type_;
- uint16_t code_;
- uint32_t value_;
+ quint16 _type;
+ quint16 _code;
+ quint32 _value;
// InputEvents are immutable. Prohibit assignment:
InputEvent& operator=(InputEvent const&); // There intentionally is no implementation.
public:
- InputEvent(uint16_t type, uint16_t code, uint32_t value = 0) : type_(type), code_(code), value_(value)
+ InputEvent(quint16 type, quint16 code, quint32 value = 0) : _type(type), _code(code), _value(value)
{
}
- InputEvent(InputEvent const& other) : type_(other.type_), code_(other.code_), value_(other.value_)
+ InputEvent(InputEvent const& other) : _type(other._type), _code(other._code), _value(other._value)
{
}
@@ -59,110 +59,110 @@ public:
{
}
- static InputEvent mouseMotion(uint16_t x, uint16_t y)
+ static InputEvent mouseMotion(quint16 x, quint16 y)
{
- return InputEvent(ET_POINTER, 0, ((uint32_t)x << 16) | y);
+ return InputEvent(ET_POINTER, 0, ((quint32)x << 16) | y);
}
- static uint16_t mouseButtonsFromQt(int b);
+ static quint16 mouseButtonsFromQt(int b);
static InputEvent mousePressRelease(int button, int buttons);
static InputEvent keyboardPress(int key, int mods);
static InputEvent keyboardRelease(int key, int mods);
- static const uint16_t ET_KEY = 0;
- static const uint16_t ET_BUTTON = 1;
- static const uint16_t ET_POINTER = 2;
- static const uint16_t ET_SPECIAL = 3;
+ static const quint16 ET_KEY = 0;
+ static const quint16 ET_BUTTON = 1;
+ static const quint16 ET_POINTER = 2;
+ static const quint16 ET_SPECIAL = 3;
- static const uint16_t EC_PRESS = 0;
- static const uint16_t EC_RELEASE = 1;
- static const uint16_t EC_REBOOT = 2;
- static const uint16_t EC_SYSRQ = 3;
- static const uint16_t EC_KILL_X = 4;
- static const uint16_t EC_SAY_HELLO = 5; //< for debugging purposes
+ static const quint16 EC_PRESS = 0;
+ static const quint16 EC_RELEASE = 1;
+ static const quint16 EC_REBOOT = 2;
+ static const quint16 EC_SYSRQ = 3;
+ static const quint16 EC_KILL_X = 4;
+ static const quint16 EC_SAY_HELLO = 5; //< for debugging purposes
- typedef uint32_t event_key;
+ typedef quint32 event_key;
- typedef uint32_t event_key_modifiers;
+ typedef quint32 event_key_modifiers;
- static const uint16_t EB_LEFT = 1;
- static const uint16_t EB_MIDDLE = 2;
- static const uint16_t EB_RIGHT = 4;
+ static const quint16 EB_LEFT = 1;
+ static const quint16 EB_MIDDLE = 2;
+ static const quint16 EB_RIGHT = 4;
- static const uint32_t MODIFIER_MASK =
+ static const quint32 MODIFIER_MASK =
0x7e000000;
- uint16_t type() const
+ quint16 type() const
{
- return type_;
+ return _type;
}
- uint16_t code() const
+ quint16 code() const
{
- return code_;
+ return _code;
}
- uint32_t value() const
+ quint32 value() const
{
- return value_;
+ return _value;
}
bool isKeyboard() const
{
- return type_ == ET_KEY;
+ return _type == ET_KEY;
}
bool isButton() const
{
- return type_ == ET_BUTTON;
+ return _type == ET_BUTTON;
}
bool isPointer() const
{
- return type_ == ET_POINTER;
+ return _type == ET_POINTER;
}
bool isSpecial() const
{
- return type_ == ET_SPECIAL;
+ return _type == ET_SPECIAL;
}
bool isPress() const
{
- return code_ == EC_PRESS;
+ return _code == EC_PRESS;
}
bool isRelease() const
{
- return code_ == EC_RELEASE;
+ return _code == EC_RELEASE;
}
- uint16_t pressedButton() const
+ quint16 pressedButton() const
{
- assert(type_ == ET_BUTTON);
- return (value_ >> 16);
+ assert(_type == ET_BUTTON);
+ return (_value >> 16);
}
- uint16_t heldButtons() const
+ quint16 heldButtons() const
{
- assert(type_ == ET_BUTTON);
- return (value_ & 0xffff);
+ assert(_type == ET_BUTTON);
+ return (_value & 0xffff);
}
- uint16_t xCoord() const
+ quint16 xCoord() const
{
- assert(type_ == ET_POINTER);
- return (value_ >> 16);
+ assert(_type == ET_POINTER);
+ return (_value >> 16);
}
- uint16_t yCoord() const
+ quint16 yCoord() const
{
- assert(type_ == ET_POINTER);
- return (value_ & 0xffff);
+ assert(_type == ET_POINTER);
+ return (_value & 0xffff);
}
- static QString typeToString(uint16_t type)
+ static QString typeToString(quint16 type)
{
switch(type)
{
@@ -179,7 +179,7 @@ public:
}
}
- static QString codeToString(uint16_t code)
+ static QString codeToString(quint16 code)
{
switch(code)
{
@@ -200,17 +200,17 @@ public:
QString toString() const
{
- return QString("%1:%2:%3").arg(typeToString(type_)).arg(codeToString(code_)).arg(value_, 16);
+ return QString("%1:%2:%3").arg(typeToString(_type)).arg(codeToString(_code)).arg(_value, 16);
}
- uint32_t qt_keysym() const
+ quint32 qtKeysym() const
{
- return value_ & ~MODIFIER_MASK;
+ return _value & ~MODIFIER_MASK;
}
- uint32_t qt_modifiers() const
+ quint32 qtModifiers() const
{
- return value_ & MODIFIER_MASK;
+ return _value & MODIFIER_MASK;
}
// We want to enable InputEvent as a translation context, so we fake the tr method:
@@ -222,14 +222,14 @@ public:
struct SpecialInputEventDescription
{
- SpecialInputEventDescription(uint16_t type, uint16_t code, uint32_t value, QString const& description_)
+ SpecialInputEventDescription(quint16 type, quint16 code, quint32 value, QString const& description_)
: type(type), code(code), value(value), description(description_)
{
}
- uint16_t type;
- uint16_t code;
- uint32_t value;
+ quint16 type;
+ quint16 code;
+ quint32 value;
QString description;
InputEvent toEvent() const