3 * This file is part of the libCEC(R) library.
5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
10 * This program is dual-licensed; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
28 * For more information contact:
29 * Pulse-Eight Licensing <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
36 #include <msclr/marshal.h>
37 #include "../../include/cec.h"
43 public enum class CecDeviceType
53 public enum class CecLogLevel
64 public enum class CecLogicalAddress
66 Unknown
= -1, //not a valid logical address
86 public enum class CecAlert
91 public enum class CecParameterType
93 ParameterTypeString
= 1
96 public ref
class CecParameter
99 CecParameter(CecParameterType type
, System::String
^ strData
)
105 property CecParameterType Type
;
106 property
System::String
^ Data
;
109 public enum class CecPowerStatus
113 InTransitionStandbyToOn
= 0x02,
114 InTransitionOnToStandby
= 0x03,
118 public enum class CecVersion
128 public enum class CecDisplayControl
130 DisplayForDefaultTime
= 0x00,
131 DisplayUntilCleared
= 0x40,
132 ClearPreviousMessage
= 0x80,
133 ReservedForFutureUse
= 0xC0
136 public enum class CecMenuState
142 public enum class CecDeckControlMode
145 SkipReverseRewind
= 2,
150 public enum class CecDeckInfo
162 SkipForwardWind
= 0x1B,
163 SkipReverseRewind
= 0x1C,
164 IndexSearchForward
= 0x1D,
165 IndexSearchReverse
= 0x1E,
169 public enum class CecUserControlCode
201 PreviousChannel
= 0x32,
204 DisplayInformation
= 0x35,
225 VideoOnDemand
= 0x52,
226 ElectronicProgramGuide
= 0x53,
227 TimerProgramming
= 0x54,
228 InitialConfiguration
= 0x55,
230 PausePlayFunction
= 0x61,
231 RecordFunction
= 0x62,
232 PauseRecordFunction
= 0x63,
235 RestoreVolumeFunction
= 0x66,
237 SelectMediaFunction
= 0x68,
238 SelectAVInputFunction
= 0x69,
239 SelectAudioInputFunction
= 0x6A,
240 PowerToggleFunction
= 0x6B,
241 PowerOffFunction
= 0x6C,
242 PowerOnFunction
= 0x6D,
250 SamsungReturn
= 0x91,
254 public enum class CecVendorId
267 public enum class CecAudioStatus
269 MuteStatusMask
= 0x80,
270 VolumeStatusMask
= 0x7F,
273 VolumeStatusUnknown
= 0x7F
276 public enum class CecOpcode
281 InactiveSource
= 0x9D,
282 RequestActiveSource
= 0x85,
283 RoutingChange
= 0x80,
284 RoutingInformation
= 0x81,
285 SetStreamPath
= 0x86,
290 RecordTvScreen
= 0x0F,
291 ClearAnalogueTimer
= 0x33,
292 ClearDigitalTimer
= 0x99,
293 ClearExternalTimer
= 0xA1,
294 SetAnalogueTimer
= 0x34,
295 SetDigitalTimer
= 0x97,
296 SetExternalTimer
= 0xA2,
297 SetTimerProgramTitle
= 0x67,
298 TimerClearedStatus
= 0x43,
301 GetCecVersion
= 0x9F,
302 GivePhysicalAddress
= 0x83,
303 GetMenuLanguage
= 0x91,
304 ReportPhysicalAddress
= 0x84,
305 SetMenuLanguage
= 0x32,
308 GiveDeckStatus
= 0x1A,
310 GiveTunerDeviceStatus
= 0x08,
311 SelectAnalogueService
= 0x92,
312 SelectDigtalService
= 0x93,
313 TunerDeviceStatus
= 0x07,
314 TunerStepDecrement
= 0x06,
315 TunerStepIncrement
= 0x05,
316 DeviceVendorId
= 0x87,
317 GiveDeviceVendorId
= 0x8C,
318 VendorCommand
= 0x89,
319 VendorCommandWithId
= 0xA0,
320 VendorRemoteButtonDown
= 0x8A,
321 VendorRemoteButtonUp
= 0x8B,
327 UserControlPressed
= 0x44,
328 UserControlRelease
= 0x45,
329 GiveDevicePowerStatus
= 0x8F,
330 ReportPowerStatus
= 0x90,
333 GiveAudioStatus
= 0x71,
334 GiveSystemAudioMode
= 0x7D,
335 ReportAudioStatus
= 0x7A,
336 SetSystemAudioMode
= 0x72,
337 SystemAudioModeRequest
= 0x70,
338 SystemAudioModeStatus
= 0x7E,
340 /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */
344 public enum class CecSystemAudioStatus
350 public enum class CecClientVersion
353 Version1_5_0
= 0x1500,
354 Version1_5_1
= 0x1501,
355 Version1_5_2
= 0x1502,
356 Version1_5_3
= 0x1503,
357 Version1_6_0
= 0x1600,
358 Version1_6_1
= 0x1601,
359 Version1_6_2
= 0x1602,
360 Version1_6_3
= 0x1603,
361 Version1_7_0
= 0x1700,
362 Version1_7_1
= 0x1701
365 public enum class CecServerVersion
368 Version1_5_0
= 0x1500,
369 Version1_5_1
= 0x1501,
370 Version1_5_2
= 0x1502,
371 Version1_5_3
= 0x1503,
372 Version1_6_0
= 0x1600,
373 Version1_6_1
= 0x1601,
374 Version1_6_2
= 0x1602,
375 Version1_6_3
= 0x1603,
376 Version1_7_0
= 0x1700,
377 Version1_7_1
= 0x1701
380 public ref
class CecAdapter
383 CecAdapter(System::String
^ strPath
, System::String
^ strComPort
)
386 ComPort
= strComPort
;
389 property
System::String
^ Path
;
390 property
System::String
^ ComPort
;
393 public ref
class CecDeviceTypeList
396 CecDeviceTypeList(void)
398 Types
= gcnew array
<CecDeviceType
>(5);
399 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
400 Types
[iPtr
] = CecDeviceType::Reserved
;
403 property array
<CecDeviceType
> ^ Types
;
406 public ref
class CecLogicalAddresses
409 CecLogicalAddresses(void)
411 Addresses
= gcnew array
<CecLogicalAddress
>(16);
417 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
418 Addresses
[iPtr
] = CecLogicalAddress::Unknown
;
421 bool IsSet(CecLogicalAddress iAddress
)
423 return Addresses
[(unsigned int)iAddress
] != CecLogicalAddress::Unknown
;
426 void Set(CecLogicalAddress iAddress
)
428 Addresses
[(unsigned int)iAddress
] = iAddress
;
431 property CecLogicalAddress Primary
;
432 property array
<CecLogicalAddress
> ^ Addresses
;
435 public ref
class CecDatapacket
440 Data
= gcnew array
<uint8_t>(100);
444 void PushBack(uint8_t data
)
453 property array
<uint8_t> ^ Data
;
454 property
uint8_t Size
;
457 public ref
class CecCommand
460 CecCommand(CecLogicalAddress iInitiator
, CecLogicalAddress iDestination
, bool bAck
, bool bEom
, CecOpcode iOpcode
, int32_t iTransmitTimeout
)
462 Initiator
= iInitiator
;
463 Destination
= iDestination
;
468 TransmitTimeout
= iTransmitTimeout
;
469 Parameters
= gcnew CecDatapacket
;
475 Initiator
= CecLogicalAddress::Unknown
;
476 Destination
= CecLogicalAddress::Unknown
;
479 Opcode
= CecOpcode::None
;
482 Parameters
= gcnew CecDatapacket
;
486 void PushBack(uint8_t data
)
488 if (Initiator
== CecLogicalAddress::Unknown
&& Destination
== CecLogicalAddress::Unknown
)
490 Initiator
= (CecLogicalAddress
) (data
>> 4);
491 Destination
= (CecLogicalAddress
) (data
& 0xF);
496 Opcode
= (CecOpcode
)data
;
500 Parameters
->PushBack(data
);
505 property CecLogicalAddress Initiator
;
506 property CecLogicalAddress Destination
;
509 property CecOpcode Opcode
;
510 property CecDatapacket
^ Parameters
;
511 property
bool OpcodeSet
;
512 property
int32_t TransmitTimeout
;
515 public ref
class CecKeypress
518 CecKeypress(CecUserControlCode iKeycode
, unsigned int iDuration
)
521 Duration
= iDuration
;
527 Keycode
= CecUserControlCode::Unknown
;
533 property CecUserControlCode Keycode
;
534 property
unsigned int Duration
;
537 public ref
class CecLogMessage
540 CecLogMessage(System::String
^ strMessage
, CecLogLevel iLevel
, int64_t iTime
)
542 Message
= strMessage
;
551 Level
= CecLogLevel::None
;
557 property
System::String
^Message
;
558 property CecLogLevel Level
;
559 property
int64_t Time
;
562 ref
class CecCallbackMethods
; //forward
563 public ref
class LibCECConfiguration
566 LibCECConfiguration(void)
569 DeviceTypes
= gcnew
CecDeviceTypeList();
570 AutodetectAddress
= true;
571 PhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
572 BaseDevice
= (CecLogicalAddress
)CEC_DEFAULT_BASE_DEVICE
;
573 HDMIPort
= CEC_DEFAULT_HDMI_PORT
;
574 ClientVersion
= CecClientVersion::VersionPre1_5
;
575 ServerVersion
= CecServerVersion::VersionPre1_5
;
576 TvVendor
= CecVendorId::Unknown
;
578 GetSettingsFromROM
= false;
579 UseTVMenuLanguage
= CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE
== 1;
580 ActivateSource
= CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1;
582 WakeDevices
= gcnew
CecLogicalAddresses();
583 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1)
584 WakeDevices
->Set(CecLogicalAddress::Tv
);
586 PowerOffDevices
= gcnew
CecLogicalAddresses();
587 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN
== 1)
588 PowerOffDevices
->Set(CecLogicalAddress::Broadcast
);
590 PowerOffScreensaver
= CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER
== 1;
591 PowerOffOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY
== 1;
593 SendInactiveSource
= CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE
== 1;
594 LogicalAddresses
= gcnew
CecLogicalAddresses();
596 PowerOffDevicesOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY
== 1;
597 ShutdownOnStandby
= CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY
== 1;
601 void SetCallbacks(CecCallbackMethods
^callbacks
)
603 Callbacks
= callbacks
;
606 void Update(const CEC::libcec_configuration
&config
)
608 DeviceName
= gcnew
System::String(config
.strDeviceName
);
610 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
611 DeviceTypes
->Types
[iPtr
] = (CecDeviceType
)config
.deviceTypes
.types
[iPtr
];
613 AutodetectAddress
= config
.bAutodetectAddress
== 1;
614 PhysicalAddress
= config
.iPhysicalAddress
;
615 BaseDevice
= (CecLogicalAddress
)config
.baseDevice
;
616 HDMIPort
= config
.iHDMIPort
;
617 ClientVersion
= (CecClientVersion
)config
.clientVersion
;
618 ServerVersion
= (CecServerVersion
)config
.serverVersion
;
619 TvVendor
= (CecVendorId
)config
.tvVendor
;
621 // player specific settings
622 GetSettingsFromROM
= config
.bGetSettingsFromROM
== 1;
623 UseTVMenuLanguage
= config
.bUseTVMenuLanguage
== 1;
624 ActivateSource
= config
.bActivateSource
== 1;
626 WakeDevices
->Clear();
627 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
628 if (config
.wakeDevices
[iPtr
])
629 WakeDevices
->Set((CecLogicalAddress
)iPtr
);
631 PowerOffDevices
->Clear();
632 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
633 if (config
.powerOffDevices
[iPtr
])
634 PowerOffDevices
->Set((CecLogicalAddress
)iPtr
);
636 PowerOffScreensaver
= config
.bPowerOffScreensaver
== 1;
637 PowerOffOnStandby
= config
.bPowerOffOnStandby
== 1;
639 if (ServerVersion
>= CecServerVersion::Version1_5_1
)
640 SendInactiveSource
= config
.bSendInactiveSource
== 1;
642 if (ServerVersion
>= CecServerVersion::Version1_5_3
)
644 LogicalAddresses
->Clear();
645 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
646 if (config
.logicalAddresses
[iPtr
])
647 LogicalAddresses
->Set((CecLogicalAddress
)iPtr
);
650 if (ServerVersion
>= CecServerVersion::Version1_6_0
)
652 FirmwareVersion
= config
.iFirmwareVersion
;
653 PowerOffDevicesOnStandby
= config
.bPowerOffDevicesOnStandby
== 1;
654 ShutdownOnStandby
= config
.bShutdownOnStandby
== 1;
657 if (ServerVersion
>= CecServerVersion::Version1_6_2
)
658 DeviceLanguage
= gcnew
System::String(config
.strDeviceLanguage
);
660 if (ServerVersion
>= CecServerVersion::Version1_6_3
)
661 MonitorOnlyClient
= config
.bMonitorOnly
== 1;
664 property
System::String
^ DeviceName
;
665 property CecDeviceTypeList
^ DeviceTypes
;
666 property
bool AutodetectAddress
;
667 property
uint16_t PhysicalAddress
;
668 property CecLogicalAddress BaseDevice
;
669 property
uint8_t HDMIPort
;
670 property CecClientVersion ClientVersion
;
671 property CecServerVersion ServerVersion
;
672 property CecVendorId TvVendor
;
674 // player specific settings
675 property
bool GetSettingsFromROM
;
676 property
bool UseTVMenuLanguage
;
677 property
bool ActivateSource
;
678 property CecLogicalAddresses
^WakeDevices
;
679 property CecLogicalAddresses
^PowerOffDevices
;
680 property
bool PowerOffScreensaver
;
681 property
bool PowerOffOnStandby
;
682 property
bool SendInactiveSource
;
683 property CecLogicalAddresses
^LogicalAddresses
;
684 property
uint16_t FirmwareVersion
;
685 property
bool PowerOffDevicesOnStandby
;
686 property
bool ShutdownOnStandby
;
687 property
bool MonitorOnlyClient
;
688 property
System::String
^ DeviceLanguage
;
689 property CecCallbackMethods
^ Callbacks
;
692 // the callback methods are called by unmanaged code, so we need some delegates for this
694 // unmanaged callback methods
695 typedef int (__stdcall
*LOGCB
) (const CEC::cec_log_message
&message
);
696 typedef int (__stdcall
*KEYCB
) (const CEC::cec_keypress
&key
);
697 typedef int (__stdcall
*COMMANDCB
)(const CEC::cec_command
&command
);
698 typedef int (__stdcall
*CONFIGCB
) (const CEC::libcec_configuration
&config
);
699 typedef int (__stdcall
*ALERTCB
) (const CEC::libcec_alert
, const CEC::libcec_parameter
&data
);
700 typedef int (__stdcall
*MENUCB
) (const CEC::cec_menu_state newVal
);
701 typedef void (__stdcall
*ACTICB
) (const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
703 static LOGCB g_logCB
;
704 static KEYCB g_keyCB
;
705 static COMMANDCB g_commandCB
;
706 static CONFIGCB g_configCB
;
707 static ALERTCB g_alertCB
;
708 static MENUCB g_menuCB
;
709 static ACTICB g_sourceActivatedCB
;
710 static CEC::ICECCallbacks g_cecCallbacks
;
712 int CecLogMessageCB(void *cbParam
, const CEC::cec_log_message
&message
)
715 return g_logCB(message
);
719 int CecKeyPressCB(void *cbParam
, const CEC::cec_keypress
&key
)
726 int CecCommandCB(void *cbParam
, const CEC::cec_command
&command
)
729 return g_commandCB(command
);
733 int CecConfigCB(void *cbParam
, const CEC::libcec_configuration
&config
)
736 return g_configCB(config
);
740 int CecAlertCB(void *cbParam
, const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
743 return g_alertCB(alert
, data
);
747 int CecMenuCB(void *cbParam
, const CEC::cec_menu_state newVal
)
750 return g_menuCB(newVal
);
754 void CecSourceActivatedCB(void *cbParam
, const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
756 if (g_sourceActivatedCB
)
757 g_sourceActivatedCB(logicalAddress
, bActivated
);
761 // delegates for the unmanaged callback methods
762 public delegate
int CecLogMessageManagedDelegate(const CEC::cec_log_message
&);
763 public delegate
int CecKeyPressManagedDelegate(const CEC::cec_keypress
&);
764 public delegate
int CecCommandManagedDelegate(const CEC::cec_command
&);
765 public delegate
int CecConfigManagedDelegate(const CEC::libcec_configuration
&);
766 public delegate
int CecAlertManagedDelegate(const CEC::libcec_alert
, const CEC::libcec_parameter
&);
767 public delegate
int CecMenuManagedDelegate(const CEC::cec_menu_state newVal
);
768 public delegate
void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
770 // callback method interface
771 public ref
class CecCallbackMethods
774 CecCallbackMethods(void)
776 m_bHasCallbacks
= false;
777 m_bDelegatesCreated
= false;
780 ~CecCallbackMethods(void)
786 !CecCallbackMethods(void)
792 virtual void DisableCallbacks(void)
797 virtual bool EnableCallbacks(CecCallbackMethods
^ callbacks
)
800 if (!m_bHasCallbacks
)
802 m_bHasCallbacks
= true;
803 m_callbacks
= callbacks
;
810 virtual int ReceiveLogMessage(CecLogMessage
^ message
)
815 virtual int ReceiveKeypress(CecKeypress
^ key
)
820 virtual int ReceiveCommand(CecCommand
^ command
)
825 virtual int ConfigurationChanged(LibCECConfiguration
^ config
)
830 virtual int ReceiveAlert(CecAlert alert
, CecParameter
^ data
)
835 virtual int ReceiveMenuStateChange(CecMenuState newVal
)
840 virtual void SourceActivated(CecLogicalAddress logicalAddress
, bool bActivated
)
845 // managed callback methods
846 int CecLogMessageManaged(const CEC::cec_log_message
&message
)
850 iReturn
= m_callbacks
->ReceiveLogMessage(gcnew
CecLogMessage(gcnew
System::String(message
.message
), (CecLogLevel
)message
.level
, message
.time
));
854 int CecKeyPressManaged(const CEC::cec_keypress
&key
)
858 iReturn
= m_callbacks
->ReceiveKeypress(gcnew
CecKeypress((CecUserControlCode
)key
.keycode
, key
.duration
));
862 int CecCommandManaged(const CEC::cec_command
&command
)
867 CecCommand
^ newCommand
= gcnew
CecCommand((CecLogicalAddress
)command
.initiator
, (CecLogicalAddress
)command
.destination
, command
.ack
== 1 ? true : false, command
.eom
== 1 ? true : false, (CecOpcode
)command
.opcode
, command
.transmit_timeout
);
868 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
869 newCommand
->Parameters
->PushBack(command
.parameters
[iPtr
]);
870 iReturn
= m_callbacks
->ReceiveCommand(newCommand
);
875 int CecConfigManaged(const CEC::libcec_configuration
&config
)
880 LibCECConfiguration
^netConfig
= gcnew
LibCECConfiguration();
881 netConfig
->Update(config
);
882 iReturn
= m_callbacks
->ConfigurationChanged(netConfig
);
887 int CecAlertManaged(const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
892 CecParameterType newType
= (CecParameterType
)data
.paramType
;
893 if (newType
== CecParameterType::ParameterTypeString
)
895 System::String
^ newData
= gcnew
System::String((const char *)data
.paramData
, 0, 128);
896 CecParameter
^ newParam
= gcnew
CecParameter(newType
, newData
);
897 iReturn
= m_callbacks
->ReceiveAlert((CecAlert
)alert
, newParam
);
903 int CecMenuManaged(const CEC::cec_menu_state newVal
)
908 iReturn
= m_callbacks
->ReceiveMenuStateChange((CecMenuState
)newVal
);
913 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
916 m_callbacks
->SourceActivated((CecLogicalAddress
)logicalAddress
, bActivated
== 1);
919 void DestroyDelegates()
921 m_bHasCallbacks
= false;
922 if (m_bDelegatesCreated
)
924 m_bDelegatesCreated
= false;
925 m_logMessageGCHandle
.Free();
926 m_keypressGCHandle
.Free();
927 m_commandGCHandle
.Free();
928 m_alertGCHandle
.Free();
929 m_menuGCHandle
.Free();
930 m_sourceActivatedGCHandle
.Free();
934 void CreateDelegates()
938 if (!m_bDelegatesCreated
)
940 msclr::interop::marshal_context
^ context
= gcnew
msclr::interop::marshal_context();
942 // create the delegate method for the log message callback
943 m_logMessageDelegate
= gcnew
CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged
);
944 m_logMessageGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate
);
945 g_logCB
= static_cast<LOGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate
).ToPointer());
946 g_cecCallbacks
.CBCecLogMessage
= CecLogMessageCB
;
948 // create the delegate method for the keypress callback
949 m_keypressDelegate
= gcnew
CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged
);
950 m_keypressGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate
);
951 g_keyCB
= static_cast<KEYCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate
).ToPointer());
952 g_cecCallbacks
.CBCecKeyPress
= CecKeyPressCB
;
954 // create the delegate method for the command callback
955 m_commandDelegate
= gcnew
CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged
);
956 m_commandGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate
);
957 g_commandCB
= static_cast<COMMANDCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate
).ToPointer());
958 g_cecCallbacks
.CBCecCommand
= CecCommandCB
;
960 // create the delegate method for the configuration change callback
961 m_configDelegate
= gcnew
CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged
);
962 m_configGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate
);
963 g_configCB
= static_cast<CONFIGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate
).ToPointer());
964 g_cecCallbacks
.CBCecConfigurationChanged
= CecConfigCB
;
966 // create the delegate method for the alert callback
967 m_alertDelegate
= gcnew
CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged
);
968 m_alertGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate
);
969 g_alertCB
= static_cast<ALERTCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate
).ToPointer());
970 g_cecCallbacks
.CBCecAlert
= CecAlertCB
;
972 // create the delegate method for the menu callback
973 m_menuDelegate
= gcnew
CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged
);
974 m_menuGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate
);
975 g_menuCB
= static_cast<MENUCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate
).ToPointer());
976 g_cecCallbacks
.CBCecMenuStateChanged
= CecMenuCB
;
978 // create the delegate method for the source activated callback
979 m_sourceActivatedDelegate
= gcnew
CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged
);
980 m_sourceActivatedGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate
);
981 g_sourceActivatedCB
= static_cast<ACTICB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate
).ToPointer());
982 g_cecCallbacks
.CBCecSourceActivated
= CecSourceActivatedCB
;
985 m_bDelegatesCreated
= true;
989 CecLogMessageManagedDelegate
^ m_logMessageDelegate
;
990 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle
;
991 LOGCB m_logMessageCallback
;
993 CecKeyPressManagedDelegate
^ m_keypressDelegate
;
994 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle
;
995 KEYCB m_keypressCallback
;
997 CecCommandManagedDelegate
^ m_commandDelegate
;
998 static System::Runtime::InteropServices::GCHandle m_commandGCHandle
;
999 COMMANDCB m_commandCallback
;
1001 CecConfigManagedDelegate
^ m_configDelegate
;
1002 static System::Runtime::InteropServices::GCHandle m_configGCHandle
;
1003 CONFIGCB m_configCallback
;
1005 CecAlertManagedDelegate
^ m_alertDelegate
;
1006 static System::Runtime::InteropServices::GCHandle m_alertGCHandle
;
1007 CONFIGCB m_alertCallback
;
1009 CecMenuManagedDelegate
^ m_menuDelegate
;
1010 static System::Runtime::InteropServices::GCHandle m_menuGCHandle
;
1011 MENUCB m_menuCallback
;
1013 CecSourceActivatedManagedDelegate
^ m_sourceActivatedDelegate
;
1014 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle
;
1015 ACTICB m_sourceActivatedCallback
;
1017 CecCallbackMethods
^ m_callbacks
;
1018 bool m_bHasCallbacks
;
1019 bool m_bDelegatesCreated
;