backwards compatibility for older client versions and the new double tap timeout...
[deb_libcec.git] / src / lib / CECClient.cpp
index 12ca4ceb753c4bda0a2cf9c94969502372dd9d8c..0bc9705ee5882887d84261a1a82dcb319676e34c 100644 (file)
@@ -876,7 +876,7 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
     m_configuration.bMonitorOnly               = configuration.bMonitorOnly;
     m_configuration.cecVersion                 = configuration.cecVersion;
     m_configuration.adapterType                = configuration.adapterType;
-    m_configuration.iDoubleTapTimeoutMs        = configuration.iDoubleTapTimeoutMs;
+    m_configuration.iDoubleTapTimeout50Ms      = configuration.iDoubleTapTimeout50Ms;
     m_configuration.deviceTypes.Add(configuration.deviceTypes[0]);
 
     if (m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5)
@@ -1457,6 +1457,14 @@ void CCECClient::CallbackAddCommand(const cec_command &command)
     m_configuration.callbacks->CBCecCommand(m_configuration.callbackParam, command);
 }
 
+uint32_t CCECClient::DoubleTapTimeoutMS(void)
+{
+  CLockObject lock(m_cbMutex);
+  return m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_2_0 ?
+      m_configuration.iDoubleTapTimeout50Ms * DOUBLE_TAP_TIMEOUT_UNIT_SIZE :
+      m_configuration.iDoubleTapTimeout50Ms;
+}
+
 void CCECClient::CallbackAddKey(const cec_keypress &key)
 {
   CLockObject lock(m_cbMutex);
@@ -1466,7 +1474,7 @@ void CCECClient::CallbackAddKey(const cec_keypress &key)
     int64_t now = GetTimeMs();
     if (m_lastKeypress.keycode != key.keycode ||
         key.duration > 0 ||
-        now - m_iLastKeypressTime >= m_configuration.iDoubleTapTimeoutMs * DOUBLE_TAP_TIMEOUT_UNIT_SIZE)
+        now - m_iLastKeypressTime >= DoubleTapTimeoutMS())
     {
       // no double tap
       if (key.duration == 0)