From 21fa005bec345a6b80229c1218e04fb59a17ccdb Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 21 Sep 2012 12:45:33 +0200 Subject: [PATCH] moved code that handles the previous keypress --- src/lib/CECClient.cpp | 7 ++++++- src/lib/implementations/CECCommandHandler.cpp | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index c9525af..0bbc081 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -972,9 +972,14 @@ void CCECClient::AddKey(void) void CCECClient::AddKey(const cec_keypress &key) { + // send back the previous key if there is one + AddKey(); + { CLockObject lock(m_mutex); - m_iCurrentButton = key.duration > 0 ? CEC_USER_CONTROL_CODE_UNKNOWN : key.keycode; + m_iCurrentButton = key.duration > 0 || key.keycode > CEC_USER_CONTROL_CODE_MAX ? + CEC_USER_CONTROL_CODE_UNKNOWN : + key.keycode; m_buttontime = key.duration > 0 ? 0 : GetTimeMs(); } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index f20f6af..d23340f 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -673,9 +673,6 @@ int CCECCommandHandler::HandleUserControlPressed(const cec_command &command) CCECClient *client = device->GetClient(); if (client) - client->AddKey(); - - if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX) client->SetCurrentButton((cec_user_control_code) command.parameters[0]); if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER || -- 2.34.1