From 117863dd4fef4d19bc3590c513ec1192427f2249 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 25 Oct 2012 14:26:23 +0200 Subject: [PATCH] fixed - some TVs send keypresses to us without making us the active source. mark us as active source when this happens. issue #71 --- src/lib/implementations/CECCommandHandler.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index c5a5836..3b0187a 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -673,13 +673,15 @@ int CCECCommandHandler::HandleUserControlPressed(const cec_command &command) client->SetCurrentButton((cec_user_control_code) command.parameters[0]); if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER || - command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION) + command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION|| + command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION) { bool bPowerOn(true); - // CEC_USER_CONTROL_CODE_POWER operates as a toggle + // CEC_USER_CONTROL_CODE_POWER and CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION operate as a toggle // assume CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION does not - if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER) + if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER || + command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION) { cec_power_status status = device->GetCurrentPowerStatus(); bPowerOn = !(status == CEC_POWER_STATUS_ON || status == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); @@ -696,6 +698,12 @@ int CCECCommandHandler::HandleUserControlPressed(const cec_command &command) device->SetMenuState(CEC_MENU_STATE_DEACTIVATED); } } + else if (command.parameters[0] != CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION) + { + // we're not marked as active source, but the tv sends keypresses to us, so assume it forgot to activate us + if (!device->IsActiveSource() && command.initiator == CECDEVICE_TV) + device->ActivateSource(); + } return COMMAND_HANDLED; } -- 2.34.1