From: Lars Op den Kamp Date: Tue, 27 Nov 2012 01:01:55 +0000 (+0100) Subject: added comboKey and iComboKeyTimeoutMs to libcec_configuration. force cec_user_control... X-Git-Tag: upstream/2.2.0~1^2~9^2~1^2~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ac3f990141108fb7864f8c67f3c997ccc536fdd6;p=deb_libcec.git added comboKey and iComboKeyTimeoutMs to libcec_configuration. force cec_user_control_code_unknown to 0xFF. #define CEC_FEATURE_CONFIGURABLE_COMBO_KEY. default combo key to F1(blue) --- diff --git a/include/cectypes.h b/include/cectypes.h index dfcebfe..e85bcfa 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -264,6 +264,11 @@ namespace CEC { */ #define CEC_FORWARD_STANDBY_MIN_INTERVAL 10000 +/*! + * default timeout in milliseconds for combo keys + */ +#define CEC_DEFAULT_COMBO_TIMEOUT_MS 1000 + /*! * the virtual device path to use for the Raspberry Pi's CEC wire */ @@ -309,6 +314,8 @@ namespace CEC { #define MSGESC 0xFD #define ESCOFFSET 3 +// defines to make compile time checks for certain features easy +#define CEC_FEATURE_CONFIGURABLE_COMBO_KEY 1 typedef enum cec_abort_reason { @@ -691,7 +698,7 @@ typedef enum cec_user_control_code CEC_USER_CONTROL_CODE_AN_RETURN = 0x91, CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST = 0x96, CEC_USER_CONTROL_CODE_MAX = 0x96, - CEC_USER_CONTROL_CODE_UNKNOWN + CEC_USER_CONTROL_CODE_UNKNOWN = 0xFF } cec_user_control_code; typedef enum cec_logical_address @@ -1379,7 +1386,8 @@ typedef enum cec_client_version CEC_CLIENT_VERSION_2_0_2 = 0x2002, CEC_CLIENT_VERSION_2_0_3 = 0x2003, CEC_CLIENT_VERSION_2_0_4 = 0x2004, - CEC_CLIENT_VERSION_CURRENT = 0x2004 + CEC_CLIENT_VERSION_2_0_5 = 0x2005, + CEC_CLIENT_VERSION_CURRENT = 0x2005 } cec_client_version; typedef enum cec_server_version @@ -1406,7 +1414,8 @@ typedef enum cec_server_version CEC_SERVER_VERSION_2_0_2 = 0x2002, CEC_SERVER_VERSION_2_0_3 = 0x2003, CEC_SERVER_VERSION_2_0_4 = 0x2004, - CEC_SERVER_VERSION_CURRENT = 0x2004 + CEC_SERVER_VERSION_2_0_5 = 0x2005, + CEC_SERVER_VERSION_CURRENT = 0x2005 } cec_server_version; struct libcec_configuration @@ -1445,6 +1454,8 @@ struct libcec_configuration cec_version cecVersion; /*!< CEC spec version to use by libCEC. defaults to v1.4. added in 1.8.0 */ cec_adapter_type adapterType; /*!< type of the CEC adapter that we're connected to. added in 1.8.2 */ uint8_t iDoubleTapTimeoutMs; /*!< prevent double taps withing this timeout. defaults to 200ms. added in 2.0.0 */ + cec_user_control_code comboKey; /*!< key code that initiates combo keys. defaults to CEC_USER_CONTROL_CODE_F1_BLUE. CEC_USER_CONTROL_CODE_UNKNOWN to disable. added in 2.0.5 */ + uint32_t iComboKeyTimeoutMs; /*!< timeout until the combo key is sent as normal keypress */ #ifdef __cplusplus libcec_configuration(void) { Clear(); } @@ -1478,7 +1489,9 @@ struct libcec_configuration bMonitorOnly == other.bMonitorOnly && cecVersion == other.cecVersion && adapterType == other.adapterType && - iDoubleTapTimeoutMs == other.iDoubleTapTimeoutMs); + iDoubleTapTimeoutMs == other.iDoubleTapTimeoutMs && + (other.clientVersion <= CEC_CLIENT_VERSION_2_0_4 || comboKey == other.comboKey) && + (other.clientVersion <= CEC_CLIENT_VERSION_2_0_4 || iComboKeyTimeoutMs == other.iComboKeyTimeoutMs)); } bool operator!=(const libcec_configuration &other) const @@ -1495,8 +1508,8 @@ struct libcec_configuration baseDevice = (cec_logical_address)CEC_DEFAULT_BASE_DEVICE; iHDMIPort = CEC_DEFAULT_HDMI_PORT; tvVendor = (uint64_t)CEC_VENDOR_UNKNOWN; - clientVersion = (uint32_t)CEC_CLIENT_VERSION_2_0_0; - serverVersion = (uint32_t)CEC_SERVER_VERSION_2_0_0; + clientVersion = (uint32_t)CEC_CLIENT_VERSION_CURRENT; + serverVersion = (uint32_t)CEC_SERVER_VERSION_CURRENT; bAutodetectAddress = 0; bGetSettingsFromROM = CEC_DEFAULT_SETTING_GET_SETTINGS_FROM_ROM; bUseTVMenuLanguage = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE; @@ -1513,6 +1526,8 @@ struct libcec_configuration cecVersion = (cec_version)CEC_DEFAULT_SETTING_CEC_VERSION; adapterType = ADAPTERTYPE_UNKNOWN; iDoubleTapTimeoutMs = CEC_DOUBLE_TAP_TIMEOUT_MS; + comboKey = CEC_USER_CONTROL_CODE_STOP; + iComboKeyTimeoutMs = CEC_DEFAULT_COMBO_TIMEOUT_MS; memset(strDeviceName, 0, 13); deviceTypes.Clear(); diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index 2e0045c..c1ade4c 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -47,9 +47,6 @@ using namespace PLATFORM; #define LIB_CEC m_processor->GetLib() #define ToString(x) CCECTypeUtils::ToString(x) -#define COMBO_KEY CEC_USER_CONTROL_CODE_STOP -#define COMBO_TIMEOUT_MS 1000 - CCECClient::CCECClient(CCECProcessor *processor, const libcec_configuration &configuration) : m_processor(processor), m_bInitialised(false), @@ -803,6 +800,7 @@ bool CCECClient::GetCurrentConfiguration(libcec_configuration &configuration) bool CCECClient::SetConfiguration(const libcec_configuration &configuration) { + libcec_configuration defaultSettings; bool bIsRunning(m_processor && m_processor->CECInitialised()); CCECBusDevice *primary = bIsRunning ? GetPrimaryDevice() : NULL; uint16_t iPA = primary ? primary->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS; @@ -838,7 +836,19 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration) m_configuration.bMonitorOnly = configuration.bMonitorOnly; m_configuration.cecVersion = configuration.cecVersion; m_configuration.adapterType = configuration.adapterType; - m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); + m_configuration.iDoubleTapTimeoutMs = configuration.iDoubleTapTimeoutMs; + m_configuration.deviceTypes.Add(configuration.deviceTypes[0]); + + if (m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5) + { + m_configuration.comboKey = configuration.comboKey; + m_configuration.iComboKeyTimeoutMs = configuration.iComboKeyTimeoutMs; + } + else + { + m_configuration.comboKey = defaultSettings.comboKey; + m_configuration.iComboKeyTimeoutMs = defaultSettings.iComboKeyTimeoutMs; + } } bool bNeedReinit(false); @@ -918,7 +928,10 @@ void CCECClient::AddKey(bool bSendComboKey /* = false */) { key.duration = (unsigned int) (GetTimeMs() - m_buttontime); - if (key.duration > COMBO_TIMEOUT_MS || m_iCurrentButton != COMBO_KEY || bSendComboKey) + cec_user_control_code comboKey(m_configuration.comboKey); + uint32_t iTimeoutMs(m_configuration.iComboKeyTimeoutMs); + + if (key.duration > iTimeoutMs || m_iCurrentButton != comboKey || bSendComboKey) { key.keycode = m_iCurrentButton; @@ -946,10 +959,12 @@ void CCECClient::AddKey(const cec_keypress &key) } cec_keypress transmitKey(key); + cec_user_control_code comboKey(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ? + m_configuration.comboKey : CEC_USER_CONTROL_CODE_STOP); { CLockObject lock(m_mutex); - if (m_iCurrentButton == COMBO_KEY && key.duration == 0) + if (m_iCurrentButton == comboKey && key.duration == 0) { // stop + ok -> exit if (key.keycode == CEC_USER_CONTROL_CODE_SELECT) @@ -980,7 +995,7 @@ void CCECClient::AddKey(const cec_keypress &key) } } - if (key.keycode != COMBO_KEY || key.duration > 0) + if (key.keycode != comboKey || key.duration > 0) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "key pressed: %s (%1x)", ToString(transmitKey.keycode), transmitKey.keycode); CallbackAddKey(transmitKey); @@ -1004,10 +1019,14 @@ void CCECClient::CheckKeypressTimeout(void) { CLockObject lock(m_mutex); uint64_t iNow = GetTimeMs(); + cec_user_control_code comboKey(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ? + m_configuration.comboKey : CEC_USER_CONTROL_CODE_STOP); + uint32_t iTimeoutMs(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ? + m_configuration.iComboKeyTimeoutMs : CEC_DEFAULT_COMBO_TIMEOUT_MS); if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && - ((m_iCurrentButton == COMBO_KEY && iNow - m_buttontime > COMBO_TIMEOUT_MS) || - (m_iCurrentButton != COMBO_KEY && iNow - m_buttontime > CEC_BUTTON_TIMEOUT))) + ((m_iCurrentButton == comboKey && iNow - m_buttontime > iTimeoutMs) || + (m_iCurrentButton != comboKey && iNow - m_buttontime > CEC_BUTTON_TIMEOUT))) { key.duration = (unsigned int) (iNow - m_buttontime); key.keycode = m_iCurrentButton; diff --git a/src/lib/CECTypeUtils.h b/src/lib/CECTypeUtils.h index 7699b89..b3e209b 100644 --- a/src/lib/CECTypeUtils.h +++ b/src/lib/CECTypeUtils.h @@ -565,6 +565,8 @@ namespace CEC return "2.0.3"; case CEC_CLIENT_VERSION_2_0_4: return "2.0.4"; + case CEC_CLIENT_VERSION_2_0_5: + return "2.0.5"; default: return "Unknown"; } @@ -618,6 +620,8 @@ namespace CEC return "2.0.3"; case CEC_SERVER_VERSION_2_0_4: return "2.0.4"; + case CEC_SERVER_VERSION_2_0_5: + return "2.0.5"; default: return "Unknown"; }