X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftestclient%2Fmain.cpp;h=b0492866449751f28d4a456a0c49fd344c74c67f;hb=f57cba645f0f22c109355ef55c78cf328adc2d93;hp=b324de214a408fe03678c94af0ceb06eed937fe6;hpb=b74fd339e942f438e288f9e26cca404a5a430925;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index b324de2..b049286 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -30,7 +30,7 @@ * http://www.pulse-eight.net/ */ -#include +#include "../../include/cec.h" #include #include @@ -198,7 +198,7 @@ void ListDevices(ICECAdapter *parser) else { PrintToStdOut("Found devices: %d\n", iDevicesFound); - for (unsigned int iDevicePtr = 0; iDevicePtr < iDevicesFound; iDevicePtr++) + 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); } } @@ -273,9 +273,12 @@ void ShowHelpConsole(void) "[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 << @@ -289,6 +292,64 @@ void ShowHelpConsole(void) "================================================================================" << 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") @@ -828,7 +889,10 @@ bool ProcessConsoleCommand(ICECAdapter *parser, string &input) 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;