cec: fixed - correct initiator for keypresses
[deb_libcec.git] / src / lib / CECClient.cpp
index 013a7656209dc7ca9b76004291ba6a3f0f85c015..5b4529788487f19305da14379242bb5e4fcd82fd 100644 (file)
@@ -678,21 +678,19 @@ uint8_t CCECClient::SendMuteAudio(void)
 
 bool CCECClient::SendKeypress(const cec_logical_address iDestination, const cec_user_control_code key, bool bWait /* = true */)
 {
-  CCECBusDevice *device = GetPrimaryDevice();
   CCECBusDevice *dest = m_processor->GetDevice(iDestination);
 
-  return device && dest ?
-      device->TransmitKeypress(GetPrimaryLogicalAdddress(), key, bWait) :
+  return dest ?
+      dest->TransmitKeypress(GetPrimaryLogicalAdddress(), key, bWait) :
       false;
 }
 
 bool CCECClient::SendKeyRelease(const cec_logical_address iDestination, bool bWait /* = true */)
 {
-  CCECBusDevice *device = GetPrimaryDevice();
   CCECBusDevice *dest = m_processor->GetDevice(iDestination);
 
-  return device && dest ?
-      device->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait) :
+  return dest ?
+      dest->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait) :
       false;
 }
 
@@ -741,6 +739,13 @@ bool CCECClient::GetCurrentConfiguration(libcec_configuration &configuration)
     memcpy(configuration.strDeviceLanguage, m_configuration.strDeviceLanguage, 3);
     configuration.iFirmwareBuildDate      = m_configuration.iFirmwareBuildDate;
   }
+
+  // client version 1.6.3
+  if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3)
+  {
+    configuration.bMonitorOnly            = m_configuration.bMonitorOnly;
+  }
+
   return true;
 }
 
@@ -792,6 +797,12 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
       memcpy(m_configuration.strDeviceLanguage, configuration.strDeviceLanguage, 3);
     }
 
+    // client version 1.6.3
+    if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3)
+    {
+      m_configuration.bMonitorOnly = configuration.bMonitorOnly;
+    }
+
     // ensure that there is at least 1 device type set
     if (m_configuration.deviceTypes.IsEmpty())
       m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
@@ -1175,7 +1186,10 @@ bool CCECClient::SwitchMonitoring(bool bEnable)
     if (bEnable)
       return m_processor->UnregisterClient(this);
     else
+    {
+      m_configuration.bMonitorOnly = false;
       return m_processor->RegisterClient(this);
+    }
   }
 
   return false;