From 3ef1760662ea7d157c97fa4a3d26f8ce7138747f Mon Sep 17 00:00:00 2001 From: Mark Kendall Date: Fri, 20 Apr 2012 11:56:06 +0100 Subject: [PATCH] Add a default menu language to libcec_configuration. bugzid: 699 and set this language for devices controlled by libcec. --- include/cectypes.h | 6 +++++- src/lib/CECProcessor.cpp | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/cectypes.h b/include/cectypes.h index 4edf4ba..a1bafac 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -82,6 +82,7 @@ namespace CEC { #define CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY 0 #define CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE 1 #define CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY 1 +#define CEC_DEFAULT_DEVICE_LANGUAGE "eng" #define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500 #define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000 @@ -1085,7 +1086,8 @@ typedef enum cec_client_version CEC_CLIENT_VERSION_1_5_2 = 0x1502, CEC_CLIENT_VERSION_1_5_3 = 0x1503, CEC_CLIENT_VERSION_1_6_0 = 0x1600, - CEC_CLIENT_VERSION_1_6_1 = 0x1601 + CEC_CLIENT_VERSION_1_6_1 = 0x1601, + CEC_CLIENT_VERSION_1_6_2 = 0x1602 } cec_client_version; typedef enum cec_server_version @@ -1129,6 +1131,7 @@ typedef struct libcec_configuration uint16_t iFirmwareVersion; /*!< the firmware version of the adapter. added in 1.6.0 */ uint8_t bPowerOffDevicesOnStandby; /*!< put devices in standby when the PC/player is put in standby. added in 1.6.0 */ uint8_t bShutdownOnStandby; /*!< shutdown this PC when the TV is switched off. only used when bPowerOffOnStandby = 0. added in 1.6.0 */ + char strDeviceLanguage[3]; /*!< the menu language used by the client. 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ */ #ifdef __cplusplus /*! @@ -1164,6 +1167,7 @@ typedef struct libcec_configuration logicalAddresses.Clear(); iFirmwareVersion = CEC_FW_VERSION_UNKNOWN; bPowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY; + memcpy(strDeviceLanguage, CEC_DEFAULT_DEVICE_LANGUAGE, 3); callbackParam = NULL; callbacks = NULL; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index cf42233..3f91fbf 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -240,6 +240,21 @@ bool CCECProcessor::Initialise(void) /* make the primary device the active source if the option is set */ if (m_configuration.bActivateSource == 1) m_busDevices[m_configuration.logicalAddresses.primary]->m_bActiveSource = true; + + /* set the default menu language for devices we control */ + cec_menu_language language; + language.device = m_configuration.logicalAddresses.primary; + memcpy(language.language, m_configuration.strDeviceLanguage, 3); + language.language[3] = 0; + + for (uint8_t iPtr = 0; iPtr < 16; iPtr++) + { + if (m_configuration.logicalAddresses[iPtr]) + { + language.device = (cec_logical_address) iPtr; + m_busDevices[iPtr]->SetMenuLanguage(language); + } + } } /* get the vendor id from the TV, so we are using the correct handler */ @@ -377,12 +392,6 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) previousDevice->SetCecVersion(CEC_VERSION_UNKNOWN); newDevice->SetMenuLanguage(previousDevice->GetMenuLanguage(false)); - cec_menu_language lang; - lang.device = previousDevice->GetLogicalAddress(); - for (unsigned int iPtr = 0; iPtr < 4; iPtr++) - lang.language[iPtr] = '?'; - lang.language[3] = 0; - previousDevice->SetMenuLanguage(lang); newDevice->SetMenuState(previousDevice->GetMenuState()); previousDevice->SetMenuState(CEC_MENU_STATE_DEACTIVATED); @@ -1654,6 +1663,12 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration) m_configuration.bShutdownOnStandby = configuration->bShutdownOnStandby; } + // client version 1.6.2 + if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_2) + { + snprintf(m_configuration.strDeviceLanguage, 3, "%s", configuration->strDeviceLanguage); + } + // ensure that there is at least 1 device type set if (m_configuration.deviceTypes.IsEmpty()) m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); -- 2.34.1