X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=23fd550b068ea9a2a4ee15550faadb6dbb2faa6e;hb=5827f4aa75371f5633afbc4fd98336a08f39352f;hp=80bc280a3bb9b8af47e7be43582baa8ef9f22111;hpb=3fd2a2b89c3f6f9d8e28c19e45622386a981ef8d;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 80bc280..23fd550 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -44,7 +44,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) : m_processor(m_busDevice->GetProcessor()), m_iTransmitTimeout(CEC_DEFAULT_TRANSMIT_TIMEOUT), m_iTransmitWait(CEC_DEFAULT_TRANSMIT_WAIT), - m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES) + m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES), + m_bHandlerInited(false) { } @@ -158,6 +159,9 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) case CEC_OPCODE_TEXT_VIEW_ON: HandleTextViewOn(command); break; + case CEC_OPCODE_FEATURE_ABORT: + HandleFeatureAbort(command); + break; default: UnhandledCommand(command); bHandled = false; @@ -221,6 +225,15 @@ bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command) return SetVendorId(command); } +bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command) +{ + if (command.parameters.size == 2) + { + m_processor->m_busDevices[command.initiator]->SetUnsupportedFeature((cec_opcode)command.parameters[0]); + } + return true; +} + bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command) { if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination)) @@ -299,7 +312,11 @@ bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) - return device->TransmitPhysicalAddress(); + { + device->SetActiveSource(); + return device->TransmitPhysicalAddress() && + device->TransmitActiveSource(); + } } return false; @@ -577,8 +594,10 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) } } } - - m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]); + else + { + m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]); + } return true; } } @@ -888,21 +907,21 @@ bool CCECCommandHandler::TransmitDeckStatus(const cec_logical_address iInitiator return Transmit(command); } -bool CCECCommandHandler::TransmitKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key) +bool CCECCommandHandler::TransmitKeypress(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */) { cec_command command; cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_USER_CONTROL_PRESSED); command.parameters.PushBack((uint8_t)key); - return Transmit(command); + return Transmit(command, bWait); } -bool CCECCommandHandler::TransmitKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination) +bool CCECCommandHandler::TransmitKeyRelease(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWait /* = true */) { cec_command command; cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_USER_CONTROL_RELEASE); - return Transmit(command); + return Transmit(command, bWait); } bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* = true */) @@ -920,3 +939,21 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* return false; } + +bool CCECCommandHandler::InitHandler(void) +{ + if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) + { + CCECBusDevice *primary = m_processor->GetPrimaryDevice(); + primary->SetPowerStatus(CEC_POWER_STATUS_ON); + primary->SetMenuState(CEC_MENU_STATE_ACTIVATED); + + if (m_processor->GetPrimaryDevice()->GetPhysicalAddress(false) != 0xffff) + { + m_processor->SetActiveSource(); + primary->TransmitMenuState(m_busDevice->GetLogicalAddress()); + m_bHandlerInited = true; + } + } + return true; +}