diff --git a/mythtv/libs/libmythui/cecadapter.cpp b/mythtv/libs/libmythui/cecadapter.cpp
index 00a8c73..a761e32 100644
a
|
b
|
class CECAdapterPriv |
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
| 129 | // initialise the host on which libCEC is running |
| 130 | adapter->InitVideoStandalone(); |
| 131 | |
129 | 132 | // find adapters |
130 | 133 | cec_adapter *devices = new cec_adapter[MAX_CEC_DEVICES]; |
131 | 134 | uint8_t num_devices = adapter->FindAdapters(devices, MAX_CEC_DEVICES, NULL); |
… |
… |
class CECAdapterPriv |
231 | 234 | |
232 | 235 | switch (command.opcode) |
233 | 236 | { |
234 | | // TODO |
| 237 | case CEC_OPCODE_MENU_REQUEST: |
| 238 | cec_keypress key; |
| 239 | key.keycode = CEC_USER_CONTROL_CODE_ROOT_MENU; |
| 240 | key.duration = 5; |
| 241 | HandleKeyPress(key); |
| 242 | // SetMenuState could be used to disable the TV menu here |
| 243 | // That may be a user-unfriendly thing to do |
| 244 | // So they have to see both the TV menu and the MythTV menu |
| 245 | break; |
| 246 | |
235 | 247 | default: |
236 | 248 | break; |
237 | 249 | } |
… |
… |
class CECAdapterPriv |
252 | 264 | |
253 | 265 | QString code; |
254 | 266 | int action = 0; |
| 267 | Qt::KeyboardModifier modifier = Qt::NoModifier; |
255 | 268 | switch (key.keycode) |
256 | 269 | { |
257 | 270 | case CEC_USER_CONTROL_CODE_NUMBER0: |
… |
… |
class CECAdapterPriv |
365 | 378 | case CEC_USER_CONTROL_CODE_PLAY: |
366 | 379 | action = Qt::Key_P; |
367 | 380 | code = "PLAY"; |
| 381 | // Play set to control-p to differentiate from pause |
| 382 | modifier = Qt::ControlModifier; |
368 | 383 | break; |
369 | 384 | case CEC_USER_CONTROL_CODE_PAUSE: |
370 | | action = Qt::Key_P; // same as play |
| 385 | action = Qt::Key_P; |
371 | 386 | code = "PAUSE"; |
372 | 387 | break; |
373 | 388 | case CEC_USER_CONTROL_CODE_STOP: |
… |
… |
class CECAdapterPriv |
566 | 581 | return 1; |
567 | 582 | |
568 | 583 | GetMythUI()->ResetScreensaver(); |
569 | | QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, action, Qt::NoModifier); |
| 584 | QKeyEvent* ke = new QKeyEvent(QEvent::KeyPress, action, modifier); |
570 | 585 | qApp->postEvent(GetMythMainWindow(), (QEvent*)ke); |
571 | 586 | |
572 | 587 | return 1; |
… |
… |
CECAdapter::CECAdapter() : MThread("CECAdapter"), m_priv(new CECAdapterPriv) |
721 | 736 | |
722 | 737 | void CECAdapter::run() |
723 | 738 | { |
724 | | for (;;) { |
| 739 | RunProlog(); |
| 740 | while (IsValid()) { |
725 | 741 | // Note that a lock is used because the QWaitCondition needs it |
726 | 742 | // None of the other HandleActions callers need the lock because |
727 | 743 | // they call HandleActions at open/close time, when |
728 | 744 | // nothing else can be calling it.... |
729 | 745 | gHandleActionsLock->lock(); |
730 | 746 | gActionsReady->wait(gHandleActionsLock); |
731 | | m_priv->HandleActions(); |
| 747 | if (IsValid()) { |
| 748 | m_priv->HandleActions(); |
| 749 | } |
732 | 750 | gHandleActionsLock->unlock(); |
733 | 751 | } |
| 752 | RunEpilog(); |
734 | 753 | } |
735 | 754 | |
736 | 755 | CECAdapter::~CECAdapter() |
737 | 756 | { |
738 | 757 | QMutexLocker lock(gLock); |
739 | 758 | |
740 | | // stop thread |
741 | | if (isRunning()) |
742 | | { |
743 | | LOG(VB_GENERAL, LOG_DEBUG, LOC + "Stopping thread."); |
744 | | exit(); |
745 | | } |
746 | | |
747 | 759 | // delete the actual adapter |
748 | 760 | m_priv->Close(); |
| 761 | // Free the thread |
| 762 | gActionsReady->wakeAll(); |
| 763 | // Wait for it to end |
| 764 | wait(); |
749 | 765 | } |
750 | 766 | |
751 | 767 | bool CECAdapter::IsValid(void) |
752 | 768 | { |
753 | | QMutexLocker lock(gLock); |
754 | 769 | return m_priv->valid; |
755 | 770 | } |
756 | 771 | |