Fix typo in rejecting invalid keycodes
[deb_libcec.git] / src / lib / CECClient.cpp
index a67b956c7cf5d71f2e94041a4a5b93dbc7b66083..837214f456f54e724c29032664087064875874f9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -973,10 +973,10 @@ void CCECClient::AddKey(bool bSendComboKey /* = false */)
     {
       key.duration = (unsigned int) (GetTimeMs() - m_buttontime);
 
-      cec_user_control_code comboKey(m_configuration.comboKey);
-      uint32_t iTimeoutMs(m_configuration.iComboKeyTimeoutMs);
-
-      if (key.duration > iTimeoutMs || m_iCurrentButton != comboKey || bSendComboKey)
+      if (key.duration > m_configuration.iComboKeyTimeoutMs ||
+          m_configuration.iComboKeyTimeoutMs == 0 ||
+          m_iCurrentButton != m_configuration.comboKey ||
+          bSendComboKey)
       {
         key.keycode = m_iCurrentButton;
 
@@ -995,7 +995,7 @@ void CCECClient::AddKey(bool bSendComboKey /* = false */)
 
 void CCECClient::AddKey(const cec_keypress &key)
 {
-  if (key.keycode > CEC_USER_CONTROL_CODE_MAX &&
+  if (key.keycode > CEC_USER_CONTROL_CODE_MAX ||
       key.keycode < CEC_USER_CONTROL_CODE_SELECT)
   {
     // send back the previous key if there is one
@@ -1009,7 +1009,7 @@ void CCECClient::AddKey(const cec_keypress &key)
 
   {
     CLockObject lock(m_mutex);
-    if (m_iCurrentButton == comboKey && key.duration == 0)
+    if (m_configuration.iComboKeyTimeoutMs > 0 && m_iCurrentButton == comboKey && key.duration == 0)
     {
       // stop + ok -> exit
       if (key.keycode == CEC_USER_CONTROL_CODE_SELECT)
@@ -1070,7 +1070,7 @@ void CCECClient::CheckKeypressTimeout(void)
         m_configuration.iComboKeyTimeoutMs : CEC_DEFAULT_COMBO_TIMEOUT_MS);
 
     if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN &&
-          ((m_iCurrentButton == comboKey && iNow - m_buttontime > iTimeoutMs) ||
+          ((m_iCurrentButton == comboKey && iTimeoutMs > 0 && iNow - m_buttontime > iTimeoutMs) ||
           (m_iCurrentButton != comboKey && iNow - m_buttontime > CEC_BUTTON_TIMEOUT)))
     {
       key.duration = (unsigned int) (iNow - m_buttontime);