3 * This file is part of the libCEC(R) library.
5 * libCEC(R) is Copyright (C) 2011-2013 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/
34 #include "../lib/platform/threads/mutex.h"
36 #include <msclr/marshal.h>
37 #include "../../include/cec.h"
43 /// LibCecSharp namespace
45 /// <see cref="LibCecSharp" />
49 /// The device type. For client applications, libCEC only supports RecordingDevice, PlaybackDevice or Tuner.
50 /// libCEC uses RecordingDevice by default.
52 public enum class CecDeviceType
63 /// Reserved / do not use
75 /// Audio system / AVR
81 /// Log level that can be used by the logging callback method to filter messages from libCEC.
83 public enum class CecLogLevel
90 /// libCEC encountered a serious problem, and couldn't complete an action.
94 /// libCEC warns that it encountered a problem, but recovered.
98 /// libCEC informs the client about a CEC state change.
102 /// Raw CEC data traffic
106 /// Debugging messages
110 /// Display all messages
116 /// A logical address on the CEC bus
118 public enum class CecLogicalAddress
121 /// Not a valid logical address
129 /// Recording device 1
131 RecordingDevice1
= 1,
133 /// Recording device 2
135 RecordingDevice2
= 2,
141 /// Playback device 1
145 /// Audio system / AVR
157 /// Playback device 2
161 /// Recording device 3
163 RecordingDevice3
= 9,
169 /// Playback device 3
171 PlaybackDevice3
= 11,
173 /// Reserved address 1
177 /// Reserved address 2
185 /// Unregistered / new device
189 /// Broadcast address
195 /// The type of alert when libCEC calls the CecAlert callback
197 public enum class CecAlert
200 /// The device needs servicing. This is set when the firmware can be upgraded, or when a problem with the firmware is detected.
201 /// The latest firmware flash tool can be downloaded from http://packages.pulse-eight.net/
205 /// The connection to the adapter was lost, probably because the device got unplugged.
209 /// No permission from the OS to access the adapter.
213 /// The device is being used by another program.
217 /// The physical address that is assigned to the adapter is already being used.
219 PhysicalAddressError
,
221 /// The TV does not respond to polls.
227 /// The type of parameter that is sent with the CecAlert callback
229 public enum class CecParameterType
232 /// The parameter is a string
234 ParameterTypeString
= 1
238 /// A parameter for the CecAlert callback
240 public ref
class CecParameter
244 /// Create a new parameter
246 /// <param name="type">The type of this parameter.</param>
247 /// <param name="data">The value of this parameter.</param>
248 CecParameter(CecParameterType type
, System::String
^ data
)
255 /// The type of this parameter
257 property CecParameterType Type
;
259 /// The value of this parameter
261 property
System::String
^ Data
;
265 /// The power status of a CEC device
267 public enum class CecPowerStatus
278 /// In transition from standby to on
280 InTransitionStandbyToOn
= 0x02,
282 /// In transition from on to standby
284 InTransitionOnToStandby
= 0x03,
292 /// The CEC version of a CEC device
294 public enum class CecVersion
323 /// Parameter for OSD string display, that controls how to display the string
325 public enum class CecDisplayControl
328 /// Display for the default time
330 DisplayForDefaultTime
= 0x00,
332 /// Display until it is cleared by ClearPreviousMessage
334 DisplayUntilCleared
= 0x40,
336 /// Clear message displayed by DisplayUntilCleared
338 ClearPreviousMessage
= 0x80,
340 /// Reserved / do not use
342 ReservedForFutureUse
= 0xC0
346 /// The menu state of a CEC device
348 public enum class CecMenuState
361 /// Deck control mode for playback and recording devices
363 public enum class CecDeckControlMode
366 /// Skip forward / wind
370 /// Skip reverse / rewind
372 SkipReverseRewind
= 2,
384 /// Deck status for playback and recording devices
386 public enum class CecDeckInfo
401 /// Showing still frame
409 /// Playing slow reverse
421 /// No media detected
425 /// Stop / not playing
429 /// Skip forward / wind
431 SkipForwardWind
= 0x1B,
433 /// Skip reverse / rewind
435 SkipReverseRewind
= 0x1C,
437 /// Index search forward
439 IndexSearchForward
= 0x1D,
441 /// Index search reverse
443 IndexSearchReverse
= 0x1E,
445 /// Other / unknown status
451 /// User control code, the key code when the user presses or releases a button on the remote.
452 /// Used by SendKeypress() and the CecKey callback.
454 public enum class CecUserControlCode
477 /// Direction right + up
481 /// Direction right + down
485 /// Direction left + up
489 /// Direction left + down
579 PreviousChannel
= 0x32,
581 /// Select sound track
589 /// Display information
591 DisplayInformation
= 0x35,
605 /// Toggle powered on / standby
669 /// Toggle sub picture
673 /// Toggle video on demand
675 VideoOnDemand
= 0x52,
677 /// Toggle electronic program guide (EPG)
679 ElectronicProgramGuide
= 0x53,
681 /// Toggle timer programming
683 TimerProgramming
= 0x54,
685 /// Set initial configuration
687 InitialConfiguration
= 0x55,
689 /// Start playback function
693 /// Pause playback function
695 PausePlayFunction
= 0x61,
697 /// Toggle recording function
699 RecordFunction
= 0x62,
701 /// Pause recording function
703 PauseRecordFunction
= 0x63,
705 /// Stop playback function
709 /// Mute audio function
713 /// Restore volume function
715 RestoreVolumeFunction
= 0x66,
721 /// Select media function
723 SelectMediaFunction
= 0x68,
725 /// Select AV input function
727 SelectAVInputFunction
= 0x69,
729 /// Select audio input function
731 SelectAudioInputFunction
= 0x6A,
733 /// Toggle powered on / standby function
735 PowerToggleFunction
= 0x6B,
737 /// Power off function
739 PowerOffFunction
= 0x6C,
741 /// Power on function
743 PowerOnFunction
= 0x6D,
753 /// F3 / green button
757 /// F4 / yellow button
769 /// Max. valid key code for standard buttons
773 /// Extra return button on Samsung remotes
775 SamsungReturn
= 0x91,
777 /// Unknown / invalid key code
783 /// Vendor IDs for CEC devices
785 public enum class CecVendorId
797 Panasonic
= 0x008045,
809 HarmanKardon
= 0x9C645E,
814 /// Audio status of audio system / AVR devices
816 public enum class CecAudioStatus
821 MuteStatusMask
= 0x80,
823 /// Not muted, volume status mask
825 VolumeStatusMask
= 0x7F,
837 VolumeStatusUnknown
= 0x7F
841 /// CEC opcodes, as described in the HDMI CEC specification
843 public enum class CecOpcode
850 /// Image view on: power on display for image display
854 /// Text view on: power on display for text display
858 /// Device no longer is the active source
860 InactiveSource
= 0x9D,
862 /// Request which device has the active source status
864 RequestActiveSource
= 0x85,
866 /// Routing change for HDMI switches
868 RoutingChange
= 0x80,
870 /// Routing information for HDMI switches
872 RoutingInformation
= 0x81,
874 /// Change the stream path to the given physical address
876 SetStreamPath
= 0x86,
878 /// Inform that a device went into standby mode
890 /// Recording status information
894 /// Record current display
896 RecordTvScreen
= 0x0F,
898 /// Clear analogue timer
900 ClearAnalogueTimer
= 0x33,
902 /// Clear digital timer
904 ClearDigitalTimer
= 0x99,
906 /// Clear external timer
908 ClearExternalTimer
= 0xA1,
910 /// Set analogue timer
912 SetAnalogueTimer
= 0x34,
914 /// Set digital timer
916 SetDigitalTimer
= 0x97,
918 /// Set external timer
920 SetExternalTimer
= 0xA2,
922 /// Set program title of a timer
924 SetTimerProgramTitle
= 0x67,
926 /// Timer status cleared
928 TimerClearedStatus
= 0x43,
930 /// Timer status information
934 /// CEC version used by a device
938 /// Request CEC version of a device
940 GetCecVersion
= 0x9F,
942 /// Request physical address of a device
944 GivePhysicalAddress
= 0x83,
946 /// Request language code of the menu language of a device
947 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
949 GetMenuLanguage
= 0x91,
951 /// Report the physical address
953 ReportPhysicalAddress
= 0x84,
955 /// Report the language code of the menu language
956 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
958 SetMenuLanguage
= 0x32,
960 /// Deck control for playback and recording devices
964 /// Deck status for playback and recording devices
968 /// Request deck status from playback and recording devices
970 GiveDeckStatus
= 0x1A,
972 /// Start playback on playback and recording devices
976 /// Request tuner status
978 GiveTunerDeviceStatus
= 0x08,
980 /// Select analogue service on a tuner
982 SelectAnalogueService
= 0x92,
984 /// Select digital service on a tuner
986 SelectDigtalService
= 0x93,
988 /// Report tuner device status
990 TunerDeviceStatus
= 0x07,
992 /// Tuner step decrement
994 TunerStepDecrement
= 0x06,
996 /// Tuner step increment
998 TunerStepIncrement
= 0x05,
1000 /// Report device vendor ID
1002 DeviceVendorId
= 0x87,
1004 /// Request device vendor ID
1006 GiveDeviceVendorId
= 0x8C,
1008 /// Vendor specific command
1010 VendorCommand
= 0x89,
1012 /// Vendor specific command with vendor ID
1014 VendorCommandWithId
= 0xA0,
1016 /// Vendor specific remote button pressed
1018 VendorRemoteButtonDown
= 0x8A,
1020 /// Vendor specific remote button released
1022 VendorRemoteButtonUp
= 0x8B,
1024 /// Display / clear OSD string
1026 SetOsdString
= 0x64,
1028 /// Request device OSD name
1032 /// Report device OSD name
1036 /// Request device menu status
1040 /// Report device menu status
1044 /// Remote button pressed
1046 UserControlPressed
= 0x44,
1048 /// Remote button released
1050 UserControlRelease
= 0x45,
1052 /// Request device power status
1054 GiveDevicePowerStatus
= 0x8F,
1056 /// Report device power status
1058 ReportPowerStatus
= 0x90,
1060 /// Feature abort / unsupported command
1062 FeatureAbort
= 0x00,
1068 /// Give audio status
1070 GiveAudioStatus
= 0x71,
1072 /// Give audiosystem mode
1074 GiveSystemAudioMode
= 0x7D,
1076 /// Report device audio status
1078 ReportAudioStatus
= 0x7A,
1080 /// Set audiosystem mode
1082 SetSystemAudioMode
= 0x72,
1084 /// Request audiosystem mode
1086 SystemAudioModeRequest
= 0x70,
1088 /// Report audiosystem mode
1090 SystemAudioModeStatus
= 0x7E,
1092 /// Set audio bitrate
1094 SetAudioRate
= 0x9A,
1096 /// When this opcode is set, no opcode will be sent to the device / poll message
1097 /// This is one of the reserved numbers
1103 /// Audiosystem status
1105 public enum class CecSystemAudioStatus
1118 /// libCEC client application version
1120 public enum class CecClientVersion
1129 Version1_5_0
= 0x1500,
1133 Version1_5_1
= 0x1501,
1137 Version1_5_2
= 0x1502,
1141 Version1_5_3
= 0x1503,
1145 Version1_6_0
= 0x1600,
1149 Version1_6_1
= 0x1601,
1153 Version1_6_2
= 0x1602,
1157 Version1_6_3
= 0x1603,
1161 Version1_7_0
= 0x1700,
1165 Version1_7_1
= 0x1701,
1169 Version1_7_2
= 0x1702,
1173 Version1_8_0
= 0x1800,
1177 Version1_8_1
= 0x1801,
1181 Version1_8_2
= 0x1802,
1185 Version1_9_0
= 0x1900,
1189 Version1_99_0
= 0x1990,
1193 Version2_0_0
= 0x2000,
1197 Version2_0_1
= 0x2001,
1201 Version2_0_2
= 0x2002,
1205 Version2_0_3
= 0x2003,
1209 Version2_0_4
= 0x2004,
1213 Version2_0_5
= 0x2005,
1217 Version2_1_0
= 0x2100,
1221 Version2_1_1
= 0x2101,
1225 Version2_1_2
= 0x2102,
1229 Version2_1_3
= 0x2103,
1231 /// The current version
1233 CurrentVersion
= 0x2103
1239 public enum class CecServerVersion
1248 Version1_5_0
= 0x1500,
1252 Version1_5_1
= 0x1501,
1256 Version1_5_2
= 0x1502,
1260 Version1_5_3
= 0x1503,
1264 Version1_6_0
= 0x1600,
1268 Version1_6_1
= 0x1601,
1272 Version1_6_2
= 0x1602,
1276 Version1_6_3
= 0x1603,
1280 Version1_7_0
= 0x1700,
1284 Version1_7_1
= 0x1701,
1288 Version1_7_2
= 0x1702,
1292 Version1_8_0
= 0x1800,
1296 Version1_8_1
= 0x1801,
1300 Version1_8_2
= 0x1802,
1304 Version1_9_0
= 0x1900,
1308 Version1_99_0
= 0x1990,
1312 Version2_0_0
= 0x2000,
1316 Version2_0_1
= 0x2001,
1320 Version2_0_2
= 0x2002,
1324 Version2_0_3
= 0x2003,
1328 Version2_0_4
= 0x2004,
1332 Version2_0_5
= 0x2005,
1336 Version2_1_0
= 0x2100,
1340 Version2_1_1
= 0x2101,
1344 Version2_1_2
= 0x2102,
1348 Version2_1_3
= 0x2103,
1350 /// The current version
1352 CurrentVersion
= 0x2103
1356 /// Type of adapter to which libCEC is connected
1358 public enum class CecAdapterType
1361 /// Unknown adapter type
1365 /// Pulse-Eight USB-CEC adapter
1367 PulseEightExternal
= 0x1,
1369 /// Pulse-Eight CEC daughterboard
1371 PulseEightDaughterboard
= 0x2,
1375 RaspberryPi
= 0x100,
1383 /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system
1385 public ref
class CecAdapter
1389 /// Create a new CEC adapter descriptor
1391 /// <param name="path"> The path descriptor for this CEC adapter</param>
1392 /// <param name="comPort">The COM port of this CEC adapter</param>
1393 CecAdapter(System::String
^ path
, System::String
^ comPort
)
1400 /// The path descriptor for this CEC adapter
1402 property
System::String
^ Path
;
1405 /// The COM port of this CEC adapter
1407 property
System::String
^ ComPort
;
1411 /// A list of CEC device types
1413 public ref
class CecDeviceTypeList
1417 /// Create a new empty list of CEC device types
1419 CecDeviceTypeList(void)
1421 Types
= gcnew array
<CecDeviceType
>(5);
1422 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1423 Types
[iPtr
] = CecDeviceType::Reserved
;
1427 /// The array with CecDeviceType instances in this list.
1429 property array
<CecDeviceType
> ^ Types
;
1433 /// A list of logical addresses
1435 public ref
class CecLogicalAddresses
1439 /// Create a new empty list of logical addresses
1441 CecLogicalAddresses(void)
1443 Addresses
= gcnew array
<CecLogicalAddress
>(16);
1448 /// Clears this list
1452 Primary
= CecLogicalAddress::Unknown
;
1453 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
1454 Addresses
[iPtr
] = CecLogicalAddress::Unknown
;
1458 /// Checks whether a logical address is set in this list.
1460 /// <param name="address">The address to check.</param>
1461 /// <returns>True when set, false otherwise</returns>
1462 bool IsSet(CecLogicalAddress address
)
1464 return Addresses
[(unsigned int)address
] != CecLogicalAddress::Unknown
;
1468 /// Add a logical address to this list (if it's not set already)
1470 /// <param name="address">The address to add.</param>
1471 void Set(CecLogicalAddress address
)
1473 Addresses
[(unsigned int)address
] = address
;
1474 if (Primary
== CecLogicalAddress::Unknown
)
1479 /// The primary (first) address in this list
1481 property CecLogicalAddress Primary
;
1484 /// The list of addresses
1486 property array
<CecLogicalAddress
> ^ Addresses
;
1491 /// Byte array used for CEC command parameters
1493 public ref
class CecDatapacket
1497 /// Create a new byte array with maximum size 100
1501 Data
= gcnew array
<uint8_t>(100);
1506 /// Adds a byte to this byte array
1508 /// <param name="data">The byte to add.</param>
1509 void PushBack(uint8_t data
)
1521 property array
<uint8_t> ^ Data
;
1524 /// Current data size
1526 property
uint8_t Size
;
1530 /// A CEC command that is received or transmitted over the CEC bus
1532 public ref
class CecCommand
1536 /// Create a new CEC command instance
1538 /// <param name="initiator">The initiator of the command</param>
1539 /// <param name="destination">The receiver of the command</param>
1540 /// <param name="ack">True when the ack bit is set, false otherwise</param>
1541 /// <param name="eom">True when the eom bit is set, false otherwise</param>
1542 /// <param name="opcode">The CEC opcode of this command</param>
1543 /// <param name="transmitTimeout">The timeout to use when transmitting a command</param>
1544 CecCommand(CecLogicalAddress initiator
, CecLogicalAddress destination
, bool ack
, bool eom
, CecOpcode opcode
, int32_t transmitTimeout
)
1546 Initiator
= initiator
;
1547 Destination
= destination
;
1552 TransmitTimeout
= transmitTimeout
;
1553 Parameters
= gcnew CecDatapacket
;
1558 /// Create a new empty CEC command instance
1562 Initiator
= CecLogicalAddress::Unknown
;
1563 Destination
= CecLogicalAddress::Unknown
;
1566 Opcode
= CecOpcode::None
;
1568 TransmitTimeout
= 0;
1569 Parameters
= gcnew CecDatapacket
;
1574 /// Pushes a byte of data to this CEC command
1576 /// <param name="data">The byte to add</param>
1577 void PushBack(uint8_t data
)
1579 if (Initiator
== CecLogicalAddress::Unknown
&& Destination
== CecLogicalAddress::Unknown
)
1581 Initiator
= (CecLogicalAddress
) (data
>> 4);
1582 Destination
= (CecLogicalAddress
) (data
& 0xF);
1584 else if (!OpcodeSet
)
1587 Opcode
= (CecOpcode
)data
;
1591 Parameters
->PushBack(data
);
1596 /// True when this command is empty, false otherwise.
1598 property
bool Empty
;
1600 /// The initiator of the command
1602 property CecLogicalAddress Initiator
;
1604 /// The destination of the command
1606 property CecLogicalAddress Destination
;
1608 /// True when the ack bit is set, false otherwise
1612 /// True when the eom bit is set, false otherwise
1616 /// The CEC opcode of the command
1618 property CecOpcode Opcode
;
1620 /// The parameters of this command
1622 property CecDatapacket
^ Parameters
;
1624 /// True when an opcode is set, false otherwise (poll message)
1626 property
bool OpcodeSet
;
1628 /// The timeout to use when transmitting a command
1630 property
int32_t TransmitTimeout
;
1634 /// A key press that was received
1636 public ref
class CecKeypress
1640 /// Create a new key press instance
1642 /// <param name="keycode">The key code of this key press</param>
1643 /// <param name="duration">The duration of this key press in milliseconds</param>
1644 CecKeypress(CecUserControlCode keycode
, unsigned int duration
)
1647 Duration
= duration
;
1652 /// Create a new empty key press instance
1656 Keycode
= CecUserControlCode::Unknown
;
1662 /// True when empty, false otherwise
1664 property
bool Empty
;
1666 /// The key code of this key press
1668 property CecUserControlCode Keycode
;
1670 /// The duration of this key press in milliseconds
1672 property
unsigned int Duration
;
1676 /// A log message that libCEC generated
1678 public ref
class CecLogMessage
1682 /// Create a new log message
1684 /// <param name="message">The actual message</param>
1685 /// <param name="level">The log level, so the application can choose what type information to display</param>
1686 /// <param name="time">The timestamp of this message, in milliseconds after connecting</param>
1687 CecLogMessage(System::String
^ message
, CecLogLevel level
, int64_t time
)
1696 /// Create a new empty log message
1701 Level
= CecLogLevel::None
;
1707 /// True when empty, false otherwise.
1709 property
bool Empty
;
1711 /// The actual message
1713 property
System::String
^Message
;
1715 /// The log level, so the application can choose what type information to display
1717 property CecLogLevel Level
;
1719 /// The timestamp of this message, in milliseconds after connecting
1721 property
int64_t Time
;
1724 ref
class CecCallbackMethods
; //forward declaration
1727 /// The configuration that libCEC uses.
1729 public ref
class LibCECConfiguration
1733 /// Create a new configuration instance with default settings.
1735 LibCECConfiguration(void)
1738 DeviceTypes
= gcnew
CecDeviceTypeList();
1739 AutodetectAddress
= true;
1740 PhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
1741 BaseDevice
= (CecLogicalAddress
)CEC_DEFAULT_BASE_DEVICE
;
1742 HDMIPort
= CEC_DEFAULT_HDMI_PORT
;
1743 ClientVersion
= CecClientVersion::CurrentVersion
;
1744 ServerVersion
= CecServerVersion::CurrentVersion
;
1745 TvVendor
= CecVendorId::Unknown
;
1747 GetSettingsFromROM
= false;
1748 UseTVMenuLanguage
= CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE
== 1;
1749 ActivateSource
= CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1;
1751 WakeDevices
= gcnew
CecLogicalAddresses();
1752 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1)
1753 WakeDevices
->Set(CecLogicalAddress::Tv
);
1755 PowerOffDevices
= gcnew
CecLogicalAddresses();
1756 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN
== 1)
1757 PowerOffDevices
->Set(CecLogicalAddress::Broadcast
);
1759 PowerOffScreensaver
= CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER
== 1;
1760 PowerOffOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY
== 1;
1762 SendInactiveSource
= CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE
== 1;
1763 LogicalAddresses
= gcnew
CecLogicalAddresses();
1764 FirmwareVersion
= 1;
1765 PowerOffDevicesOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY
== 1;
1766 ShutdownOnStandby
= CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY
== 1;
1767 DeviceLanguage
= "";
1768 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1769 CECVersion
= (CecVersion
)CEC_DEFAULT_SETTING_CEC_VERSION
;
1770 AdapterType
= CecAdapterType::Unknown
;
1774 /// Change the callback method pointers in this configuration instance.
1776 /// <param name="callbacks">The new callbacks</param>
1777 void SetCallbacks(CecCallbackMethods
^callbacks
)
1779 Callbacks
= callbacks
;
1783 /// Update this configuration with data received from libCEC
1785 /// <param name="config">The configuration that was received from libCEC</param>
1786 void Update(const CEC::libcec_configuration
&config
)
1788 DeviceName
= gcnew
System::String(config
.strDeviceName
);
1790 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1791 DeviceTypes
->Types
[iPtr
] = (CecDeviceType
)config
.deviceTypes
.types
[iPtr
];
1793 AutodetectAddress
= config
.bAutodetectAddress
== 1;
1794 PhysicalAddress
= config
.iPhysicalAddress
;
1795 BaseDevice
= (CecLogicalAddress
)config
.baseDevice
;
1796 HDMIPort
= config
.iHDMIPort
;
1797 ClientVersion
= (CecClientVersion
)config
.clientVersion
;
1798 ServerVersion
= (CecServerVersion
)config
.serverVersion
;
1799 TvVendor
= (CecVendorId
)config
.tvVendor
;
1801 // player specific settings
1802 GetSettingsFromROM
= config
.bGetSettingsFromROM
== 1;
1803 UseTVMenuLanguage
= config
.bUseTVMenuLanguage
== 1;
1804 ActivateSource
= config
.bActivateSource
== 1;
1806 WakeDevices
->Clear();
1807 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1808 if (config
.wakeDevices
[iPtr
])
1809 WakeDevices
->Set((CecLogicalAddress
)iPtr
);
1811 PowerOffDevices
->Clear();
1812 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1813 if (config
.powerOffDevices
[iPtr
])
1814 PowerOffDevices
->Set((CecLogicalAddress
)iPtr
);
1816 PowerOffScreensaver
= config
.bPowerOffScreensaver
== 1;
1817 PowerOffOnStandby
= config
.bPowerOffOnStandby
== 1;
1819 if (ServerVersion
>= CecServerVersion::Version1_5_1
)
1820 SendInactiveSource
= config
.bSendInactiveSource
== 1;
1822 if (ServerVersion
>= CecServerVersion::Version1_5_3
)
1824 LogicalAddresses
->Clear();
1825 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1826 if (config
.logicalAddresses
[iPtr
])
1827 LogicalAddresses
->Set((CecLogicalAddress
)iPtr
);
1830 if (ServerVersion
>= CecServerVersion::Version1_6_0
)
1832 FirmwareVersion
= config
.iFirmwareVersion
;
1833 PowerOffDevicesOnStandby
= config
.bPowerOffDevicesOnStandby
== 1;
1834 ShutdownOnStandby
= config
.bShutdownOnStandby
== 1;
1837 if (ServerVersion
>= CecServerVersion::Version1_6_2
)
1839 DeviceLanguage
= gcnew
System::String(config
.strDeviceLanguage
);
1840 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1841 FirmwareBuildDate
= FirmwareBuildDate
->AddSeconds(config
.iFirmwareBuildDate
);
1844 if (ServerVersion
>= CecServerVersion::Version1_6_3
)
1845 MonitorOnlyClient
= config
.bMonitorOnly
== 1;
1847 if (ServerVersion
>= CecServerVersion::Version1_8_0
)
1848 CECVersion
= (CecVersion
)config
.cecVersion
;
1850 if (ServerVersion
>= CecServerVersion::Version1_8_2
)
1851 AdapterType
= (CecAdapterType
)config
.adapterType
;
1853 if (ServerVersion
>= CecServerVersion::Version2_1_0
)
1854 PowerOnScreensaver
= config
.bPowerOnScreensaver
== 1;
1858 /// The device name to use on the CEC bus
1860 property
System::String
^ DeviceName
;
1863 /// The device type(s) to use on the CEC bus for libCEC
1865 property CecDeviceTypeList
^ DeviceTypes
;
1868 /// (read only) set to true by libCEC when the physical address was autodetected
1870 property
bool AutodetectAddress
;
1873 /// The physical address of the CEC adapter
1875 property
uint16_t PhysicalAddress
;
1878 /// The logical address of the device to which the adapter is connected. Only used when PhysicalAddress = 0 or when the adapter doesn't support autodetection
1880 property CecLogicalAddress BaseDevice
;
1883 /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection
1885 property
uint8_t HDMIPort
;
1888 /// The client API version to use
1890 property CecClientVersion ClientVersion
;
1893 /// The version of libCEC
1895 property CecServerVersion ServerVersion
;
1898 /// Override the vendor ID of the TV. Leave this untouched to autodetect
1900 property CecVendorId TvVendor
;
1903 /// True to read the settings from the EEPROM, which possibly override the settings passed here
1905 property
bool GetSettingsFromROM
;
1908 /// Use the language setting of the TV in the client application. Must be implemented by the client application.
1909 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1911 property
bool UseTVMenuLanguage
;
1914 /// Make libCEC the active source when starting the client application
1916 property
bool ActivateSource
;
1919 /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter.
1921 property CecLogicalAddresses
^WakeDevices
;
1924 /// List of devices to power off when calling StandbyDevices() without any parameter.
1926 property CecLogicalAddresses
^PowerOffDevices
;
1929 /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application.
1931 property
bool PowerOffScreensaver
;
1934 /// Power off the PC when the TV powers off. Must be implemented by the client application.
1936 property
bool PowerOffOnStandby
;
1939 /// Send an inactive source message when exiting the client application.
1941 property
bool SendInactiveSource
;
1944 /// The list of logical addresses that libCEC is using
1946 property CecLogicalAddresses
^LogicalAddresses
;
1949 /// The firmware version of the adapter to which libCEC is connected
1951 property
uint16_t FirmwareVersion
;
1954 /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
1956 property
bool PowerOffDevicesOnStandby
;
1959 /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false
1961 property
bool ShutdownOnStandby
;
1964 /// True to start a monitor-only client, false to start a standard client.
1966 property
bool MonitorOnlyClient
;
1969 /// The language code of the menu language that libCEC reports to other devices.
1970 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1972 property
System::String
^ DeviceLanguage
;
1975 /// The callback methods to use.
1977 property CecCallbackMethods
^ Callbacks
;
1980 /// The build date of the firmware.
1982 property
System::DateTime
^ FirmwareBuildDate
;
1985 /// The CEC version that libCEC uses.
1987 property CecVersion CECVersion
;
1990 /// The type of adapter that libCEC is connected to.
1992 property CecAdapterType AdapterType
;
1995 /// True to power on when quitting the screensaver.
1997 property
bool PowerOnScreensaver
;
2000 // the callback methods are called by unmanaged code, so we need some delegates for this
2002 // unmanaged callback methods
2003 typedef int (__stdcall
*LOGCB
) (const CEC::cec_log_message
&message
);
2004 typedef int (__stdcall
*KEYCB
) (const CEC::cec_keypress
&key
);
2005 typedef int (__stdcall
*COMMANDCB
)(const CEC::cec_command
&command
);
2006 typedef int (__stdcall
*CONFIGCB
) (const CEC::libcec_configuration
&config
);
2007 typedef int (__stdcall
*ALERTCB
) (const CEC::libcec_alert
, const CEC::libcec_parameter
&data
);
2008 typedef int (__stdcall
*MENUCB
) (const CEC::cec_menu_state newVal
);
2009 typedef void (__stdcall
*ACTICB
) (const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
2012 /// libCEC callback methods. Unmanaged code.
2017 /// Log message callback
2021 /// Key press/release callback
2025 /// Raw CEC data callback
2027 COMMANDCB commandCB
;
2029 /// Updated configuration callback
2033 /// Alert message callback
2037 /// Menu status change callback
2041 /// Source (de)activated callback
2043 ACTICB sourceActivatedCB
;
2044 } UnmanagedCecCallbacks
;
2046 static PLATFORM::CMutex g_callbackMutex
;
2047 static std::vector
<UnmanagedCecCallbacks
> g_unmanagedCallbacks
;
2048 static CEC::ICECCallbacks g_cecCallbacks
;
2051 /// Called by libCEC to send back a log message to the application
2053 /// <param name="cbParam">Pointer to the callback struct</param>
2054 /// <param name="message">The log message</param>
2055 /// <return>1 when handled, 0 otherwise</return>
2056 int CecLogMessageCB(void *cbParam
, const CEC::cec_log_message message
)
2060 size_t iPtr
= (size_t)cbParam
;
2061 PLATFORM::CLockObject
lock(g_callbackMutex
);
2062 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2063 return g_unmanagedCallbacks
[iPtr
].logCB(message
);
2069 /// Called by libCEC to send back a key press or release to the application
2071 /// <param name="cbParam">Pointer to the callback struct</param>
2072 /// <param name="key">The key press command that libCEC received</param>
2073 /// <return>1 when handled, 0 otherwise</return>
2074 int CecKeyPressCB(void *cbParam
, const CEC::cec_keypress key
)
2078 size_t iPtr
= (size_t)cbParam
;
2079 PLATFORM::CLockObject
lock(g_callbackMutex
);
2080 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2081 return g_unmanagedCallbacks
[iPtr
].keyCB(key
);
2087 /// Called by libCEC to send back raw CEC data to the application
2089 /// <param name="cbParam">Pointer to the callback struct</param>
2090 /// <param name="command">The raw CEC data</param>
2091 /// <return>1 when handled, 0 otherwise</return>
2092 int CecCommandCB(void *cbParam
, const CEC::cec_command command
)
2096 size_t iPtr
= (size_t)cbParam
;
2097 PLATFORM::CLockObject
lock(g_callbackMutex
);
2098 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2099 return g_unmanagedCallbacks
[iPtr
].commandCB(command
);
2105 /// Called by libCEC to send back an updated configuration to the application
2107 /// <param name="cbParam">Pointer to the callback struct</param>
2108 /// <param name="config">The new configuration</param>
2109 /// <return>1 when handled, 0 otherwise</return>
2110 int CecConfigCB(void *cbParam
, const CEC::libcec_configuration config
)
2114 size_t iPtr
= (size_t)cbParam
;
2115 PLATFORM::CLockObject
lock(g_callbackMutex
);
2116 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2117 return g_unmanagedCallbacks
[iPtr
].configCB(config
);
2123 /// Called by libCEC to send back an alert message to the application
2125 /// <param name="cbParam">Pointer to the callback struct</param>
2126 /// <param name="data">The alert message</param>
2127 /// <return>1 when handled, 0 otherwise</return>
2128 int CecAlertCB(void *cbParam
, const CEC::libcec_alert alert
, const CEC::libcec_parameter data
)
2132 size_t iPtr
= (size_t)cbParam
;
2133 PLATFORM::CLockObject
lock(g_callbackMutex
);
2134 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2135 return g_unmanagedCallbacks
[iPtr
].alertCB(alert
, data
);
2141 /// Called by libCEC to send back a menu state change to the application
2143 /// <param name="cbParam">Pointer to the callback struct</param>
2144 /// <param name="newVal">The new menu state</param>
2145 /// <return>1 when handled, 0 otherwise</return>
2146 int CecMenuCB(void *cbParam
, const CEC::cec_menu_state newVal
)
2150 size_t iPtr
= (size_t)cbParam
;
2151 PLATFORM::CLockObject
lock(g_callbackMutex
);
2152 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2153 return g_unmanagedCallbacks
[iPtr
].menuCB(newVal
);
2159 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated
2161 /// <param name="cbParam">Pointer to the callback struct</param>
2162 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2163 /// <param name="activated">True when activated, false when deactivated</param>
2164 void CecSourceActivatedCB(void *cbParam
, const CEC::cec_logical_address logicalAddress
, const uint8_t activated
)
2168 size_t iPtr
= (size_t)cbParam
;
2169 PLATFORM::CLockObject
lock(g_callbackMutex
);
2170 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2171 g_unmanagedCallbacks
[iPtr
].sourceActivatedCB(logicalAddress
, activated
);
2177 /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods
2179 public delegate
int CecLogMessageManagedDelegate(const CEC::cec_log_message
&);
2181 /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods
2183 public delegate
int CecKeyPressManagedDelegate(const CEC::cec_keypress
&);
2185 /// Delegate method for the CecCommandCB callback in CecCallbackMethods
2187 public delegate
int CecCommandManagedDelegate(const CEC::cec_command
&);
2189 /// Delegate method for the CecConfigCB callback in CecCallbackMethods
2191 public delegate
int CecConfigManagedDelegate(const CEC::libcec_configuration
&);
2193 /// Delegate method for the CecAlertCB callback in CecCallbackMethods
2195 public delegate
int CecAlertManagedDelegate(const CEC::libcec_alert
, const CEC::libcec_parameter
&);
2197 /// Delegate method for the CecMenuCB callback in CecCallbackMethods
2199 public delegate
int CecMenuManagedDelegate(const CEC::cec_menu_state
);
2201 /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods
2203 public delegate
void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address
, const uint8_t);
2206 /// Assign the callback methods in the g_cecCallbacks struct
2208 void AssignCallbacks()
2210 g_cecCallbacks
.CBCecLogMessage
= CecLogMessageCB
;
2211 g_cecCallbacks
.CBCecKeyPress
= CecKeyPressCB
;
2212 g_cecCallbacks
.CBCecCommand
= CecCommandCB
;
2213 g_cecCallbacks
.CBCecConfigurationChanged
= CecConfigCB
;
2214 g_cecCallbacks
.CBCecAlert
= CecAlertCB
;
2215 g_cecCallbacks
.CBCecMenuStateChanged
= CecMenuCB
;
2216 g_cecCallbacks
.CBCecSourceActivated
= CecSourceActivatedCB
;
2220 /// The callback methods that libCEC uses
2222 public ref
class CecCallbackMethods
2225 CecCallbackMethods(void)
2227 m_iCallbackPtr
= -1;
2229 m_bHasCallbacks
= false;
2230 m_bDelegatesCreated
= false;
2233 ~CecCallbackMethods(void)
2239 /// Pointer to the callbacks struct entry
2241 size_t GetCallbackPtr(void)
2243 PLATFORM::CLockObject
lock(g_callbackMutex
);
2244 return m_iCallbackPtr
;
2248 !CecCallbackMethods(void)
2255 /// Disable callback methods
2257 virtual void DisableCallbacks(void)
2263 /// Enable callback methods
2265 /// <param name="callbacks">Callback methods to activate</param>
2266 /// <return>true when handled, false otherwise</return>
2267 virtual bool EnableCallbacks(CecCallbackMethods
^ callbacks
)
2270 if (!m_bHasCallbacks
)
2272 m_bHasCallbacks
= true;
2273 m_callbacks
= callbacks
;
2281 /// Called by libCEC to send back a log message to the application.
2282 /// Override in the application to handle this callback.
2284 /// <param name="message">The log message</param>
2285 /// <return>1 when handled, 0 otherwise</return>
2286 virtual int ReceiveLogMessage(CecLogMessage
^ message
)
2292 /// Called by libCEC to send back a key press or release to the application.
2293 /// Override in the application to handle this callback.
2295 /// <param name="key">The key press command that libCEC received</param>
2296 /// <return>1 when handled, 0 otherwise</return>
2297 virtual int ReceiveKeypress(CecKeypress
^ key
)
2303 /// Called by libCEC to send back raw CEC data to the application.
2304 /// Override in the application to handle this callback.
2306 /// <param name="command">The raw CEC data</param>
2307 /// <return>1 when handled, 0 otherwise</return>
2308 virtual int ReceiveCommand(CecCommand
^ command
)
2314 /// Called by libCEC to send back an updated configuration to the application.
2315 /// Override in the application to handle this callback.
2317 /// <param name="config">The new configuration</param>
2318 /// <return>1 when handled, 0 otherwise</return>
2319 virtual int ConfigurationChanged(LibCECConfiguration
^ config
)
2325 /// Called by libCEC to send back an alert message to the application.
2326 /// Override in the application to handle this callback.
2328 /// <param name="data">The alert message</param>
2329 /// <return>1 when handled, 0 otherwise</return>
2330 virtual int ReceiveAlert(CecAlert alert
, CecParameter
^ data
)
2336 /// Called by libCEC to send back a menu state change to the application.
2337 /// Override in the application to handle this callback.
2339 /// <param name="newVal">The new menu state</param>
2340 /// <return>1 when handled, 0 otherwise</return>
2341 virtual int ReceiveMenuStateChange(CecMenuState newVal
)
2347 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated.
2348 /// Override in the application to handle this callback.
2350 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2351 /// <param name="activated">True when activated, false when deactivated</param>
2352 virtual void SourceActivated(CecLogicalAddress logicalAddress
, bool activated
)
2357 // managed callback methods
2358 int CecLogMessageManaged(const CEC::cec_log_message
&message
)
2361 if (m_bHasCallbacks
)
2362 iReturn
= m_callbacks
->ReceiveLogMessage(gcnew
CecLogMessage(gcnew
System::String(message
.message
), (CecLogLevel
)message
.level
, message
.time
));
2366 int CecKeyPressManaged(const CEC::cec_keypress
&key
)
2369 if (m_bHasCallbacks
)
2370 iReturn
= m_callbacks
->ReceiveKeypress(gcnew
CecKeypress((CecUserControlCode
)key
.keycode
, key
.duration
));
2374 int CecCommandManaged(const CEC::cec_command
&command
)
2377 if (m_bHasCallbacks
)
2379 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
);
2380 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
2381 newCommand
->Parameters
->PushBack(command
.parameters
[iPtr
]);
2382 iReturn
= m_callbacks
->ReceiveCommand(newCommand
);
2387 int CecConfigManaged(const CEC::libcec_configuration
&config
)
2390 if (m_bHasCallbacks
)
2392 LibCECConfiguration
^netConfig
= gcnew
LibCECConfiguration();
2393 netConfig
->Update(config
);
2394 iReturn
= m_callbacks
->ConfigurationChanged(netConfig
);
2399 int CecAlertManaged(const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
2402 if (m_bHasCallbacks
)
2404 CecParameterType newType
= (CecParameterType
)data
.paramType
;
2405 if (newType
== CecParameterType::ParameterTypeString
)
2407 System::String
^ newData
= gcnew
System::String((const char *)data
.paramData
, 0, 128);
2408 CecParameter
^ newParam
= gcnew
CecParameter(newType
, newData
);
2409 iReturn
= m_callbacks
->ReceiveAlert((CecAlert
)alert
, newParam
);
2415 int CecMenuManaged(const CEC::cec_menu_state newVal
)
2418 if (m_bHasCallbacks
)
2420 iReturn
= m_callbacks
->ReceiveMenuStateChange((CecMenuState
)newVal
);
2425 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
2427 if (m_bHasCallbacks
)
2428 m_callbacks
->SourceActivated((CecLogicalAddress
)logicalAddress
, bActivated
== 1);
2431 void DestroyDelegates()
2433 m_bHasCallbacks
= false;
2434 if (m_bDelegatesCreated
)
2436 m_bDelegatesCreated
= false;
2437 m_logMessageGCHandle
.Free();
2438 m_keypressGCHandle
.Free();
2439 m_commandGCHandle
.Free();
2440 m_alertGCHandle
.Free();
2441 m_menuGCHandle
.Free();
2442 m_sourceActivatedGCHandle
.Free();
2446 void CreateDelegates()
2450 if (!m_bDelegatesCreated
)
2452 msclr::interop::marshal_context
^ context
= gcnew
msclr::interop::marshal_context();
2454 // create the delegate method for the log message callback
2455 m_logMessageDelegate
= gcnew
CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged
);
2456 m_logMessageGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate
);
2457 m_logMessageCallback
= static_cast<LOGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate
).ToPointer());
2459 // create the delegate method for the keypress callback
2460 m_keypressDelegate
= gcnew
CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged
);
2461 m_keypressGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate
);
2462 m_keypressCallback
= static_cast<KEYCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate
).ToPointer());
2464 // create the delegate method for the command callback
2465 m_commandDelegate
= gcnew
CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged
);
2466 m_commandGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate
);
2467 m_commandCallback
= static_cast<COMMANDCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate
).ToPointer());
2469 // create the delegate method for the configuration change callback
2470 m_configDelegate
= gcnew
CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged
);
2471 m_configGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate
);
2472 m_configCallback
= static_cast<CONFIGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate
).ToPointer());
2474 // create the delegate method for the alert callback
2475 m_alertDelegate
= gcnew
CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged
);
2476 m_alertGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate
);
2477 m_alertCallback
= static_cast<ALERTCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate
).ToPointer());
2479 // create the delegate method for the menu callback
2480 m_menuDelegate
= gcnew
CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged
);
2481 m_menuGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate
);
2482 m_menuCallback
= static_cast<MENUCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate
).ToPointer());
2484 // create the delegate method for the source activated callback
2485 m_sourceActivatedDelegate
= gcnew
CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged
);
2486 m_sourceActivatedGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate
);
2487 m_sourceActivatedCallback
= static_cast<ACTICB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate
).ToPointer());
2491 UnmanagedCecCallbacks unmanagedCallbacks
;
2492 unmanagedCallbacks
.logCB
= m_logMessageCallback
;
2493 unmanagedCallbacks
.keyCB
= m_keypressCallback
;
2494 unmanagedCallbacks
.commandCB
= m_commandCallback
;
2495 unmanagedCallbacks
.configCB
= m_configCallback
;
2496 unmanagedCallbacks
.alertCB
= m_alertCallback
;
2497 unmanagedCallbacks
.menuCB
= m_menuCallback
;
2498 unmanagedCallbacks
.sourceActivatedCB
= m_sourceActivatedCallback
;
2500 PLATFORM::CLockObject
lock(g_callbackMutex
);
2501 g_unmanagedCallbacks
.push_back(unmanagedCallbacks
);
2502 m_iCallbackPtr
= g_unmanagedCallbacks
.size() - 1;
2503 m_bDelegatesCreated
= true;
2507 CecLogMessageManagedDelegate
^ m_logMessageDelegate
;
2508 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle
;
2509 LOGCB m_logMessageCallback
;
2511 CecKeyPressManagedDelegate
^ m_keypressDelegate
;
2512 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle
;
2513 KEYCB m_keypressCallback
;
2515 CecCommandManagedDelegate
^ m_commandDelegate
;
2516 static System::Runtime::InteropServices::GCHandle m_commandGCHandle
;
2517 COMMANDCB m_commandCallback
;
2519 CecConfigManagedDelegate
^ m_configDelegate
;
2520 static System::Runtime::InteropServices::GCHandle m_configGCHandle
;
2521 CONFIGCB m_configCallback
;
2523 CecAlertManagedDelegate
^ m_alertDelegate
;
2524 static System::Runtime::InteropServices::GCHandle m_alertGCHandle
;
2525 ALERTCB m_alertCallback
;
2527 CecMenuManagedDelegate
^ m_menuDelegate
;
2528 static System::Runtime::InteropServices::GCHandle m_menuGCHandle
;
2529 MENUCB m_menuCallback
;
2531 CecSourceActivatedManagedDelegate
^ m_sourceActivatedDelegate
;
2532 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle
;
2533 ACTICB m_sourceActivatedCallback
;
2535 CecCallbackMethods
^ m_callbacks
;
2536 bool m_bHasCallbacks
;
2537 bool m_bDelegatesCreated
;
2538 size_t m_iCallbackPtr
;