LibCecSharp: added the new parameters
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:01:35 +0000 (16:01 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:01:35 +0000 (16:01 +0100)
src/LibCecSharp/CecSharpTypes.h
src/LibCecSharp/LibCecSharp.cpp

index 2a32724a6d1c6935619bbdc719b321bcf831d1d7..212d8181e3a758dbc7d69c0312011170ffec6962 100644 (file)
@@ -360,6 +360,11 @@ namespace CecSharp
                CecLogicalAddresses(void)
                {
                        Addresses = gcnew array<CecLogicalAddress>(16);
+                       Clear();
+               }
+
+               void Clear(void)
+               {
                        for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
                                Addresses[iPtr] = CecLogicalAddress::Unregistered;
                }
@@ -369,6 +374,11 @@ namespace CecSharp
                        return Addresses[(unsigned int)iAddress] != CecLogicalAddress::Unregistered;
                }
 
+         void Set(CecLogicalAddress iAddress)
+               {
+                       Addresses[(unsigned int)iAddress] = iAddress;
+               }
+
                property CecLogicalAddress          Primary;
                property array<CecLogicalAddress> ^ Addresses;
        };
@@ -512,11 +522,20 @@ namespace CecSharp
                        BaseDevice          = (CecLogicalAddress)CEC_DEFAULT_BASE_DEVICE;
                        HDMIPort            = CEC_DEFAULT_HDMI_PORT;
                        ClientVersion       = CecClientVersion::VersionPre1_5;
+                       TvVendor            = CecVendorId::Unknown;
 
                        GetSettingsFromROM  = false;
                        UseTVMenuLanguage   = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE == 1;
-                       PowerOnStartup      = CEC_DEFAULT_SETTING_POWER_ON_STARTUP == 1;
-                       PowerOffShutdown    = CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1;
+                       ActivateSource      = CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1;
+
+                       WakeDevices         = gcnew CecLogicalAddresses();
+                       if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1)
+                               WakeDevices->Set(CecLogicalAddress::Tv);
+
+                       PowerOffDevices     = gcnew CecLogicalAddresses();
+                       if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1)
+                               PowerOffDevices->Set(CecLogicalAddress::Broadcast);
+
                        PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1;
                        PowerOffOnStandby   = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1;
                }
@@ -526,22 +545,24 @@ namespace CecSharp
                        Callbacks = callbacks;
                }
 
-               property System::String ^    DeviceName;
-               property CecDeviceTypeList ^ DeviceTypes;
-               property uint16_t            PhysicalAddress;
-               property CecLogicalAddress   BaseDevice;
-               property uint8_t             HDMIPort;
-               property CecClientVersion    ClientVersion;
+               property System::String ^     DeviceName;
+               property CecDeviceTypeList ^  DeviceTypes;
+               property uint16_t             PhysicalAddress;
+               property CecLogicalAddress    BaseDevice;
+               property uint8_t              HDMIPort;
+               property CecClientVersion     ClientVersion;
+               property CecVendorId          TvVendor;
 
                // player specific settings
-               property bool                GetSettingsFromROM;
-               property bool                UseTVMenuLanguage;
-               property bool                PowerOnStartup;
-               property bool                PowerOffShutdown;
-               property bool                PowerOffScreensaver;
-               property bool                PowerOffOnStandby;
-
-               property CecCallbackMethods ^Callbacks;
+               property bool                 GetSettingsFromROM;
+               property bool                 UseTVMenuLanguage;
+               property bool                 ActivateSource;
+               property CecLogicalAddresses ^WakeDevices;
+               property CecLogicalAddresses ^PowerOffDevices;
+               property bool                 PowerOffScreensaver;
+               property bool                 PowerOffOnStandby;
+
+               property CecCallbackMethods ^ Callbacks;
        };
 
        // the callback methods are called by unmanaged code, so we need some delegates for this
@@ -718,8 +739,20 @@ namespace CecSharp
                                netConfig->HDMIPort = config.iHDMIPort;
                                netConfig->ClientVersion = (CecClientVersion)config.clientVersion;
                                netConfig->GetSettingsFromROM = config.bGetSettingsFromROM == 1;
-                               netConfig->PowerOnStartup = config.bPowerOnStartup == 1;
-                               netConfig->PowerOffShutdown = config.bPowerOffShutdown == 1;
+                               netConfig->ActivateSource = config.bActivateSource == 1;
+
+                               netConfig->WakeDevices->Clear();
+                               int iDevices(0);
+                               for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
+                                       if (config.wakeDevices[iPtr])
+                                               netConfig->WakeDevices->Addresses[iDevices++] = (CecLogicalAddress)iPtr;
+
+                               netConfig->PowerOffDevices->Clear();
+                               iDevices = 0;
+                               for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
+                                       if (config.powerOffDevices[iPtr])
+                                               netConfig->PowerOffDevices->Addresses[iDevices++] = (CecLogicalAddress)iPtr;
+
                                netConfig->PowerOffScreensaver = config.bPowerOffScreensaver == 1;
                                netConfig->PowerOffOnStandby = config.bPowerOffOnStandby == 1;
 
index 1c073d9baedaae0e15989df8daf2821f54447c63..9c1c44ad0a7ca5db1eba0822809eee24a0893265 100644 (file)
@@ -98,8 +98,20 @@ namespace CecSharp
                        config.iHDMIPort            = netConfig->HDMIPort;
                        config.clientVersion        = (cec_client_version)netConfig->ClientVersion;
                        config.bGetSettingsFromROM  = netConfig->GetSettingsFromROM;
-                       config.bPowerOnStartup      = netConfig->PowerOnStartup;
-                       config.bPowerOffShutdown    = netConfig->PowerOffShutdown;
+                       config.bActivateSource      = netConfig->ActivateSource;
+                       config.tvVendor             = (cec_vendor_id)netConfig->TvVendor;
+                       config.wakeDevices.Clear();
+                       for (int iPtr = 0; iPtr < 16; iPtr++)
+                       {
+                               if (netConfig->WakeDevices->IsSet((CecLogicalAddress)iPtr))
+                                       config.wakeDevices.Set((cec_logical_address)iPtr);
+                       }
+                       config.powerOffDevices.Clear();
+                       for (int iPtr = 0; iPtr < 16; iPtr++)
+                       {
+                               if (netConfig->PowerOffDevices->IsSet((CecLogicalAddress)iPtr))
+                                       config.powerOffDevices.Set((cec_logical_address)iPtr);
+                       }
                        config.bPowerOffScreensaver = netConfig->PowerOffScreensaver;
                        config.bPowerOffOnStandby   = netConfig->PowerOffOnStandby;
                        config.callbacks            = &g_cecCallbacks;
@@ -137,6 +149,7 @@ namespace CecSharp
                {
                        // delete the callbacks, since these might already have been destroyed in .NET
                        m_libCec->EnableCallbacks(NULL, NULL);
+                       m_libCec->StandbyDevices();
                        m_libCec->Close();
                }
 
@@ -422,8 +435,21 @@ namespace CecSharp
                                configuration->PhysicalAddress = config.iPhysicalAddress;
                                configuration->PowerOffOnStandby = config.bPowerOffOnStandby == 1;
                                configuration->PowerOffScreensaver = config.bPowerOffScreensaver == 1;
-                               configuration->PowerOffShutdown = config.bPowerOffShutdown == 1;
-                               configuration->PowerOnStartup = config.bPowerOnStartup == 1;
+                               configuration->ActivateSource = config.bActivateSource == 1;
+                               configuration->TvVendor = (CecVendorId)config.tvVendor;
+
+                               configuration->WakeDevices->Clear();
+                               int iDevices(0);
+                               for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
+                                       if (config.wakeDevices[iPtr])
+                                               configuration->WakeDevices->Addresses[iDevices++] = (CecLogicalAddress)iPtr;
+
+                               configuration->PowerOffDevices->Clear();
+                               iDevices = 0;
+                               for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
+                                       if (config.powerOffDevices[iPtr])
+                                               configuration->PowerOffDevices->Addresses[iDevices++] = (CecLogicalAddress)iPtr;
+
                                configuration->UseTVMenuLanguage = config.bUseTVMenuLanguage == 1;
                                for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
                                        configuration->DeviceTypes->Types[iPtr] = (CecDeviceType)config.deviceTypes.types[iPtr];