press & hold
[deb_libcec.git] / src / lib / CECClient.cpp
index 004d741379b27e97eb287112c641838d7fe9b23e..2e0045ced209f8f856406b990458d93840069d1d 100644 (file)
@@ -208,7 +208,7 @@ bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice, const uint8_
 
 void CCECClient::ResetPhysicalAddress(void)
 {
-  SetPhysicalAddress(m_configuration);
+  SetPhysicalAddress(CEC_DEFAULT_PHYSICAL_ADDRESS);
 }
 
 void CCECClient::SetPhysicalAddress(const libcec_configuration &configuration)
@@ -937,12 +937,13 @@ void CCECClient::AddKey(bool bSendComboKey /* = false */)
 
 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)
+  {
+    // send back the previous key if there is one
+    AddKey();
     return;
+  }
 
   cec_keypress transmitKey(key);
 
@@ -964,8 +965,19 @@ 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 (m_iCurrentButton == key.keycode)
+    {
+      m_buttontime = GetTimeMs();
+    }
+    else
+    {
+      AddKey();
+      if (key.duration == 0)
+      {
+        m_iCurrentButton = transmitKey.keycode;
+        m_buttontime = m_iCurrentButton == CEC_USER_CONTROL_CODE_UNKNOWN || key.duration > 0 ? 0 : GetTimeMs();
+      }
+    }
   }
 
   if (key.keycode != COMBO_KEY || key.duration > 0)