moved code that handles the previous keypress
[deb_libcec.git] / src / lib / CECClient.cpp
index e7ac9556349601af73230fbc73904c918ed8777d..0bbc081191652ba7b65a80bb88bd2070d5358e40 100644 (file)
@@ -802,6 +802,14 @@ bool CCECClient::GetCurrentConfiguration(libcec_configuration &configuration)
     configuration.bMonitorOnly            = m_configuration.bMonitorOnly;
   }
 
+  // client version 1.8.0
+  if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0)
+    configuration.cecVersion              = m_configuration.cecVersion;
+
+  // client version 1.8.2
+  if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_2)
+    configuration.adapterType             = m_configuration.adapterType;
+
   return true;
 }
 
@@ -859,6 +867,14 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
       m_configuration.bMonitorOnly = configuration.bMonitorOnly;
     }
 
+    // client version 1.8.0
+    if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0)
+      m_configuration.cecVersion   = configuration.cecVersion;
+
+    // client version 1.8.2
+    if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_2)
+      m_configuration.adapterType  = configuration.adapterType;
+
     // ensure that there is at least 1 device type set
     if (m_configuration.deviceTypes.IsEmpty())
       m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
@@ -956,9 +972,14 @@ void CCECClient::AddKey(void)
 
 void CCECClient::AddKey(const cec_keypress &key)
 {
+  // send back the previous key if there is one
+  AddKey();
+
   {
     CLockObject lock(m_mutex);
-    m_iCurrentButton = key.duration > 0 ? CEC_USER_CONTROL_CODE_UNKNOWN : key.keycode;
+    m_iCurrentButton = key.duration > 0 || key.keycode > CEC_USER_CONTROL_CODE_MAX ?
+        CEC_USER_CONTROL_CODE_UNKNOWN :
+        key.keycode;
     m_buttontime = key.duration > 0 ? 0 : GetTimeMs();
   }