+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:
* autoconf 2.13 or later
* automake 1.11 or later
* pkg-config
+* libtool
* udev development headers v151 or later
* gcc 4.2 or later
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";
+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:
*/
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.
*/
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>
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_ */
#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
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
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 */
#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;
*/
using System;
-using System.Collections.Generic;
using System.Text;
using CecSharp;
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)
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 +
"================================================================================");
}
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")
// 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")]
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
-[assembly:AssemblyVersionAttribute("1.5.0.0")];
+[assembly:AssemblyVersionAttribute("1.5.2.0")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
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
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)
PowerOffScreensaver = config.bPowerOffScreensaver == 1;
PowerOffOnStandby = config.bPowerOffOnStandby == 1;
+ SendInactiveSource = config.bSendInactiveSource == 1;
}
property System::String ^ DeviceName;
property CecLogicalAddresses ^PowerOffDevices;
property bool PowerOffScreensaver;
property bool PowerOffOnStandby;
+ property bool SendInactiveSource;
property CecCallbackMethods ^ Callbacks;
};
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)
{
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;
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;
CecCallbackMethods ^ m_callbacks;
bool m_bHasCallbacks;
+ bool m_bDelegatesCreated;
};
}
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;
}
config.bPowerOffScreensaver = netConfig->PowerOffScreensaver ? 1 : 0;
config.bPowerOffOnStandby = netConfig->PowerOffOnStandby ? 1 : 0;
+ config.bSendInactiveSource = netConfig->SendInactiveSource ? 1 : 0;
config.callbacks = &g_cecCallbacks;
}
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);
private:
ICECAdapter * m_libCec;
+ CecCallbackMethods ^ m_callbacks;
};
}
{
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) { }
}
{
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) { }
}
{
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) { }
}
{
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) { }
}
{
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) { }
}
{
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) { }
}
{
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) { }
}
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) { }
}
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
namespace CecConfigGui
{
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();
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();
//
// 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
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
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);
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)
case "wake_devices":
{
config.WakeDevices.Clear();
- string[] split = value.Split(new char[] { ' ' });
+ string[] split = value.Split(new[] { ' ' });
foreach (string dev in split)
{
byte iLogicalAddress;
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;
}
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)
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);
SetControlEnabled(cbPowerOffDevices, val);
SetControlEnabled(cbVendorOverride, val);
SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
+ SetControlEnabled(cbSendInactiveSource, val);
SetControlEnabled(bClose, val);
SetControlEnabled(bSaveConfig, val);
SetControlEnabled(bReloadConfig, val);
}
#region Actions
- public void ReloadXMLConfiguration()
+ public void ReloadXmlConfiguration()
{
LoadXMLConfiguration(ref Config);
Lib.SetConfiguration(Config);
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();
}
}
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();
}
}
{
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();
}
}
{
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();
}
}
{
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();
}
}
{
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();
}
}
{
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
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)
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)
{
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();
}
}
private void bCancel_Click(object sender, EventArgs e)
{
- this.Dispose();
+ Dispose();
}
private void bSave_Click(object sender, EventArgs e)
Config.ActivateSource = cbActivateSource.Checked;
Config.PowerOffScreensaver = cbPowerOffScreensaver.Checked;
Config.PowerOffOnStandby = cbPowerOffOnStandby.Checked;
+ Config.SendInactiveSource = cbSendInactiveSource.Checked;
Config.WakeDevices = WakeDevices;
Config.PowerOffDevices = PowerOffDevices;
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();
}
else
{
- ReloadXMLConfiguration();
+ ReloadXmlConfiguration();
}
}
{
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) { }
}
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)
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)
{
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
{
if (tbLog.InvokeRequired)
{
- UpdateLogCallback d = new UpdateLogCallback(UpdateLog);
+ UpdateLogCallback d = UpdateLog;
try
{
- this.Invoke(d, new object[] { });
+ Invoke(d, new object[] { });
}
catch (Exception) { }
}
SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
+ SetCheckboxChecked(cbSendInactiveSource, Config.SendInactiveSource);
UpdateSelectedDevice();
for (int iPtr = 0; iPtr < 15; iPtr++)
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));
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));
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Text;
using System.Windows.Forms;
using CecSharp;
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);
}
using System;
-using System.Collections.Generic;
using System.Windows.Forms;
namespace CecConfigGui
// 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")]
using CecSharp;
-using System.Windows.Forms;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
using System;
-using System.Collections.Generic;
-using System.Text;
using CecSharp;
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)
-using System;
-using System.Collections.Generic;
-using System.Text;
-using CecSharp;
+using CecSharp;
namespace CecConfigGui.actions
{
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
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 ===");
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())
{
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();
m_logicalAddresses.Clear();
CreateBusDevices();
m_configuration.Clear();
- m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+ m_configuration.serverVersion = configuration->serverVersion;
SetConfiguration(configuration);
if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN)
m_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;
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)
CLockObject lock(m_mutex);
m_configuration.baseDevice = iBaseDevice;
m_configuration.iHDMIPort = iPort;
- m_configuration.bAutodetectAddress = false;
}
if (!IsRunning() && !bForce)
{
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())
{
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";
}
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";
}
}
}
-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)
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
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);
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);
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;
}
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;
}
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);
#include "LibCEC.h"
#include "adapter/USBCECAdapterDetection.h"
+#include "adapter/USBCECAdapterCommunication.h"
#include "CECProcessor.h"
#include "devices/CECBusDevice.h"
#include "platform/util/timeutils.h"
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;
}
va_end(argList);
CLibCEC *instance = CLibCEC::GetInstance();
+ if (!instance)
+ return;
CLockObject lock(instance->m_mutex);
cec_log_message message;
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);
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)
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);
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);
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;
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
* @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
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 */
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;
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;
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;
}
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);
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)
uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
{
uint16_t iReturn(m_iFirmwareVersion);
- if (!IsRunning())
- return iReturn;
if (iReturn == CEC_FW_VERSION_UNKNOWN)
{
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;
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)
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());
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;
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
}
bReturn = false;
}
+ else if (!strcmp(argv[iArgPtr], "--bootloader"))
+ {
+ LibCecBootloader();
+ bReturn = false;
+ }
else if (!strcmp(argv[iArgPtr], "--single-command") ||
!strcmp(argv[iArgPtr], "-s"))
{
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