X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecSharp%2FLibCecSharp.cpp;h=7f0667a84066d92245f91ba1827c7aa263aabcdc;hb=c2ce7bd11448e5e84ccce0ff5e466ca82e713190;hp=d6154c36cfe09ddb733b9d37bd08bd0dca4cc0aa;hpb=d465a51a29a9a81aade24ba75591b8bac1a57d0c;p=deb_libcec.git diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index d6154c3..7f0667a 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -45,13 +45,15 @@ namespace CecSharp public: LibCecSharp(LibCECConfiguration ^config) { - CecCallbackMethods::EnableCallbacks(config->Callbacks); + m_callbacks = config->Callbacks; + CecCallbackMethods::EnableCallbacks(m_callbacks); if (!InitialiseLibCec(config)) throw gcnew Exception("Could not initialise LibCecSharp"); } LibCecSharp(String ^ strDeviceName, CecDeviceTypeList ^ deviceTypes) { + m_callbacks = gcnew CecCallbackMethods(); LibCECConfiguration ^config = gcnew LibCECConfiguration(); config->SetCallbacks(this); config->DeviceName = strDeviceName; @@ -89,7 +91,8 @@ namespace CecSharp { config.Clear(); - _snprintf_s(config.strDeviceName, 13, context->marshal_as(netConfig->DeviceName)); + const char *strDeviceName = context->marshal_as(netConfig->DeviceName); + memcpy_s(config.strDeviceName, 13, strDeviceName, 13); for (unsigned int iPtr = 0; iPtr < 5; iPtr++) config.deviceTypes.types[iPtr] = (cec_device_type)netConfig->DeviceTypes->Types[iPtr]; @@ -115,6 +118,27 @@ namespace CecSharp } config.bPowerOffScreensaver = netConfig->PowerOffScreensaver ? 1 : 0; config.bPowerOffOnStandby = netConfig->PowerOffOnStandby ? 1 : 0; + + if (netConfig->ServerVersion >= CecServerVersion::Version1_5_1) + config.bSendInactiveSource = netConfig->SendInactiveSource ? 1 : 0; + + if (netConfig->ServerVersion >= CecServerVersion::Version1_6_0) + { + config.bPowerOffDevicesOnStandby = netConfig->PowerOffDevicesOnStandby ? 1 : 0; + config.bShutdownOnStandby = netConfig->ShutdownOnStandby ? 1 : 0; + } + + if (netConfig->ServerVersion >= CecServerVersion::Version1_6_2) + { + const char *strDeviceLanguage = context->marshal_as(netConfig->DeviceLanguage); + memcpy_s(config.strDeviceLanguage, 3, strDeviceLanguage, 3); + } + + if (netConfig->ServerVersion >= CecServerVersion::Version1_6_3) + { + config.bMonitorOnly = netConfig->MonitorOnlyClient ? 1 : 0; + } + config.callbacks = &g_cecCallbacks; } @@ -139,6 +163,8 @@ namespace CecSharp bool Open(String ^ strPort, int iTimeoutMs) { + CecCallbackMethods::EnableCallbacks(m_callbacks); + EnableCallbacks(m_callbacks); marshal_context ^ context = gcnew marshal_context(); const char* strPortC = context->marshal_as(strPort); bool bReturn = m_libCec->Open(strPortC, iTimeoutMs); @@ -209,7 +235,7 @@ namespace CecSharp cec_keypress key; if (m_libCec->GetNextKeypress(&key)) { - return gcnew CecKeypress(key.keycode, key.duration); + return gcnew CecKeypress((CecUserControlCode)key.keycode, key.duration); } return gcnew CecKeypress(); @@ -476,6 +502,31 @@ namespace CecSharp return bReturn; } + bool IsLibCECActiveSource() + { + return m_libCec->IsLibCECActiveSource(); + } + + bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs) + { + bool bReturn(false); + marshal_context ^ context = gcnew marshal_context(); + + libcec_configuration config; + config.Clear(); + + const char* strPortC = port->Length > 0 ? context->marshal_as(port) : NULL; + + if (m_libCec->GetDeviceInformation(strPortC, &config, timeoutMs)) + { + configuration->Update(config); + bReturn = true; + } + + delete context; + return bReturn; + } + String ^ ToString(CecLogicalAddress iAddress) { const char *retVal = m_libCec->ToString((cec_logical_address)iAddress); @@ -550,5 +601,6 @@ namespace CecSharp private: ICECAdapter * m_libCec; + CecCallbackMethods ^ m_callbacks; }; }