#define CEC_FW_VERSION_UNKNOWN 0xFFFF
#define CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE 1
-#define CEC_DEFAULT_SETTING_POWER_ON_STARTUP 1
+#define CEC_DEFAULT_SETTING_ACTIVATE_SOURCE 1
#define CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN 1
#define CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER 1
#define CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY 1
uint16_t iPhysicalAddress; /*!< the physical address of the CEC adapter */
cec_logical_address baseDevice; /*!< the logical address of the device to which the adapter is connected. only used when iPhysicalAddress = 0 */
uint8_t iHDMIPort; /*!< the HDMI port to which the adapter is connected. only used when iPhysicalAddress = 0 */
- cec_vendor_id tvVendor; /*!< the vendor ID of the TV. leave this untouched to autodetect */
- cec_logical_addresses wakeDevices; /*!< wake these CEC devices when starting libCEC */
+ cec_vendor_id tvVendor; /*!< override the vendor ID of the TV. leave this untouched to autodetect */
+ cec_logical_addresses wakeDevices; /*!< wake these CEC devices when initialising libCEC or when calling PowerOnDevices() without any parameter */
+ cec_logical_addresses powerOffDevices; /*!< power off these devices when calling StandbyDevices() without any parameter */
// player specific settings
uint8_t bGetSettingsFromROM; /*!< true to get the settings from the ROM (if set, and a v2 ROM is present), false to use these settings. */
uint8_t bUseTVMenuLanguage; /*!< use the menu language of the TV in the player application */
- uint8_t bPowerOnStartup; /*!< power on CEC devices when start the player application */
- uint8_t bPowerOffShutdown; /*!< power off CEC devices when stopping the player application */
+ uint8_t bActivateSource; /*!< make libCEC the active source on the bus when starting the player application */
uint8_t bPowerOffScreensaver; /*!< put devices in standby mode when activating the screensaver */
uint8_t bPowerOffOnStandby; /*!< put this PC in standby mode when the TV is switched off */
tvVendor = CEC_VENDOR_UNKNOWN;
clientVersion = CEC_CLIENT_VERSION_PRE_1_5;
wakeDevices.Clear();
+ powerOffDevices.Clear();
bGetSettingsFromROM = 0;
bUseTVMenuLanguage = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE;
- bPowerOnStartup = CEC_DEFAULT_SETTING_POWER_ON_STARTUP;
- bPowerOffShutdown = CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN;
+ bActivateSource = CEC_DEFAULT_SETTING_ACTIVATE_SOURCE;
+ #if CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1
+ powerOffDevices.Set(CECDEVICE_BROADCAST);
+ #endif
+ #if CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1
+ wakeDevices.Set(CECDEVICE_TV);
+ #endif
bPowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER;
bPowerOffOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY;
}
{
- PrintToStdOut("Do you want to power on CEC devices when starting the application (y/n)?");
+ PrintToStdOut("Do you want to make the CEC adapter the active source when starting the application (y/n)?");
string input;
getline(cin, input);
cin.clear();
- g_config.bPowerOnStartup = (input == "y" || input == "Y") ? 1 : 0;
+ g_config.bActivateSource = (input == "y" || input == "Y") ? 1 : 0;
}
{
string input;
getline(cin, input);
cin.clear();
- g_config.bPowerOffShutdown = (input == "y" || input == "Y") ? 1 : 0;
+ if (input == "y" || input == "Y")
+ g_config.powerOffDevices.Set(CECDEVICE_BROADCAST);
}
{
PrintToStdOut("Connected to HDMI device: %X", (uint8_t)g_config.baseDevice);
PrintToStdOut("Physical address: %4X", g_config.iPhysicalAddress);
PrintToStdOut("Use the TV's language setting: %s", g_config.bUseTVMenuLanguage ? "yes" : "no");
- PrintToStdOut("Power on the TV when starting XBMC: %s", g_config.bPowerOnStartup ? "yes" : "no");
- PrintToStdOut("Power off devices when stopping XBMC: %s", g_config.bPowerOffShutdown ? "yes" : "no");
+ PrintToStdOut("Make the adapter the active source when starting XBMC: %s", g_config.bActivateSource ? "yes" : "no");
+ PrintToStdOut("Power off devices when stopping XBMC: %s", g_config.powerOffDevices.IsSet(CECDEVICE_BROADCAST) ? "yes" : "no");
PrintToStdOut("Put devices in standby mode when activating screensaver: %s", g_config.bPowerOffScreensaver ? "yes" : "no");
PrintToStdOut("Put this PC in standby mode when the TV is switched off: %s\n\n", g_config.bPowerOffOnStandby ? "yes" : "no");
"\t<setting id=\"connected_device\" value=\"" << (int)g_config.baseDevice << "\" />\n" <<
"\t<setting id=\"physical_address\" value=\"" << hex << g_config.iPhysicalAddress << "\" />\n" <<
"\t<setting id=\"use_tv_menu_language\" value=\"" << (int)g_config.bUseTVMenuLanguage << "\" />\n" <<
- "\t<setting id=\"cec_power_on_startup\" value=\"" << (int)g_config.bPowerOnStartup << "\" />\n" <<
- "\t<setting id=\"cec_power_off_shutdown\" value=\"" << (int)g_config.bPowerOffShutdown << "\" />\n" <<
+ "\t<setting id=\"cec_power_on_startup\" value=\"" << (int)g_config.bActivateSource << "\" />\n" <<
+ "\t<setting id=\"cec_power_off_shutdown\" value=\"" << (int)(g_config.powerOffDevices.IsSet(CECDEVICE_BROADCAST) ? 1 : 0) << "\" />\n" <<
"\t<setting id=\"cec_standby_screensaver\" value=\"" << (int)g_config.bPowerOffScreensaver << "\" />\n" <<
"\t<setting id=\"standby_pc_on_tv_standby\" value=\"" << (int)g_config.bPowerOffOnStandby << "\" />\n" <<
"\t<setting id=\"enabled\" value=\"1\" />\n" <<
else if (m_configuration.iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort, true)) == false)
CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_configuration.iHDMIPort, ToString(m_configuration.baseDevice), (uint8_t)m_configuration.baseDevice);
- WakeDevices();
+ PowerOnDevices();
SetInitialised(bReturn);
CLibCEC::ConfigurationChanged(m_configuration);
return bReturn;
}
-void CCECProcessor::WakeDevices(void)
-{
- for (uint8_t iPtr = 0; iPtr <= 0xF; iPtr++)
- {
- if (m_configuration.wakeDevices[iPtr])
- m_busDevices[iPtr]->PowerOn();
- }
-}
-
bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, uint32_t iTimeoutMs /* = 10000 */)
{
bool bReturn(false);
return m_busDevices[iDestination]->TransmitKeyRelease(bWait);
}
+bool CCECProcessor::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
+{
+ if (address == CECDEVICE_BROADCAST && m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_5_0)
+ {
+ bool bReturn(true);
+ for (uint8_t iPtr = 0; iPtr <= 0xF; iPtr++)
+ {
+ if (m_configuration.powerOffDevices[iPtr])
+ bReturn &= m_busDevices[iPtr]->Standby();
+ }
+ return bReturn;
+ }
+
+ return m_busDevices[address]->Standby();
+}
+
+bool CCECProcessor::PowerOnDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
+{
+ if (address == CECDEVICE_BROADCAST && m_configuration.clientVersion >= CEC_CLIENT_VERSION_1_5_0)
+ {
+ bool bReturn(true);
+ for (uint8_t iPtr = 0; iPtr <= 0xF; iPtr++)
+ {
+ if (m_configuration.powerOffDevices[iPtr])
+ bReturn &= m_busDevices[iPtr]->PowerOn();
+ }
+ return bReturn;
+ }
+
+ return m_busDevices[address]->PowerOn();
+}
+
const char *CCECProcessor::ToString(const cec_device_type type)
{
switch (type)
{
m_configuration.wakeDevices = configuration->wakeDevices;
if (!bNeedsReinit && IsRunning())
- WakeDevices();
+ PowerOnDevices();
}
// just copy these
m_configuration.bGetSettingsFromROM = configuration->bGetSettingsFromROM;
- m_configuration.bPowerOnStartup = configuration->bPowerOnStartup;
- m_configuration.bPowerOffShutdown = configuration->bPowerOffShutdown;
+ m_configuration.powerOffDevices = configuration->powerOffDevices;
m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver;
m_configuration.bPowerOffOnStandby = configuration->bPowerOffOnStandby;
configuration->tvVendor = m_configuration.tvVendor;
configuration->wakeDevices = m_configuration.wakeDevices;
configuration->bGetSettingsFromROM = m_configuration.bGetSettingsFromROM;
- configuration->bPowerOnStartup = m_configuration.bPowerOnStartup;
- configuration->bPowerOffShutdown = m_configuration.bPowerOffShutdown;
+ configuration->powerOffDevices = m_configuration.powerOffDevices;
configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver;
configuration->bPowerOffOnStandby = m_configuration.bPowerOffOnStandby;
virtual bool IsInitialised(void);
virtual bool SetStreamPath(uint16_t iPhysicalAddress);
virtual cec_client_version GetClientVersion(void) const { return m_configuration.clientVersion; };
+ virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST);
+ virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_BROADCAST);
virtual bool SetActiveView(void);
virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
void SetInitialised(bool bSetTo = true);
void CreateBusDevices(void);
- void WakeDevices(void);
void ReplaceHandlers(void);
void ScanCECBus(void);
bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
bool CLibCEC::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV */)
{
- return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->PowerOn() : false;
+ return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->PowerOnDevices(address) : false;
}
bool CLibCEC::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
{
- return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->Standby() : false;
+ return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->StandbyDevices(address) : false;
}
bool CLibCEC::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)