2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
34 #include "RLCommandHandler.h"
36 #include "lib/platform/util/timeutils.h"
37 #include "lib/devices/CECBusDevice.h"
38 #include "lib/CECProcessor.h"
39 #include "lib/LibCEC.h"
40 #include "lib/CECClient.h"
43 using namespace PLATFORM
;
45 #define RL_KEY_TOP_MENU 0x10
46 #define RL_KEY_DVD_MENU 0x11
48 CRLCommandHandler::CRLCommandHandler(CCECBusDevice
*busDevice
,
49 int32_t iTransmitTimeout
/* = CEC_DEFAULT_TRANSMIT_TIMEOUT */,
50 int32_t iTransmitWait
/* = CEC_DEFAULT_TRANSMIT_WAIT */,
51 int8_t iTransmitRetries
/* = CEC_DEFAULT_TRANSMIT_RETRIES */,
52 int64_t iActiveSourcePending
/* = 0 */) :
53 CCECCommandHandler(busDevice
, iTransmitTimeout
, iTransmitWait
, iTransmitRetries
, iActiveSourcePending
)
55 m_vendorId
= CEC_VENDOR_TOSHIBA
;
58 bool CRLCommandHandler::InitHandler(void)
62 m_bHandlerInited
= true;
64 if (m_busDevice
->GetLogicalAddress() != CECDEVICE_TV
)
67 CCECBusDevice
*primary
= m_processor
->GetPrimaryDevice();
68 if (primary
&& primary
->GetLogicalAddress() != CECDEVICE_UNREGISTERED
)
70 /* imitate Toshiba devices */
71 if (m_busDevice
->GetLogicalAddress() != primary
->GetLogicalAddress())
73 primary
->SetVendorId(CEC_VENDOR_TOSHIBA
);
74 primary
->ReplaceHandler(false);
77 if (m_busDevice
->GetLogicalAddress() == CECDEVICE_TV
)
79 /* send the vendor id */
80 primary
->TransmitVendorID(CECDEVICE_BROADCAST
, false, false);
87 int CRLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command
&command
)
89 if (!m_processor
->IsHandledByLibCEC(command
.destination
))
90 return CEC_ABORT_REASON_INVALID_OPERAND
;
92 if (command
.parameters
.size
< 4)
93 return CEC_ABORT_REASON_INVALID_OPERAND
;
95 // check whether the vendor id matches
96 if (command
.parameters
[0] != 0x00 ||
97 command
.parameters
[1] != 0x00 ||
98 command
.parameters
[2] != 0x39)
99 return CEC_ABORT_REASON_INVALID_OPERAND
;
101 bool bHandled(false);
102 CCECClient
* client
= m_processor
->GetClient(command
.destination
);
105 switch (command
.parameters
[3])
107 // user control pressed
108 case CEC_OPCODE_USER_CONTROL_PRESSED
:
109 if (command
.parameters
.size
== 5)
111 switch (command
.parameters
[4])
113 // top menu -> root menu
114 case RL_KEY_TOP_MENU
:
115 client
->SetCurrentButton(CEC_USER_CONTROL_CODE_ROOT_MENU
);
117 // dvd menu -> contents menu
118 case RL_KEY_DVD_MENU
:
119 client
->SetCurrentButton(CEC_USER_CONTROL_CODE_CONTENTS_MENU
);
122 RequestEmailFromCustomer(command
);
128 // user control released
129 case CEC_OPCODE_USER_CONTROL_RELEASE
:
140 CCECCommandHandler::HandleDeviceVendorCommandWithId(command
);