X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecSharp%2FLibCecSharp.cpp;h=81c857fb2fed67c2475365eab980289d32aaf21b;hb=b0a5e4fc9b66620b00f937f7e9a406bf22aaaf1d;hp=76dd00624e7948d3fcbf9eedfcf7d73f156f1b86;hpb=a8fffd1b5fe9ce8b60e110f08f69448c5eb5593a;p=deb_libcec.git diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index 76dd006..81c857f 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -82,6 +82,7 @@ namespace CecSharp ConvertConfiguration(context, config, libCecConfig); m_libCec = (ICECAdapter *) CECInitialise(&libCecConfig); + config->Update(libCecConfig); delete context; return m_libCec != NULL; @@ -91,7 +92,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]; @@ -117,8 +119,26 @@ namespace CecSharp } config.bPowerOffScreensaver = netConfig->PowerOffScreensaver ? 1 : 0; config.bPowerOffOnStandby = netConfig->PowerOffOnStandby ? 1 : 0; - config.bSendInactiveSource = netConfig->SendInactiveSource ? 1 : 0; - config.callbacks = &g_cecCallbacks; + + 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; } public: @@ -168,7 +188,7 @@ namespace CecSharp virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks) override { if (m_libCec && CecCallbackMethods::EnableCallbacks(callbacks)) - return m_libCec->EnableCallbacks(NULL, &g_cecCallbacks); + return m_libCec->EnableCallbacks((void*)GetCallbackPtr(), &g_cecCallbacks); return false; } @@ -214,7 +234,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(); @@ -481,6 +501,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); @@ -553,6 +598,17 @@ namespace CecSharp return gcnew String(retVal); } + String ^ GetLibInfo() + { + const char *retVal = m_libCec->GetLibInfo(); + return gcnew String(retVal); + } + + void InitVideoStandalone() + { + m_libCec->InitVideoStandalone(); + } + private: ICECAdapter * m_libCec; CecCallbackMethods ^ m_callbacks;