Broadcast = 15
};
+ public enum class CecAlert
+ {
+ ServiceDevice = 1
+ };
+
+ public enum class CecParameterType
+ {
+ ParameterTypeString = 1
+ };
+
+ public ref class CecParameter
+ {
+ public:
+ CecParameter(CecParameterType type, System::String ^ strData)
+ {
+ Type = type;
+ Data = strData;
+ }
+
+ property CecParameterType Type;
+ property System::String ^ Data;
+ };
+
public enum class CecPowerStatus
{
On = 0x00,
{
VersionPre1_5 = 0,
Version1_5_0 = 0x1500,
- Version1_5_1 = 0x1501,
- Version1_5_2 = 0x1502,
- Version1_5_3 = 0x1503,
- Version1_6_0 = 0x1600
+ Version1_5_1 = 0x1501,
+ Version1_5_2 = 0x1502,
+ Version1_5_3 = 0x1503,
+ Version1_6_0 = 0x1600,
+ Version1_6_1 = 0x1601,
+ Version1_6_2 = 0x1602
};
- public enum class CecServerVersion
+ public enum class CecServerVersion
{
VersionPre1_5 = 0,
Version1_5_0 = 0x1500,
- Version1_5_1 = 0x1501,
- Version1_5_2 = 0x1502,
- Version1_5_3 = 0x1503,
- Version1_6_0 = 0x1600
+ Version1_5_1 = 0x1501,
+ Version1_5_2 = 0x1502,
+ Version1_5_3 = 0x1503,
+ Version1_6_0 = 0x1600,
+ Version1_6_1 = 0x1601,
+ Version1_6_2 = 0x1602
};
public ref class CecAdapter
typedef int (__stdcall *KEYCB) (const CEC::cec_keypress &key);
typedef int (__stdcall *COMMANDCB)(const CEC::cec_command &command);
typedef int (__stdcall *CONFIGCB) (const CEC::libcec_configuration &config);
+ typedef int (__stdcall *ALERTCB) (const CEC::libcec_alert, const CEC::libcec_parameter &data);
+ typedef int (__stdcall *MENUCB) (const CEC::cec_menu_state newVal);
static LOGCB g_logCB;
static KEYCB g_keyCB;
static COMMANDCB g_commandCB;
static CONFIGCB g_configCB;
+ static ALERTCB g_alertCB;
+ static MENUCB g_menuCB;
static CEC::ICECCallbacks g_cecCallbacks;
int CecLogMessageCB(void *cbParam, const CEC::cec_log_message &message)
return 0;
}
- int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const libcec_parameter &data)
+ int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data)
{
if (g_alertCB)
return g_alertCB(alert, data);
return 0;
}
+ int CecMenuCB(void *cbParam, const CEC::cec_menu_state newVal)
+ {
+ if (g_menuCB)
+ return g_menuCB(newVal);
+ return 0;
+ }
+
#pragma managed
// delegates for the unmanaged callback methods
public delegate int CecLogMessageManagedDelegate(const CEC::cec_log_message &);
public delegate int CecCommandManagedDelegate(const CEC::cec_command &);
public delegate int CecConfigManagedDelegate(const CEC::libcec_configuration &);
public delegate int CecAlertManagedDelegate(const CEC::libcec_alert, const CEC::libcec_parameter &);
+ public delegate int CecMenuManagedDelegate(const CEC::cec_menu_state newVal);
// callback method interface
public ref class CecCallbackMethods
{
return 0;
}
+
+ virtual int ReceiveAlert(CecAlert alert, CecParameter ^ data)
+ {
+ return 0;
+ }
+
+ virtual int ReceiveMenuStateChange(CecMenuState newVal)
+ {
+ return 0;
+ }
+
protected:
// managed callback methods
int CecLogMessageManaged(const CEC::cec_log_message &message)
return iReturn;
}
+ int CecAlertManaged(const CEC::libcec_alert alert, const CEC::libcec_parameter &data)
+ {
+ int iReturn(0);
+ if (m_bHasCallbacks)
+ {
+ CecParameterType newType = (CecParameterType)data.paramType;
+ if (newType == CecParameterType::ParameterTypeString)
+ {
+ System::String ^ newData = gcnew System::String((const char *)data.paramData, 0, 128);
+ CecParameter ^ newParam = gcnew CecParameter(newType, newData);
+ iReturn = m_callbacks->ReceiveAlert((CecAlert)alert, newParam);
+ }
+ }
+ return iReturn;
+ }
+
+ int CecMenuManaged(const CEC::cec_menu_state newVal)
+ {
+ int iReturn(0);
+ if (m_bHasCallbacks)
+ {
+ iReturn = m_callbacks->ReceiveMenuStateChange((CecMenuState)newVal);
+ }
+ return iReturn;
+ }
+
void DestroyDelegates()
{
m_bHasCallbacks = false;
m_logMessageGCHandle.Free();
m_keypressGCHandle.Free();
m_commandGCHandle.Free();
+ m_alertGCHandle.Free();
+ m_menuGCHandle.Free();
}
}
// create the delegate method for the alert callback
m_alertDelegate = gcnew CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged);
m_alertGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate);
- g_alertCB = static_cast<CONFIGCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate).ToPointer());
+ g_alertCB = static_cast<ALERTCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate).ToPointer());
g_cecCallbacks.CBCecAlert = CecAlertCB;
+ // create the delegate method for the menu callback
+ m_menuDelegate = gcnew CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged);
+ m_menuGCHandle = System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate);
+ g_menuCB = static_cast<MENUCB>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate).ToPointer());
+ g_cecCallbacks.CBCecMenuStateChanged = CecMenuCB;
+
delete context;
m_bDelegatesCreated = true;
}
static System::Runtime::InteropServices::GCHandle m_alertGCHandle;
CONFIGCB m_alertCallback;
+ CecMenuManagedDelegate ^ m_menuDelegate;
+ static System::Runtime::InteropServices::GCHandle m_menuGCHandle;
+ MENUCB m_menuCallback;
+
CecCallbackMethods ^ m_callbacks;
bool m_bHasCallbacks;
bool m_bDelegatesCreated;