/*
* This file is part of the libCEC(R) library.
*
- * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
* libCEC(R) is an original work, containing original code.
*
* libCEC(R) is a trademark of Pulse-Eight Limited.
if (command.parameters.size == 2)
{
uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
- CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iAddress);
+ CCECBusDevice *device = m_processor->GetDevice(command.initiator);
if (device)
{
+ device->SetPhysicalAddress(iAddress);
device->MarkAsActiveSource();
- return COMMAND_HANDLED;
}
+
+ m_processor->GetDevices()->SignalAll(command.opcode);
+ return COMMAND_HANDLED;
}
return CEC_ABORT_REASON_INVALID_OPERAND;
int CCECCommandHandler::HandleImageViewOn(const cec_command &command)
{
CCECBusDevice *device = GetDevice(command.destination);
- if (device && (device->GetCurrentStatus() == CEC_DEVICE_STATUS_PRESENT ||
- device->GetCurrentStatus() == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC))
+ if (device && device->GetCurrentStatus() == CEC_DEVICE_STATUS_PRESENT)
{
if (device->GetCurrentPowerStatus() == CEC_POWER_STATUS_STANDBY ||
device->GetCurrentPowerStatus() == CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY)
device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+ CCECBusDevice* tv = GetDevice(CECDEVICE_TV);
+ if (tv)
+ tv->OnImageViewOnSent(false);
}
return COMMAND_HANDLED;
}
/* one of the device handled by libCEC has been made active */
CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
- if (device && device->IsHandledByLibCEC())
+ if (device)
{
- device->ActivateSource();
+ if (device->IsHandledByLibCEC() && !device->IsActiveSource())
+ device->ActivateSource();
+ else
+ device->MarkAsActiveSource();
return COMMAND_HANDLED;
}
+ else
+ {
+ cec_logical_address previousSource = m_processor->GetActiveSource(false);
+ CCECBusDevice* device = m_processor->GetDevice(previousSource);
+ if (device && device->GetCurrentPhysicalAddress() != iStreamAddress)
+ device->MarkAsInactiveSource();
+ }
}
return CEC_ABORT_REASON_INVALID_OPERAND;
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);
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->MarkAsActiveSource();
+ }
return COMMAND_HANDLED;
}
if (device)
device->SetPhysicalAddress(iNewAddress);
else
- {
LIB_CEC->AddLog(CEC_LOG_DEBUG, "device with logical address %X not found", iAddress);
- }
/* another device reported the same physical address as ours */
if (client)
+ {
+ libcec_parameter param;
+ param.paramType = CEC_PARAMETER_TYPE_STRING;
+ param.paramData = (void*)"Physical address in use by another device. Please verify your settings";
+ client->Alert(CEC_ALERT_PHYSICAL_ADDRESS_ERROR, param);
client->ResetPhysicalAddress();
+ }
}
else
{
return Transmit(command, !bWaitForResponse, false);
}
+bool CCECCommandHandler::TransmitRequestAudioStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */)
+{
+ cec_command command;
+ cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_GIVE_AUDIO_STATUS);
+
+ return Transmit(command, !bWaitForResponse, false);
+}
+
bool CCECCommandHandler::TransmitRequestPhysicalAddress(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */)
{
cec_command command;
return Transmit(command, false, bIsReply);
}
-bool CCECCommandHandler::TransmitSetMenuLanguage(const cec_logical_address iInitiator, const char lang[3], bool bIsReply)
+bool CCECCommandHandler::TransmitSetMenuLanguage(const cec_logical_address iInitiator, const char lang[4], bool bIsReply)
{
cec_command command;
command.Format(command, iInitiator, CECDEVICE_BROADCAST, CEC_OPCODE_SET_MENU_LANGUAGE);
return Transmit(command, false, bIsReply);
}
-bool CCECCommandHandler::TransmitVendorID(const cec_logical_address iInitiator, uint64_t iVendorId, bool bIsReply)
+bool CCECCommandHandler::TransmitVendorID(const cec_logical_address iInitiator, const cec_logical_address UNUSED(iDestination), uint64_t iVendorId, bool bIsReply)
{
cec_command command;
cec_command::Format(command, iInitiator, CECDEVICE_BROADCAST, CEC_OPCODE_DEVICE_VENDOR_ID);
LIB_CEC->AddLog(CEC_LOG_DEBUG, "not sending command '%s': destination device '%s' marked as handled by libCEC", ToString(command.opcode),ToString(command.destination));
return bReturn;
}
+ else if (destinationDevice->IsUnsupportedFeature(command.opcode))
+ {
+ return true;
+ }
}
{
- uint8_t iTries(0), iMaxTries(!command.opcode_set ? 1 : m_iTransmitRetries + 1);
- while (!bReturn && ++iTries <= iMaxTries && !m_busDevice->IsUnsupportedFeature(command.opcode))
+ uint8_t iTries(0), iMaxTries(m_iTransmitRetries + 1);
+ while (!bReturn && ++iTries <= iMaxTries)
{
if ((bReturn = m_processor->Transmit(command, bIsReply)) == true)
{
bool bTvPresent = (tv && tv->GetStatus() == CEC_DEVICE_STATUS_PRESENT);
bool bActiveSourceFailed(false);
if (bTvPresent)
- {
- if (tv->GetCurrentPowerStatus() != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
- bActiveSourceFailed = !m_busDevice->TransmitImageViewOn();
- }
+ bActiveSourceFailed = !m_busDevice->TransmitImageViewOn();
else
LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV not present, not sending 'image view on'");
CLockObject lock(m_mutex);
m_iActiveSourcePending = GetTimeMs() + iDelay;
}
+
+void CCECCommandHandler::RequestEmailFromCustomer(const cec_command& command)
+{
+ bool bInserted(false);
+ map<cec_opcode, vector<cec_command> >::iterator it = m_logsRequested.find(command.opcode);
+ if (it != m_logsRequested.end())
+ {
+ for (vector<cec_command>::const_iterator it2 = it->second.begin(); it2 != it->second.end(); it2++)
+ {
+ // we already logged this one
+ if ((*it2).parameters == command.parameters)
+ return;
+ }
+
+ it->second.push_back(command);
+ bInserted = true;
+ }
+
+ if (!bInserted)
+ {
+ vector<cec_command> commands;
+ commands.push_back(command);
+ m_logsRequested.insert(make_pair(command.opcode, commands));
+ }
+
+ LIB_CEC->AddLog(CEC_LOG_NOTICE, "key with keycode '%s' 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.", CCECTypeUtils::ToString(command).c_str());
+}
+