X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FANCommandHandler.cpp;h=554b637f783a7c56f89d5b1baeec23bcffb66ecf;hb=9a54dc825e7730a1f2cb8edb201256dbd88da614;hp=7c2d05906d7b4a33550edb0eb55cbfcdd129268f;hpb=36cc67e083b00ccd6c74be13f5dbf61601dc2795;p=deb_libcec.git diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index 7c2d059..554b637 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -48,61 +48,45 @@ CANCommandHandler::CANCommandHandler(CCECBusDevice *busDevice) : m_bOPTSendDeckStatusUpdateOnActiveSource = false; } -bool CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) +int CANCommandHandler::HandleVendorRemoteButtonDown(const cec_command &command) { - if (m_processor->CECInitialised() && command.parameters.size > 0) - { - CCECClient *client = m_processor->GetClient(command.destination); - - cec_keypress key; - key.duration = CEC_BUTTON_TIMEOUT; - key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN; + if (command.parameters.size == 0) + return CEC_ABORT_REASON_INVALID_OPERAND; - switch (command.parameters[0]) - { - case CEC_USER_CONTROL_CODE_AN_RETURN: - key.keycode = client && client->GetClientVersion() >= CEC_CLIENT_VERSION_1_5_0 ? - CEC_USER_CONTROL_CODE_AN_RETURN : - CEC_USER_CONTROL_CODE_EXIT; - break; - case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: - key.keycode = CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST; - break; - default: - break; - } + if (!m_processor->CECInitialised()) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; - if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN && client) - client->AddKey(key); - } + CCECClient *client = m_processor->GetClient(command.destination); + if (!client) + return CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND; - return true; -} + cec_keypress key; + key.duration = CEC_BUTTON_TIMEOUT; + key.keycode = CEC_USER_CONTROL_CODE_UNKNOWN; -bool CANCommandHandler::HandleCommand(const cec_command &command) -{ - bool bHandled(false); - if (m_processor->IsHandledByLibCEC(command.destination)) + switch (command.parameters[0]) { - switch(command.opcode) - { - case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: - bHandled = true; - HandleVendorRemoteButtonDown(command); - break; - case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: - bHandled = true; - HandleUserControlRelease(command); - break; - default: - break; - } + case CEC_USER_CONTROL_CODE_AN_RETURN: + key.keycode = client && client->GetClientVersion() >= CEC_CLIENT_VERSION_1_5_0 ? + CEC_USER_CONTROL_CODE_AN_RETURN : + CEC_USER_CONTROL_CODE_EXIT; + break; + case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: + key.keycode = CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST; + break; + default: + break; } - if (!bHandled) - bHandled = CCECCommandHandler::HandleCommand(command); + if (key.keycode != CEC_USER_CONTROL_CODE_UNKNOWN && client) + client->AddKey(key); + + return COMMAND_HANDLED; +} - return bHandled; +int CANCommandHandler::HandleVendorRemoteButtonUp(const cec_command &command) +{ + return HandleUserControlRelease(command); } bool CANCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)