cec: added GetLogicalAddresses()/cec_get_logical_addresses() to the interface, that...
[deb_libcec.git] / src / testclient / main.cpp
index c8e6819f091ba6741d06e9e685ee41fd5e7d406f..b987ff9ac37d7e3b8994d5107dac0087b6ba2bd0 100644 (file)
@@ -278,6 +278,7 @@ void ShowHelpConsole(void)
   "[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 <<
@@ -291,6 +292,28 @@ 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")
@@ -868,7 +891,8 @@ bool ProcessConsoleCommand(ICECAdapter *parser, string &input)
       ProcessCommandLOG(parser, command, input) ||
       ProcessCommandSCAN(parser, command, input) ||
       ProcessCommandSP(parser, command, input) ||
-      ProcessCommandSPL(parser, command, input);
+      ProcessCommandSPL(parser, command, input) ||
+      ProcessCommandSELF(parser, command, input);
     }
   }
   return true;