From: Lars Op den Kamp Date: Thu, 25 Oct 2012 12:26:23 +0000 (+0200) Subject: fixed - some TVs send keypresses to us without making us the active source. mark... X-Git-Tag: upstream/2.2.0~1^2~13^2~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=117863dd4fef4d19bc3590c513ec1192427f2249;p=deb_libcec.git fixed - some TVs send keypresses to us without making us the active source. mark us as active source when this happens. issue #71 --- 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; }