Merge branch 'master' into release
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 29 Feb 2012 00:10:32 +0000 (01:10 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 29 Feb 2012 00:10:32 +0000 (01:10 +0100)
52 files changed:
.gitignore
COPYING
ChangeLog
debian/changelog
include/cec.h
include/cecloader.h
include/cectypes.h
project/libcec.vcxproj
project/libcec.vcxproj.filters
src/CecSharpTester/CecSharpClient.cs
src/LibCecSharp/CecSharpTypes.h
src/LibCecSharp/LibCecSharp.cpp
src/cec-config-gui/AsyncForm.cs
src/cec-config-gui/CecButtonConfig.cs
src/cec-config-gui/CecConfigGUI.Designer.cs
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/DeviceInformation.cs
src/cec-config-gui/Program.cs
src/cec-config-gui/actions/RescanDevices.cs
src/cec-config-gui/actions/SendActivateSource.cs
src/cec-config-gui/actions/SendImageViewOn.cs
src/cec-config-gui/actions/SendStandby.cs
src/cec-config-gui/actions/ShowDeviceInfo.cs
src/cec-config-gui/actions/UpdateConnectedDevice.cs
src/cec-config-gui/actions/UpdateDeviceInfo.cs
src/cec-config-gui/actions/UpdateEvent.cs
src/cec-config-gui/actions/UpdatePhysicalAddress.cs
src/cec-config/Makefile.am
src/cec-config/cec-config.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/Makefile.am
src/lib/adapter/AdapterCommunication.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h
src/lib/devices/CECBusDevice.h
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/RLCommandHandler.cpp [new file with mode: 0644]
src/lib/implementations/RLCommandHandler.h [new file with mode: 0644]
src/lib/platform/posix/os-threads.h
src/lib/platform/sockets/socket.h
src/lib/platform/threads/mutex.h
src/lib/platform/threads/threads.h
src/lib/platform/util/buffer.h
src/lib/platform/util/timeutils.h
src/testclient/Makefile.am
src/testclient/main.cpp
support/cec-flash-device.sh
support/create-driver-installer.cmd
support/create-installer.cmd

index 2a282e97d818bfb640ea65bf235125be4742cfc8..fbf4edc91fe3b9c3d92965ea5db93df262ce47c0 100644 (file)
 *.suo
 *.user
 
-/support/sign-binary.cmd
-/support/create-cat.cmd
+/support/private
 
 /driver/p8usb-cec.cat
+/bootloader-driver/p8_usb_dfu.cat
 
 aclocal.m4
 autom4te.cache
diff --git a/COPYING b/COPYING
index d07d89b3f912ec23da397fb040c4399de2fb951e..c19af3b5065b44fe8f18d30f929b1e1f9beb25e4 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,34 +1,33 @@
-/*
- * 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 a original work, containing original code.
- *
- * libCEC(R) is a trademark of Pulse-Eight Limited.
- *
- * This program is dual-licensed; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- *
- * Alternatively, you can license this library under a commercial license,
- * please contact Pulse-Eight Licensing for more information.
- *
- * For more information contact:
- * Pulse-Eight Licensing       <license@pulse-eight.com>
- *     http://www.pulse-eight.com/
- *     http://www.pulse-eight.net/
- */
+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 a original work, containing original code.
+
+libCEC(R) is a trademark of Pulse-Eight Limited.
+
+This program is dual-licensed; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Alternatively, you can license this library under a commercial license,
+please contact Pulse-Eight Licensing for more information.
+
+For more information contact:
+Pulse-Eight Licensing       <license@pulse-eight.com>
+    http://www.pulse-eight.com/
+    http://www.pulse-eight.net/
+
+
  
                      GNU GENERAL PUBLIC LICENSE
                        Version 2, June 1991
index f7cbc06ba87cd5f38ce4df2d566f581565ca4445..d407e38ef70c1d5cd8627b5a2ee53cd3a4b04a72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,60 @@
+libcec (1.5-2) unstable; urgency=low
+
+  * changed/added:
+    * added Toshiba's vendor id, and set the device ID of the primary device to
+      Toshiba's and transmit it when starting
+    * lock in SyncedBuffer
+    * added a timeout to StopThread()
+    * also add commands to unsupported features when receiving
+      CEC_ABORT_REASON_REFUSED
+    * cec-config-gui: set cbPortNumber enabled when the physical address
+      override isn't checked instead
+    * cec-config-gui: added support for the new 'send inactive source' setting
+
+  * interface changes:
+    * added an 'send inactive source' option to libcec_configuration, only
+      supported by client/server 1.5.1 and up. bugzid: 439
+    * added a command to the interface to start the bootloader directly,
+      without going through all checks. bugzid: 218
+    * LibCecSharp: implemented support for the new 'send inactive source'
+      setting
+
+  * fixed:
+    * don't send an updated configuration when libCEC hasn't been initialised
+      fully. bugzid: 459
+    * don't send an updated configuration back when initialising. let the
+      client call the GetCurrentConfiguration() method. bugzid: 459
+    * configuration updates from libCEC. bugzid: 459
+    * fixed accidental double deref. the method parameter already does that.
+      github #24
+    * use CLOCK_MONOTONIC for timing info, since gettimeofday is affected by
+      ntp and by manually adjusting the system time
+    * the timeout value of pthread_cond_timedwait has to be referenced to
+      CLOCK_REALTIME
+    * don't add data to the input buffer in CUSBCECAdapterCommunication before
+      it's fully initialised
+    * fixed return value of CUSBCECAdapterCommunication::ParseMessage(). fixes
+      messages not being parsed in certain occasions
+    * don't try to transmit when the processor is being stopped
+    * set the server version in the LibCEC's constructor, since this is
+      checked by clients. fixes 'invalid libCEC version' popup when inserting
+      the adapter
+    * don't wait for the full timeout to pass in CCECProcessor::
+      OpenConnection(), but retry to connect 2 times. fixes 'port busy' errors
+      when initialising libCEC. bugzid: 436
+    * use the correct Sleep() method in CCECProcessor::OpenConnection(). the
+      thread hasn't been started there yet, so the sleep wasn't working. fixes
+      'device or resource busy' when plugging in the adapter. bugzid: 436
+    * check the adapter ping and firmware before starting the reader thread, so
+      we really leave the com port alone for a second when it fails because of
+      a busy error. bugzid: 436
+    * ensure that the connection is really closed before retrying to connect.
+      bugzid: 436
+    * LibCecSharp: recreate the delegates properly when (re)connecting to
+      LibCecSharp
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Tue, 28 Feb 2012 21:19:00 +0100
+
 libcec (1.5-1) unstable; urgency=low
 
   * changed/added:
index f7cbc06ba87cd5f38ce4df2d566f581565ca4445..d407e38ef70c1d5cd8627b5a2ee53cd3a4b04a72 100644 (file)
@@ -1,3 +1,60 @@
+libcec (1.5-2) unstable; urgency=low
+
+  * changed/added:
+    * added Toshiba's vendor id, and set the device ID of the primary device to
+      Toshiba's and transmit it when starting
+    * lock in SyncedBuffer
+    * added a timeout to StopThread()
+    * also add commands to unsupported features when receiving
+      CEC_ABORT_REASON_REFUSED
+    * cec-config-gui: set cbPortNumber enabled when the physical address
+      override isn't checked instead
+    * cec-config-gui: added support for the new 'send inactive source' setting
+
+  * interface changes:
+    * added an 'send inactive source' option to libcec_configuration, only
+      supported by client/server 1.5.1 and up. bugzid: 439
+    * added a command to the interface to start the bootloader directly,
+      without going through all checks. bugzid: 218
+    * LibCecSharp: implemented support for the new 'send inactive source'
+      setting
+
+  * fixed:
+    * don't send an updated configuration when libCEC hasn't been initialised
+      fully. bugzid: 459
+    * don't send an updated configuration back when initialising. let the
+      client call the GetCurrentConfiguration() method. bugzid: 459
+    * configuration updates from libCEC. bugzid: 459
+    * fixed accidental double deref. the method parameter already does that.
+      github #24
+    * use CLOCK_MONOTONIC for timing info, since gettimeofday is affected by
+      ntp and by manually adjusting the system time
+    * the timeout value of pthread_cond_timedwait has to be referenced to
+      CLOCK_REALTIME
+    * don't add data to the input buffer in CUSBCECAdapterCommunication before
+      it's fully initialised
+    * fixed return value of CUSBCECAdapterCommunication::ParseMessage(). fixes
+      messages not being parsed in certain occasions
+    * don't try to transmit when the processor is being stopped
+    * set the server version in the LibCEC's constructor, since this is
+      checked by clients. fixes 'invalid libCEC version' popup when inserting
+      the adapter
+    * don't wait for the full timeout to pass in CCECProcessor::
+      OpenConnection(), but retry to connect 2 times. fixes 'port busy' errors
+      when initialising libCEC. bugzid: 436
+    * use the correct Sleep() method in CCECProcessor::OpenConnection(). the
+      thread hasn't been started there yet, so the sleep wasn't working. fixes
+      'device or resource busy' when plugging in the adapter. bugzid: 436
+    * check the adapter ping and firmware before starting the reader thread, so
+      we really leave the com port alone for a second when it fails because of
+      a busy error. bugzid: 436
+    * ensure that the connection is really closed before retrying to connect.
+      bugzid: 436
+    * LibCecSharp: recreate the delegates properly when (re)connecting to
+      LibCecSharp
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Tue, 28 Feb 2012 21:19:00 +0100
+
 libcec (1.5-1) unstable; urgency=low
 
   * changed/added:
index 4a6ad989e7ef84042c2d47928cffda86e1b77124..0332088906e72a0a5c254ec42b023251aa02e00e 100644 (file)
@@ -443,6 +443,12 @@ extern "C" DECLSPEC void * CECInit(const char *strDeviceName, CEC::cec_device_ty
  */
 extern "C" DECLSPEC void * CECInitialise(CEC::libcec_configuration *configuration);
 
+/*!
+ * @brief Try to connect to the adapter and send the "start bootloader" command, without initialising libCEC and going through all checks
+ * @return True when the command was send, false otherwise.
+ */
+extern "C" DECLSPEC bool CECStartBootloader(void);
+
 /*!
  * @brief Unload the CEC adapter library.
  */
index 624f29a5c7a54961ab53f0565e95945138fbb65c..5d4361d6199034c31b24732f52fe01c7fa137a8c 100644 (file)
@@ -111,6 +111,34 @@ void UnloadLibCec(CEC::ICECAdapter *device)
   g_libCEC = NULL;
 }
 
+/*!
+ * @brief Start the bootloader on the first device that was detected.
+ * @param strLib The name of and/or path to libCEC
+ * @return True when the command was sent, false otherwise.
+ */
+bool LibCecBootloader(const char *strLib = NULL)
+{
+  if (!g_libCEC)
+#if defined(_WIN64)
+    g_libCEC = LoadLibrary(strLib ? strLib : "libcec.x64.dll");
+#else
+    g_libCEC = LoadLibrary(strLib ? strLib : "libcec.dll");
+#endif
+  if (!g_libCEC)
+    return NULL;
+
+  typedef bool (__cdecl*_LibCecBootloader)(void);
+  _LibCecBootloader LibCecBootloader;
+  LibCecBootloader = (_LibCecBootloader) (GetProcAddress(g_libCEC, "CECStartBootloader"));
+  if (!LibCecBootloader)
+    return false;
+
+  bool bReturn = LibCecBootloader();
+  FreeLibrary(g_libCEC);
+  g_libCEC = NULL;
+  return bReturn;
+}
+
 #else
 
 #include <dlfcn.h>
@@ -206,6 +234,44 @@ void UnloadLibCec(CEC::ICECAdapter *device)
   dlclose(g_libCEC);
 }
 
+/*!
+ * @brief Start the bootloader on the first device that was detected.
+ * @param strLib The name of and/or path to libCEC
+ * @return True when the command was sent, false otherwise.
+ */
+bool LibCecBootloader(const char *strLib = NULL)
+{
+  if (!g_libCEC)
+  {
+#if defined(__APPLE__)
+    g_libCEC = dlopen(strLib ? strLib : "libcec.dylib", RTLD_LAZY);
+#else
+    g_libCEC = dlopen(strLib ? strLib : "libcec.so", RTLD_LAZY);
+#endif
+    if (!g_libCEC)
+    {
+#if defined(__APPLE__)
+      cout << "cannot find " << (strLib ? strLib : "libcec.dylib") << dlerror() << endl;
+#else
+      cout << "cannot find " << (strLib ? strLib : "libcec.so") << dlerror() << endl;
+#endif
+      return NULL;
+    }
+  }
+
+  typedef bool _LibCecBootloader(void);
+  _LibCecBootloader* LibCecBootloader = (_LibCecBootloader*) dlsym(g_libCEC, "CECStartBootloader");
+  if (!LibCecBootloader)
+  {
+    cout << "cannot find CECStartBootloader" << endl;
+    return NULL;
+  }
+
+  bool bReturn = LibCecBootloader();
+  dlclose(g_libCEC);
+  return bReturn;
+}
+
 #endif
 
 #endif /* CECLOADER_H_ */
index 5f25b9437e2f58d9b3c087a4d00f7376a8fd9cb4..76056cd63458701285c5c5d1fe9c741c7cd50de9 100644 (file)
@@ -72,12 +72,14 @@ namespace CEC {
 #define CEC_BUTTON_TIMEOUT           500
 #define CEC_POWER_STATE_REFRESH_TIME 30000
 #define CEC_FW_VERSION_UNKNOWN       0xFFFF
+#define CEC_CONNECT_TRIES            3
 
 #define CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE  1
 #define CEC_DEFAULT_SETTING_ACTIVATE_SOURCE       1
 #define CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN    1
 #define CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER 1
 #define CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY  1
+#define CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE  1
 
 #define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500
 #define CEC_DEFAULT_TRANSMIT_TIMEOUT    1000
@@ -620,6 +622,7 @@ typedef enum cec_vendor_id
   CEC_VENDOR_YAMAHA    = 0x00A0DE,
   CEC_VENDOR_PHILIPS   = 0x00903E,
   CEC_VENDOR_SONY      = 0x080046,
+  CEC_VENDOR_TOSHIBA   = 0x000039,
   CEC_VENDOR_UNKNOWN   = 0
 } cec_vendor_id;
 
@@ -944,13 +947,15 @@ typedef struct ICECCallbacks
 typedef enum cec_client_version
 {
   CEC_CLIENT_VERSION_PRE_1_5 = 0,
-  CEC_CLIENT_VERSION_1_5_0   = 0x1500
+  CEC_CLIENT_VERSION_1_5_0   = 0x1500,
+  CEC_CLIENT_VERSION_1_5_1   = 0x1501
 } cec_client_version;
 
 typedef enum cec_server_version
 {
   CEC_SERVER_VERSION_PRE_1_5 = 0,
-  CEC_SERVER_VERSION_1_5_0   = 0x1500
+  CEC_SERVER_VERSION_1_5_0   = 0x1500,
+  CEC_SERVER_VERSION_1_5_1   = 0x1501
 } cec_server_version;
 
 typedef struct libcec_configuration
@@ -974,6 +979,7 @@ typedef struct libcec_configuration
   uint8_t               bActivateSource;      /*!< make libCEC the active source on the bus when starting the player application */
   uint8_t               bPowerOffScreensaver; /*!< put devices in standby mode when activating the screensaver */
   uint8_t               bPowerOffOnStandby;   /*!< put this PC in standby mode when the TV is switched off */
+  uint8_t               bSendInactiveSource;  /*!< send an 'inactive source' message when stopping the player. added in 1.5.1 */
 
   void *                callbackParam;        /*!< the object to pass along with a call of the callback methods. NULL to ignore */
   ICECCallbacks *       callbacks;            /*!< the callback methods to use. set this to NULL when not using callbacks */
@@ -999,11 +1005,12 @@ typedef struct libcec_configuration
     #if CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN == 1
     powerOffDevices.Set(CECDEVICE_BROADCAST);
     #endif
-               #if CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1
-               wakeDevices.Set(CECDEVICE_TV);
-               #endif
+    #if CEC_DEFAULT_SETTING_ACTIVATE_SOURCE == 1
+    wakeDevices.Set(CECDEVICE_TV);
+    #endif
     bPowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER;
     bPowerOffOnStandby   = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY;
+    bSendInactiveSource  = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE;
 
     callbackParam    = NULL;
     callbacks        = NULL;
index 0ca4ccafb3ab20a0f107c9d12ab500fb0e46d127..3c1e89b837222c5325caf766a1bdb2899582cf4d 100644 (file)
@@ -36,6 +36,7 @@
     <ClInclude Include="..\src\lib\devices\CECTV.h" />
     <ClInclude Include="..\src\lib\implementations\ANCommandHandler.h" />
     <ClInclude Include="..\src\lib\implementations\CECCommandHandler.h" />
+    <ClInclude Include="..\src\lib\implementations\RLCommandHandler.h" />
     <ClInclude Include="..\src\lib\implementations\SLCommandHandler.h" />
     <ClInclude Include="..\src\lib\implementations\VLCommandHandler.h" />
     <ClInclude Include="..\src\lib\LibCEC.h" />
@@ -66,6 +67,7 @@
     <ClCompile Include="..\src\lib\devices\CECTV.cpp" />
     <ClCompile Include="..\src\lib\implementations\ANCommandHandler.cpp" />
     <ClCompile Include="..\src\lib\implementations\CECCommandHandler.cpp" />
+    <ClCompile Include="..\src\lib\implementations\RLCommandHandler.cpp" />
     <ClCompile Include="..\src\lib\implementations\SLCommandHandler.cpp" />
     <ClCompile Include="..\src\lib\implementations\VLCommandHandler.cpp" />
     <ClCompile Include="..\src\lib\LibCEC.cpp" />
index a85f501934f38b3a36245e205f3f472b60a3412b..56f1a464a29d6120280b634ab8b04d097e78c28f 100644 (file)
     <ClInclude Include="..\src\lib\adapter\USBCECAdapterMessage.h">
       <Filter>adapter</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\lib\implementations\RLCommandHandler.h">
+      <Filter>implementations</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\src\lib\CECProcessor.cpp" />
     <ClCompile Include="..\src\lib\adapter\USBCECAdapterDetection.cpp">
       <Filter>adapter</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\lib\implementations\RLCommandHandler.cpp">
+      <Filter>implementations</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="libcec.rc" />
index 006c83ae24e15a72e0063aff54690dfd4867ede2..442c282afacedfd0843193d97499780e2a843400 100644 (file)
@@ -31,7 +31,6 @@
  */
 
 using System;
-using System.Collections.Generic;
 using System.Text;
 using CecSharp;
 
@@ -94,45 +93,7 @@ namespace CecSharpClient
       return 1;
     }
 
-    void FlushLog()
-    {
-      CecLogMessage message = Lib.GetNextLogMessage();
-      bool bGotMessage = !message.Empty;
-      while (bGotMessage)
-      {
-        if (((int)message.Level & LogLevel) == (int)message.Level)
-        {
-          string strLevel = "";
-          switch (message.Level)
-          {
-            case CecLogLevel.Error:
-              strLevel = "ERROR:   ";
-              break;
-            case CecLogLevel.Warning:
-              strLevel = "WARNING: ";
-              break;
-            case CecLogLevel.Notice:
-              strLevel = "NOTICE:  ";
-              break;
-            case CecLogLevel.Traffic:
-              strLevel = "TRAFFIC: ";
-              break;
-            case CecLogLevel.Debug:
-              strLevel = "DEBUG:   ";
-              break;
-            default:
-              break;
-          }
-          string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message);
-          Console.WriteLine(strLog);
-        }
-
-        message = Lib.GetNextLogMessage();
-        bGotMessage = !message.Empty;
-      }
-    }
-
-    public bool Connect(int timeout)
+      public bool Connect(int timeout)
     {
       CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
       if (adapters.Length > 0)
@@ -168,31 +129,31 @@ namespace CecSharpClient
     void ShowConsoleHelp()
     {
       Console.WriteLine(
-        "================================================================================" + System.Environment.NewLine +
-        "Available commands:" + System.Environment.NewLine +
-        System.Environment.NewLine +
-        "[tx] {bytes}              transfer bytes over the CEC line." + System.Environment.NewLine +
-        "[txn] {bytes}             transfer bytes but don't wait for transmission ACK." + System.Environment.NewLine +
-        "[on] {address}            power on the device with the given logical address." + System.Environment.NewLine +
-        "[standby] {address}       put the device with the given address in standby mode." + System.Environment.NewLine +
-        "[la] {logical_address}    change the logical address of the CEC adapter." + System.Environment.NewLine +
-        "[pa] {physical_address}   change the physical address of the CEC adapter." + System.Environment.NewLine +
-        "[osd] {addr} {string}     set OSD message on the specified device." + System.Environment.NewLine +
-        "[ver] {addr}              get the CEC version of the specified device." + System.Environment.NewLine +
-        "[ven] {addr}              get the vendor ID of the specified device." + System.Environment.NewLine +
-        "[lang] {addr}             get the menu language of the specified device." + System.Environment.NewLine +
-        "[pow] {addr}              get the power status of the specified device." + System.Environment.NewLine +
-        "[poll] {addr}             poll the specified device." + System.Environment.NewLine +
-        "[scan]                    scan the CEC bus and display device info" + System.Environment.NewLine +
-        "[mon] {1|0}               enable or disable CEC bus monitoring." + System.Environment.NewLine +
-        "[log] {1 - 31}            change the log level. see cectypes.h for values." + System.Environment.NewLine +
-        "[ping]                    send a ping command to the CEC adapter." + System.Environment.NewLine +
-        "[bl]                      to let the adapter enter the bootloader, to upgrade" + System.Environment.NewLine +
-        "                          the flash rom." + System.Environment.NewLine +
-        "[r]                       reconnect to the CEC adapter." + System.Environment.NewLine +
-        "[h] or [help]             show this help." + System.Environment.NewLine +
-        "[q] or [quit]             to quit the CEC test client and switch off all" + System.Environment.NewLine +
-        "                          connected CEC devices." + System.Environment.NewLine +
+        "================================================================================" + Environment.NewLine +
+        "Available commands:" + Environment.NewLine +
+        Environment.NewLine +
+        "[tx] {bytes}              transfer bytes over the CEC line." + Environment.NewLine +
+        "[txn] {bytes}             transfer bytes but don't wait for transmission ACK." + Environment.NewLine +
+        "[on] {address}            power on the device with the given logical address." + Environment.NewLine +
+        "[standby] {address}       put the device with the given address in standby mode." + Environment.NewLine +
+        "[la] {logical_address}    change the logical address of the CEC adapter." + Environment.NewLine +
+        "[pa] {physical_address}   change the physical address of the CEC adapter." + Environment.NewLine +
+        "[osd] {addr} {string}     set OSD message on the specified device." + Environment.NewLine +
+        "[ver] {addr}              get the CEC version of the specified device." + Environment.NewLine +
+        "[ven] {addr}              get the vendor ID of the specified device." + Environment.NewLine +
+        "[lang] {addr}             get the menu language of the specified device." + Environment.NewLine +
+        "[pow] {addr}              get the power status of the specified device." + Environment.NewLine +
+        "[poll] {addr}             poll the specified device." + Environment.NewLine +
+        "[scan]                    scan the CEC bus and display device info" + Environment.NewLine +
+        "[mon] {1|0}               enable or disable CEC bus monitoring." + Environment.NewLine +
+        "[log] {1 - 31}            change the log level. see cectypes.h for values." + Environment.NewLine +
+        "[ping]                    send a ping command to the CEC adapter." + Environment.NewLine +
+        "[bl]                      to let the adapter enter the bootloader, to upgrade" + Environment.NewLine +
+        "                          the flash rom." + Environment.NewLine +
+        "[r]                       reconnect to the CEC adapter." + Environment.NewLine +
+        "[h] or [help]             show this help." + Environment.NewLine +
+        "[q] or [quit]             to quit the CEC test client and switch off all" + Environment.NewLine +
+        "                          connected CEC devices." + Environment.NewLine +
         "================================================================================");
     }
 
@@ -205,7 +166,7 @@ namespace CecSharpClient
         Console.WriteLine("waiting for input");
 
         command = Console.ReadLine();
-        if (command.Length == 0)
+        if (command != null && command.Length == 0)
           continue;
         string[] splitCommand = command.Split(' ');
         if (splitCommand[0] == "tx" || splitCommand[0] == "txn")
index 5d617941b0f4316c422cd257c249d5aba62281b8..65fa7cd4fa5e22bd2d8ba71b74edb39a91d73b33 100644 (file)
@@ -326,13 +326,15 @@ namespace CecSharp
        public enum class CecClientVersion
        {
                VersionPre1_5 = 0,
-               Version1_5_0  = 0x1500
+               Version1_5_0  = 0x1500,
+    Version1_5_1  = 0x1501
        };
 
   public enum class CecServerVersion
        {
                VersionPre1_5 = 0,
-               Version1_5_0  = 0x1500
+               Version1_5_0  = 0x1500,
+    Version1_5_1  = 0x1501
        };
 
        public ref class CecAdapter
@@ -547,6 +549,7 @@ namespace CecSharp
 
                        PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1;
                        PowerOffOnStandby   = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1;
+      SendInactiveSource  = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE == 1;
                }
 
                void SetCallbacks(CecCallbackMethods ^callbacks)
@@ -586,6 +589,7 @@ namespace CecSharp
 
                        PowerOffScreensaver = config.bPowerOffScreensaver == 1;
                        PowerOffOnStandby = config.bPowerOffOnStandby == 1;
+      SendInactiveSource = config.bSendInactiveSource == 1;
                }
 
                property System::String ^     DeviceName;
@@ -606,6 +610,7 @@ namespace CecSharp
                property CecLogicalAddresses ^PowerOffDevices;
                property bool                 PowerOffScreensaver;
                property bool                 PowerOffOnStandby;
+    property bool                 SendInactiveSource;
 
                property CecCallbackMethods ^ Callbacks;
        };
@@ -663,37 +668,11 @@ namespace CecSharp
        public ref class CecCallbackMethods
        {
        public:
-               CecCallbackMethods(void)
-               {
-                       m_bHasCallbacks = false;
-                       msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context();
-
-                       // create the delegate method for the log message callback
-                       m_logMessageDelegate           = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged);
-                       m_logMessageGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate);
-                       g_logCB                        = static_cast<LOGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer());
-                       g_cecCallbacks.CBCecLogMessage = CecLogMessageCB;
-
-                       // create the delegate method for the keypress callback
-                       m_keypressDelegate           = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged);
-                       m_keypressGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate);
-                       g_keyCB                      = static_cast<KEYCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer());
-                       g_cecCallbacks.CBCecKeyPress = CecKeyPressCB;
-
-                       // create the delegate method for the command callback
-                       m_commandDelegate           = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged);
-                       m_commandGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate);
-                       g_commandCB                 = static_cast<COMMANDCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer());
-                       g_cecCallbacks.CBCecCommand = CecCommandCB;
-
-                       // create the delegate method for the configuration change callback
-                       m_configDelegate            = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged);
-                       m_configGCHandle            = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate);
-                       g_configCB                  = static_cast<CONFIGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer());
-                       g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB;
-
-                       delete context;
-               }
+    CecCallbackMethods(void)
+    {
+      m_bHasCallbacks = false;
+      m_bDelegatesCreated = false;
+    }
 
        ~CecCallbackMethods(void)
    {
@@ -709,13 +688,12 @@ namespace CecSharp
        public:
                virtual void DisableCallbacks(void)
                {
-                       if (m_bHasCallbacks)
-                               delete m_callbacks;
-                       m_bHasCallbacks = false;
+                       DestroyDelegates();
                }
+
                virtual bool EnableCallbacks(CecCallbackMethods ^ callbacks)
                {
-                       DisableCallbacks();
+      CreateDelegates();
                        if (!m_bHasCallbacks)
                        {
                                m_bHasCallbacks = true;
@@ -790,16 +768,53 @@ namespace CecSharp
 
                void DestroyDelegates()
                {
-                       if (m_bHasCallbacks)
+      m_bHasCallbacks = false;
+                       if (m_bDelegatesCreated)
                        {
-                               m_bHasCallbacks = false;
-                               delete m_callbacks;
+        m_bDelegatesCreated = false;
                                m_logMessageGCHandle.Free();
                                m_keypressGCHandle.Free();
                                m_commandGCHandle.Free();
                        }
                }
 
+    void CreateDelegates()
+    {
+      DestroyDelegates();
+
+      if (!m_bDelegatesCreated)
+      {
+        msclr::interop::marshal_context ^ context = gcnew msclr::interop::marshal_context();
+
+        // create the delegate method for the log message callback
+        m_logMessageDelegate           = gcnew CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged);
+        m_logMessageGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate);
+        g_logCB                        = static_cast<LOGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate).ToPointer());
+        g_cecCallbacks.CBCecLogMessage = CecLogMessageCB;
+
+        // create the delegate method for the keypress callback
+        m_keypressDelegate           = gcnew CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged);
+        m_keypressGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate);
+        g_keyCB                      = static_cast<KEYCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate).ToPointer());
+        g_cecCallbacks.CBCecKeyPress = CecKeyPressCB;
+
+        // create the delegate method for the command callback
+        m_commandDelegate           = gcnew CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged);
+        m_commandGCHandle           = System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate);
+        g_commandCB                 = static_cast<COMMANDCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate).ToPointer());
+        g_cecCallbacks.CBCecCommand = CecCommandCB;
+
+        // create the delegate method for the configuration change callback
+        m_configDelegate            = gcnew CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged);
+        m_configGCHandle            = System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate);
+        g_configCB                  = static_cast<CONFIGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate).ToPointer());
+        g_cecCallbacks.CBCecConfigurationChanged = CecConfigCB;
+
+        delete context;
+        m_bDelegatesCreated = true;
+      }
+    }
+
                CecLogMessageManagedDelegate ^                    m_logMessageDelegate;
                static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle;
                LOGCB                                             m_logMessageCallback;
@@ -818,5 +833,6 @@ namespace CecSharp
 
                CecCallbackMethods ^ m_callbacks;
          bool                 m_bHasCallbacks;
+    bool                 m_bDelegatesCreated;
        };
 }
index 014dea00741571e7d6b9c2af440d5ab83551e2df..76dd00624e7948d3fcbf9eedfcf7d73f156f1b86 100644 (file)
@@ -45,13 +45,15 @@ namespace CecSharp
        public:
          LibCecSharp(LibCECConfiguration ^config)
                {
-                       CecCallbackMethods::EnableCallbacks(config->Callbacks);
+      m_callbacks = config->Callbacks;
+                       CecCallbackMethods::EnableCallbacks(m_callbacks);
                        if (!InitialiseLibCec(config))
                                throw gcnew Exception("Could not initialise LibCecSharp");
                }
 
                LibCecSharp(String ^ strDeviceName, CecDeviceTypeList ^ deviceTypes)
                {
+      m_callbacks = gcnew CecCallbackMethods();
                        LibCECConfiguration ^config = gcnew LibCECConfiguration();
                        config->SetCallbacks(this);
                        config->DeviceName  = strDeviceName;
@@ -80,8 +82,6 @@ namespace CecSharp
                        ConvertConfiguration(context, config, libCecConfig);
 
                        m_libCec = (ICECAdapter *) CECInitialise(&libCecConfig);
-                       config->Update(libCecConfig);
-
 
                        delete context;
                        return m_libCec != NULL;
@@ -117,6 +117,7 @@ namespace CecSharp
                        }
                        config.bPowerOffScreensaver = netConfig->PowerOffScreensaver ? 1 : 0;
                        config.bPowerOffOnStandby   = netConfig->PowerOffOnStandby ? 1 : 0;
+      config.bSendInactiveSource  = netConfig->SendInactiveSource ? 1 : 0;
                        config.callbacks            = &g_cecCallbacks;
                }
 
@@ -141,6 +142,8 @@ namespace CecSharp
 
                bool Open(String ^ strPort, int iTimeoutMs)
                {
+      CecCallbackMethods::EnableCallbacks(m_callbacks);
+      EnableCallbacks(m_callbacks);
                        marshal_context ^ context = gcnew marshal_context();
                        const char* strPortC = context->marshal_as<const char*>(strPort);
                        bool bReturn = m_libCec->Open(strPortC, iTimeoutMs);
@@ -552,5 +555,6 @@ namespace CecSharp
 
        private:
                ICECAdapter *        m_libCec;
+    CecCallbackMethods ^ m_callbacks;
        };
 }
index 5898ce54be44112ecfc4da1341c7f930bd2fb6a6..c4d02bf2edc7676d8e92abc6de02e02e10fa12ea 100644 (file)
@@ -10,10 +10,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetControlEnabledCallback d = new SetControlEnabledCallback(SetControlEnabled);
+        SetControlEnabledCallback d = SetControlEnabled;
         try
         {
-          this.Invoke(d, new object[] { control, val });
+          Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
       }
@@ -28,10 +28,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetControlTextCallback d = new SetControlTextCallback(SetControlText);
+        SetControlTextCallback d = SetControlText;
         try
         {
-          this.Invoke(d, new object[] { control, val });
+          Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
       }
@@ -46,10 +46,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetCheckboxCheckedCallback d = new SetCheckboxCheckedCallback(SetCheckboxChecked);
+        SetCheckboxCheckedCallback d = SetCheckboxChecked;
         try
         {
-          this.Invoke(d, new object[] { control, val });
+          Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
       }
@@ -64,10 +64,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetCheckboxItemCheckedCallback d = new SetCheckboxItemCheckedCallback(SetCheckboxItemChecked);
+        SetCheckboxItemCheckedCallback d = SetCheckboxItemChecked;
         try
         {
-          this.Invoke(d, new object[] { control, index, val });
+          Invoke(d, new object[] { control, index, val });
         }
         catch (Exception) { }
       }
@@ -82,10 +82,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue);
+        SetProgressValueCallback d = SetProgressValue;
         try
         {
-          this.Invoke(d, new object[] { control, val });
+          Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
       }
@@ -100,10 +100,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetComboBoxItemsCallback d = new SetComboBoxItemsCallback(SetComboBoxItems);
+        SetComboBoxItemsCallback d = SetComboBoxItems;
         try
         {
-          this.Invoke(d, new object[] { control, selectedText, val });
+          Invoke(d, new object[] { control, selectedText, val });
         }
         catch (Exception) { }
       }
@@ -120,10 +120,10 @@ namespace CecConfigGui
     {
       if (control.InvokeRequired)
       {
-        SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
+        SetControlVisibleCallback d = SetControlVisible;
         try
         {
-          this.Invoke(d, new object[] { control, val });
+          Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
       }
@@ -136,12 +136,12 @@ namespace CecConfigGui
     delegate void DisplayDialogCallback(Form control, bool modal);
     public void DisplayDialog(Form control, bool modal)
     {
-      if (this.InvokeRequired)
+      if (InvokeRequired)
       {
-        DisplayDialogCallback d = new DisplayDialogCallback(DisplayDialog);
+        DisplayDialogCallback d = DisplayDialog;
         try
         {
-          this.Invoke(d, new object[] { control, modal });
+          Invoke(d, new object[] { control, modal });
         }
         catch (Exception) { }
       }
index 1c2cc81916a286379790be92742f177ee4504861..1fb070d40b14d419910634e1ae940d4e1c4273a4 100644 (file)
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
 
 namespace CecConfigGui
 {
index d45e6d315b32c14e1bca227f86bd82a1403fccee..417aec229f63df1f4532dd6980731ac9360ef09c 100644 (file)
@@ -19,6 +19,7 @@
       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CecConfigGUI));
       this.tabControl1 = new System.Windows.Forms.TabControl();
       this.Configuration = new System.Windows.Forms.TabPage();
+      this.cbOverrideAddress = new System.Windows.Forms.CheckBox();
       this.bReloadConfig = new System.Windows.Forms.Button();
       this.cbVendorOverride = new System.Windows.Forms.CheckBox();
       this.cbVendorId = new System.Windows.Forms.ComboBox();
@@ -73,7 +74,7 @@
       this.helpConnectedHDMIDevice = new System.Windows.Forms.ToolTip(this.components);
       this.helpPhysicalAddress = new System.Windows.Forms.ToolTip(this.components);
       this.helpDeviceType = new System.Windows.Forms.ToolTip(this.components);
-      this.cbOverrideAddress = new System.Windows.Forms.CheckBox();
+      this.cbSendInactiveSource = new System.Windows.Forms.CheckBox();
       this.tabControl1.SuspendLayout();
       this.Configuration.SuspendLayout();
       this.tbButtons.SuspendLayout();
@@ -98,6 +99,7 @@
       // 
       // Configuration
       // 
+      this.Configuration.Controls.Add(this.cbSendInactiveSource);
       this.Configuration.Controls.Add(this.cbOverrideAddress);
       this.Configuration.Controls.Add(this.bReloadConfig);
       this.Configuration.Controls.Add(this.cbVendorOverride);
       this.Configuration.Text = "Configuration";
       this.Configuration.UseVisualStyleBackColor = true;
       // 
+      // cbOverrideAddress
+      // 
+      this.cbOverrideAddress.AutoSize = true;
+      this.cbOverrideAddress.Enabled = false;
+      this.cbOverrideAddress.Location = new System.Drawing.Point(10, 97);
+      this.cbOverrideAddress.Name = "cbOverrideAddress";
+      this.cbOverrideAddress.Size = new System.Drawing.Size(147, 17);
+      this.cbOverrideAddress.TabIndex = 31;
+      this.cbOverrideAddress.Text = "Override physical address";
+      this.cbOverrideAddress.UseVisualStyleBackColor = true;
+      this.cbOverrideAddress.CheckedChanged += new System.EventHandler(this.cbOverrideAddress_CheckedChanged);
+      // 
       // bReloadConfig
       // 
       this.bReloadConfig.Enabled = false;
       // 
       this.cbPowerOffOnStandby.AutoSize = true;
       this.cbPowerOffOnStandby.Enabled = false;
-      this.cbPowerOffOnStandby.Location = new System.Drawing.Point(10, 297);
+      this.cbPowerOffOnStandby.Location = new System.Drawing.Point(9, 278);
       this.cbPowerOffOnStandby.Name = "cbPowerOffOnStandby";
       this.cbPowerOffOnStandby.Size = new System.Drawing.Size(292, 17);
       this.cbPowerOffOnStandby.TabIndex = 22;
       // 
       this.cbPowerOffScreensaver.AutoSize = true;
       this.cbPowerOffScreensaver.Enabled = false;
-      this.cbPowerOffScreensaver.Location = new System.Drawing.Point(10, 273);
+      this.cbPowerOffScreensaver.Location = new System.Drawing.Point(9, 255);
       this.cbPowerOffScreensaver.Name = "cbPowerOffScreensaver";
       this.cbPowerOffScreensaver.Size = new System.Drawing.Size(301, 17);
       this.cbPowerOffScreensaver.TabIndex = 21;
       // 
       this.cbActivateSource.AutoSize = true;
       this.cbActivateSource.Enabled = false;
-      this.cbActivateSource.Location = new System.Drawing.Point(10, 249);
+      this.cbActivateSource.Location = new System.Drawing.Point(9, 232);
       this.cbActivateSource.Name = "cbActivateSource";
       this.cbActivateSource.Size = new System.Drawing.Size(284, 17);
       this.cbActivateSource.TabIndex = 19;
       // 
       this.cbUseTVMenuLanguage.AutoSize = true;
       this.cbUseTVMenuLanguage.Enabled = false;
-      this.cbUseTVMenuLanguage.Location = new System.Drawing.Point(10, 225);
+      this.cbUseTVMenuLanguage.Location = new System.Drawing.Point(10, 209);
       this.cbUseTVMenuLanguage.Name = "cbUseTVMenuLanguage";
       this.cbUseTVMenuLanguage.Size = new System.Drawing.Size(168, 17);
       this.cbUseTVMenuLanguage.TabIndex = 18;
       // 
       this.lPlayerConfig.AutoSize = true;
       this.lPlayerConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-      this.lPlayerConfig.Location = new System.Drawing.Point(6, 188);
+      this.lPlayerConfig.Location = new System.Drawing.Point(6, 182);
       this.lPlayerConfig.Name = "lPlayerConfig";
       this.lPlayerConfig.Size = new System.Drawing.Size(198, 24);
       this.lPlayerConfig.TabIndex = 16;
       this.lStatus.TabIndex = 2;
       this.lStatus.Text = "Initialising...";
       // 
-      // cbOverrideAddress
+      // cbSendInactiveSource
       // 
-      this.cbOverrideAddress.AutoSize = true;
-      this.cbOverrideAddress.Enabled = false;
-      this.cbOverrideAddress.Location = new System.Drawing.Point(10, 97);
-      this.cbOverrideAddress.Name = "cbOverrideAddress";
-      this.cbOverrideAddress.Size = new System.Drawing.Size(147, 17);
-      this.cbOverrideAddress.TabIndex = 31;
-      this.cbOverrideAddress.Text = "Override physical address";
-      this.cbOverrideAddress.UseVisualStyleBackColor = true;
-      this.cbOverrideAddress.CheckedChanged += new System.EventHandler(this.cbOverrideAddress_CheckedChanged);
+      this.cbSendInactiveSource.AutoSize = true;
+      this.cbSendInactiveSource.Enabled = false;
+      this.cbSendInactiveSource.Location = new System.Drawing.Point(9, 301);
+      this.cbSendInactiveSource.Name = "cbSendInactiveSource";
+      this.cbSendInactiveSource.Size = new System.Drawing.Size(261, 17);
+      this.cbSendInactiveSource.TabIndex = 32;
+      this.cbSendInactiveSource.Text = "Send \'inactive source\' when shutting down XBMC";
+      this.cbSendInactiveSource.UseVisualStyleBackColor = true;
       // 
       // CecConfigGUI
       // 
     private System.Windows.Forms.Label lConnectedPhysicalAddress;
     private System.Windows.Forms.Label lAdapterConfig;
     private System.Windows.Forms.CheckBox cbOverrideAddress;
+    private System.Windows.Forms.CheckBox cbSendInactiveSource;
   }
 }
\ No newline at end of file
index 5004e041024dfa77eac9913bfbc49a6fd09b4482..94ce2ad5a016212f4897d41c74c4c4457fc13d2e 100644 (file)
@@ -1,7 +1,5 @@
 ï»¿using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
@@ -30,7 +28,7 @@ namespace CecConfigGui
       Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
       Config.DeviceName = "CEC Config";
       Config.GetSettingsFromROM = true;
-      Config.ClientVersion = CecClientVersion.Version1_5_0;
+      Config.ClientVersion = CecClientVersion.Version1_5_1;
       Callbacks = new CecCallbackWrapper(this);
       Config.SetCallbacks(Callbacks);
       LoadXMLConfiguration(ref Config);
@@ -40,8 +38,8 @@ namespace CecConfigGui
       LoadButtonConfiguration();
 
       ActiveProcess = new ConnectToDevice(ref Lib, Config);
-      ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-      (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+      ActiveProcess.EventHandler += ProcessEventHandler;
+      (new Thread(ActiveProcess.Run)).Start();
     }
 
     private bool LoadXMLConfiguration(ref LibCECConfiguration config)
@@ -136,7 +134,7 @@ namespace CecConfigGui
                   case "wake_devices":
                     {
                       config.WakeDevices.Clear();
-                      string[] split = value.Split(new char[] { ' ' });
+                      string[] split = value.Split(new[] { ' ' });
                       foreach (string dev in split)
                       {
                         byte iLogicalAddress;
@@ -162,6 +160,10 @@ namespace CecConfigGui
                   case "port":
                     //TODO
                     break;
+                  // 1.5.1 settings
+                  case "send_inactive_source":
+                    config.SendInactiveSource = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                    break;
                   default:
                     break;
                 }
@@ -178,85 +180,85 @@ namespace CecConfigGui
     private void LoadButtonConfiguration()
     {
       //TODO load the real configuration
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select", (new CecSharp.CecKeypress() { Keycode = 0x00 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Up", (new CecSharp.CecKeypress() { Keycode = 0x01 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Down", (new CecSharp.CecKeypress() { Keycode = 0x02 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left", (new CecSharp.CecKeypress() { Keycode = 0x03 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right", (new CecSharp.CecKeypress() { Keycode = 0x04 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Up", (new CecSharp.CecKeypress() { Keycode = 0x05 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Down", (new CecSharp.CecKeypress() { Keycode = 0x06 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Up", (new CecSharp.CecKeypress() { Keycode = 0x07 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Down", (new CecSharp.CecKeypress() { Keycode = 0x08 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Root menu", (new CecSharp.CecKeypress() { Keycode = 0x09 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Setup menu", (new CecSharp.CecKeypress() { Keycode = 0x0A }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Contents menu", (new CecSharp.CecKeypress() { Keycode = 0x0B }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Favourite menu", (new CecSharp.CecKeypress() { Keycode = 0x0C }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Exit", (new CecSharp.CecKeypress() { Keycode = 0x0D }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("0", (new CecSharp.CecKeypress() { Keycode = 0x20 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("1", (new CecSharp.CecKeypress() { Keycode = 0x21 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("2", (new CecSharp.CecKeypress() { Keycode = 0x22 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("3", (new CecSharp.CecKeypress() { Keycode = 0x23 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("4", (new CecSharp.CecKeypress() { Keycode = 0x24 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("5", (new CecSharp.CecKeypress() { Keycode = 0x25 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("6", (new CecSharp.CecKeypress() { Keycode = 0x26 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("7", (new CecSharp.CecKeypress() { Keycode = 0x27 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("8", (new CecSharp.CecKeypress() { Keycode = 0x28 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("9", (new CecSharp.CecKeypress() { Keycode = 0x29 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem(".", (new CecSharp.CecKeypress() { Keycode = 0x2A }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Enter", (new CecSharp.CecKeypress() { Keycode = 0x2B }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Clear", (new CecSharp.CecKeypress() { Keycode = 0x2C }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Next favourite", (new CecSharp.CecKeypress() { Keycode = 0x2F }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel up", (new CecSharp.CecKeypress() { Keycode = 0x30 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel down", (new CecSharp.CecKeypress() { Keycode = 0x31 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Previous channel", (new CecSharp.CecKeypress() { Keycode = 0x32 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sound select", (new CecSharp.CecKeypress() { Keycode = 0x33 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Input select", (new CecSharp.CecKeypress() { Keycode = 0x34 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Display information", (new CecSharp.CecKeypress() { Keycode = 0x35 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Help", (new CecSharp.CecKeypress() { Keycode = 0x36 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page up", (new CecSharp.CecKeypress() { Keycode = 0x37 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page down", (new CecSharp.CecKeypress() { Keycode = 0x38 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power", (new CecSharp.CecKeypress() { Keycode = 0x40 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume up", (new CecSharp.CecKeypress() { Keycode = 0x41 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume down", (new CecSharp.CecKeypress() { Keycode = 0x42 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute", (new CecSharp.CecKeypress() { Keycode = 0x43 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play", (new CecSharp.CecKeypress() { Keycode = 0x44 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop", (new CecSharp.CecKeypress() { Keycode = 0x45 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause", (new CecSharp.CecKeypress() { Keycode = 0x46 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record", (new CecSharp.CecKeypress() { Keycode = 0x47 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Rewind", (new CecSharp.CecKeypress() { Keycode = 0x48 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Fast forward", (new CecSharp.CecKeypress() { Keycode = 0x49 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Eject", (new CecSharp.CecKeypress() { Keycode = 0x4A }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Forward", (new CecSharp.CecKeypress() { Keycode = 0x4B }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Backward", (new CecSharp.CecKeypress() { Keycode = 0x4C }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop record", (new CecSharp.CecKeypress() { Keycode = 0x4D }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record", (new CecSharp.CecKeypress() { Keycode = 0x4E }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Angle", (new CecSharp.CecKeypress() { Keycode = 0x50 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sub picture", (new CecSharp.CecKeypress() { Keycode = 0x51 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Video on demand", (new CecSharp.CecKeypress() { Keycode = 0x52 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Electronic program guide", (new CecSharp.CecKeypress() { Keycode = 0x53 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Timer programming", (new CecSharp.CecKeypress() { Keycode = 0x54 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Initial configuration", (new CecSharp.CecKeypress() { Keycode = 0x55 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play (function)", (new CecSharp.CecKeypress() { Keycode = 0x60 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause play (function)", (new CecSharp.CecKeypress() { Keycode = 0x61 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record (function)", (new CecSharp.CecKeypress() { Keycode = 0x62 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record (function)", (new CecSharp.CecKeypress() { Keycode = 0x63 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop (function)", (new CecSharp.CecKeypress() { Keycode = 0x64 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute (function)", (new CecSharp.CecKeypress() { Keycode = 0x65 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Restore volume", (new CecSharp.CecKeypress() { Keycode = 0x66 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Tune", (new CecSharp.CecKeypress() { Keycode = 0x67 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select media", (new CecSharp.CecKeypress() { Keycode = 0x68 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select AV input", (new CecSharp.CecKeypress() { Keycode = 0x69 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select audio input", (new CecSharp.CecKeypress() { Keycode = 0x6A }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power toggle", (new CecSharp.CecKeypress() { Keycode = 0x6B }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power off", (new CecSharp.CecKeypress() { Keycode = 0x6C }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power on", (new CecSharp.CecKeypress() { Keycode = 0x6D }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F1 (blue)", (new CecSharp.CecKeypress() { Keycode = 0x71 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F2 (red)", (new CecSharp.CecKeypress() { Keycode = 0x72 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F3 (green)", (new CecSharp.CecKeypress() { Keycode = 0x73 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F4 (yellow)", (new CecSharp.CecKeypress() { Keycode = 0x74 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F5", (new CecSharp.CecKeypress() { Keycode = 0x75 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Data", (new CecSharp.CecKeypress() { Keycode = 0x76 }), string.Empty));
-      this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecSharp.CecKeypress() { Keycode = 0x91 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select", (new CecKeypress { Keycode = 0x00 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Up", (new CecKeypress { Keycode = 0x01 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Down", (new CecKeypress { Keycode = 0x02 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left", (new CecKeypress { Keycode = 0x03 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right", (new CecKeypress { Keycode = 0x04 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Up", (new CecKeypress { Keycode = 0x05 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Down", (new CecKeypress { Keycode = 0x06 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Up", (new CecKeypress { Keycode = 0x07 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Down", (new CecKeypress { Keycode = 0x08 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Root menu", (new CecKeypress { Keycode = 0x09 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Setup menu", (new CecKeypress { Keycode = 0x0A }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Contents menu", (new CecKeypress { Keycode = 0x0B }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Favourite menu", (new CecKeypress { Keycode = 0x0C }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Exit", (new CecKeypress { Keycode = 0x0D }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("0", (new CecKeypress { Keycode = 0x20 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("1", (new CecKeypress { Keycode = 0x21 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("2", (new CecKeypress { Keycode = 0x22 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("3", (new CecKeypress { Keycode = 0x23 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("4", (new CecKeypress { Keycode = 0x24 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("5", (new CecKeypress { Keycode = 0x25 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("6", (new CecKeypress { Keycode = 0x26 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("7", (new CecKeypress { Keycode = 0x27 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("8", (new CecKeypress { Keycode = 0x28 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("9", (new CecKeypress { Keycode = 0x29 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem(".", (new CecKeypress { Keycode = 0x2A }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Enter", (new CecKeypress { Keycode = 0x2B }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Clear", (new CecKeypress { Keycode = 0x2C }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Next favourite", (new CecKeypress { Keycode = 0x2F }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel up", (new CecKeypress { Keycode = 0x30 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel down", (new CecKeypress { Keycode = 0x31 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Previous channel", (new CecKeypress { Keycode = 0x32 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sound select", (new CecKeypress { Keycode = 0x33 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Input select", (new CecKeypress { Keycode = 0x34 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Display information", (new CecKeypress { Keycode = 0x35 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Help", (new CecKeypress { Keycode = 0x36 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page up", (new CecKeypress { Keycode = 0x37 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page down", (new CecKeypress { Keycode = 0x38 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power", (new CecKeypress { Keycode = 0x40 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume up", (new CecKeypress { Keycode = 0x41 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume down", (new CecKeypress { Keycode = 0x42 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute", (new CecKeypress { Keycode = 0x43 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play", (new CecKeypress { Keycode = 0x44 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop", (new CecKeypress { Keycode = 0x45 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause", (new CecKeypress { Keycode = 0x46 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record", (new CecKeypress { Keycode = 0x47 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Rewind", (new CecKeypress { Keycode = 0x48 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Fast forward", (new CecKeypress { Keycode = 0x49 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Eject", (new CecKeypress { Keycode = 0x4A }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Forward", (new CecKeypress { Keycode = 0x4B }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Backward", (new CecKeypress { Keycode = 0x4C }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop record", (new CecKeypress { Keycode = 0x4D }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record", (new CecKeypress { Keycode = 0x4E }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Angle", (new CecKeypress { Keycode = 0x50 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sub picture", (new CecKeypress { Keycode = 0x51 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Video on demand", (new CecKeypress { Keycode = 0x52 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Electronic program guide", (new CecKeypress { Keycode = 0x53 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Timer programming", (new CecKeypress { Keycode = 0x54 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Initial configuration", (new CecKeypress { Keycode = 0x55 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play (function)", (new CecKeypress { Keycode = 0x60 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause play (function)", (new CecKeypress { Keycode = 0x61 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record (function)", (new CecKeypress { Keycode = 0x62 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record (function)", (new CecKeypress { Keycode = 0x63 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop (function)", (new CecKeypress { Keycode = 0x64 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute (function)", (new CecKeypress { Keycode = 0x65 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Restore volume", (new CecKeypress { Keycode = 0x66 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Tune", (new CecKeypress { Keycode = 0x67 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select media", (new CecKeypress { Keycode = 0x68 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select AV input", (new CecKeypress { Keycode = 0x69 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select audio input", (new CecKeypress { Keycode = 0x6A }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power toggle", (new CecKeypress { Keycode = 0x6B }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power off", (new CecKeypress { Keycode = 0x6C }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power on", (new CecKeypress { Keycode = 0x6D }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F1 (blue)", (new CecKeypress { Keycode = 0x71 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F2 (red)", (new CecKeypress { Keycode = 0x72 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F3 (green)", (new CecKeypress { Keycode = 0x73 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F4 (yellow)", (new CecKeypress { Keycode = 0x74 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F5", (new CecKeypress { Keycode = 0x75 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Data", (new CecKeypress { Keycode = 0x76 }), string.Empty));
+      cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecKeypress { Keycode = 0x91 }), string.Empty));
     }
 
     private void ProcessEventHandler(object src, UpdateEvent updateEvent)
@@ -324,8 +326,8 @@ namespace CecConfigGui
 
     private void SetControlsEnabled(bool val)
     {
-      SetControlEnabled(cbPortNumber, val && !Config.AutodetectAddress);
-      SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 && !Config.AutodetectAddress ? val : false);
+      SetControlEnabled(cbPortNumber, val && !cbOverrideAddress.Checked);
+      SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 && !cbOverrideAddress.Checked && val);
       SetControlEnabled(cbOverrideAddress, val);
       SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress && cbOverrideAddress.Checked);
       SetControlEnabled(cbDeviceType, val);
@@ -337,6 +339,7 @@ namespace CecConfigGui
       SetControlEnabled(cbPowerOffDevices, val);
       SetControlEnabled(cbVendorOverride, val);
       SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
+      SetControlEnabled(cbSendInactiveSource, val);
       SetControlEnabled(bClose, val);
       SetControlEnabled(bSaveConfig, val);
       SetControlEnabled(bReloadConfig, val);
@@ -392,7 +395,7 @@ namespace CecConfigGui
     }
 
     #region Actions
-    public void ReloadXMLConfiguration()
+    public void ReloadXmlConfiguration()
     {
       LoadXMLConfiguration(ref Config);
       Lib.SetConfiguration(Config);
@@ -407,8 +410,8 @@ namespace CecConfigGui
         UpdatingInfoPanel = panel;
         panel.SetControlEnabled(panel.bUpdate, false);
         ActiveProcess = new UpdateDeviceInfo(this, ref Lib, panel);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -420,8 +423,8 @@ namespace CecConfigGui
         SetControlText(cbPortNumber, string.Empty);
         SetControlText(cbConnectedDevice, string.Empty);
         ActiveProcess = new UpdatePhysicalAddress(ref Lib, physicalAddress);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -431,8 +434,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new UpdateConfiguration(ref Lib, Config);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -442,8 +445,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new SendImageViewOn(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -453,8 +456,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new SendActivateSource(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -464,8 +467,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new SendStandby(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -475,8 +478,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new ShowDeviceInfo(this, ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
     #endregion
@@ -485,6 +488,8 @@ namespace CecConfigGui
     private void cbOverrideAddress_CheckedChanged(object sender, EventArgs e)
     {
       SetControlEnabled(tbPhysicalAddress, ((CheckBox)sender).Checked);
+      SetControlEnabled(cbPortNumber, !((CheckBox)sender).Checked);
+      SetControlEnabled(cbConnectedDevice, !((CheckBox)sender).Checked && cbConnectedDevice.Items.Count > 1);
     }
 
     private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
@@ -502,9 +507,9 @@ namespace CecConfigGui
     private void UpdateSelectedDevice()
     {
       if (HasAVRDevice)
-        SetComboBoxItems(this.cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString, new object[] { TVVendorString, AVRVendorString });
+        SetComboBoxItems(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString, new object[] { TVVendorString, AVRVendorString });
       else
-        SetComboBoxItems(this.cbConnectedDevice, TVVendorString, new object[] { TVVendorString });
+        SetComboBoxItems(cbConnectedDevice, TVVendorString, new object[] { TVVendorString });
     }
 
     public void SetConnectedDevice(CecLogicalAddress address, int portnumber)
@@ -513,8 +518,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new UpdateConnectedDevice(ref Lib, address, portnumber);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
 
@@ -525,7 +530,7 @@ namespace CecConfigGui
 
     private void bCancel_Click(object sender, EventArgs e)
     {
-      this.Dispose();
+      Dispose();
     }
 
     private void bSave_Click(object sender, EventArgs e)
@@ -536,6 +541,7 @@ namespace CecConfigGui
       Config.ActivateSource = cbActivateSource.Checked;
       Config.PowerOffScreensaver = cbPowerOffScreensaver.Checked;
       Config.PowerOffOnStandby = cbPowerOffOnStandby.Checked;
+      Config.SendInactiveSource = cbSendInactiveSource.Checked;
       Config.WakeDevices = WakeDevices;
       Config.PowerOffDevices = PowerOffDevices;
 
@@ -610,6 +616,10 @@ namespace CecConfigGui
               output.Append(strSleepDevices.ToString().Trim()); 
               output.AppendLine("\" />");
 
+              // only supported by 1.5.1+ clients
+              output.AppendLine("<!-- the following lines are only supported by v1.5.1+ clients -->");
+              output.AppendLine("<setting id=\"send_inactive_source\" value=\"" + (Config.SendInactiveSource ? 1 : 0) + "\" />");
+
               output.AppendLine("</settings>");
               writer.Write(output.ToString());
               writer.Close();
@@ -640,7 +650,7 @@ namespace CecConfigGui
       }
       else
       {
-        ReloadXMLConfiguration();
+        ReloadXmlConfiguration();
       }
     }
 
@@ -708,10 +718,10 @@ namespace CecConfigGui
     {
       if (dgButtons.InvokeRequired)
       {
-        SelectKeypressRowCallback d = new SelectKeypressRowCallback(SelectKeypressRow);
+        SelectKeypressRowCallback d = SelectKeypressRow;
         try
         {
-          this.Invoke(d, new object[] { key });
+          Invoke(d, new object[] { key });
         }
         catch (Exception) { }
       }
@@ -764,39 +774,39 @@ namespace CecConfigGui
     delegate void SetActiveDevicesCallback(string[] activeDevices);
     private void SetActiveDevices(string[] activeDevices)
     {
-      if (this.cbCommandDestination.InvokeRequired)
+      if (cbCommandDestination.InvokeRequired)
       {
-        SetActiveDevicesCallback d = new SetActiveDevicesCallback(SetActiveDevices);
+        SetActiveDevicesCallback d = SetActiveDevices;
         try
         {
-          this.Invoke(d, new object[] { activeDevices });
+          Invoke(d, new object[] { activeDevices });
         }
         catch (Exception) { }
       }
       else
       {
-        this.cbCommandDestination.Items.Clear();
+        cbCommandDestination.Items.Clear();
         foreach (string item in activeDevices)
-          this.cbCommandDestination.Items.Add(item);
+          cbCommandDestination.Items.Add(item);
       }
     }
 
     delegate CecLogicalAddress GetTargetDeviceCallback();
     private CecLogicalAddress GetTargetDevice()
     {
-      if (this.cbCommandDestination.InvokeRequired)
+      if (cbCommandDestination.InvokeRequired)
       {
-        GetTargetDeviceCallback d = new GetTargetDeviceCallback(GetTargetDevice);
+        GetTargetDeviceCallback d = GetTargetDevice;
         CecLogicalAddress retval = CecLogicalAddress.Unknown;
         try
         {
-          retval = (CecLogicalAddress)this.Invoke(d, new object[] { });
+          retval = (CecLogicalAddress)Invoke(d, new object[] { });
         }
         catch (Exception) { }
         return retval;
       }
 
-      return GetLogicalAddressFromString(this.cbCommandDestination.Text);
+      return GetLogicalAddressFromString(cbCommandDestination.Text);
     }
 
     private CecLogicalAddress GetLogicalAddressFromString(string name)
@@ -863,11 +873,11 @@ namespace CecConfigGui
     private void cbCommandDestination_SelectedIndexChanged(object sender, EventArgs e)
     {
       bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem);
-      this.bVolUp.Enabled = enableVolumeButtons;
-      this.bVolDown.Enabled = enableVolumeButtons;
-      this.bMute.Enabled = enableVolumeButtons;
-      this.bActivateSource.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
-      this.bScan.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
+      bVolUp.Enabled = enableVolumeButtons;
+      bVolDown.Enabled = enableVolumeButtons;
+      bMute.Enabled = enableVolumeButtons;
+      bActivateSource.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
+      bScan.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
     }
 
     private void bVolUp_Click(object sender, EventArgs e)
@@ -897,8 +907,8 @@ namespace CecConfigGui
       {
         SetControlsEnabled(false);
         ActiveProcess = new RescanDevices(ref Lib);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+        ActiveProcess.EventHandler += ProcessEventHandler;
+        (new Thread(ActiveProcess.Run)).Start();
       }
     }
     #endregion
@@ -909,10 +919,10 @@ namespace CecConfigGui
     {
       if (tbLog.InvokeRequired)
       {
-        UpdateLogCallback d = new UpdateLogCallback(UpdateLog);
+        UpdateLogCallback d = UpdateLog;
         try
         {
-          this.Invoke(d, new object[] { });
+          Invoke(d, new object[] { });
         }
         catch (Exception) { }
       }
@@ -1038,6 +1048,7 @@ namespace CecConfigGui
       SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
       SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
       SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
+      SetCheckboxChecked(cbSendInactiveSource, Config.SendInactiveSource);
       UpdateSelectedDevice();
 
       for (int iPtr = 0; iPtr < 15; iPtr++)
@@ -1153,7 +1164,7 @@ namespace CecConfigGui
       get
       {
         CecLogicalAddresses addr = new CecLogicalAddresses();
-        foreach (object item in this.cbWakeDevices.CheckedItems)
+        foreach (object item in cbWakeDevices.CheckedItems)
         {
           string c = item as string;
           addr.Set(GetLogicalAddressFromString(c));
@@ -1166,7 +1177,7 @@ namespace CecConfigGui
       get
       {
         CecLogicalAddresses addr = new CecLogicalAddresses();
-        foreach (object item in this.cbPowerOffDevices.CheckedItems)
+        foreach (object item in cbPowerOffDevices.CheckedItems)
         {
           string c = item as string;
           addr.Set(GetLogicalAddressFromString(c));
index 0743e9ed655905b6784b1c7b7da93b6b875f08e1..f7992e3ef68e2fe11cb5872da187380dee61a77d 100644 (file)
@@ -1,9 +1,4 @@
 ï»¿using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Text;
 using System.Windows.Forms;
 using CecSharp;
 
@@ -19,8 +14,8 @@ namespace CecConfigGui
       Lib = lib;
       Address = address;
       InitializeComponent();
-      this.lDevice.Text = lib.ToString(address);
-      this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
+      lDevice.Text = lib.ToString(address);
+      lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
       Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
     }
 
index 0bc424c6f5b6aeb9d1084d0ca1993162293837a1..25dbf33ade6553d75cdfba4ba2a19d52559445ae 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using System;
-using System.Collections.Generic;
 using System.Windows.Forms;
 
 namespace CecConfigGui
index c81538d6577a3185391c3532429d3d47da06449d..33c6be9e0dbc092815c09db36949040408ae3405 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using CecSharp;
-using System.Windows.Forms;
 
 namespace CecConfigGui.actions
 {
index 17154d6d0f47c78db902de3ae36a761bd6b22ddc..1470c1988975698b275966eb8d1e95a9d0352b84 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index 29e261eaff0a1da95b7da184df7ba8a1b488ebe1..6757073b3214cc7110b723ae632dd6e585185dd6 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index f2b587ea522944923b3c43d64f93e692fc989c35..99bd0239d5faeb9c6153c40ff7ca9f82b7cddd3d 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index 628d4a9829a44d24faa3b4dcff8804b83976650e..8e6a48de71cbb42b8e07648ce80c7d1181746e5b 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index c91358ebbc9ca2dea206b2be1b942cfe7c27a198..3fb635ba79e598fefc3899d27fc7e4e2f2fce13a 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index 3cbde24d31ecf3da825378944eb38dfa14e05a8f..4fbf3934d9320ac2d8bdd35e70f5da6a71b32db6 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index dae21bfc438439d024a819805821bfeedb626f8b..a7e2df6bbb2227e83aea53d9692f87dc1c517941 100644 (file)
@@ -1,6 +1,4 @@
 ï»¿using System;
-using System.Collections.Generic;
-using System.Text;
 using CecSharp;
 
 namespace CecConfigGui
@@ -62,11 +60,7 @@ namespace CecConfigGui
 
   public abstract class UpdateProcess
   {
-    public UpdateProcess()
-    {
-    }
-
-    public void SendEvent(UpdateEventType type)
+      public void SendEvent(UpdateEventType type)
     {
       EventHandler<UpdateEvent> temp = EventHandler;
       if (temp != null)
index 1ed32ce2612ce7359861e3789b3aab37ab2d53d9..fab730455689c43583c8352d58f7c51ce3e22de6 100644 (file)
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
 
 namespace CecConfigGui.actions
 {
index a6c6c393d13af441e0b61369e86f1c9af59edb9d..d7e869b948ed806a519c79e6cff14ce1ea704648 100644 (file)
@@ -2,4 +2,4 @@ bin_PROGRAMS = cec-config
 cec_config_SOURCES = cec-config.cpp
 
 cec_config_CPPFLAGS = -I@abs_top_srcdir@/include
-cec_config_LDFLAGS = @LIBS_DL@
\ No newline at end of file
+cec_config_LDFLAGS = @LIBS_DL@ -lrt
\ No newline at end of file
index d0840cec926546a56c6e1660c82cb832279f9de1..c46bbacf6f4f638bca702d0b0f0d27ce55224e2a 100644 (file)
@@ -410,7 +410,15 @@ int main (int UNUSED(argc), char *UNUSED(argv[]))
     string input;
     getline(cin, input);
     cin.clear();
-    g_config.bPowerOffOnStandby = (input == "y" || input == "Y");
+    g_config.bPowerOffOnStandby = (input == "y" || input == "Y") ? 1 : 0;
+  }
+
+  {
+    PrintToStdOut("Do you want to send an inactive source message when stopping the application (y/n)?");
+    string input;
+    getline(cin, input);
+    cin.clear();
+    g_config.bSendInactiveSource = (input == "y" || input == "Y") ? 1 : 0;
   }
 
   PrintToStdOut("\n\n=== USB-CEC Adapter Configuration Summary ===");
@@ -421,7 +429,8 @@ int main (int UNUSED(argc), char *UNUSED(argv[]))
   PrintToStdOut("Make the adapter the active source when starting XBMC:   %s", g_config.bActivateSource ? "yes" : "no");
   PrintToStdOut("Power off devices when stopping XBMC:                    %s", g_config.powerOffDevices.IsSet(CECDEVICE_BROADCAST) ? "yes" : "no");
   PrintToStdOut("Put devices in standby mode when activating screensaver: %s", g_config.bPowerOffScreensaver ? "yes" : "no");
-  PrintToStdOut("Put this PC in standby mode when the TV is switched off: %s\n\n", g_config.bPowerOffOnStandby ? "yes" : "no");
+  PrintToStdOut("Put this PC in standby mode when the TV is switched off: %s", g_config.bPowerOffOnStandby ? "yes" : "no");
+  PrintToStdOut("Seend an inactive source message when stopping XBMC:     %s\n\n", g_config.bSendInactiveSource ? "yes" : "no");
 
   if (g_parser->CanPersistConfiguration())
   {
@@ -446,18 +455,29 @@ int main (int UNUSED(argc), char *UNUSED(argv[]))
     configOutput.open("usb_2548_1001.xml");
     if (configOutput.is_open())
     {
+      CStdString strWakeDevices;
+      for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
+        if (g_config.wakeDevices[iPtr])
+          strWakeDevices.AppendFormat(" %d" + iPtr);
+      CStdString strStandbyDevices;
+      for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
+        if (g_config.powerOffDevices[iPtr])
+          strStandbyDevices.AppendFormat(" %d" + iPtr);
+
       configOutput <<
         "<settings>\n" <<
-          "\t<setting id=\"cec_hdmi_port\" value=\"" << g_config.iHDMIPort << "\" />\n" <<
-          "\t<setting id=\"connected_device\" value=\"" << (int)g_config.baseDevice << "\" />\n" <<
-          "\t<setting id=\"physical_address\" value=\"" << hex << g_config.iPhysicalAddress << "\" />\n" <<
-          "\t<setting id=\"use_tv_menu_language\" value=\"" << (int)g_config.bUseTVMenuLanguage << "\" />\n" <<
-          "\t<setting id=\"cec_power_on_startup\" value=\"" << (int)g_config.bActivateSource << "\" />\n" <<
-          "\t<setting id=\"cec_power_off_shutdown\" value=\"" << (int)(g_config.powerOffDevices.IsSet(CECDEVICE_BROADCAST) ? 1 : 0) << "\" />\n" <<
+          "\t<setting id=\"enabled\" value=\"1\" />\n" <<
+          "\t<setting id=\"activate_source\" value=\"" << (int)g_config.bActivateSource << "\" />\n" <<
+          "\t<setting id=\"wake_devices\" value=\"" << strWakeDevices.Trim().c_str() << "\" />\n" <<
+          "\t<setting id=\"standby_devices\" value=\"" << strStandbyDevices.Trim().c_str() << "\" />\n" <<
           "\t<setting id=\"cec_standby_screensaver\" value=\"" << (int)g_config.bPowerOffScreensaver << "\" />\n" <<
           "\t<setting id=\"standby_pc_on_tv_standby\" value=\"" << (int)g_config.bPowerOffOnStandby << "\" />\n" <<
-          "\t<setting id=\"enabled\" value=\"1\" />\n" <<
+          "\t<setting id=\"use_tv_menu_language\" value=\"" << (int)g_config.bUseTVMenuLanguage << "\" />\n" <<
+          "\t<setting id=\"physical_address\" value=\"" << hex << g_config.iPhysicalAddress << "\" />\n" <<
+          "\t<setting id=\"cec_hdmi_port\" value=\"" << g_config.iHDMIPort << "\" />\n" <<
+          "\t<setting id=\"connected_device\" value=\"" << (int)g_config.baseDevice << "\" />\n" <<
           "\t<setting id=\"port\" value=\"\" />\n" <<
+          "\t<setting id=\"send_inactive_source\" value=\"" << (int)g_config.bSendInactiveSource << "\" />\n" <<
         "</settings>";
       configOutput.close();
 
index 63009a87202617066ab8ef96227a83381d6790b2..96e82ce626ff4f23f3e3287b0ead0cd26f2797df 100644 (file)
@@ -60,13 +60,11 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configur
   m_logicalAddresses.Clear();
   CreateBusDevices();
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion = configuration->serverVersion;
   SetConfiguration(configuration);
 
   if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN)
     m_busDevices[CECDEVICE_TV]->ReplaceHandler(false);
-
-  GetCurrentConfiguration(configuration);
 }
 
 CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress) :
@@ -80,7 +78,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
     m_iLastTransmission(0)
 {
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion    = CEC_SERVER_VERSION_1_5_1;
 
   // client version < 1.5.0
   m_configuration.clientVersion    = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5;
@@ -183,16 +181,15 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
     return bReturn;
   }
 
-  uint64_t iNow = GetTimeMs();
-  uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT;
+  CTimeout timeout(iTimeoutMs > 0 ? iTimeoutMs : CEC_DEFAULT_TRANSMIT_WAIT);
 
   /* open a new connection */
   unsigned iConnectTry(0);
-  while (iNow < iTarget && (bReturn = m_communication->Open(this, iTimeoutMs)) == false)
+  while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES))) == false)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
-    Sleep(500);
-    iNow = GetTimeMs();
+    m_communication->Close();
+    CEvent::Sleep(1000);
   }
 
   if (bReturn)
@@ -573,7 +570,6 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort,
     CLockObject lock(m_mutex);
     m_configuration.baseDevice = iBaseDevice;
     m_configuration.iHDMIPort = iPort;
-    m_configuration.bAutodetectAddress = false;
   }
 
   if (!IsRunning() && !bForce)
@@ -679,11 +675,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress, bool bSendUpda
   {
     CLockObject lock(m_mutex);
     m_configuration.iPhysicalAddress = iPhysicalAddress;
-    if (m_configuration.bAutodetectAddress)
-    {
-      m_configuration.baseDevice = CECDEVICE_UNKNOWN;
-      m_configuration.iHDMIPort = 0;
-    }
+    CLibCEC::AddLog(CEC_LOG_DEBUG, "setting physical address to '%4x'", iPhysicalAddress);
 
     if (!m_logicalAddresses.IsEmpty())
     {
@@ -886,6 +878,8 @@ bool CCECProcessor::Transmit(const cec_command &data)
   uint8_t iMaxTries(0);
   {
     CLockObject lock(m_mutex);
+    if (IsStopped())
+      return false;
     LogOutput(data);
     m_iLastTransmission = GetTimeMs();
     if (!m_communication || !m_communication->IsOpen())
@@ -1363,6 +1357,8 @@ const char *CCECProcessor::ToString(const cec_vendor_id vendor)
     return "Philips";
   case CEC_VENDOR_SONY:
     return "Sony";
+  case CEC_VENDOR_TOSHIBA:
+    return "Toshiba";
   default:
     return "Unknown";
   }
@@ -1376,6 +1372,8 @@ const char *CCECProcessor::ToString(const cec_client_version version)
     return "pre-1.5";
   case CEC_CLIENT_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_CLIENT_VERSION_1_5_1:
+    return "1.5.1";
   default:
     return "Unknown";
   }
@@ -1389,6 +1387,8 @@ const char *CCECProcessor::ToString(const cec_server_version version)
     return "pre-1.5";
   case CEC_SERVER_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_SERVER_VERSION_1_5_1:
+      return "1.5.1";
   default:
     return "Unknown";
   }
@@ -1439,9 +1439,31 @@ void CCECBusScan::WaitUntilIdle(void)
   }
 }
 
-bool CCECProcessor::StartBootloader(void)
+bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
 {
-  return m_communication->StartBootloader();
+  if (!m_communication && strPort)
+  {
+    bool bReturn(false);
+    IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort);
+    CTimeout timeout(10000);
+    int iConnectTry(0);
+    while (timeout.TimeLeft() > 0 && (bReturn = comm->Open(NULL, (timeout.TimeLeft() / CEC_CONNECT_TRIES)), true) == false)
+    {
+      CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
+      comm->Close();
+      Sleep(500);
+    }
+    if (comm->IsOpen())
+    {
+      bReturn = comm->StartBootloader();
+      delete comm;
+    }
+    return bReturn;
+  }
+  else
+  {
+    return m_communication->StartBootloader();
+  }
 }
 
 bool CCECProcessor::PingAdapter(void)
@@ -1467,9 +1489,9 @@ bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
 
 bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
 {
-       bool bReinit(false);
+  bool bReinit(false);
   CCECBusDevice *primary = IsRunning() ? GetPrimaryDevice() : NULL;
-       cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
+  cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
   m_configuration.clientVersion  = configuration->clientVersion;
 
   // client version 1.5.0
@@ -1478,51 +1500,59 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   bool bDeviceTypeChanged = IsRunning () && m_configuration.deviceTypes != configuration->deviceTypes;
   m_configuration.deviceTypes = configuration->deviceTypes;
 
+  bool bPhysicalAddressChanged(false);
+
   // autodetect address
-  uint16_t iPhysicalAddress = IsRunning() && configuration->bAutodetectAddress ? m_communication->GetPhysicalAddress() : 0;
-  bool bPhysicalAutodetected = IsRunning() && configuration->bAutodetectAddress && iPhysicalAddress != m_configuration.iPhysicalAddress && iPhysicalAddress != 0;
-  if (bPhysicalAutodetected)
+  bool bPhysicalAutodetected(false);
+  if (IsRunning() && configuration->bAutodetectAddress == 1)
   {
-    m_configuration.iPhysicalAddress = iPhysicalAddress;
-    m_configuration.bAutodetectAddress = true;
-  }
-  else
-  {
-    m_configuration.bAutodetectAddress = false;
+    uint16_t iPhysicalAddress = m_communication->GetPhysicalAddress();
+    if (iPhysicalAddress != 0)
+    {
+      if (IsRunning())
+        CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - autodetected physical address '%4x'", __FUNCTION__, iPhysicalAddress);
+      bPhysicalAddressChanged = (m_configuration.iPhysicalAddress != iPhysicalAddress);
+      m_configuration.iPhysicalAddress = iPhysicalAddress;
+      m_configuration.iHDMIPort = 0;
+      m_configuration.baseDevice = CECDEVICE_UNKNOWN;
+      bPhysicalAutodetected = true;
+    }
   }
 
   // physical address
-  bool bPhysicalAddressChanged(false);
   if (!bPhysicalAutodetected)
   {
-    bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
+    if (configuration->iPhysicalAddress != 0)
+      bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using physical address '%4x'", __FUNCTION__, configuration->iPhysicalAddress);
     m_configuration.iPhysicalAddress = configuration->iPhysicalAddress;
   }
 
-  // base device
   bool bHdmiPortChanged(false);
   if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
   {
+    // base device
     bHdmiPortChanged = IsRunning() && m_configuration.baseDevice != configuration->baseDevice;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using base device '%x'", __FUNCTION__, (int)configuration->baseDevice);
     m_configuration.baseDevice = configuration->baseDevice;
-  }
-  else
-  {
-    m_configuration.baseDevice = CECDEVICE_UNKNOWN;
-  }
 
-  // hdmi port
-  if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
-  {
+    // hdmi port
     bHdmiPortChanged |= IsRunning() && m_configuration.iHDMIPort != configuration->iHDMIPort;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using HDMI port '%d'", __FUNCTION__, configuration->iHDMIPort);
     m_configuration.iHDMIPort = configuration->iHDMIPort;
   }
   else
   {
-    m_configuration.iHDMIPort = 0;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - resetting HDMI port and base device to defaults", __FUNCTION__);
+    m_configuration.baseDevice = CECDEVICE_UNKNOWN;
+    m_configuration.iHDMIPort  = 0;
   }
 
-       bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged || bPhysicalAutodetected;
+  bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged;
 
   // device name
   snprintf(m_configuration.strDeviceName, 13, "%s", configuration->strDeviceName);
@@ -1556,19 +1586,28 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver;
   m_configuration.bPowerOffOnStandby   = configuration->bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    m_configuration.bSendInactiveSource = configuration->bSendInactiveSource;
+
   // ensure that there is at least 1 device type set
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
 
   if (bReinit)
   {
-               if (bDeviceTypeChanged)
-                       return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);
-               else if (bPhysicalAddressChanged)
-                       return SetPhysicalAddress(m_configuration.iPhysicalAddress);
+    if (bDeviceTypeChanged)
+      return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);
+    else if (bPhysicalAddressChanged)
+      return SetPhysicalAddress(m_configuration.iPhysicalAddress);
     else
       return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
   }
+  else if (m_configuration.bActivateSource == 1 && IsRunning() && !IsActiveSource(m_logicalAddresses.primary))
+  {
+    // activate the source if we're not already the active source
+    SetActiveSource(m_configuration.deviceTypes.types[0]);
+  }
 
   return true;
 }
@@ -1594,6 +1633,10 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
   configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver;
   configuration->bPowerOffOnStandby   = m_configuration.bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    configuration->bSendInactiveSource = m_configuration.bSendInactiveSource;
+
   return true;
 }
 
index ee74f081bfe994bafa480d915aff12a89b44e57d..08bf8d00bf441fbfada9b51191b3cbc939d241fe 100644 (file)
@@ -40,7 +40,7 @@
 namespace CEC
 {
   class CLibCEC;
-  struct IAdapterCommunication;
+  class IAdapterCommunication;
   class CCECBusDevice;
 
   class CCECProcessor : public PLATFORM::CThread, public IAdapterCommunicationCallback
@@ -137,7 +137,7 @@ namespace CEC
       virtual bool FindLogicalAddresses(void);
       virtual bool SetAckMask(uint16_t iMask);
 
-      virtual bool StartBootloader(void);
+      virtual bool StartBootloader(const char *strPort = NULL);
       virtual bool PingAdapter(void);
       virtual void HandlePoll(cec_logical_address initiator, cec_logical_address destination);
       virtual bool HandleReceiveFailed(cec_logical_address initiator);
index 26748ab7e1436b43d597d2d400b60343001c79a1..b36d25425d87dd298dc51011023f202b1d49b17d 100644 (file)
@@ -33,6 +33,7 @@
 #include "LibCEC.h"
 
 #include "adapter/USBCECAdapterDetection.h"
+#include "adapter/USBCECAdapterCommunication.h"
 #include "CECProcessor.h"
 #include "devices/CECBusDevice.h"
 #include "platform/util/timeutils.h"
@@ -59,12 +60,12 @@ CLibCEC::CLibCEC(libcec_configuration *configuration) :
     m_callbacks(configuration->callbacks),
     m_cbParam(configuration->callbackParam)
 {
+  configuration->serverVersion = CEC_SERVER_VERSION_1_5_1;
   m_cec = new CCECProcessor(this, configuration);
 }
 
 CLibCEC::~CLibCEC(void)
 {
-  Close();
   delete m_cec;
 }
 
@@ -351,6 +352,8 @@ void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
   va_end(argList);
 
   CLibCEC *instance = CLibCEC::GetInstance();
+  if (!instance)
+    return;
   CLockObject lock(instance->m_mutex);
 
   cec_log_message message;
@@ -367,6 +370,8 @@ void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
 void CLibCEC::AddKey(const cec_keypress &key)
 {
   CLibCEC *instance = CLibCEC::GetInstance();
+  if (!instance)
+    return;
   CLockObject lock(instance->m_mutex);
 
   AddLog(CEC_LOG_DEBUG, "key pressed: %1x", key.keycode);
@@ -387,7 +392,8 @@ void CLibCEC::ConfigurationChanged(const libcec_configuration &config)
 
   if (instance->m_callbacks &&
       config.clientVersion >= CEC_CLIENT_VERSION_1_5_0 &&
-      instance->m_callbacks->CBCecConfigurationChanged != NULL)
+      instance->m_callbacks->CBCecConfigurationChanged != NULL &&
+      instance->m_cec->IsInitialised())
     instance->m_callbacks->CBCecConfigurationChanged(instance->m_cbParam, config);
 }
 
@@ -405,6 +411,8 @@ void CLibCEC::SetCurrentButton(cec_user_control_code iButtonCode)
 void CLibCEC::AddKey(void)
 {
   CLibCEC *instance = CLibCEC::GetInstance();
+  if (!instance)
+    return;
   CLockObject lock(instance->m_mutex);
 
   if (instance->m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN)
@@ -427,6 +435,8 @@ void CLibCEC::AddKey(void)
 void CLibCEC::AddCommand(const cec_command &command)
 {
   CLibCEC *instance = CLibCEC::GetInstance();
+  if (!instance)
+    return;
   CLockObject lock(instance->m_mutex);
 
   AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", instance->m_cec->ToString(command.initiator), command.initiator, instance->m_cec->ToString(command.destination), command.destination, instance->m_cec->ToString(command.opcode), command.opcode);
@@ -478,7 +488,7 @@ void CLibCEC::SetInstance(CLibCEC *instance)
   g_libCEC_instance = instance;
 }
 
-void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types, uint16_t iPhysicalAddress /* = 0 */)
+void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types, uint16_t UNUSED(iPhysicalAddress) /* = 0 */)
 {
   CLibCEC *lib = new CLibCEC(strDeviceName, types);
   CLibCEC::SetInstance(lib);
@@ -492,6 +502,26 @@ void * CECInitialise(libcec_configuration *configuration)
   return static_cast< void* > (lib);
 }
 
+bool CECStartBootloader(void)
+{
+  bool bReturn(false);
+  cec_adapter deviceList[1];
+  if (CUSBCECAdapterDetection::FindAdapters(deviceList, 1) > 0)
+  {
+    CUSBCECAdapterCommunication comm(NULL, deviceList[0].comm);
+    CTimeout timeout(10000);
+    while (timeout.TimeLeft() > 0 && (bReturn = comm.Open(NULL, (timeout.TimeLeft() / CEC_CONNECT_TRIES)), true) == false)
+    {
+      comm.Close();
+      CEvent::Sleep(500);
+    }
+    if (comm.IsOpen())
+      bReturn = comm.StartBootloader();
+  }
+
+  return bReturn;
+}
+
 void CECDestroy(CEC::ICECAdapter *UNUSED(instance))
 {
   CLibCEC::SetInstance(NULL);
@@ -559,7 +589,7 @@ const char *CLibCEC::ToString(const cec_server_version version)
 
 bool CLibCEC::GetCurrentConfiguration(libcec_configuration *configuration)
 {
-  return m_cec->GetCurrentConfiguration(configuration);
+  return m_cec->IsInitialised() && m_cec->GetCurrentConfiguration(configuration);
 }
 
 bool CLibCEC::SetConfiguration(const libcec_configuration *configuration)
index e2e815392d1bef72bd31b5ef4998b3cc35a1a722..9241a2c3f8336ce602ee353367f4ca7f52eeb4e7 100644 (file)
@@ -134,11 +134,11 @@ namespace CEC
       static CLibCEC *GetInstance(void);
       static void SetInstance(CLibCEC *instance);
 
+      CCECProcessor *                         m_cec;
     protected:
       int64_t                                 m_iStartTime;
       cec_user_control_code                   m_iCurrentButton;
       int64_t                                 m_buttontime;
-      CCECProcessor *                         m_cec;
       PLATFORM::SyncedBuffer<cec_log_message> m_logBuffer;
       PLATFORM::SyncedBuffer<cec_keypress>    m_keyBuffer;
       PLATFORM::SyncedBuffer<cec_command>     m_commandBuffer;
index 5df7c60021140b6a677ab0190956f5a8d93d172e..f6ab05e07a7ff23b0c5bc2f3bfb0f64a6a5db9be 100644 (file)
@@ -23,7 +23,8 @@ libcec_la_SOURCES = CECProcessor.cpp \
                     implementations/CECCommandHandler.cpp \
                     implementations/SLCommandHandler.cpp \
                     implementations/VLCommandHandler.cpp \
+                                       implementations/RLCommandHandler.cpp \
                     platform/posix/serialport.cpp
 
-libcec_la_LDFLAGS = @LIBS@ -version-info @VERSION@
+libcec_la_LDFLAGS = @LIBS@ -version-info @VERSION@ -lrt
 libcec_la_CPPFLAGS = -I@abs_top_srcdir@/include
index 9ee29518d3a7cdac3d345ef413bbb2d1a055f93c..d78b11d0164d37e4cf66f1c13b353aa2bc62717b 100644 (file)
@@ -46,9 +46,12 @@ namespace CEC
     ADAPTER_MESSAGE_STATE_ERROR                 /**< an error occured */
   } cec_adapter_message_state;
 
-  struct IAdapterCommunicationCallback
+  class IAdapterCommunicationCallback
   {
   public:
+    IAdapterCommunicationCallback(void) {}
+    virtual ~IAdapterCommunicationCallback(void) {}
+
     /*!
      * @brief Callback method for IAdapterCommunication, called when a new cec_command is received
      * @param command The command that has been received
@@ -57,16 +60,20 @@ namespace CEC
     virtual bool OnCommandReceived(const cec_command &command) = 0;
   };
 
-  struct IAdapterCommunication
+  class IAdapterCommunication
   {
   public:
+    IAdapterCommunication(void) {}
+    virtual ~IAdapterCommunication(void) {}
+
     /*!
      * @brief Open a connection to the CEC adapter
      * @param cb The callback struct. if set to NULL, the Read() method has to be used to read commands. if set, OnCommandReceived() will be called for each command that was received
      * @param iTimeoutMs Connection timeout in ms
+     * @param bSkipChecks Skips all initial checks of the adapter, and starts the reader/writer threads directly after connecting.
      * @return True when connected, false otherwise
      */
-    virtual bool Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs = 10000) = 0;
+    virtual bool Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs = 10000, bool bSkipChecks = false) = 0;
 
     /*!
      * @brief Close an open connection
index 80670e42f5c981f01bb2b1aff2c2d6c0fec345f6..2fe62fedcc134cab6cfb6ce3894ba16f93cd3735 100644 (file)
@@ -67,7 +67,8 @@ CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(CCECProcessor *processo
     m_lastInitiator(CECDEVICE_UNKNOWN),
     m_bNextIsEscaped(false),
     m_bGotStart(false),
-    m_messageProcessor(NULL)
+    m_messageProcessor(NULL),
+    m_bInitialised(false)
 {
   m_port = new PLATFORM::CSerialPort(strPort, iBaudRate);
 }
@@ -89,7 +90,7 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
   while (iNow < iTarget && (bPinged = PingAdapter()) == false)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to a ping (try %d)", ++iPingTry);
-    Sleep(500);
+    CEvent::Sleep(500);
     iNow = GetTimeMs();
   }
 
@@ -99,7 +100,7 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
   while (bPinged && iNow < iTarget && (m_iFirmwareVersion = GetFirmwareVersion()) == CEC_FW_VERSION_UNKNOWN)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond with a correct firmware version (try %d)", ++iFwVersionTry);
-    Sleep(500);
+    CEvent::Sleep(500);
     iNow = GetTimeMs();
   }
 
@@ -111,7 +112,7 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
     while (iNow < iTarget && (bControlled = SetControlledMode(true)) == false)
     {
       CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond correctly to setting controlled mode (try %d)", ++iControlledTry);
-      Sleep(500);
+      CEvent::Sleep(500);
       iNow = GetTimeMs();
     }
     bReturn = bControlled;
@@ -119,10 +120,15 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
   else
     bReturn = true;
 
+  {
+    CLockObject lock(m_mutex);
+    m_bInitialised = bReturn;
+  }
+
   return bReturn;
 }
 
-bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs /* = 10000 */)
+bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs /* = 10000 */, bool bSkipChecks /* = false */)
 {
   uint64_t iNow = GetTimeMs();
   uint64_t iTimeout = iNow + iTimeoutMs;
@@ -163,29 +169,35 @@ bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32
 
     CLibCEC::AddLog(CEC_LOG_DEBUG, "connection opened, clearing any previous input and waiting for active transmissions to end before starting");
 
-    //clear any input bytes
-    uint8_t buff[1024];
-    while (m_port->Read(buff, 1024, 100) > 0)
+    if (!bSkipChecks)
     {
-      CLibCEC::AddLog(CEC_LOG_DEBUG, "data received, clearing it");
-      Sleep(250);
+      //clear any input bytes
+      uint8_t buff[1024];
+      while (m_port->Read(buff, 1024, 100) > 0)
+      {
+        CLibCEC::AddLog(CEC_LOG_DEBUG, "data received, clearing it");
+        Sleep(250);
+      }
     }
   }
 
-  if (CreateThread())
+  if (!bSkipChecks && !CheckAdapter())
+  {
+    CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter failed to pass basic checks");
+    return false;
+  }
+  else
   {
-    if (!CheckAdapter())
+    if (CreateThread())
     {
-      StopThread();
-      CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter failed to pass basic checks");
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "communication thread started");
+      return true;
     }
     else
     {
-      CLibCEC::AddLog(CEC_LOG_DEBUG, "communication thread started");
-      return true;
+      CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a communication thread");
     }
   }
-  CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a communication thread");
 
   return false;
 }
@@ -208,7 +220,7 @@ void *CUSBCECAdapterCommunication::Process(void)
     {
       CLockObject lock(m_mutex);
       ReadFromDevice(50);
-      bCommandReceived = m_callback && Read(command, 0);
+      bCommandReceived = m_callback && Read(command, 0) && m_bInitialised;
     }
 
     /* push the next command to the callback method if there is one */
@@ -320,7 +332,7 @@ bool CUSBCECAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeou
     if (iTimeout == 0 || !m_rcvCondition.Wait(m_mutex, m_bHasData, iTimeout))
       return false;
     m_inBuffer.Pop(buf);
-    m_bHasData = m_inBuffer.Size() > 0;
+    m_bHasData = !m_inBuffer.IsEmpty();
   }
 
   if (buf)
@@ -364,11 +376,9 @@ bool CUSBCECAdapterCommunication::StartBootloader(void)
 
 bool CUSBCECAdapterCommunication::PingAdapter(void)
 {
-  bool bReturn(false);
-  if (!IsRunning())
-    return bReturn;
-
+  CLockObject lock(m_mutex);
   CLibCEC::AddLog(CEC_LOG_DEBUG, "sending ping");
+
   CCECAdapterMessage *output = new CCECAdapterMessage;
 
   output->PushBack(MSGSTART);
@@ -376,11 +386,16 @@ bool CUSBCECAdapterCommunication::PingAdapter(void)
   output->PushBack(MSGEND);
   output->isTransmission = false;
 
-  if ((bReturn = Write(output)) == false)
-    CLibCEC::AddLog(CEC_LOG_ERROR, "could not ping the adapter");
+  SendMessageToAdapter(output);
+  bool bWriteOk = output->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
   delete output;
+  if (!bWriteOk)
+  {
+    CLibCEC::AddLog(CEC_LOG_ERROR, "could not ping the adapter");
+    return false;
+  }
 
-  return bReturn;
+  return true;
 }
 
 bool CUSBCECAdapterCommunication::ParseMessage(const CCECAdapterMessage &msg)
@@ -425,7 +440,6 @@ bool CUSBCECAdapterCommunication::ParseMessage(const CCECAdapterMessage &msg)
         m_currentframe.PushBack(msg[1]);
         m_currentframe.eom = msg.IsEOM();
       }
-      bEom = msg.IsEOM();
     }
     break;
   default:
@@ -433,14 +447,12 @@ bool CUSBCECAdapterCommunication::ParseMessage(const CCECAdapterMessage &msg)
   }
 
   CLibCEC::AddLog(bIsError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
-  return bEom;
+  return msg.IsEOM();
 }
 
 uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
 {
   uint16_t iReturn(m_iFirmwareVersion);
-  if (!IsRunning())
-    return iReturn;
 
   if (iReturn == CEC_FW_VERSION_UNKNOWN)
   {
@@ -541,7 +553,7 @@ bool CUSBCECAdapterCommunication::SetAckMaskInternal(uint16_t iMask, bool bWrite
 
 bool CUSBCECAdapterCommunication::SetControlledMode(bool controlled)
 {
-  bool bReturn(false);
+  CLockObject lock(m_mutex);
   CLibCEC::AddLog(CEC_LOG_DEBUG, "turning controlled mode %s", controlled ? "on" : "off");
 
   CCECAdapterMessage *output = new CCECAdapterMessage;
@@ -552,11 +564,16 @@ bool CUSBCECAdapterCommunication::SetControlledMode(bool controlled)
   output->PushBack(MSGEND);
   output->isTransmission = false;
 
-  if ((bReturn = Write(output)) == false)
-    CLibCEC::AddLog(CEC_LOG_ERROR, "could not set controlled mode");
+  SendMessageToAdapter(output);
+  bool bWriteOk = output->state == ADAPTER_MESSAGE_STATE_SENT;
   delete output;
+  if (!bWriteOk)
+  {
+    CLibCEC::AddLog(CEC_LOG_ERROR, "could not set controlled mode");
+    return false;
+  }
 
-  return bReturn;
+  return true;
 }
 
 bool CUSBCECAdapterCommunication::IsOpen(void)
@@ -610,11 +627,11 @@ bool CUSBCECAdapterCommunication::WaitForAck(CCECAdapterMessage &message)
       switch(msg.Message())
       {
       case MSGCODE_COMMAND_ACCEPTED:
-        CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
         if (iPacketsLeft > 0)
           iPacketsLeft--;
         if (!message.isTransmission && iPacketsLeft == 0)
           bTransmitSucceeded = true;
+        CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - waiting for %d more", msg.ToString().c_str(), iPacketsLeft);
         break;
       case MSGCODE_TRANSMIT_SUCCEEDED:
         CLibCEC::AddLog(CEC_LOG_DEBUG, msg.ToString());
index d1f033fbfac90cc9f698a494776447543893e9f8..c71453a4a4f0cf20a3827f0a4714a8d091e1160c 100644 (file)
@@ -69,7 +69,7 @@ namespace CEC
     CUSBCECAdapterCommunication(CCECProcessor *processor, const char *strPort, uint16_t iBaudRate = 38400);
     virtual ~CUSBCECAdapterCommunication();
 
-    virtual bool Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs = 10000);
+    virtual bool Open(IAdapterCommunicationCallback *cb, uint32_t iTimeoutMs = 10000, bool bSkipChecks = false);
     virtual void Close(void);
     virtual bool IsOpen(void);
     virtual CStdString GetError(void) const;
@@ -106,7 +106,7 @@ namespace CEC
     PLATFORM::SyncedBuffer<CCECAdapterMessage *> m_inBuffer;
     PLATFORM::SyncedBuffer<CCECAdapterMessage *> m_outBuffer;
     PLATFORM::CMutex                             m_mutex;
-    PLATFORM::CCondition<volatile bool &>        m_rcvCondition;
+    PLATFORM::CCondition<volatile bool>          m_rcvCondition;
     volatile bool                                m_bHasData;
     uint8_t                                      m_iLineTimeout;
     uint16_t                                     m_iFirmwareVersion;
@@ -117,5 +117,6 @@ namespace CEC
     bool                                         m_bGotStart;
     IAdapterCommunicationCallback *              m_callback;
     CUSBCECAdapterProcessor *                    m_messageProcessor;
+    bool                                         m_bInitialised;
   };
 };
index 5428ec1c8ddbf7f35ed415f5fd159bc742f9bb25..30ac2dc788df51c50251eaae0c8a4488799ccc03 100644 (file)
@@ -40,12 +40,10 @@ namespace CEC
 {
   class CCECProcessor;
   class CCECCommandHandler;
-  class CSLCommandHandler;
 
   class CCECBusDevice
   {
     friend class CCECProcessor;
-    friend class CSLCommandHandler;
 
   public:
     CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
@@ -108,9 +106,10 @@ namespace CEC
     virtual bool TransmitKeypress(cec_user_control_code key, bool bWait = true);
     virtual bool TransmitKeyRelease(bool bWait = true);
 
+    bool ReplaceHandler(bool bActivateSource = true);
+
   protected:
     void CheckVendorIdRequested(void);
-    bool ReplaceHandler(bool bActivateSource = true);
     void MarkBusy(void);
     void MarkReady(void);
 
index d2fe2fd9f742101948ceb97b08c5cbbab3a55fc6..a9b4c40c57f2c7f483b9e1036ee60357a233fc88 100644 (file)
@@ -242,7 +242,9 @@ bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
 
 bool CCECCommandHandler::HandleFeatureAbort(const cec_command &command)
 {
-  if (command.parameters.size == 2 && command.parameters[1] == CEC_ABORT_REASON_UNRECOGNIZED_OPCODE)
+  if (command.parameters.size == 2 &&
+        (command.parameters[1] == CEC_ABORT_REASON_UNRECOGNIZED_OPCODE ||
+         command.parameters[1] == CEC_ABORT_REASON_REFUSED))
     m_processor->m_busDevices[command.initiator]->SetUnsupportedFeature((cec_opcode)command.parameters[0]);
   return true;
 }
diff --git a/src/lib/implementations/RLCommandHandler.cpp b/src/lib/implementations/RLCommandHandler.cpp
new file mode 100644 (file)
index 0000000..9643ee5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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 an original work, containing original code.
+ *
+ * libCEC(R) is a trademark of Pulse-Eight Limited.
+ *
+ * This program is dual-licensed; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Alternatively, you can license this library under a commercial license,
+ * please contact Pulse-Eight Licensing for more information.
+ *
+ * For more information contact:
+ * Pulse-Eight Licensing       <license@pulse-eight.com>
+ *     http://www.pulse-eight.com/
+ *     http://www.pulse-eight.net/
+ */
+
+#include "RLCommandHandler.h"
+#include "../devices/CECBusDevice.h"
+#include "../CECProcessor.h"
+#include "../LibCEC.h"
+
+using namespace CEC;
+using namespace PLATFORM;
+
+CRLCommandHandler::CRLCommandHandler(CCECBusDevice *busDevice) :
+    CCECCommandHandler(busDevice)
+{
+  m_vendorId = CEC_VENDOR_TOSHIBA;
+  CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
+  /* imitate Toshiba devices */
+  if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+  {
+    primary->SetVendorId(CEC_VENDOR_TOSHIBA);
+    primary->ReplaceHandler(false);
+  }
+}
+
+bool CRLCommandHandler::InitHandler(void)
+{
+  if (m_bHandlerInited)
+    return true;
+  m_bHandlerInited = true;
+
+  if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+  {
+    CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
+    /* send the vendor id */
+    primary->TransmitVendorID(CECDEVICE_BROADCAST);
+  }
+
+  return true;
+}
diff --git a/src/lib/implementations/RLCommandHandler.h b/src/lib/implementations/RLCommandHandler.h
new file mode 100644 (file)
index 0000000..944a649
--- /dev/null
@@ -0,0 +1,47 @@
+#pragma once
+/*
+ * 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 an original work, containing original code.
+ *
+ * libCEC(R) is a trademark of Pulse-Eight Limited.
+ *
+ * This program is dual-licensed; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Alternatively, you can license this library under a commercial license,
+ * please contact Pulse-Eight Licensing for more information.
+ *
+ * For more information contact:
+ * Pulse-Eight Licensing       <license@pulse-eight.com>
+ *     http://www.pulse-eight.com/
+ *     http://www.pulse-eight.net/
+ */
+
+#include "CECCommandHandler.h"
+#include "../platform/util/timeutils.h"
+
+namespace CEC
+{
+  class CRLCommandHandler : public CCECCommandHandler
+  {
+  public:
+    CRLCommandHandler(CCECBusDevice *busDevice);
+    virtual ~CRLCommandHandler(void) {};
+
+    virtual bool InitHandler(void);
+  };
+};
index 5216ffe7793ac40bea9c28bf93ffbb6e7cba986b..fc28fc9017235fcb4804797dbf217cd2da8897c3 100644 (file)
@@ -48,13 +48,19 @@ namespace PLATFORM
 
   inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0)
   {
-    struct timespec abstime;
-    struct timeval now;
-    gettimeofday(&now, NULL);
-    iIncreaseBy += now.tv_usec / 1000;
-    abstime.tv_sec = now.tv_sec + (time_t)(iIncreaseBy / 1000);
-    abstime.tv_nsec = (int32_t)((iIncreaseBy % (uint32_t)1000) * (uint32_t)1000000);
-    return abstime;
+    struct timespec now;
+    #ifdef __APPLE__
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    now.tv_sec  = tv.tv_sec + 0;
+    now.tv_nsec = 0;
+    #else
+    clock_gettime(CLOCK_REALTIME, &now);
+    #endif
+    now.tv_nsec += iIncreaseBy % 1000 * 1000000;
+    now.tv_sec  += iIncreaseBy / 1000 + now.tv_nsec / 1000000000;
+    now.tv_nsec %= 1000000000;
+    return now;
   }
 
   typedef pthread_t thread_t;
index 369fbe4c9f78101ba6cef915e1bff37e4737f8e2..f56d515c5e76676f95573555db07ad41523fe887 100644 (file)
@@ -220,9 +220,9 @@ namespace PLATFORM
       m_condition.Signal();
     }
 
-    _Socket *          m_socket;
-    CMutex             m_mutex;
-    CCondition<bool &> m_condition;
-    bool               m_bIsIdle;
+    _Socket *        m_socket;
+    CMutex           m_mutex;
+    CCondition<bool> m_condition;
+    bool             m_bIsIdle;
   };
 };
index 6bd126e4c7452b1658e285386e5dd0f106917700..ed60ba8724612fae369e1fd7e9e33ede7877e97e 100644 (file)
@@ -343,11 +343,11 @@ namespace PLATFORM
       return bReturn;
     }
 
-    volatile bool              m_bSignaled;
-    CCondition<volatile bool&> m_condition;
-    CMutex                     m_mutex;
-    volatile bool              m_bBroadcast;
-    unsigned int               m_iWaitingThreads;
-    bool                       m_bAutoReset;
+    volatile bool             m_bSignaled;
+    CCondition<volatile bool> m_condition;
+    CMutex                    m_mutex;
+    volatile bool             m_bBroadcast;
+    unsigned int              m_iWaitingThreads;
+    bool                      m_bAutoReset;
   };
 }
index f2de310a23749f7960ef3882008c61e317c5eeb9..c730da8256743c8132f7ef69279a365aa892854d 100644 (file)
@@ -103,7 +103,11 @@ namespace PLATFORM
       return bReturn;
     }
 
-    virtual bool StopThread(bool bWaitForExit = true)
+    /*!
+     * @brief Stop the thread
+     * @param iWaitMs negative = don't wait, 0 = infinite, or the amount of ms to wait
+     */
+    virtual bool StopThread(int iWaitMs = 5000)
     {
       bool bReturn(true);
       bool bRunning(false);
@@ -113,12 +117,17 @@ namespace PLATFORM
         m_bStop = true;
       }
 
-      if (bRunning && bWaitForExit)
+      if (bRunning && iWaitMs >= 0)
       {
-        void *retVal = NULL;
-        bReturn = ThreadsWait(m_thread, &retVal);
+        CLockObject lock(m_threadMutex);
+        bReturn = m_threadCondition.Wait(m_threadMutex, m_bStopped, iWaitMs);
+      }
+      else
+      {
+        bReturn = true;
       }
-      return true;
+
+      return bReturn;
     }
 
     virtual bool Sleep(uint32_t iTimeout)
@@ -133,11 +142,11 @@ namespace PLATFORM
     void SetRunning(bool bSetTo);
 
   private:
-    bool               m_bStop;
-    bool               m_bRunning;
-    bool               m_bStopped;
-    CCondition<bool &> m_threadCondition;
-    CMutex             m_threadMutex;
-    thread_t           m_thread;
+    bool             m_bStop;
+    bool             m_bRunning;
+    bool             m_bStopped;
+    CCondition<bool> m_threadCondition;
+    CMutex           m_threadMutex;
+    thread_t         m_thread;
   };
 };
index ce6029c622cda793261f8de667e1cdc2af5c2ebc..56ffd6450225384359ce1cb4a159d784d3fb624e 100644 (file)
@@ -40,24 +40,32 @@ namespace PLATFORM
     struct SyncedBuffer
     {
     public:
-      SyncedBuffer(size_t iMaxSize = 100)
-      {
-        m_maxSize = iMaxSize;
-      }
+      SyncedBuffer(size_t iMaxSize = 100) :
+          m_maxSize(iMaxSize) {}
 
       virtual ~SyncedBuffer(void)
       {
-        CLockObject lock(m_mutex, true);
         Clear();
       }
 
       void Clear(void)
       {
+        CLockObject lock(m_mutex);
         while (!m_buffer.empty())
           m_buffer.pop();
       }
 
-      size_t Size(void) const { return m_buffer.size(); }
+      size_t Size(void)
+      {
+        CLockObject lock(m_mutex);
+        return m_buffer.size();
+      }
+
+      bool IsEmpty(void)
+      {
+        CLockObject lock(m_mutex);
+        return m_buffer.empty();
+      }
 
       bool Push(_BType entry)
       {
index 3b1ef700c8f4213ca1a1f2af3ee15e5e6f5d71e7..b886f88a1cd58511b5cf03d9088af3456f6d54ac 100644 (file)
@@ -92,9 +92,9 @@ namespace PLATFORM
     }
     return -1;
   #else
-    timeval time;
-    gettimeofday(&time, NULL);
-    return (int64_t) (time.tv_sec * 1000 + time.tv_usec / 1000);
+    timespec time;
+    clock_gettime(CLOCK_MONOTONIC, &time);
+    return (int64_t)time.tv_sec * 1000 + time.tv_nsec / 1000000;
   #endif
   }
 
index 726cf621d352212e7b03306d8d975f1f263387bb..8c7862e57da721c19f3e541764484fa4cbb93e5e 100644 (file)
@@ -2,4 +2,4 @@ bin_PROGRAMS = cec-client
 cec_client_SOURCES = main.cpp
 
 cec_client_CPPFLAGS = -I@abs_top_srcdir@/include
-cec_client_LDFLAGS = @LIBS_DL@
\ No newline at end of file
+cec_client_LDFLAGS = @LIBS_DL@ -lrt
\ No newline at end of file
index 69309bc7dfc078592691e4b99acb035dcca1097a..2b2c54dc772fc4e99b12d9cf4244efa3ea7986fc 100644 (file)
@@ -975,6 +975,11 @@ bool ProcessCommandLineArguments(int argc, char *argv[])
         }
         bReturn = false;
       }
+      else if (!strcmp(argv[iArgPtr], "--bootloader"))
+      {
+        LibCecBootloader();
+        bReturn = false;
+      }
       else if (!strcmp(argv[iArgPtr], "--single-command") ||
           !strcmp(argv[iArgPtr], "-s"))
       {
index 93ee576e94b7d24384304267ec9cb608bb966beb..10715cb93c0b36213f861d55edaf07a912daa695 100755 (executable)
@@ -26,7 +26,7 @@ _enter_bootloader()
   echo "Instructing the CEC adapter to enter bootloader mode"
   cec_adapter=`lsusb  | grep "2548:1001" | wc -l`
   if [ $cec_adapter -gt 0 ]; then
-    echo "bl" | cec-client -s -d 2
+    echo "bl" | cec-client --bootloader
     echo "Waiting for the device to reinitialise"
     sleep 5
   fi
index b07bc894e60d33bf380d4b8613d517053d2e6dd9..86d17cf8fae16864a44983a8bcca462dfd621244 100644 (file)
@@ -11,9 +11,6 @@ rem Check for the Windows DDK
 IF NOT EXIST "C:\WinDDK\7600.16385.1" GOTO NODDK
 set DDK="C:\WinDDK\7600.16385.1"
 
-cd ..\project
-
-del /s /f /q ..\build
 mkdir ..\build
 
 echo. Copying driver installer
@@ -21,9 +18,10 @@ copy "%DDK%\redist\DIFx\dpinst\MultiLin\amd64\dpinst.exe" ..\build\dpinst-amd64.
 copy "%DDK%\redist\DIFx\dpinst\MultiLin\x86\dpinst.exe" ..\build\dpinst-x86.exe
 
 :CREATECAT
-IF EXIST "..\support\create-cat.cmd" (
+cd ..\driver
+IF EXIST "..\support\private\create-cat.cmd" (
   echo. Updating the catalogue
-  CALL ..\support\create-cat.cmd
+  CALL ..\support\private\create-cat.cmd p8usb-cec.cat
 )
 
 :CREATEINSTALLER
@@ -33,9 +31,9 @@ echo. Creating the installer
 IF NOT EXIST "..\build\p8-usbcec-driver-installer.exe" GOTO :ERRORCREATINGINSTALLER
 
 rem Sign the installer if sign-binary.cmd exists
-IF EXIST "..\support\sign-binary.cmd" (
+IF EXIST "..\support\private\sign-binary.cmd" (
   echo. Signing the installer binaries
-  CALL ..\support\sign-binary.cmd ..\build\p8-usbcec-driver-installer.exe
+  CALL ..\support\private\sign-binary.cmd ..\build\p8-usbcec-driver-installer.exe
 )
 
 echo. The installer can be found here: ..\build\p8-usbcec-driver-installer.exe
index d3f04ff4c6f25ed1ef1419d5aa2b60a0f0e5e99a..8c37a8f93a8317d4559782fb3bd64441c578c12c 100644 (file)
@@ -102,18 +102,18 @@ del /q /f ..\build\libcec.x64.lib
 
 rem Check for sign-binary.cmd, only present on the Pulse-Eight production build system
 rem Calls signtool.exe and signs the DLLs with Pulse-Eight's code signing key
-IF NOT EXIST "..\support\sign-binary.cmd" GOTO CREATEINSTALLER
+IF NOT EXIST "..\support\private\sign-binary.cmd" GOTO CREATEINSTALLER
 echo. Signing all binaries
-CALL ..\support\sign-binary.cmd ..\build\cec-client.exe
-CALL ..\support\sign-binary.cmd ..\build\CecSharpTester.exe
-CALL ..\support\sign-binary.cmd ..\build\libcec.dll
-CALL ..\support\sign-binary.cmd ..\build\LibCecSharp.dll
-CALL ..\support\sign-binary.cmd ..\build\cec-config-gui.exe
-CALL ..\support\sign-binary.cmd ..\build\x64\cec-client.x64.exe
-CALL ..\support\sign-binary.cmd ..\build\x64\CecSharpTester.exe
-CALL ..\support\sign-binary.cmd ..\build\x64\libcec.x64.dll
-CALL ..\support\sign-binary.cmd ..\build\x64\LibCecSharp.dll
-CALL ..\support\sign-binary.cmd ..\build\x64\cec-config-gui.exe
+CALL ..\support\private\sign-binary.cmd ..\build\cec-client.exe
+CALL ..\support\private\sign-binary.cmd ..\build\CecSharpTester.exe
+CALL ..\support\private\sign-binary.cmd ..\build\libcec.dll
+CALL ..\support\private\sign-binary.cmd ..\build\LibCecSharp.dll
+CALL ..\support\private\sign-binary.cmd ..\build\cec-config-gui.exe
+CALL ..\support\private\sign-binary.cmd ..\build\x64\cec-client.x64.exe
+CALL ..\support\private\sign-binary.cmd ..\build\x64\CecSharpTester.exe
+CALL ..\support\private\sign-binary.cmd ..\build\x64\libcec.x64.dll
+CALL ..\support\private\sign-binary.cmd ..\build\x64\LibCecSharp.dll
+CALL ..\support\private\sign-binary.cmd ..\build\x64\cec-config-gui.exe
 
 :CREATEINSTALLER
 echo. Creating the installer
@@ -122,9 +122,9 @@ echo. Creating the installer
 IF NOT EXIST "..\build\libCEC-installer.exe" GOTO :ERRORCREATINGINSTALLER
 
 rem Sign the installer if sign-binary.cmd exists
-IF EXIST "..\support\sign-binary.cmd" (
+IF EXIST "..\support\private\sign-binary.cmd" (
   echo. Signing the installer binaries
-  CALL ..\support\sign-binary.cmd ..\build\libCEC-installer.exe
+  CALL ..\support\private\sign-binary.cmd ..\build\libCEC-installer.exe
 )
 
 echo. The installer can be found here: ..\build\libCEC-installer.exe