From 95ba7a09eb9bb15df28f8310fdcc9433157e58cf Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 3 Nov 2011 20:35:36 +0100 Subject: [PATCH] cec: don't hack around the issue that samsung's vendor specific keypresses aren't sending release events, but just push a translated keypress directly --- src/lib/CECProcessor.cpp | 5 +++++ src/lib/CECProcessor.h | 1 + src/lib/LibCEC.cpp | 7 +++++++ src/lib/LibCEC.h | 1 + src/lib/implementations/ANCommandHandler.cpp | 16 +++++++--------- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index c83bdc0..f781b6f 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -394,6 +394,11 @@ void CCECProcessor::AddCommand(const cec_command &command) m_controller->AddCommand(command); } +void CCECProcessor::AddKey(cec_keypress &key) +{ + m_controller->AddKey(key); +} + void CCECProcessor::AddKey(void) { m_controller->AddKey(); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 895445f..d865167 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -75,6 +75,7 @@ namespace CEC virtual void SetCurrentButton(cec_user_control_code iButtonCode); virtual void AddCommand(const cec_command &command); + virtual void AddKey(cec_keypress &key); virtual void AddKey(void); virtual void AddLog(cec_log_level level, const CStdString &strMessage); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 0efef00..95e2a2e 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -227,6 +227,13 @@ void CLibCEC::AddLog(cec_log_level level, const string &strMessage) } } +void CLibCEC::AddKey(cec_keypress &key) +{ + m_keyBuffer.Push(key); + m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN; + m_buttontime = 0; +} + void CLibCEC::AddKey(void) { if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN) diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 203facb..1997039 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -82,6 +82,7 @@ namespace CEC virtual void AddLog(cec_log_level level, const std::string &strMessage); virtual void AddKey(void); + virtual void AddKey(cec_keypress &key); virtual void AddCommand(const cec_command &command); virtual void CheckKeypressTimeout(void); virtual void SetCurrentButton(cec_user_control_code iButtonCode); diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index ef972f8..f1e3dd5 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -46,28 +46,26 @@ bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) { if (command.parameters.size > 0) { - m_busDevice->GetProcessor()->AddKey(); + cec_keypress key; + key.duration = CEC_BUTTON_TIMEOUT; + key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN; - uint8_t iButton = 0; switch (command.parameters[0]) { case CEC_AN_USER_CONTROL_CODE_RETURN: - iButton = CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL; + key.keycode = CEC_USER_CONTROL_CODE_EXIT; break; default: break; } - if (iButton > 0 && iButton <= CEC_USER_CONTROL_CODE_MAX) + if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN) { CStdString strLog; - strLog.Format("key pressed: %1x", iButton); + strLog.Format("key pressed: %1x", key.keycode); m_busDevice->AddLog(CEC_LOG_DEBUG, strLog); - m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]); - - // these ones don't send key release events - m_busDevice->GetProcessor()->AddKey(); + m_busDevice->GetProcessor()->AddKey(key); } } -- 2.34.1