* http://www.pulse-eight.net/
*/
-#include <cec.h>
+#include "../../include/cec.h"
#include <cstdio>
#include <fcntl.h>
void ListDevices(ICECAdapter *parser)
{
cec_adapter *devices = new cec_adapter[10];
- uint8_t iDevicesFound = parser->FindAdapters(devices, 10, NULL);
+ int8_t iDevicesFound = parser->FindAdapters(devices, 10, NULL);
if (iDevicesFound <= 0)
{
PrintToStdOut("Found devices: NONE");
}
else
{
- PrintToStdOut("Found devices: %d", iDevicesFound);
- for (unsigned int iDevicePtr = 0; iDevicePtr < iDevicesFound; iDevicePtr++)
- PrintToStdOut("device: %d\npath: %s\ncom port: %s", iDevicePtr + 1, devices[iDevicePtr].path, devices[iDevicePtr].comm);
+ PrintToStdOut("Found devices: %d\n", iDevicesFound);
+ for (int8_t iDevicePtr = 0; iDevicePtr < iDevicesFound; iDevicePtr++)
+ PrintToStdOut("device: %d\npath: %s\ncom port: %s\n", iDevicePtr + 1, devices[iDevicePtr].path, devices[iDevicePtr].comm);
}
}
"[lad] lists active devices on the bus" << endl <<
"[ad] {addr} checks whether the specified device is active." << endl <<
"[at] {type} checks whether the specified device type is active." << endl <<
+ "[sp] {addr} makes the specified physical address active." << endl <<
+ "[spl] {addr} makes the specified logical address active." << endl <<
"[volup] send a volume up command to the amp if present" << endl <<
"[voldown] send a volume down command to the amp if present" << endl <<
"[mute] send a mute/unmute command to the amp if present" << endl <<
+ "[self] show the list of addresses controlled by libCEC" << endl <<
"[scan] scan the CEC bus and display device info" << endl <<
"[mon] {1|0} enable or disable CEC bus monitoring." << endl <<
"[log] {1 - 31} change the log level. see cectypes.h for values." << endl <<
"================================================================================" << endl;
}
+bool ProcessCommandSELF(ICECAdapter *parser, const string &command, string & UNUSED(arguments))
+{
+ if (command == "self")
+ {
+ cec_logical_addresses addr = parser->GetLogicalAddresses();
+ CStdString strOut = "Addresses controlled by libCEC: ";
+ bool bFirst(true);
+ for (uint8_t iPtr = 0; iPtr <= 15; iPtr++)
+ {
+ if (addr[iPtr])
+ {
+ strOut.AppendFormat((bFirst ? "%d%s" : ", %d%s"), iPtr, parser->IsActiveSource((cec_logical_address)iPtr) ? "*" : "");
+ bFirst = false;
+ }
+ }
+ PrintToStdOut(strOut.c_str());
+ return true;
+ }
+
+ return false;
+}
+
+bool ProcessCommandSP(ICECAdapter *parser, const string &command, string &arguments)
+{
+ if (command == "sp")
+ {
+ string strAddress;
+ int iAddress;
+ if (GetWord(arguments, strAddress))
+ {
+ sscanf(strAddress.c_str(), "%x", &iAddress);
+ if (iAddress >= 0 && iAddress <= 0xFFFF)
+ parser->SetStreamPath((uint16_t)iAddress);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool ProcessCommandSPL(ICECAdapter *parser, const string &command, string &arguments)
+{
+ if (command == "spl")
+ {
+ string strAddress;
+ cec_logical_address iAddress;
+ if (GetWord(arguments, strAddress))
+ {
+ iAddress = (cec_logical_address)atoi(strAddress.c_str());
+ if (iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ parser->SetStreamPath(iAddress);
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool ProcessCommandTX(ICECAdapter *parser, const string &command, string &arguments)
{
if (command == "tx" || command == "txn")
ProcessCommandR(parser, command, input) ||
ProcessCommandH(parser, command, input) ||
ProcessCommandLOG(parser, command, input) ||
- ProcessCommandSCAN(parser, command, input);
+ ProcessCommandSCAN(parser, command, input) ||
+ ProcessCommandSP(parser, command, input) ||
+ ProcessCommandSPL(parser, command, input) ||
+ ProcessCommandSELF(parser, command, input);
}
}
return true;