102 toggleRemoteBasic = remoteMenu->addAction(QString("Basic Remote")); |
103 toggleRemoteBasic = remoteMenu->addAction(QString("Basic Remote")); |
103 toggleRemoteBasic->setCheckable(true); |
104 toggleRemoteBasic->setCheckable(true); |
104 |
105 |
105 toggleRemoteCallHandlingEx = remoteMenu->addAction(QString("Call Handl. Ex Remote")); |
106 toggleRemoteCallHandlingEx = remoteMenu->addAction(QString("Call Handl. Ex Remote")); |
106 toggleRemoteCallHandlingEx->setCheckable(true); |
107 toggleRemoteCallHandlingEx->setCheckable(true); |
107 |
108 |
|
109 toggleRemoteSideKeys = remoteMenu->addAction(QString("Side Keys Events")); |
|
110 toggleRemoteSideKeys->setCheckable(true); |
|
111 toggleRemoteSideKeys->setEnabled(false); // not implemented yet |
|
112 |
108 toggleRemoteExtEvents = remoteMenu->addAction(QString("Extended Remote Events")); |
113 toggleRemoteExtEvents = remoteMenu->addAction(QString("Extended Remote Events")); |
109 toggleRemoteExtEvents->setCheckable(true); |
114 toggleRemoteExtEvents->setCheckable(true); |
110 |
115 |
111 connect(toggleRemoteBasic, SIGNAL(toggled(bool)), this, SLOT(enableRemBasic(bool))); |
116 connect(toggleRemoteBasic, SIGNAL(toggled(bool)), this, SLOT(enableRemBasic(bool))); |
112 connect(toggleRemoteCallHandlingEx, SIGNAL(toggled(bool)), this, SLOT(enableRemCallHandlingEx(bool))); |
117 connect(toggleRemoteCallHandlingEx, SIGNAL(toggled(bool)), this, SLOT(enableRemCallHandlingEx(bool))); |
|
118 connect(toggleRemoteSideKeys, SIGNAL(toggled(bool)), this, SLOT(enableRemoteSideKeys(bool))); |
113 connect(toggleRemoteExtEvents, SIGNAL(toggled(bool)), this, SLOT(enableRemoteExtEvents(bool))); |
119 connect(toggleRemoteExtEvents, SIGNAL(toggled(bool)), this, SLOT(enableRemoteExtEvents(bool))); |
114 |
120 |
115 connect(remoteAllOn, SIGNAL(triggered(bool)), this, SLOT(remoteAll(bool))); |
121 connect(remoteAllOn, SIGNAL(triggered(bool)), this, SLOT(remoteAll(bool))); |
116 connect(remoteAllOff, SIGNAL(triggered(bool)), this, SLOT(remoteNone(bool))); |
122 connect(remoteAllOff, SIGNAL(triggered(bool)), this, SLOT(remoteNone(bool))); |
117 |
123 |
204 TX_EXIT |
212 TX_EXIT |
205 } |
213 } |
206 |
214 |
207 void KeyCaptureTestApp::addTextLine(QString aText) |
215 void KeyCaptureTestApp::addTextLine(QString aText) |
208 { |
216 { |
|
217 TX_ENTRY |
209 TX_LOG_ARGS( QString("aText=%1").arg(aText)); |
218 TX_LOG_ARGS( QString("aText=%1").arg(aText)); |
210 if ( !aText.endsWith("\n")) |
219 if ( !aText.endsWith("\n")) |
211 aText = aText + "\n"; |
220 aText = aText + "\n"; |
212 QString msg = mTextArea->toPlainText(); |
221 QString msg = mTextArea->toPlainText(); |
213 msg = aText + msg; |
222 msg = aText + msg; |
214 mTextArea->setPlainText(msg); |
223 mTextArea->setPlainText(msg); |
|
224 TX_EXIT |
215 } |
225 } |
216 |
226 |
217 bool KeyCaptureTestApp::event(QEvent *ev) |
227 bool KeyCaptureTestApp::event(QEvent *ev) |
218 { |
228 { |
219 processEvent(ev); |
229 TX_ENTRY |
220 return QMainWindow::event(ev); |
230 // processEvent(QString("[E]"), ev); |
|
231 bool ret = QMainWindow::event(ev); |
|
232 TX_EXIT_ARGS("ret=" << ret); |
|
233 return ret; |
221 } |
234 } |
222 |
235 |
223 bool KeyCaptureTestApp::eventFilter(QObject *o, QEvent *ev) |
236 bool KeyCaptureTestApp::eventFilter(QObject *o, QEvent *ev) |
224 { |
237 { |
225 processEvent(ev); |
238 TX_ENTRY |
226 return QMainWindow::eventFilter(o, ev); |
239 // processEvent(QString("[F]"), ev); |
227 } |
240 bool ret=QMainWindow::eventFilter(o, ev); |
228 |
241 TX_EXIT_ARGS("ret=" << ret); |
229 void KeyCaptureTestApp::processEvent(QEvent *ev) |
242 return ret; |
230 { |
243 } |
|
244 |
|
245 void KeyCaptureTestApp::processEvent(const QString &prefix, QEvent *ev) |
|
246 { |
|
247 TX_ENTRY_ARGS(reinterpret_cast<int>(ev)); |
231 if (ev){ |
248 if (ev){ |
232 if (ev->type() == QEvent::KeyPress){ |
249 if (ev->type() == QEvent::KeyPress){ |
233 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
250 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
234 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
251 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
235 |
252 |
236 addTextLine(QString("KeyPress:%1\n").arg(keyName)); |
253 addTextLine(prefix + QString("KeyPress:%1\n").arg(keyName)); |
237 } else if (ev->type() == QEvent::KeyRelease){ |
254 } else if (ev->type() == QEvent::KeyRelease){ |
238 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
255 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
239 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
256 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
240 |
257 |
241 addTextLine(QString("KeyRelease:%1\n").arg(keyName)); |
258 addTextLine(prefix + QString("KeyRelease:%1\n").arg(keyName)); |
242 } else if (ev->type() == XQKeyCapture::remoteEventType_KeyPress()){ |
259 } else if (ev->type() == XQKeyCapture::remoteEventType_KeyPress()){ |
243 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
260 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
244 |
261 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
|
262 |
|
263 addTextLine(prefix + QString("KeyPress:%1 (native:%2)\n").arg(keyName).arg(static_cast<int>(keyEvent->nativeVirtualKey()))); |
|
264 } else if (ev->type() == XQKeyCapture::remoteEventType_KeyRelease()){ |
|
265 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
245 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
266 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
246 |
267 |
247 addTextLine(QString("KeyPress:%1\n").arg(keyName)); |
268 addTextLine(prefix + QString("KeyRelease:%1 (native:%2)\n").arg(keyName).arg(static_cast<int>(keyEvent->nativeVirtualKey()))); |
248 addTextLine(QString("Native virtual key:%1\n").arg((int)keyEvent->nativeVirtualKey())); |
|
249 } else if (ev->type() == XQKeyCapture::remoteEventType_KeyRelease()){ |
|
250 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); |
|
251 |
|
252 QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); |
|
253 |
|
254 addTextLine(QString("KeyRelease:%1\n").arg(keyName)); |
|
255 addTextLine(QString("Native virtual key:%1\n").arg((int)keyEvent->nativeVirtualKey())); |
|
256 } |
269 } |
257 } |
270 } |
|
271 TX_EXIT_ARGS(reinterpret_cast<int>(ev)); |
258 } |
272 } |
259 |
273 |
260 void KeyCaptureTestApp::enableRemBasic(bool enable) |
274 void KeyCaptureTestApp::enableRemBasic(bool enable) |
261 { |
275 { |
262 if (enable) { |
276 if (enable) { |
263 addTextLine("Remote Basic enabled"); |
277 addTextLine("Remote Basic enabled"); |
264 QFlags<XQKeyCapture::CapturingFlag> flags = XQKeyCapture::CaptureNone; |
278 QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureBasic; |
265 if (toggleRemoteExtEvents->isChecked()) |
279 mKeyCapture->captureRemoteKeys(flags); |
266 flags = XQKeyCapture::CaptureEnableRemoteExtEvents; |
|
267 if (toggleRemoteCallHandlingEx->isChecked()) |
|
268 flags |= XQKeyCapture::CaptureCallHandlingExt; |
|
269 mKeyCapture->captureRemoteKeys(flags |= XQKeyCapture::CaptureBasic); |
|
270 } else { |
280 } else { |
271 addTextLine("Remote Basic disabled"); |
281 addTextLine("Remote Basic disabled"); |
272 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureBasic); |
282 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureBasic); |
273 } |
283 } |
274 } |
284 } |
275 |
285 |
|
286 void KeyCaptureTestApp::enableRemoteSideKeys(bool enable) |
|
287 { |
|
288 if (enable) { |
|
289 addTextLine("Side Keys enabled"); |
|
290 QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureSideKeys; |
|
291 mKeyCapture->captureRemoteKeys(flags); |
|
292 } else { |
|
293 addTextLine("Side Keys disabled"); |
|
294 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureSideKeys); |
|
295 } |
|
296 } |
|
297 |
276 void KeyCaptureTestApp::enableRemCallHandlingEx(bool enable) |
298 void KeyCaptureTestApp::enableRemCallHandlingEx(bool enable) |
277 { |
299 { |
278 if (enable) { |
300 if (enable) { |
279 addTextLine("Remote Call Handling Ext. enabled"); |
301 addTextLine("Remote Call Handling Ext. enabled"); |
280 QFlags<XQKeyCapture::CapturingFlag> flags = XQKeyCapture::CaptureNone; |
302 QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureCallHandlingExt; |
281 if (toggleRemoteExtEvents->isChecked()) |
303 mKeyCapture->captureRemoteKeys(flags); |
282 flags = XQKeyCapture::CaptureEnableRemoteExtEvents; |
|
283 if (toggleRemoteBasic->isChecked()) |
|
284 flags |= XQKeyCapture::CaptureBasic; |
|
285 mKeyCapture->captureRemoteKeys(flags | XQKeyCapture::CaptureCallHandlingExt); |
|
286 } else { |
304 } else { |
287 addTextLine("Remote Call Handling Ext. disabled"); |
305 addTextLine("Remote Call Handling Ext. disabled"); |
288 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt); |
306 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt); |
289 } |
307 } |
290 } |
308 } |
291 |
309 |
292 void KeyCaptureTestApp::enableRemoteExtEvents(bool enable) |
310 void KeyCaptureTestApp::enableRemoteExtEvents(bool enable) |
293 { |
311 { |
294 if (enable) { |
312 if (enable) { |
295 addTextLine("Remote Events Ext. enabled"); |
313 addTextLine("Remote Events Ext. enabled"); |
296 QFlags<XQKeyCapture::CapturingFlag> flags = XQKeyCapture::CaptureNone; |
314 QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureEnableRemoteExtEvents; |
297 if (toggleRemoteCallHandlingEx->isChecked()) |
315 mKeyCapture->captureRemoteKeys(flags); |
298 flags = XQKeyCapture::CaptureCallHandlingExt; |
|
299 if (toggleRemoteBasic->isChecked()) |
|
300 flags |= XQKeyCapture::CaptureBasic; |
|
301 mKeyCapture->captureRemoteKeys(flags | XQKeyCapture::CaptureEnableRemoteExtEvents); |
|
302 } else { |
316 } else { |
303 addTextLine("Remote Events Ext. disabled"); |
317 addTextLine("Remote Events Ext. disabled"); |
304 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureEnableRemoteExtEvents); |
318 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureEnableRemoteExtEvents); |
305 } |
319 } |
306 } |
320 } |
311 toggleRemoteBasic->setChecked(true); |
325 toggleRemoteBasic->setChecked(true); |
312 toggleRemoteCallHandlingEx->setChecked(true); |
326 toggleRemoteCallHandlingEx->setChecked(true); |
313 toggleRemoteExtEvents->setChecked(true); |
327 toggleRemoteExtEvents->setChecked(true); |
314 addTextLine("Remote: enable all"); |
328 addTextLine("Remote: enable all"); |
315 mKeyCapture->captureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt | XQKeyCapture::CaptureBasic | |
329 mKeyCapture->captureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt | XQKeyCapture::CaptureBasic | |
316 XQKeyCapture::CaptureEnableRemoteExtEvents); |
330 XQKeyCapture::CaptureSideKeys | XQKeyCapture::CaptureEnableRemoteExtEvents); |
317 } |
331 } |
318 |
332 |
319 void KeyCaptureTestApp::remoteNone(bool enable) |
333 void KeyCaptureTestApp::remoteNone(bool enable) |
320 { |
334 { |
321 Q_UNUSED(enable); |
335 Q_UNUSED(enable); |
322 toggleRemoteBasic->setChecked(false); |
336 toggleRemoteBasic->setChecked(false); |
323 toggleRemoteCallHandlingEx->setChecked(false); |
337 toggleRemoteCallHandlingEx->setChecked(false); |
324 toggleRemoteExtEvents->setChecked(false); |
338 toggleRemoteExtEvents->setChecked(false); |
325 addTextLine("Remote: disable all"); |
339 addTextLine("Remote: disable all"); |
326 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt | XQKeyCapture::CaptureBasic | |
340 mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt | XQKeyCapture::CaptureBasic | |
327 XQKeyCapture::CaptureEnableRemoteExtEvents); |
341 XQKeyCapture::CaptureSideKeys | XQKeyCapture::CaptureEnableRemoteExtEvents); |
328 } |
342 } |
|
343 |
|
344 QFlags<XQKeyCapture::CapturingFlag> KeyCaptureTestApp::getFlags() |
|
345 { |
|
346 QFlags<XQKeyCapture::CapturingFlag> flags = XQKeyCapture::CaptureNone |
|
347 // remote call handling extension |
|
348 | (toggleRemoteCallHandlingEx->isChecked() |
|
349 ? XQKeyCapture::CaptureCallHandlingExt : XQKeyCapture::CaptureNone) |
|
350 // basic remcon accesory events |
|
351 | (toggleRemoteBasic->isChecked() |
|
352 ? XQKeyCapture::CaptureBasic : XQKeyCapture::CaptureNone) |
|
353 // side keys api |
|
354 | (toggleRemoteSideKeys->isChecked() |
|
355 ? XQKeyCapture::CaptureSideKeys : XQKeyCapture::CaptureNone) |
|
356 // generate extevents |
|
357 | (toggleRemoteExtEvents->isChecked() |
|
358 ? XQKeyCapture::CaptureEnableRemoteExtEvents : XQKeyCapture::CaptureNone); |
|
359 return flags; |
|
360 } |