fixed - only set m_iCurrentButton when the duration isn't known yet. fixes duplicate...
[deb_libcec.git] / src / lib / CECClient.cpp
index f85a53c2a6cae81bae6d17134ffa6b2fc3313f6e..dc4bbd88676f06ff6b9cf6bf9aebc87d521abae8 100644 (file)
@@ -940,21 +940,21 @@ void CCECClient::AddKey(const cec_keypress &key)
   // send back the previous key if there is one
   AddKey();
 
+  if (key.keycode > CEC_USER_CONTROL_CODE_MAX &&
+      key.keycode < CEC_USER_CONTROL_CODE_SELECT)
+    return;
+
   cec_keypress transmitKey(key);
 
   {
     CLockObject lock(m_mutex);
-    if (key.duration > 0 || key.keycode > CEC_USER_CONTROL_CODE_MAX)
-    {
-      transmitKey.keycode = CEC_USER_CONTROL_CODE_UNKNOWN;
-    }
-    else if (m_iCurrentButton == COMBO_KEY)
+    if (m_iCurrentButton == COMBO_KEY && key.duration == 0)
     {
       // stop + ok -> exit
       if (key.keycode == CEC_USER_CONTROL_CODE_SELECT)
         transmitKey.keycode = CEC_USER_CONTROL_CODE_EXIT;
       // stop + pause -> root menu
-      else if (key.keycode == CEC_USER_CONTROL_CODE_ROOT_MENU)
+      else if (key.keycode == CEC_USER_CONTROL_CODE_PAUSE)
         transmitKey.keycode = CEC_USER_CONTROL_CODE_ROOT_MENU;
       // stop + play -> dot (which is handled as context menu in xbmc)
       else if (key.keycode == CEC_USER_CONTROL_CODE_PLAY)
@@ -964,12 +964,18 @@ void CCECClient::AddKey(const cec_keypress &key)
         AddKey(true);
     }
 
-    m_iCurrentButton = transmitKey.keycode;
-    m_buttontime = m_iCurrentButton == CEC_USER_CONTROL_CODE_UNKNOWN || key.duration > 0 ? 0 : GetTimeMs();
+    if (key.duration == 0)
+    {
+      m_iCurrentButton = transmitKey.keycode;
+      m_buttontime = m_iCurrentButton == CEC_USER_CONTROL_CODE_UNKNOWN || key.duration > 0 ? 0 : GetTimeMs();
+    }
   }
 
-  LIB_CEC->AddLog(CEC_LOG_DEBUG, "key pressed: %s (%1x)", ToString(transmitKey.keycode), transmitKey.keycode);
-  CallbackAddKey(transmitKey);
+  if (key.keycode != COMBO_KEY || key.duration > 0)
+  {
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "key pressed: %s (%1x)", ToString(transmitKey.keycode), transmitKey.keycode);
+    CallbackAddKey(transmitKey);
+  }
 }
 
 void CCECClient::SetCurrentButton(const cec_user_control_code iButtonCode)
@@ -1255,7 +1261,7 @@ bool CCECClient::PollDevice(const cec_logical_address iAddress)
   CCECBusDevice *primary = GetPrimaryDevice();
   // poll the destination, with the primary as source
   if (primary)
-    return primary->TransmitPoll(iAddress, false);
+    return primary->TransmitPoll(iAddress, true);
 
   return m_processor ? m_processor->PollDevice(iAddress) : false;
 }