summaryrefslogtreecommitdiffstats
path: root/src/input/inputEvent.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/inputEvent.h')
-rw-r--r--src/input/inputEvent.h49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/input/inputEvent.h b/src/input/inputEvent.h
index 7a64bfc..2f557ce 100644
--- a/src/input/inputEvent.h
+++ b/src/input/inputEvent.h
@@ -18,9 +18,7 @@
#define INPUTEVENT_H_
#include <cassert>
-#include <string>
-#include <sstream>
-#include <stdint.h>
+#include <QString>
#ifndef __linux
# error "This will only run on a Linux system. Porting is required for other systems."
@@ -46,8 +44,13 @@ private:
// 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) : type_(type), code_(code), value_(value)
+ InputEvent(uint16_t type, uint16_t code, uint32_t value = 0) : type_(type), code_(code), value_(value)
+ {
+ }
+
+ InputEvent(InputEvent const& other) : type_(other.type_), code_(other.code_), value_(other.value_)
{
}
@@ -158,7 +161,7 @@ public:
return (value_ & 0xffff);
}
- static std::string typeToString(uint16_t type)
+ static QString typeToString(uint16_t type)
{
switch(type)
{
@@ -171,13 +174,11 @@ public:
case ET_SPECIAL:
return "SPECIAL";
default:
- std::ostringstream s;
- s << std::hex << type;
- return s.str();
+ return QString::number(type, 16);
}
}
- static std::string codeToString(uint16_t code)
+ static QString codeToString(uint16_t code)
{
switch(code)
{
@@ -192,17 +193,13 @@ public:
case EC_KILL_X:
return "KILL_X";
default:
- std::ostringstream s;
- s << std::hex << code;
- return s.str();
+ return QString::number(code, 16);
}
}
- std::string toString() const
+ QString toString() const
{
- std::ostringstream s;
- s << typeToString(type_) << ':' << codeToString(code_) << ':' << std::hex << value_;
- return s.str();
+ return QString("%1:%2:%3").arg(typeToString(type_)).arg(codeToString(code_)).arg(value_, 16);
}
uint32_t qt_keysym() const
@@ -216,4 +213,24 @@ public:
}
};
+struct SpecialInputEventDescription
+{
+ SpecialInputEventDescription(uint16_t type, uint16_t code, uint32_t value, QString const& description_)
+ : type(type), code(code), value(value), description(description_)
+ {
+ }
+
+ uint16_t type;
+ uint16_t code;
+ uint32_t value;
+ QString description;
+
+ InputEvent toEvent() const
+ {
+ return InputEvent(type, code, value);
+ }
+
+ static QList<SpecialInputEventDescription> describeSpecialEvents();
+};
+
#endif /* INPUTEVENT_H_ */