aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Op den Kamp <lars@opdenkamp.eu>2012-10-07 13:00:33 +0200
committerLars Op den Kamp <lars@opdenkamp.eu>2012-10-09 02:02:44 +0200
commitd45a20d190750119bdb644465c229f9176f36f82 (patch)
tree087c332f4c82aee4e372a17bc550e0523d08d6a8
parent0549eb20abad8d7c05471d5c80785e028d6bed0c (diff)
[cec] simplify 'wake_devices' and 'standby_devices' settings by showing an enum instead of a string with logical addresses
-rw-r--r--language/English/strings.po4
-rw-r--r--system/peripherals.xml28
-rw-r--r--xbmc/peripherals/devices/PeripheralCecAdapter.cpp79
-rw-r--r--xbmc/peripherals/devices/PeripheralCecAdapter.h2
4 files changed, 87 insertions, 26 deletions
diff --git a/language/English/strings.po b/language/English/strings.po
index fc23d6bff8..7cbb3012c1 100644
--- a/language/English/strings.po
+++ b/language/English/strings.po
@@ -11033,3 +11033,7 @@ msgctxt "#36038"
msgid "Amplifier / AVR device"
msgstr ""
+msgctxt "#36039"
+msgid "TV and AVR device (explicit)"
+msgstr ""
+
diff --git a/system/peripherals.xml b/system/peripherals.xml
index 26c3494b19..5e41d7553a 100644
--- a/system/peripherals.xml
+++ b/system/peripherals.xml
@@ -12,12 +12,12 @@
<peripheral vendor_product="2708:1001" bus="rpi" name="Raspberry Pi CEC Adapter" mapTo="cec">
<setting key="enabled" type="bool" value="1" label="305" order="1" />
<setting key="activate_source" type="bool" value="1" label="36020" order="2" />
- <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
- <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
- <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
- <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
- <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="7" />
- <setting key="send_inactive_source" type="bool" value="1" label="36025" order="8" />
+ <setting key="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
+ <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
+ <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
+ <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="7" />
+ <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
+ <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
<setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
<setting key="tv_vendor" type="int" value="0" configurable="0" />
@@ -27,17 +27,19 @@
<setting key="cec_hdmi_port" type="int" value="1" label="36015" configurable="0" />
<setting key="connected_device" type="int" label="36019" value="0" configurable="0" />
<setting key="port" type="string" value="" label="36022" configurable="0" />
+ <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
</peripheral>
<peripheral vendor_product="2548:1001,2548:1002" bus="usb" name="Pulse-Eight CEC Adapter" mapTo="cec">
<setting key="enabled" type="bool" value="1" label="305" order="1" />
<setting key="activate_source" type="bool" value="1" label="36020" order="2" />
- <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
- <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
- <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
- <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
- <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="7" />
- <setting key="send_inactive_source" type="bool" value="1" label="36025" order="8" />
+ <setting key="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
+ <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
+ <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
+ <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="6" />
+ <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
+ <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
<setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
<setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" order="10" />
<setting key="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" order="11" />
@@ -48,6 +50,8 @@
<setting key="tv_vendor" type="int" value="0" configurable="0" />
<setting key="device_name" type="string" value="XBMC" configurable="0" />
<setting key="device_type" type="int" value="1" configurable="0" />
+ <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
</peripheral>
<peripheral vendor_product="15C2:32,15C2:33,15C2:34,15C2:35,15C2:36,15C2:37,15C2:38,15C2:39,15C2:3A,15C2:3B,15C2:3C,15C2:3D,15C2:3E,15C2:3F,15C2:41,15C2:42,15C2:43,15C2:44,15C2:45,15C2:46" bus="usb" name="iMON HID device" mapTo="imon">
diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
index 6f20476267..3c6d71204a 100644
--- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
@@ -53,6 +53,8 @@ using namespace std;
#define LOCALISED_ID_TV 36037
#define LOCALISED_ID_AVR 36038
+#define LOCALISED_ID_TV_AVR 36039
+#define LOCALISED_ID_NONE 231
class DllLibCECInterface
{
@@ -186,6 +188,12 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
{
if (feature == FEATURE_CEC && !m_bStarted && GetSettingBool("enabled"))
{
+ // hide settings that have an override set
+ if (!GetSettingString("wake_devices_advanced").IsEmpty())
+ SetSettingVisible("wake_devices", false);
+ if (!GetSettingString("standby_devices_advanced").IsEmpty())
+ SetSettingVisible("standby_devices", false);
+
SetConfigurationFromSettings();
m_callbacks.Clear();
m_callbacks.CBCecLogMessage = &CecLogMessage;
@@ -1252,19 +1260,11 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
// set the devices to wake when starting
m_configuration.wakeDevices = config.wakeDevices;
- CStdString strWakeDevices;
- for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.wakeDevices[iPtr])
- strWakeDevices.AppendFormat(" %X", iPtr);
- bChanged |= SetSetting("wake_devices", strWakeDevices.Trim());
+ bChanged |= WriteLogicalAddresses(config.wakeDevices, "wake_devices", "wake_devices_advanced");
// set the devices to power off when stopping
m_configuration.powerOffDevices = config.powerOffDevices;
- CStdString strPowerOffDevices;
- for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.powerOffDevices[iPtr])
- strPowerOffDevices.AppendFormat(" %X", iPtr);
- bChanged |= SetSetting("standby_devices", strPowerOffDevices.Trim());
+ bChanged |= WriteLogicalAddresses(config.powerOffDevices, "standby_devices", "standby_devices_advanced");
// set the boolean settings
m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
@@ -1349,14 +1349,20 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
m_configuration.tvVendor = iVendor;
// read the devices to wake when starting
- CStdString strWakeDevices = CStdString(GetSettingString("wake_devices")).Trim();
+ CStdString strWakeDevices = CStdString(GetSettingString("wake_devices_advanced")).Trim();
m_configuration.wakeDevices.Clear();
- ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
+ if (!strWakeDevices.IsEmpty())
+ ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
+ else
+ ReadLogicalAddresses(GetSettingInt("wake_devices"), m_configuration.wakeDevices);
// read the devices to power off when stopping
- CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices")).Trim();
+ CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices_advanced")).Trim();
m_configuration.powerOffDevices.Clear();
- ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
+ if (!strStandbyDevices.IsEmpty())
+ ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
+ else
+ ReadLogicalAddresses(GetSettingInt("standby_devices"), m_configuration.powerOffDevices);
// read the boolean settings
m_configuration.bUseTVMenuLanguage = GetSettingBool("use_tv_menu_language") ? 1 : 0;
@@ -1384,6 +1390,51 @@ void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, ce
}
}
+void CPeripheralCecAdapter::ReadLogicalAddresses(int iLocalisedId, cec_logical_addresses &addresses)
+{
+ addresses.Clear();
+ switch (iLocalisedId)
+ {
+ case LOCALISED_ID_TV:
+ addresses.Set(CECDEVICE_TV);
+ break;
+ case LOCALISED_ID_AVR:
+ addresses.Set(CECDEVICE_AUDIOSYSTEM);
+ break;
+ case LOCALISED_ID_TV_AVR:
+ addresses.Set(CECDEVICE_TV);
+ addresses.Set(CECDEVICE_AUDIOSYSTEM);
+ break;
+ case LOCALISED_ID_NONE:
+ default:
+ break;
+ }
+}
+
+bool CPeripheralCecAdapter::WriteLogicalAddresses(const cec_logical_addresses& addresses, const string& strSettingName, const string& strAdvancedSettingName)
+{
+ bool bChanged(false);
+
+ // only update the advanced setting if it was set by the user
+ if (!GetSettingString(strAdvancedSettingName).IsEmpty())
+ {
+ CStdString strPowerOffDevices;
+ for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
+ if (addresses[iPtr])
+ strPowerOffDevices.AppendFormat(" %X", iPtr);
+ bChanged = SetSetting(strAdvancedSettingName, strPowerOffDevices.Trim());
+ }
+
+ int iSettingPowerOffDevices = LOCALISED_ID_NONE;
+ if (addresses[CECDEVICE_TV] && addresses[CECDEVICE_AUDIOSYSTEM])
+ iSettingPowerOffDevices = LOCALISED_ID_TV_AVR;
+ else if (addresses[CECDEVICE_TV])
+ iSettingPowerOffDevices = LOCALISED_ID_TV;
+ else if (addresses[CECDEVICE_AUDIOSYSTEM])
+ iSettingPowerOffDevices = LOCALISED_ID_AVR;
+ return SetSetting(strSettingName, iSettingPowerOffDevices) || bChanged;
+}
+
CPeripheralCecAdapterUpdateThread::CPeripheralCecAdapterUpdateThread(CPeripheralCecAdapter *adapter, libcec_configuration *configuration) :
CThread("CEC Adapter Update Thread"),
m_adapter(adapter),
diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.h b/xbmc/peripherals/devices/PeripheralCecAdapter.h
index b992aa3dbb..d1d939e31e 100644
--- a/xbmc/peripherals/devices/PeripheralCecAdapter.h
+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.h
@@ -119,6 +119,8 @@ namespace PERIPHERALS
void SetConfigurationFromLibCEC(const CEC::libcec_configuration &config);
void SetVersionInfo(const CEC::libcec_configuration &configuration);
static void ReadLogicalAddresses(const CStdString &strString, CEC::cec_logical_addresses &addresses);
+ static void ReadLogicalAddresses(int iLocalisedId, CEC::cec_logical_addresses &addresses);
+ bool WriteLogicalAddresses(const CEC::cec_logical_addresses& addresses, const std::string& strSettingName, const std::string& strAdvancedSettingName);
static int CecKeyPress(void *cbParam, const CEC::cec_keypress key);
void PushCecKeypress(const CecButtonPress &key);
static int CecLogMessage(void *cbParam, const CEC::cec_log_message message);