From 0549eb20abad8d7c05471d5c80785e028d6bed0c Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 9 Oct 2012 02:02:38 +0200 Subject: [PATCH] [cec] simplify settings - use an enum instead of logical addresses for the 'connected_device' setting --- language/English/strings.po | 12 +++++++++++- system/peripherals.xml | 4 ++-- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 12 ++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/language/English/strings.po b/language/English/strings.po index fb5abf832791d..fc23d6bff8e49 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -10876,7 +10876,7 @@ msgid "Product ID" msgstr "" #empty strings from id 35505 to 35999 - +#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp msgctxt "#36000" msgid "Pulse-Eight CEC adapter" msgstr "" @@ -11023,3 +11023,13 @@ msgstr "" msgctxt "#36036" msgid "On start/stop" msgstr "" + +#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp +msgctxt "#36037" +msgid "TV" +msgstr "" + +msgctxt "#36038" +msgid "Amplifier / AVR device" +msgstr "" + diff --git a/system/peripherals.xml b/system/peripherals.xml index 8abd07faaec14..26c3494b19f83 100644 --- a/system/peripherals.xml +++ b/system/peripherals.xml @@ -40,9 +40,9 @@ - + - + diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp index 4d510d4983ad4..6f20476267bc0 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp @@ -51,6 +51,9 @@ using namespace std; #define VOLUME_CHANGE_TIMEOUT 250 #define VOLUME_REFRESH_TIMEOUT 100 +#define LOCALISED_ID_TV 36037 +#define LOCALISED_ID_AVR 36038 + class DllLibCECInterface { public: @@ -1226,7 +1229,7 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu // set the connected device m_configuration.baseDevice = config.baseDevice; - bChanged |= SetSetting("connected_device", (int)config.baseDevice); + bChanged |= SetSetting("connected_device", config.baseDevice == CECDEVICE_AUDIOSYSTEM ? LOCALISED_ID_AVR : LOCALISED_ID_TV); // set the HDMI port number m_configuration.iHDMIPort = config.iHDMIPort; @@ -1328,9 +1331,10 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void) // set the connected device int iConnectedDevice = GetSettingInt("connected_device"); - if (iConnectedDevice == CECDEVICE_TV || - iConnectedDevice == CECDEVICE_AUDIOSYSTEM) - m_configuration.baseDevice = (cec_logical_address)iConnectedDevice; + if (iConnectedDevice == LOCALISED_ID_AVR) + m_configuration.baseDevice = CECDEVICE_AUDIOSYSTEM; + else if (iConnectedDevice == LOCALISED_ID_TV) + m_configuration.baseDevice = CECDEVICE_TV; // set the HDMI port number int iHDMIPort = GetSettingInt("cec_hdmi_port");