| 1 | diff --git a/mythtv/libs/libmythservicecontracts/services/frontendServices.h b/mythtv/libs/libmythservicecontracts/services/frontendServices.h
|
|---|
| 2 | index 00cfda5..2eb4933 100644
|
|---|
| 3 | --- a/mythtv/libs/libmythservicecontracts/services/frontendServices.h
|
|---|
| 4 | +++ b/mythtv/libs/libmythservicecontracts/services/frontendServices.h
|
|---|
| 5 | @@ -8,12 +8,13 @@
|
|---|
| 6 | class SERVICE_PUBLIC FrontendServices : public Service
|
|---|
| 7 | {
|
|---|
| 8 | Q_OBJECT
|
|---|
| 9 | - Q_CLASSINFO( "version", "2.0" );
|
|---|
| 10 | + Q_CLASSINFO( "version", "2.1" );
|
|---|
| 11 | Q_CLASSINFO( "SendMessage_Method", "POST" )
|
|---|
| 12 | Q_CLASSINFO( "SendNotification_Method", "POST" )
|
|---|
| 13 | Q_CLASSINFO( "SendAction_Method", "POST" )
|
|---|
| 14 | Q_CLASSINFO( "PlayRecording_Method", "POST" )
|
|---|
| 15 | Q_CLASSINFO( "PlayVideo_Method", "POST" )
|
|---|
| 16 | + Q_CLASSINFO( "SendKey_Method", "POST" )
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | public:
|
|---|
| 20 | @@ -50,6 +51,7 @@ class SERVICE_PUBLIC FrontendServices : public Service
|
|---|
| 21 | bool UseBookmark) = 0;
|
|---|
| 22 | virtual QStringList GetContextList(void) = 0;
|
|---|
| 23 | virtual DTC::FrontendActionList* GetActionList(const QString &Context) = 0;
|
|---|
| 24 | + virtual bool SendKey(const QString &Key) = 0;
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | };
|
|---|
| 28 | diff --git a/mythtv/programs/mythfrontend/services/frontend.cpp b/mythtv/programs/mythfrontend/services/frontend.cpp
|
|---|
| 29 | index de4f3c8..83621fd 100644
|
|---|
| 30 | --- a/mythtv/programs/mythfrontend/services/frontend.cpp
|
|---|
| 31 | +++ b/mythtv/programs/mythfrontend/services/frontend.cpp
|
|---|
| 32 | @@ -1,5 +1,6 @@
|
|---|
| 33 | #include <QCoreApplication>
|
|---|
| 34 | #include <QKeyEvent>
|
|---|
| 35 | +#include <QEvent>
|
|---|
| 36 |
|
|---|
| 37 | #include <unistd.h> // for usleep
|
|---|
| 38 |
|
|---|
| 39 | @@ -315,3 +316,124 @@ void Frontend::InitialiseActions(void)
|
|---|
| 40 | foreach (QString actions, gActionList)
|
|---|
| 41 | LOG(VB_GENERAL, LOG_DEBUG, LOC + QString("Action: %1").arg(actions));
|
|---|
| 42 | }
|
|---|
| 43 | +
|
|---|
| 44 | +bool Frontend::SendKey(const QString &sKey)
|
|---|
| 45 | +{
|
|---|
| 46 | + int keyCode;
|
|---|
| 47 | + int ret = false;
|
|---|
| 48 | + QObject *keyDest = NULL;
|
|---|
| 49 | + QKeyEvent *event = NULL;
|
|---|
| 50 | + QMap <QString, int> keyMap;
|
|---|
| 51 | + QString keyText;
|
|---|
| 52 | + QString msg;
|
|---|
| 53 | +
|
|---|
| 54 | + keyMap["up"] = Qt::Key_Up;
|
|---|
| 55 | + keyMap["down"] = Qt::Key_Down;
|
|---|
| 56 | + keyMap["left"] = Qt::Key_Left;
|
|---|
| 57 | + keyMap["right"] = Qt::Key_Right;
|
|---|
| 58 | + keyMap["home"] = Qt::Key_Home;
|
|---|
| 59 | + keyMap["end"] = Qt::Key_End;
|
|---|
| 60 | + keyMap["enter"] = Qt::Key_Enter;
|
|---|
| 61 | + keyMap["return"] = Qt::Key_Return;
|
|---|
| 62 | + keyMap["pageup"] = Qt::Key_PageUp;
|
|---|
| 63 | + keyMap["pagedown"] = Qt::Key_PageDown;
|
|---|
| 64 | + keyMap["escape"] = Qt::Key_Escape;
|
|---|
| 65 | + keyMap["tab"] = Qt::Key_Tab;
|
|---|
| 66 | + keyMap["backtab"] = Qt::Key_Backtab;
|
|---|
| 67 | + keyMap["space"] = Qt::Key_Space;
|
|---|
| 68 | + keyMap["backspace"] = Qt::Key_Backspace;
|
|---|
| 69 | + keyMap["insert"] = Qt::Key_Insert;
|
|---|
| 70 | + keyMap["delete"] = Qt::Key_Delete;
|
|---|
| 71 | + keyMap["plus"] = Qt::Key_Plus;
|
|---|
| 72 | + keyMap["comma"] = Qt::Key_Comma;
|
|---|
| 73 | + keyMap["minus"] = Qt::Key_Minus;
|
|---|
| 74 | + keyMap["underscore"] = Qt::Key_Underscore;
|
|---|
| 75 | + keyMap["period"] = Qt::Key_Period;
|
|---|
| 76 | + keyMap["numbersign"] = Qt::Key_NumberSign;
|
|---|
| 77 | + keyMap["poundsign"] = Qt::Key_NumberSign;
|
|---|
| 78 | + keyMap["hash"] = Qt::Key_NumberSign;
|
|---|
| 79 | + keyMap["bracketleft"] = Qt::Key_BracketLeft;
|
|---|
| 80 | + keyMap["bracketright"] = Qt::Key_BracketRight;
|
|---|
| 81 | + keyMap["backslash"] = Qt::Key_Backslash;
|
|---|
| 82 | + keyMap["dollar"] = Qt::Key_Dollar;
|
|---|
| 83 | + keyMap["percent"] = Qt::Key_Percent;
|
|---|
| 84 | + keyMap["ampersand"] = Qt::Key_Ampersand;
|
|---|
| 85 | + keyMap["parenleft"] = Qt::Key_ParenLeft;
|
|---|
| 86 | + keyMap["parenright"] = Qt::Key_ParenRight;
|
|---|
| 87 | + keyMap["asterisk"] = Qt::Key_Asterisk;
|
|---|
| 88 | + keyMap["question"] = Qt::Key_Question;
|
|---|
| 89 | + keyMap["slash"] = Qt::Key_Slash;
|
|---|
| 90 | + keyMap["colon"] = Qt::Key_Colon;
|
|---|
| 91 | + keyMap["semicolon"] = Qt::Key_Semicolon;
|
|---|
| 92 | + keyMap["less"] = Qt::Key_Less;
|
|---|
| 93 | + keyMap["equal"] = Qt::Key_Equal;
|
|---|
| 94 | + keyMap["greater"] = Qt::Key_Greater;
|
|---|
| 95 | + keyMap["f1"] = Qt::Key_F1;
|
|---|
| 96 | + keyMap["f2"] = Qt::Key_F2;
|
|---|
| 97 | + keyMap["f3"] = Qt::Key_F3;
|
|---|
| 98 | + keyMap["f4"] = Qt::Key_F4;
|
|---|
| 99 | + keyMap["f5"] = Qt::Key_F5;
|
|---|
| 100 | + keyMap["f6"] = Qt::Key_F6;
|
|---|
| 101 | + keyMap["f7"] = Qt::Key_F7;
|
|---|
| 102 | + keyMap["f8"] = Qt::Key_F8;
|
|---|
| 103 | + keyMap["f9"] = Qt::Key_F9;
|
|---|
| 104 | + keyMap["f10"] = Qt::Key_F10;
|
|---|
| 105 | + keyMap["f11"] = Qt::Key_F11;
|
|---|
| 106 | + keyMap["f12"] = Qt::Key_F12;
|
|---|
| 107 | + keyMap["f13"] = Qt::Key_F13;
|
|---|
| 108 | + keyMap["f14"] = Qt::Key_F14;
|
|---|
| 109 | + keyMap["f15"] = Qt::Key_F15;
|
|---|
| 110 | + keyMap["f16"] = Qt::Key_F16;
|
|---|
| 111 | + keyMap["f17"] = Qt::Key_F17;
|
|---|
| 112 | + keyMap["f18"] = Qt::Key_F18;
|
|---|
| 113 | + keyMap["f19"] = Qt::Key_F19;
|
|---|
| 114 | + keyMap["f20"] = Qt::Key_F20;
|
|---|
| 115 | + keyMap["f21"] = Qt::Key_F21;
|
|---|
| 116 | + keyMap["f22"] = Qt::Key_F22;
|
|---|
| 117 | + keyMap["f23"] = Qt::Key_F23;
|
|---|
| 118 | + keyMap["f24"] = Qt::Key_F24;
|
|---|
| 119 | +
|
|---|
| 120 | + if (GetMythMainWindow())
|
|---|
| 121 | + keyDest = GetMythMainWindow();
|
|---|
| 122 | + else
|
|---|
| 123 | + {
|
|---|
| 124 | + LOG(VB_UPNP, LOG_WARNING,
|
|---|
| 125 | + LOC + QString("ERROR: Application has no main window!"));
|
|---|
| 126 | + return ret;
|
|---|
| 127 | + }
|
|---|
| 128 | +
|
|---|
| 129 | + if (GetMythMainWindow()->currentWidget())
|
|---|
| 130 | + keyDest = GetMythMainWindow()->currentWidget()->focusWidget();
|
|---|
| 131 | +
|
|---|
| 132 | + if (!sKey.isEmpty() && keyMap.contains(sKey.toLower()))
|
|---|
| 133 | + {
|
|---|
| 134 | + keyCode = keyMap[sKey.toLower()];
|
|---|
| 135 | + ret = true;
|
|---|
| 136 | + }
|
|---|
| 137 | + else if (sKey.size() == 1)
|
|---|
| 138 | + {
|
|---|
| 139 | + keyCode = (int) sKey.toAscii().data()[0] & 0x7f;
|
|---|
| 140 | + ret = true;
|
|---|
| 141 | + }
|
|---|
| 142 | + else
|
|---|
| 143 | + msg = QString("Unknown Key: %1").arg(sKey);
|
|---|
| 144 | +
|
|---|
| 145 | + if (ret)
|
|---|
| 146 | + {
|
|---|
| 147 | + GetMythUI()->ResetScreensaver();
|
|---|
| 148 | +
|
|---|
| 149 | + event = new QKeyEvent(QEvent::KeyPress, keyCode, Qt::NoModifier,
|
|---|
| 150 | + keyText);
|
|---|
| 151 | + QCoreApplication::postEvent(keyDest, event);
|
|---|
| 152 | +
|
|---|
| 153 | + event = new QKeyEvent(QEvent::KeyRelease, keyCode, Qt::NoModifier,
|
|---|
| 154 | + keyText);
|
|---|
| 155 | + QCoreApplication::postEvent(keyDest, event);
|
|---|
| 156 | +
|
|---|
| 157 | + msg = QString("SendKey sent: %1").arg(sKey);
|
|---|
| 158 | + }
|
|---|
| 159 | +
|
|---|
| 160 | + LOG(VB_UPNP, LOG_INFO, LOC + msg);
|
|---|
| 161 | +
|
|---|
| 162 | + return ret;
|
|---|
| 163 | +}
|
|---|
| 164 | diff --git a/mythtv/programs/mythfrontend/services/frontend.h b/mythtv/programs/mythfrontend/services/frontend.h
|
|---|
| 165 | index 5761faa..41657ab 100644
|
|---|
| 166 | --- a/mythtv/programs/mythfrontend/services/frontend.h
|
|---|
| 167 | +++ b/mythtv/programs/mythfrontend/services/frontend.h
|
|---|
| 168 | @@ -42,6 +42,7 @@ class Frontend : public FrontendServices
|
|---|
| 169 |
|
|---|
| 170 | static bool IsValidAction(const QString &action);
|
|---|
| 171 | static void InitialiseActions(void);
|
|---|
| 172 | + bool SendKey(const QString &Key);
|
|---|
| 173 |
|
|---|
| 174 | protected:
|
|---|
| 175 | static QStringList gActionList;
|
|---|