diff options
Diffstat (limited to 'src/input/inputEvent.cpp')
-rw-r--r-- | src/input/inputEvent.cpp | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/src/input/inputEvent.cpp b/src/input/inputEvent.cpp index 9b69a3a..cff1ac8 100644 --- a/src/input/inputEvent.cpp +++ b/src/input/inputEvent.cpp @@ -1,12 +1,22 @@ /* - * inputEvent.cpp - * - * Created on: 06.09.2010 - * Author: brs + # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg + # + # This program is free software distributed under the GPL version 2. + # See http://openslx.org/COPYING + # + # If you have any feedback please consult http://openslx.org/feedback and + # send your suggestions, praise, or complaints to feedback@openslx.org + # + # General information about OpenSLX can be found at http://openslx.org/ + # -------------------------------------------------------------------------- + # inputEvent.h: + # - Definition of an input event - utility routines + # -------------------------------------------------------------------------- */ #include <QBuffer> #include <QByteArray> +#include <QCoreApplication> #include <QDataStream> #include <QKeyEvent> #include <QMouseEvent> @@ -15,18 +25,29 @@ #include <src/util/consoleLogger.h> // We implement operators to serialize and load an event: +/** + * Serialize an input event to a \ref QDataStream. + */ QDataStream& operator <<(QDataStream& ostrm, InputEvent const& evt) { - ostrm << evt.type_ << evt.code_ << evt.value_; + ostrm << evt._type << evt._code << evt._value; return ostrm; } +/** + * Load an input event from a \ref QDataStream. + */ QDataStream& operator >>(QDataStream& istrm, InputEvent& evt) { - istrm >> evt.type_ >> evt.code_ >> evt.value_; + istrm >> evt._type >> evt._code >> evt._value; return istrm; } +/** + * Produce a string-encodeable representation of an input event. + * This consists of a base64-encoded binary representation as + * generated by \ref{operator<<(QDataStream&, InputEvent const&)}. + */ void eventToString(InputEvent const& evt, QString& str) { QByteArray ba; @@ -37,6 +58,10 @@ void eventToString(InputEvent const& evt, QString& str) str = QString::fromAscii(ba.toBase64()); } +/** + * Decode the string representation of an input-event produced by + * \ref eventToString. + */ bool eventFromString(QString const& str, InputEvent& evt) { // TODO This does not do proper error checking. Only use from trusted sources! @@ -97,3 +122,34 @@ InputEvent InputEvent::keyboardRelease(int key, int mods) return InputEvent(ET_KEY, EC_RELEASE, value); } +#define describe(list, description, type, code, value) \ + list.append(SpecialInputEventDescription(InputEvent::type, InputEvent::code, value, description)) + +QList<SpecialInputEventDescription> SpecialInputEventDescription::describeSpecialEvents() +{ + QList<SpecialInputEventDescription> list; + describe(list, InputEvent::tr("Say Hello"), ET_SPECIAL, EC_SAY_HELLO, 0); + describe(list, InputEvent::tr("Reboot"), ET_SPECIAL, EC_REBOOT, 0); + describe(list, InputEvent::tr("Kill X Server"), ET_SPECIAL, EC_KILL_X, 0); + describe(list, InputEvent::tr("Reboot immediately"), ET_SPECIAL, EC_SYSRQ, 'b'); + describe(list, InputEvent::tr("Power off immediately"), ET_SPECIAL, EC_SYSRQ, 'o'); + describe(list, InputEvent::tr("Crash System"), ET_SPECIAL, EC_SYSRQ, 'c'); + describe(list, InputEvent::tr("Turn off raw keyboard mode"), ET_SPECIAL, EC_SYSRQ, 'r'); + describe(list, InputEvent::tr("Send SIGTERM to all"), ET_SPECIAL, EC_SYSRQ, 'e'); + describe(list, InputEvent::tr("Send SIGKILL to all"), ET_SPECIAL, EC_SYSRQ, 'i'); + describe(list, InputEvent::tr("Kill all on this terminal"), ET_SPECIAL, EC_SYSRQ, 'k'); + describe(list, InputEvent::tr("Activate OOM killer"), ET_SPECIAL, EC_SYSRQ, 'f'); + describe(list, InputEvent::tr("Make real-time tasks niceable"), ET_SPECIAL, EC_SYSRQ, 'n'); + describe(list, InputEvent::tr("Force-thaw filesystems"), ET_SPECIAL, EC_SYSRQ, 'j'); + describe(list, InputEvent::tr("Sync all mounted filesystems"), ET_SPECIAL, EC_SYSRQ, 's'); + describe(list, InputEvent::tr("Remount all readonly"), ET_SPECIAL, EC_SYSRQ, 'u'); + describe(list, InputEvent::tr("Show all held locks"), ET_SPECIAL, EC_SYSRQ, 'd'); + describe(list, InputEvent::tr("Show stack traces"), ET_SPECIAL, EC_SYSRQ, 'l'); + describe(list, InputEvent::tr("Dump memory info"), ET_SPECIAL, EC_SYSRQ, 'm'); + describe(list, InputEvent::tr("Dump registers and flags"), ET_SPECIAL, EC_SYSRQ, 'p'); + describe(list, InputEvent::tr("Dump timers and clockevents"), ET_SPECIAL, EC_SYSRQ, 'q'); + describe(list, InputEvent::tr("Dump task list"), ET_SPECIAL, EC_SYSRQ, 't'); + describe(list, InputEvent::tr("Dump uninterruptible tasks"), ET_SPECIAL, EC_SYSRQ, 'w'); + describe(list, InputEvent::tr("Dump ftrace buffer"), ET_SPECIAL, EC_SYSRQ, 'z'); + return list; +} |