X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecSharp%2FCecSharpTypes.h;h=65fa7cd4fa5e22bd2d8ba71b74edb39a91d73b33;hb=c3c131576fa529708881e1b0e722012218983116;hp=5d617941b0f4316c422cd257c249d5aba62281b8;hpb=3efda01ac7b070e09012a5725112eb44c17001b4;p=deb_libcec.git diff --git a/src/LibCecSharp/CecSharpTypes.h b/src/LibCecSharp/CecSharpTypes.h index 5d61794..65fa7cd 100644 --- a/src/LibCecSharp/CecSharpTypes.h +++ b/src/LibCecSharp/CecSharpTypes.h @@ -326,13 +326,15 @@ namespace CecSharp public enum class CecClientVersion { VersionPre1_5 = 0, - Version1_5_0 = 0x1500 + Version1_5_0 = 0x1500, + Version1_5_1 = 0x1501 }; public enum class CecServerVersion { VersionPre1_5 = 0, - Version1_5_0 = 0x1500 + Version1_5_0 = 0x1500, + Version1_5_1 = 0x1501 }; public ref class CecAdapter @@ -547,6 +549,7 @@ namespace CecSharp PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1; PowerOffOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1; + SendInactiveSource = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE == 1; } void SetCallbacks(CecCallbackMethods ^callbacks) @@ -586,6 +589,7 @@ namespace CecSharp PowerOffScreensaver = config.bPowerOffScreensaver == 1; PowerOffOnStandby = config.bPowerOffOnStandby == 1; + SendInactiveSource = config.bSendInactiveSource == 1; } property System::String ^ DeviceName; @@ -606,6 +610,7 @@ namespace CecSharp property CecLogicalAddresses ^PowerOffDevices; property bool PowerOffScreensaver; property bool PowerOffOnStandby; + property bool SendInactiveSource; property CecCallbackMethods ^ Callbacks; }; @@ -663,37 +668,11 @@ namespace CecSharp public ref class CecCallbackMethods { public: - CecCallbackMethods(void) - { - m_bHasCallbacks = false; - msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context(); - - // create the delegate method for the log message callback - m_logMessageDelegate = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged); - m_logMessageGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate); - g_logCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer()); - g_cecCallbacks.CBCecLogMessage = CecLogMessageCB; - - // create the delegate method for the keypress callback - m_keypressDelegate = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged); - m_keypressGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate); - g_keyCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer()); - g_cecCallbacks.CBCecKeyPress = CecKeyPressCB; - - // create the delegate method for the command callback - m_commandDelegate = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged); - m_commandGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate); - g_commandCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer()); - g_cecCallbacks.CBCecCommand = CecCommandCB; - - // create the delegate method for the configuration change callback - m_configDelegate = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged); - m_configGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate); - g_configCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer()); - g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB; - - delete context; - } + CecCallbackMethods(void) + { + m_bHasCallbacks = false; + m_bDelegatesCreated = false; + } ~CecCallbackMethods(void) { @@ -709,13 +688,12 @@ namespace CecSharp public: virtual void DisableCallbacks(void) { - if (m_bHasCallbacks) - delete m_callbacks; - m_bHasCallbacks = false; + DestroyDelegates(); } + virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks) { - DisableCallbacks(); + CreateDelegates(); if (!m_bHasCallbacks) { m_bHasCallbacks = true; @@ -790,16 +768,53 @@ namespace CecSharp void DestroyDelegates() { - if (m_bHasCallbacks) + m_bHasCallbacks = false; + if (m_bDelegatesCreated) { - m_bHasCallbacks = false; - delete m_callbacks; + m_bDelegatesCreated = false; m_logMessageGCHandle.Free(); m_keypressGCHandle.Free(); m_commandGCHandle.Free(); } } + void CreateDelegates() + { + DestroyDelegates(); + + if (!m_bDelegatesCreated) + { + msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context(); + + // create the delegate method for the log message callback + m_logMessageDelegate = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged); + m_logMessageGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate); + g_logCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer()); + g_cecCallbacks.CBCecLogMessage = CecLogMessageCB; + + // create the delegate method for the keypress callback + m_keypressDelegate = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged); + m_keypressGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate); + g_keyCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer()); + g_cecCallbacks.CBCecKeyPress = CecKeyPressCB; + + // create the delegate method for the command callback + m_commandDelegate = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged); + m_commandGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate); + g_commandCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer()); + g_cecCallbacks.CBCecCommand = CecCommandCB; + + // create the delegate method for the configuration change callback + m_configDelegate = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged); + m_configGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate); + g_configCB = static_cast(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer()); + g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB; + + delete context; + m_bDelegatesCreated = true; + } + } + CecLogMessageManagedDelegate ^ m_logMessageDelegate; static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle; LOGCB m_logMessageCallback; @@ -818,5 +833,6 @@ namespace CecSharp CecCallbackMethods ^ m_callbacks; bool m_bHasCallbacks; + bool m_bDelegatesCreated; }; }