Merge pull request #27 from Fneufneu/master
authorLars Op den Kamp <opdenkamp@gmail.com>
Sat, 3 Mar 2012 16:01:42 +0000 (08:01 -0800)
committerLars Op den Kamp <opdenkamp@gmail.com>
Sat, 3 Mar 2012 16:01:42 +0000 (08:01 -0800)
FreeBSD support

44 files changed:
ChangeLog
README
configure.ac
debian/changelog
include/cec.h
include/cecloader.h
include/cectypes.h
project/cec-config.rc
project/libcec.rc
project/testclient.rc
src/CecSharpTester/CecSharpClient.cs
src/CecSharpTester/Properties/AssemblyInfo.cs
src/LibCecSharp/AssemblyInfo.cpp
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/Properties/AssemblyInfo.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/testclient/Makefile.am
src/testclient/main.cpp
support/cec-flash-device.sh

index f7cbc06ba87cd5f38ce4df2d566f581565ca4445..15d5a73e25bc2ec09e8a77494194342f1c4d3b76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,70 @@
+libcec (1.5-3) unstable; urgency=low
+
+  * fixed:
+    * OS-X compilation
+    * default to firmware version 1 after 3 tries. some versions didn't send a
+      version.
+    * fixed cec-config win32 compilation
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Sat, 03 Mar 2012 15:21:00 +0100
+
+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:
diff --git a/README b/README
index 230054aff725c32135aaaac5fd396168c01a0447..c60a92110b70d14b70ac42ac79541f0faf8bd7ea 100644 (file)
--- a/README
+++ b/README
@@ -12,6 +12,7 @@ To compile libCEC on Linux, you'll need the following dependencies:
 * autoconf 2.13 or later
 * automake 1.11 or later
 * pkg-config
+* libtool
 * udev development headers v151 or later
 * gcc 4.2 or later
 
index 209ecf6e070ebeb575ae9a2dc77745515f86bb73..2b1e930ea082fe37256170dafb237ed2e6763459 100644 (file)
@@ -8,6 +8,7 @@ has_libudev="yes"
 case "${host}" in
   *-*-linux*)
     PKG_CHECK_MODULES([UDEV],[libudev],,[has_libudev="no";AC_MSG_WARN("library 'udev' is missing - adapter detection will not be available")])
+    LIBS+=" -lrt"
     ;;
   *-apple-darwin*)
     has_libudev="no";
index f7cbc06ba87cd5f38ce4df2d566f581565ca4445..15d5a73e25bc2ec09e8a77494194342f1c4d3b76 100644 (file)
@@ -1,3 +1,70 @@
+libcec (1.5-3) unstable; urgency=low
+
+  * fixed:
+    * OS-X compilation
+    * default to firmware version 1 after 3 tries. some versions didn't send a
+      version.
+    * fixed cec-config win32 compilation
+
+ -- Pulse-Eight Packaging <packaging@pulse-eight.com>  Sat, 03 Mar 2012 15:21:00 +0100
+
+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 5b05b13210d90d7436868cec3153260a91c78edb..095416e445020446efb37413b2c4ae08cea30657 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
@@ -945,13 +947,17 @@ 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_1_5_2   = 0x1502
 } 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_1_5_2   = 0x1502
 } cec_server_version;
 
 typedef struct libcec_configuration
@@ -975,6 +981,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 */
@@ -1000,11 +1007,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 07a63248875c3c6fca4c41ca481af8df236331e8..180f4f050acf9882a287d1144d293a21bf783876 100644 (file)
Binary files a/project/cec-config.rc and b/project/cec-config.rc differ
index 6e422e2fadf0e493a45416c2ff45c96c11d68eb6..4de5b4fa94028e021d401b8d4da0d80115dfe513 100644 (file)
Binary files a/project/libcec.rc and b/project/libcec.rc differ
index 1a3b7792d3e6d20e08702572f047441c9fbbec2f..15edfb5a5f2080c5845050e16f3992e72fee829d 100644 (file)
Binary files a/project/testclient.rc and b/project/testclient.rc differ
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 0f0423893609eff36911d4ba8505647ea0b65c08..e12aca92a80ebcf6ba338bba6b5442d790634ddd 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.0.0")]
-[assembly: AssemblyFileVersion("1.5.0.0")]
+[assembly: AssemblyVersion("1.5.2.0")]
+[assembly: AssemblyFileVersion("1.5.2.0")]
index ef09f79aed5ca5bcf76c77c2292721aa5b5f332b..5dfbef2d600b2f90fa096f30d5a2d513a24ef9f2 100644 (file)
@@ -13,7 +13,7 @@ using namespace System::Security::Permissions;
 [assembly:AssemblyTrademarkAttribute("")];
 [assembly:AssemblyCultureAttribute("")];
 
-[assembly:AssemblyVersionAttribute("1.5.0.0")];
+[assembly:AssemblyVersionAttribute("1.5.2.0")];
 
 [assembly:ComVisible(false)];
 [assembly:CLSCompliantAttribute(true)];
index 5d617941b0f4316c422cd257c249d5aba62281b8..8cdaa89a0e9e797f2931fedb936534c3009a2bd2 100644 (file)
@@ -326,13 +326,17 @@ namespace CecSharp
        public enum class CecClientVersion
        {
                VersionPre1_5 = 0,
-               Version1_5_0  = 0x1500
+               Version1_5_0  = 0x1500,
+    Version1_5_1  = 0x1501,
+    Version1_5_2  = 0x1502
        };
 
   public enum class CecServerVersion
        {
                VersionPre1_5 = 0,
-               Version1_5_0  = 0x1500
+               Version1_5_0  = 0x1500,
+    Version1_5_1  = 0x1501,
+    Version1_5_2  = 0x1502
        };
 
        public ref class CecAdapter
@@ -547,6 +551,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 +591,7 @@ namespace CecSharp
 
                        PowerOffScreensaver = config.bPowerOffScreensaver == 1;
                        PowerOffOnStandby = config.bPowerOffOnStandby == 1;
+      SendInactiveSource = config.bSendInactiveSource == 1;
                }
 
                property System::String ^     DeviceName;
@@ -606,6 +612,7 @@ namespace CecSharp
                property CecLogicalAddresses ^PowerOffDevices;
                property bool                 PowerOffScreensaver;
                property bool                 PowerOffOnStandby;
+    property bool                 SendInactiveSource;
 
                property CecCallbackMethods ^ Callbacks;
        };
@@ -663,37 +670,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 +690,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 +770,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 +835,6 @@ namespace CecSharp
 
                CecCallbackMethods ^ m_callbacks;
          bool                 m_bHasCallbacks;
+    bool                 m_bDelegatesCreated;
        };
 }
index d6154c36cfe09ddb733b9d37bd08bd0dca4cc0aa..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;
@@ -115,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;
                }
 
@@ -139,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);
@@ -550,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 b99c5531cd1e6344b8af3de4ec1b8ca98d621d10..a1206f99126633184aa7a86119ba51ec14a948ed 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.0.0")]
-[assembly: AssemblyFileVersion("1.5.0.0")]
+[assembly: AssemblyVersion("1.5.2.0")]
+[assembly: AssemblyFileVersion("1.5.2.0")]
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 d7e869b948ed806a519c79e6cff14ce1ea704648..a6c6c393d13af441e0b61369e86f1c9af59edb9d 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@ -lrt
\ No newline at end of file
+cec_config_LDFLAGS = @LIBS_DL@
\ No newline at end of file
index d0840cec926546a56c6e1660c82cb832279f9de1..456369180c069a9a66122ef720314cf38249cab5 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.c_str() << "\" />\n" <<
+          "\t<setting id=\"standby_devices\" value=\"" << strStandbyDevices.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 7c658a35d17f6a67baa238575230286413a0358f..b455ac88d9ab0558e81f77108e703be494331f4b 100644 (file)
@@ -60,7 +60,7 @@ 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)
@@ -78,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_2;
 
   // client version < 1.5.0
   m_configuration.clientVersion    = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5;
@@ -181,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)
@@ -571,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)
@@ -677,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())
     {
@@ -1378,6 +1372,10 @@ 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";
+  case CEC_CLIENT_VERSION_1_5_2:
+    return "1.5.2";
   default:
     return "Unknown";
   }
@@ -1391,6 +1389,10 @@ 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";
+  case CEC_SERVER_VERSION_1_5_2:
+    return "1.5.2";
   default:
     return "Unknown";
   }
@@ -1441,9 +1443,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)
@@ -1469,9 +1493,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
@@ -1480,51 +1504,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);
@@ -1558,6 +1590,10 @@ 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);
@@ -1571,6 +1607,11 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
     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;
 }
@@ -1596,6 +1637,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 61ea68691e36f56ceea33dca4e98ff925b030b13..08bf8d00bf441fbfada9b51191b3cbc939d241fe 100644 (file)
@@ -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 93a50198a3bcac9331b72a0014d61df1dc3db4a4..ab05822a230a1c7784dfe924f1426279578fa93e 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_2;
   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);
@@ -406,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)
@@ -428,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);
@@ -493,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);
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 f6ab05e07a7ff23b0c5bc2f3bfb0f64a6a5db9be..083775f6fbc63578cf9c07d3a140834e332c51f3 100644 (file)
@@ -26,5 +26,5 @@ libcec_la_SOURCES = CECProcessor.cpp \
                                        implementations/RLCommandHandler.cpp \
                     platform/posix/serialport.cpp
 
-libcec_la_LDFLAGS = @LIBS@ -version-info @VERSION@ -lrt
+libcec_la_LDFLAGS = @LIBS@ -version-info @VERSION@
 libcec_la_CPPFLAGS = -I@abs_top_srcdir@/include
index 38d0a13b0369bf40d6726029ef195d21bceb24a6..d78b11d0164d37e4cf66f1c13b353aa2bc62717b 100644 (file)
@@ -70,9 +70,10 @@ namespace CEC
      * @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 0f73bae0f958139e0a52a9535bae6f92d330ff6a..e51a861f28579ebe6d5685c883032626e05add52 100644 (file)
@@ -90,20 +90,26 @@ 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();
   }
 
   /* try to read the firmware version */
   m_iFirmwareVersion = CEC_FW_VERSION_UNKNOWN;
   unsigned iFwVersionTry(0);
-  while (bPinged && iNow < iTarget && (m_iFirmwareVersion = GetFirmwareVersion()) == CEC_FW_VERSION_UNKNOWN)
+  while (bPinged && iNow < iTarget && (m_iFirmwareVersion = GetFirmwareVersion()) == CEC_FW_VERSION_UNKNOWN && iFwVersionTry < 3)
   {
-    CLibCEC::AddLog(CEC_LOG_ERROR, "the adapter did not respond with a correct firmware version (try %d)", ++iFwVersionTry);
-    Sleep(500);
+    CLibCEC::AddLog(CEC_LOG_WARNING, "the adapter did not respond with a correct firmware version (try %d)", ++iFwVersionTry);
+    CEvent::Sleep(500);
     iNow = GetTimeMs();
   }
 
+  if (m_iFirmwareVersion == CEC_FW_VERSION_UNKNOWN)
+  {
+    CLibCEC::AddLog(CEC_LOG_DEBUG, "defaulting to firmware version 1");
+    m_iFirmwareVersion = 1;
+  }
+
   if (m_iFirmwareVersion >= 2)
   {
     /* try to set controlled mode */
@@ -112,7 +118,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;
@@ -128,7 +134,7 @@ bool CUSBCECAdapterCommunication::CheckAdapter(uint32_t iTimeoutMs /* = 10000 */
   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;
@@ -169,29 +175,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;
 }
@@ -370,11 +382,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);
@@ -382,11 +392,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)
@@ -444,8 +459,6 @@ bool CUSBCECAdapterCommunication::ParseMessage(const CCECAdapterMessage &msg)
 uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
 {
   uint16_t iReturn(m_iFirmwareVersion);
-  if (!IsRunning())
-    return iReturn;
 
   if (iReturn == CEC_FW_VERSION_UNKNOWN)
   {
@@ -546,7 +559,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;
@@ -557,11 +570,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)
@@ -615,11 +633,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 513900d5be28d8584d3e7431002913c2d6ec977b..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;
index 8c7862e57da721c19f3e541764484fa4cbb93e5e..726cf621d352212e7b03306d8d975f1f263387bb 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@ -lrt
\ No newline at end of file
+cec_client_LDFLAGS = @LIBS_DL@
\ 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