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 LIB_CEC m_busDevice->GetProcessor()->GetLib()
47 #define RL_KEY_TOP_MENU 0x10
48 #define RL_KEY_DVD_MENU 0x11
50 CRLCommandHandler::CRLCommandHandler(CCECBusDevice
*busDevice
,
51 int32_t iTransmitTimeout
/* = CEC_DEFAULT_TRANSMIT_TIMEOUT */,
52 int32_t iTransmitWait
/* = CEC_DEFAULT_TRANSMIT_WAIT */,
53 int8_t iTransmitRetries
/* = CEC_DEFAULT_TRANSMIT_RETRIES */,
54 int64_t iActiveSourcePending
/* = 0 */) :
55 CCECCommandHandler(busDevice
, iTransmitTimeout
, iTransmitWait
, iTransmitRetries
, iActiveSourcePending
)
57 m_vendorId
= CEC_VENDOR_TOSHIBA
;
60 bool CRLCommandHandler::InitHandler(void)
64 m_bHandlerInited
= true;
66 if (m_busDevice
->GetLogicalAddress() != CECDEVICE_TV
)
69 CCECBusDevice
*primary
= m_processor
->GetPrimaryDevice();
70 if (primary
&& primary
->GetLogicalAddress() != CECDEVICE_UNREGISTERED
)
72 /* imitate Toshiba devices */
73 if (m_busDevice
->GetLogicalAddress() != primary
->GetLogicalAddress())
75 primary
->SetVendorId(CEC_VENDOR_TOSHIBA
);
76 primary
->ReplaceHandler(false);
79 if (m_busDevice
->GetLogicalAddress() == CECDEVICE_TV
)
81 /* send the vendor id */
82 primary
->TransmitVendorID(CECDEVICE_BROADCAST
, false, false);
89 int CRLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command
&command
)
91 if (!m_processor
->IsHandledByLibCEC(command
.destination
))
92 return CEC_ABORT_REASON_INVALID_OPERAND
;
94 if (command
.parameters
.size
< 4)
95 return CEC_ABORT_REASON_INVALID_OPERAND
;
97 // check whether the vendor id matches
98 if (command
.parameters
[0] != 0x00 ||
99 command
.parameters
[1] != 0x00 ||
100 command
.parameters
[2] != 0x39)
101 return CEC_ABORT_REASON_INVALID_OPERAND
;
103 bool bHandled(false);
104 CCECClient
* client
= m_processor
->GetClient(command
.destination
);
107 switch (command
.parameters
[3])
109 // user control pressed
110 case CEC_OPCODE_USER_CONTROL_PRESSED
:
111 if (command
.parameters
.size
== 5)
113 switch (command
.parameters
[4])
115 // top menu -> root menu
116 case RL_KEY_TOP_MENU
:
117 client
->SetCurrentButton(CEC_USER_CONTROL_CODE_ROOT_MENU
);
119 // dvd menu -> contents menu
120 case RL_KEY_DVD_MENU
:
121 client
->SetCurrentButton(CEC_USER_CONTROL_CODE_CONTENTS_MENU
);
124 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "key with keycode '%02x' is not mapped in libCEC. please send an email to support@pulse-eight.com with this keycode, and tell which key you pressed, and we'll add support for this key.");
130 // user control released
131 case CEC_OPCODE_USER_CONTROL_RELEASE
:
142 CCECCommandHandler::HandleDeviceVendorCommandWithId(command
);