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