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
795 Panasonic
= 0x008045,
811 /// Audio status of audio system / AVR devices
813 public enum class CecAudioStatus
818 MuteStatusMask
= 0x80,
820 /// Not muted, volume status mask
822 VolumeStatusMask
= 0x7F,
834 VolumeStatusUnknown
= 0x7F
838 /// CEC opcodes, as described in the HDMI CEC specification
840 public enum class CecOpcode
847 /// Image view on: power on display for image display
851 /// Text view on: power on display for text display
855 /// Device no longer is the active source
857 InactiveSource
= 0x9D,
859 /// Request which device has the active source status
861 RequestActiveSource
= 0x85,
863 /// Routing change for HDMI switches
865 RoutingChange
= 0x80,
867 /// Routing information for HDMI switches
869 RoutingInformation
= 0x81,
871 /// Change the stream path to the given physical address
873 SetStreamPath
= 0x86,
875 /// Inform that a device went into standby mode
887 /// Recording status information
891 /// Record current display
893 RecordTvScreen
= 0x0F,
895 /// Clear analogue timer
897 ClearAnalogueTimer
= 0x33,
899 /// Clear digital timer
901 ClearDigitalTimer
= 0x99,
903 /// Clear external timer
905 ClearExternalTimer
= 0xA1,
907 /// Set analogue timer
909 SetAnalogueTimer
= 0x34,
911 /// Set digital timer
913 SetDigitalTimer
= 0x97,
915 /// Set external timer
917 SetExternalTimer
= 0xA2,
919 /// Set program title of a timer
921 SetTimerProgramTitle
= 0x67,
923 /// Timer status cleared
925 TimerClearedStatus
= 0x43,
927 /// Timer status information
931 /// CEC version used by a device
935 /// Request CEC version of a device
937 GetCecVersion
= 0x9F,
939 /// Request physical address of a device
941 GivePhysicalAddress
= 0x83,
943 /// Request language code of the menu language of a device
944 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
946 GetMenuLanguage
= 0x91,
948 /// Report the physical address
950 ReportPhysicalAddress
= 0x84,
952 /// Report the language code of the menu language
953 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
955 SetMenuLanguage
= 0x32,
957 /// Deck control for playback and recording devices
961 /// Deck status for playback and recording devices
965 /// Request deck status from playback and recording devices
967 GiveDeckStatus
= 0x1A,
969 /// Start playback on playback and recording devices
973 /// Request tuner status
975 GiveTunerDeviceStatus
= 0x08,
977 /// Select analogue service on a tuner
979 SelectAnalogueService
= 0x92,
981 /// Select digital service on a tuner
983 SelectDigtalService
= 0x93,
985 /// Report tuner device status
987 TunerDeviceStatus
= 0x07,
989 /// Tuner step decrement
991 TunerStepDecrement
= 0x06,
993 /// Tuner step increment
995 TunerStepIncrement
= 0x05,
997 /// Report device vendor ID
999 DeviceVendorId
= 0x87,
1001 /// Request device vendor ID
1003 GiveDeviceVendorId
= 0x8C,
1005 /// Vendor specific command
1007 VendorCommand
= 0x89,
1009 /// Vendor specific command with vendor ID
1011 VendorCommandWithId
= 0xA0,
1013 /// Vendor specific remote button pressed
1015 VendorRemoteButtonDown
= 0x8A,
1017 /// Vendor specific remote button released
1019 VendorRemoteButtonUp
= 0x8B,
1021 /// Display / clear OSD string
1023 SetOsdString
= 0x64,
1025 /// Request device OSD name
1029 /// Report device OSD name
1033 /// Request device menu status
1037 /// Report device menu status
1041 /// Remote button pressed
1043 UserControlPressed
= 0x44,
1045 /// Remote button released
1047 UserControlRelease
= 0x45,
1049 /// Request device power status
1051 GiveDevicePowerStatus
= 0x8F,
1053 /// Report device power status
1055 ReportPowerStatus
= 0x90,
1057 /// Feature abort / unsupported command
1059 FeatureAbort
= 0x00,
1065 /// Give audio status
1067 GiveAudioStatus
= 0x71,
1069 /// Give audiosystem mode
1071 GiveSystemAudioMode
= 0x7D,
1073 /// Report device audio status
1075 ReportAudioStatus
= 0x7A,
1077 /// Set audiosystem mode
1079 SetSystemAudioMode
= 0x72,
1081 /// Request audiosystem mode
1083 SystemAudioModeRequest
= 0x70,
1085 /// Report audiosystem mode
1087 SystemAudioModeStatus
= 0x7E,
1089 /// Set audio bitrate
1091 SetAudioRate
= 0x9A,
1093 /// When this opcode is set, no opcode will be sent to the device / poll message
1094 /// This is one of the reserved numbers
1100 /// Audiosystem status
1102 public enum class CecSystemAudioStatus
1115 /// libCEC client application version
1117 public enum class CecClientVersion
1126 Version1_5_0
= 0x1500,
1130 Version1_5_1
= 0x1501,
1134 Version1_5_2
= 0x1502,
1138 Version1_5_3
= 0x1503,
1142 Version1_6_0
= 0x1600,
1146 Version1_6_1
= 0x1601,
1150 Version1_6_2
= 0x1602,
1154 Version1_6_3
= 0x1603,
1158 Version1_7_0
= 0x1700,
1162 Version1_7_1
= 0x1701,
1166 Version1_7_2
= 0x1702,
1170 Version1_8_0
= 0x1800,
1174 Version1_8_1
= 0x1801,
1178 Version1_8_2
= 0x1802,
1182 Version1_9_0
= 0x1900,
1186 Version1_99_0
= 0x1990,
1190 Version2_0_0
= 0x2000,
1194 Version2_0_1
= 0x2001,
1198 Version2_0_2
= 0x2002,
1202 Version2_0_3
= 0x2003,
1206 Version2_0_4
= 0x2004,
1210 Version2_0_5
= 0x2005,
1214 Version2_1_0
= 0x2100,
1218 Version2_1_1
= 0x2101
1224 public enum class CecServerVersion
1233 Version1_5_0
= 0x1500,
1237 Version1_5_1
= 0x1501,
1241 Version1_5_2
= 0x1502,
1245 Version1_5_3
= 0x1503,
1249 Version1_6_0
= 0x1600,
1253 Version1_6_1
= 0x1601,
1257 Version1_6_2
= 0x1602,
1261 Version1_6_3
= 0x1603,
1265 Version1_7_0
= 0x1700,
1269 Version1_7_1
= 0x1701,
1273 Version1_7_2
= 0x1702,
1277 Version1_8_0
= 0x1800,
1281 Version1_8_1
= 0x1801,
1285 Version1_8_2
= 0x1802,
1289 Version1_9_0
= 0x1900,
1293 Version1_99_0
= 0x1990,
1297 Version2_0_0
= 0x2000,
1301 Version2_0_1
= 0x2001,
1305 Version2_0_2
= 0x2002,
1309 Version2_0_3
= 0x2003,
1313 Version2_0_4
= 0x2004,
1317 Version2_0_5
= 0x2005,
1321 Version2_1_0
= 0x2100,
1325 Version2_1_1
= 0x2101
1329 /// Type of adapter to which libCEC is connected
1331 public enum class CecAdapterType
1334 /// Unknown adapter type
1338 /// Pulse-Eight USB-CEC adapter
1340 PulseEightExternal
= 0x1,
1342 /// Pulse-Eight CEC daughterboard
1344 PulseEightDaughterboard
= 0x2,
1348 RaspberryPi
= 0x100,
1356 /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system
1358 public ref
class CecAdapter
1362 /// Create a new CEC adapter descriptor
1364 /// <param name="path"> The path descriptor for this CEC adapter</param>
1365 /// <param name="comPort">The COM port of this CEC adapter</param>
1366 CecAdapter(System::String
^ path
, System::String
^ comPort
)
1373 /// The path descriptor for this CEC adapter
1375 property
System::String
^ Path
;
1378 /// The COM port of this CEC adapter
1380 property
System::String
^ ComPort
;
1384 /// A list of CEC device types
1386 public ref
class CecDeviceTypeList
1390 /// Create a new empty list of CEC device types
1392 CecDeviceTypeList(void)
1394 Types
= gcnew array
<CecDeviceType
>(5);
1395 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1396 Types
[iPtr
] = CecDeviceType::Reserved
;
1400 /// The array with CecDeviceType instances in this list.
1402 property array
<CecDeviceType
> ^ Types
;
1406 /// A list of logical addresses
1408 public ref
class CecLogicalAddresses
1412 /// Create a new empty list of logical addresses
1414 CecLogicalAddresses(void)
1416 Addresses
= gcnew array
<CecLogicalAddress
>(16);
1421 /// Clears this list
1425 Primary
= CecLogicalAddress::Unknown
;
1426 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
1427 Addresses
[iPtr
] = CecLogicalAddress::Unknown
;
1431 /// Checks whether a logical address is set in this list.
1433 /// <param name="address">The address to check.</param>
1434 /// <returns>True when set, false otherwise</returns>
1435 bool IsSet(CecLogicalAddress address
)
1437 return Addresses
[(unsigned int)address
] != CecLogicalAddress::Unknown
;
1441 /// Add a logical address to this list (if it's not set already)
1443 /// <param name="address">The address to add.</param>
1444 void Set(CecLogicalAddress address
)
1446 Addresses
[(unsigned int)address
] = address
;
1447 if (Primary
== CecLogicalAddress::Unknown
)
1452 /// The primary (first) address in this list
1454 property CecLogicalAddress Primary
;
1457 /// The list of addresses
1459 property array
<CecLogicalAddress
> ^ Addresses
;
1464 /// Byte array used for CEC command parameters
1466 public ref
class CecDatapacket
1470 /// Create a new byte array with maximum size 100
1474 Data
= gcnew array
<uint8_t>(100);
1479 /// Adds a byte to this byte array
1481 /// <param name="data">The byte to add.</param>
1482 void PushBack(uint8_t data
)
1494 property array
<uint8_t> ^ Data
;
1497 /// Current data size
1499 property
uint8_t Size
;
1503 /// A CEC command that is received or transmitted over the CEC bus
1505 public ref
class CecCommand
1509 /// Create a new CEC command instance
1511 /// <param name="initiator">The initiator of the command</param>
1512 /// <param name="destination">The receiver of the command</param>
1513 /// <param name="ack">True when the ack bit is set, false otherwise</param>
1514 /// <param name="eom">True when the eom bit is set, false otherwise</param>
1515 /// <param name="opcode">The CEC opcode of this command</param>
1516 /// <param name="transmitTimeout">The timeout to use when transmitting a command</param>
1517 CecCommand(CecLogicalAddress initiator
, CecLogicalAddress destination
, bool ack
, bool eom
, CecOpcode opcode
, int32_t transmitTimeout
)
1519 Initiator
= initiator
;
1520 Destination
= destination
;
1525 TransmitTimeout
= transmitTimeout
;
1526 Parameters
= gcnew CecDatapacket
;
1531 /// Create a new empty CEC command instance
1535 Initiator
= CecLogicalAddress::Unknown
;
1536 Destination
= CecLogicalAddress::Unknown
;
1539 Opcode
= CecOpcode::None
;
1541 TransmitTimeout
= 0;
1542 Parameters
= gcnew CecDatapacket
;
1547 /// Pushes a byte of data to this CEC command
1549 /// <param name="data">The byte to add</param>
1550 void PushBack(uint8_t data
)
1552 if (Initiator
== CecLogicalAddress::Unknown
&& Destination
== CecLogicalAddress::Unknown
)
1554 Initiator
= (CecLogicalAddress
) (data
>> 4);
1555 Destination
= (CecLogicalAddress
) (data
& 0xF);
1557 else if (!OpcodeSet
)
1560 Opcode
= (CecOpcode
)data
;
1564 Parameters
->PushBack(data
);
1569 /// True when this command is empty, false otherwise.
1571 property
bool Empty
;
1573 /// The initiator of the command
1575 property CecLogicalAddress Initiator
;
1577 /// The destination of the command
1579 property CecLogicalAddress Destination
;
1581 /// True when the ack bit is set, false otherwise
1585 /// True when the eom bit is set, false otherwise
1589 /// The CEC opcode of the command
1591 property CecOpcode Opcode
;
1593 /// The parameters of this command
1595 property CecDatapacket
^ Parameters
;
1597 /// True when an opcode is set, false otherwise (poll message)
1599 property
bool OpcodeSet
;
1601 /// The timeout to use when transmitting a command
1603 property
int32_t TransmitTimeout
;
1607 /// A key press that was received
1609 public ref
class CecKeypress
1613 /// Create a new key press instance
1615 /// <param name="keycode">The key code of this key press</param>
1616 /// <param name="duration">The duration of this key press in milliseconds</param>
1617 CecKeypress(CecUserControlCode keycode
, unsigned int duration
)
1620 Duration
= duration
;
1625 /// Create a new empty key press instance
1629 Keycode
= CecUserControlCode::Unknown
;
1635 /// True when empty, false otherwise
1637 property
bool Empty
;
1639 /// The key code of this key press
1641 property CecUserControlCode Keycode
;
1643 /// The duration of this key press in milliseconds
1645 property
unsigned int Duration
;
1649 /// A log message that libCEC generated
1651 public ref
class CecLogMessage
1655 /// Create a new log message
1657 /// <param name="message">The actual message</param>
1658 /// <param name="level">The log level, so the application can choose what type information to display</param>
1659 /// <param name="time">The timestamp of this message, in milliseconds after connecting</param>
1660 CecLogMessage(System::String
^ message
, CecLogLevel level
, int64_t time
)
1669 /// Create a new empty log message
1674 Level
= CecLogLevel::None
;
1680 /// True when empty, false otherwise.
1682 property
bool Empty
;
1684 /// The actual message
1686 property
System::String
^Message
;
1688 /// The log level, so the application can choose what type information to display
1690 property CecLogLevel Level
;
1692 /// The timestamp of this message, in milliseconds after connecting
1694 property
int64_t Time
;
1697 ref
class CecCallbackMethods
; //forward declaration
1700 /// The configuration that libCEC uses.
1702 public ref
class LibCECConfiguration
1706 /// Create a new configuration instance with default settings.
1708 LibCECConfiguration(void)
1711 DeviceTypes
= gcnew
CecDeviceTypeList();
1712 AutodetectAddress
= true;
1713 PhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
1714 BaseDevice
= (CecLogicalAddress
)CEC_DEFAULT_BASE_DEVICE
;
1715 HDMIPort
= CEC_DEFAULT_HDMI_PORT
;
1716 ClientVersion
= CecClientVersion::Version2_1_1
;
1717 ServerVersion
= CecServerVersion::Version2_1_1
;
1718 TvVendor
= CecVendorId::Unknown
;
1720 GetSettingsFromROM
= false;
1721 UseTVMenuLanguage
= CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE
== 1;
1722 ActivateSource
= CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1;
1724 WakeDevices
= gcnew
CecLogicalAddresses();
1725 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1)
1726 WakeDevices
->Set(CecLogicalAddress::Tv
);
1728 PowerOffDevices
= gcnew
CecLogicalAddresses();
1729 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN
== 1)
1730 PowerOffDevices
->Set(CecLogicalAddress::Broadcast
);
1732 PowerOffScreensaver
= CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER
== 1;
1733 PowerOffOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY
== 1;
1735 SendInactiveSource
= CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE
== 1;
1736 LogicalAddresses
= gcnew
CecLogicalAddresses();
1737 FirmwareVersion
= 1;
1738 PowerOffDevicesOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY
== 1;
1739 ShutdownOnStandby
= CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY
== 1;
1740 DeviceLanguage
= "";
1741 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1742 CECVersion
= (CecVersion
)CEC_DEFAULT_SETTING_CEC_VERSION
;
1743 AdapterType
= CecAdapterType::Unknown
;
1747 /// Change the callback method pointers in this configuration instance.
1749 /// <param name="callbacks">The new callbacks</param>
1750 void SetCallbacks(CecCallbackMethods
^callbacks
)
1752 Callbacks
= callbacks
;
1756 /// Update this configuration with data received from libCEC
1758 /// <param name="config">The configuration that was received from libCEC</param>
1759 void Update(const CEC::libcec_configuration
&config
)
1761 DeviceName
= gcnew
System::String(config
.strDeviceName
);
1763 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1764 DeviceTypes
->Types
[iPtr
] = (CecDeviceType
)config
.deviceTypes
.types
[iPtr
];
1766 AutodetectAddress
= config
.bAutodetectAddress
== 1;
1767 PhysicalAddress
= config
.iPhysicalAddress
;
1768 BaseDevice
= (CecLogicalAddress
)config
.baseDevice
;
1769 HDMIPort
= config
.iHDMIPort
;
1770 ClientVersion
= (CecClientVersion
)config
.clientVersion
;
1771 ServerVersion
= (CecServerVersion
)config
.serverVersion
;
1772 TvVendor
= (CecVendorId
)config
.tvVendor
;
1774 // player specific settings
1775 GetSettingsFromROM
= config
.bGetSettingsFromROM
== 1;
1776 UseTVMenuLanguage
= config
.bUseTVMenuLanguage
== 1;
1777 ActivateSource
= config
.bActivateSource
== 1;
1779 WakeDevices
->Clear();
1780 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1781 if (config
.wakeDevices
[iPtr
])
1782 WakeDevices
->Set((CecLogicalAddress
)iPtr
);
1784 PowerOffDevices
->Clear();
1785 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1786 if (config
.powerOffDevices
[iPtr
])
1787 PowerOffDevices
->Set((CecLogicalAddress
)iPtr
);
1789 PowerOffScreensaver
= config
.bPowerOffScreensaver
== 1;
1790 PowerOffOnStandby
= config
.bPowerOffOnStandby
== 1;
1792 if (ServerVersion
>= CecServerVersion::Version1_5_1
)
1793 SendInactiveSource
= config
.bSendInactiveSource
== 1;
1795 if (ServerVersion
>= CecServerVersion::Version1_5_3
)
1797 LogicalAddresses
->Clear();
1798 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1799 if (config
.logicalAddresses
[iPtr
])
1800 LogicalAddresses
->Set((CecLogicalAddress
)iPtr
);
1803 if (ServerVersion
>= CecServerVersion::Version1_6_0
)
1805 FirmwareVersion
= config
.iFirmwareVersion
;
1806 PowerOffDevicesOnStandby
= config
.bPowerOffDevicesOnStandby
== 1;
1807 ShutdownOnStandby
= config
.bShutdownOnStandby
== 1;
1810 if (ServerVersion
>= CecServerVersion::Version1_6_2
)
1812 DeviceLanguage
= gcnew
System::String(config
.strDeviceLanguage
);
1813 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1814 FirmwareBuildDate
= FirmwareBuildDate
->AddSeconds(config
.iFirmwareBuildDate
);
1817 if (ServerVersion
>= CecServerVersion::Version1_6_3
)
1818 MonitorOnlyClient
= config
.bMonitorOnly
== 1;
1820 if (ServerVersion
>= CecServerVersion::Version1_8_0
)
1821 CECVersion
= (CecVersion
)config
.cecVersion
;
1823 if (ServerVersion
>= CecServerVersion::Version1_8_2
)
1824 AdapterType
= (CecAdapterType
)config
.adapterType
;
1826 if (ServerVersion
>= CecServerVersion::Version2_1_0
)
1827 PowerOnScreensaver
= config
.bPowerOnScreensaver
== 1;
1831 /// The device name to use on the CEC bus
1833 property
System::String
^ DeviceName
;
1836 /// The device type(s) to use on the CEC bus for libCEC
1838 property CecDeviceTypeList
^ DeviceTypes
;
1841 /// (read only) set to true by libCEC when the physical address was autodetected
1843 property
bool AutodetectAddress
;
1846 /// The physical address of the CEC adapter
1848 property
uint16_t PhysicalAddress
;
1851 /// 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
1853 property CecLogicalAddress BaseDevice
;
1856 /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection
1858 property
uint8_t HDMIPort
;
1861 /// The client API version to use
1863 property CecClientVersion ClientVersion
;
1866 /// The version of libCEC
1868 property CecServerVersion ServerVersion
;
1871 /// Override the vendor ID of the TV. Leave this untouched to autodetect
1873 property CecVendorId TvVendor
;
1876 /// True to read the settings from the EEPROM, which possibly override the settings passed here
1878 property
bool GetSettingsFromROM
;
1881 /// Use the language setting of the TV in the client application. Must be implemented by the client application.
1882 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1884 property
bool UseTVMenuLanguage
;
1887 /// Make libCEC the active source when starting the client application
1889 property
bool ActivateSource
;
1892 /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter.
1894 property CecLogicalAddresses
^WakeDevices
;
1897 /// List of devices to power off when calling StandbyDevices() without any parameter.
1899 property CecLogicalAddresses
^PowerOffDevices
;
1902 /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application.
1904 property
bool PowerOffScreensaver
;
1907 /// Power off the PC when the TV powers off. Must be implemented by the client application.
1909 property
bool PowerOffOnStandby
;
1912 /// Send an inactive source message when exiting the client application.
1914 property
bool SendInactiveSource
;
1917 /// The list of logical addresses that libCEC is using
1919 property CecLogicalAddresses
^LogicalAddresses
;
1922 /// The firmware version of the adapter to which libCEC is connected
1924 property
uint16_t FirmwareVersion
;
1927 /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
1929 property
bool PowerOffDevicesOnStandby
;
1932 /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false
1934 property
bool ShutdownOnStandby
;
1937 /// True to start a monitor-only client, false to start a standard client.
1939 property
bool MonitorOnlyClient
;
1942 /// The language code of the menu language that libCEC reports to other devices.
1943 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1945 property
System::String
^ DeviceLanguage
;
1948 /// The callback methods to use.
1950 property CecCallbackMethods
^ Callbacks
;
1953 /// The build date of the firmware.
1955 property
System::DateTime
^ FirmwareBuildDate
;
1958 /// The CEC version that libCEC uses.
1960 property CecVersion CECVersion
;
1963 /// The type of adapter that libCEC is connected to.
1965 property CecAdapterType AdapterType
;
1968 /// True to power on when quitting the screensaver.
1970 property
bool PowerOnScreensaver
;
1973 // the callback methods are called by unmanaged code, so we need some delegates for this
1975 // unmanaged callback methods
1976 typedef int (__stdcall
*LOGCB
) (const CEC::cec_log_message
&message
);
1977 typedef int (__stdcall
*KEYCB
) (const CEC::cec_keypress
&key
);
1978 typedef int (__stdcall
*COMMANDCB
)(const CEC::cec_command
&command
);
1979 typedef int (__stdcall
*CONFIGCB
) (const CEC::libcec_configuration
&config
);
1980 typedef int (__stdcall
*ALERTCB
) (const CEC::libcec_alert
, const CEC::libcec_parameter
&data
);
1981 typedef int (__stdcall
*MENUCB
) (const CEC::cec_menu_state newVal
);
1982 typedef void (__stdcall
*ACTICB
) (const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
1985 /// libCEC callback methods. Unmanaged code.
1990 /// Log message callback
1994 /// Key press/release callback
1998 /// Raw CEC data callback
2000 COMMANDCB commandCB
;
2002 /// Updated configuration callback
2006 /// Alert message callback
2010 /// Menu status change callback
2014 /// Source (de)activated callback
2016 ACTICB sourceActivatedCB
;
2017 } UnmanagedCecCallbacks
;
2019 static PLATFORM::CMutex g_callbackMutex
;
2020 static std::vector
<UnmanagedCecCallbacks
> g_unmanagedCallbacks
;
2021 static CEC::ICECCallbacks g_cecCallbacks
;
2024 /// Called by libCEC to send back a log message to the application
2026 /// <param name="cbParam">Pointer to the callback struct</param>
2027 /// <param name="message">The log message</param>
2028 /// <return>1 when handled, 0 otherwise</return>
2029 int CecLogMessageCB(void *cbParam
, const CEC::cec_log_message message
)
2033 size_t iPtr
= (size_t)cbParam
;
2034 PLATFORM::CLockObject
lock(g_callbackMutex
);
2035 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2036 return g_unmanagedCallbacks
[iPtr
].logCB(message
);
2042 /// Called by libCEC to send back a key press or release to the application
2044 /// <param name="cbParam">Pointer to the callback struct</param>
2045 /// <param name="key">The key press command that libCEC received</param>
2046 /// <return>1 when handled, 0 otherwise</return>
2047 int CecKeyPressCB(void *cbParam
, const CEC::cec_keypress key
)
2051 size_t iPtr
= (size_t)cbParam
;
2052 PLATFORM::CLockObject
lock(g_callbackMutex
);
2053 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2054 return g_unmanagedCallbacks
[iPtr
].keyCB(key
);
2060 /// Called by libCEC to send back raw CEC data to the application
2062 /// <param name="cbParam">Pointer to the callback struct</param>
2063 /// <param name="command">The raw CEC data</param>
2064 /// <return>1 when handled, 0 otherwise</return>
2065 int CecCommandCB(void *cbParam
, const CEC::cec_command command
)
2069 size_t iPtr
= (size_t)cbParam
;
2070 PLATFORM::CLockObject
lock(g_callbackMutex
);
2071 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2072 return g_unmanagedCallbacks
[iPtr
].commandCB(command
);
2078 /// Called by libCEC to send back an updated configuration to the application
2080 /// <param name="cbParam">Pointer to the callback struct</param>
2081 /// <param name="config">The new configuration</param>
2082 /// <return>1 when handled, 0 otherwise</return>
2083 int CecConfigCB(void *cbParam
, const CEC::libcec_configuration config
)
2087 size_t iPtr
= (size_t)cbParam
;
2088 PLATFORM::CLockObject
lock(g_callbackMutex
);
2089 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2090 return g_unmanagedCallbacks
[iPtr
].configCB(config
);
2096 /// Called by libCEC to send back an alert message to the application
2098 /// <param name="cbParam">Pointer to the callback struct</param>
2099 /// <param name="data">The alert message</param>
2100 /// <return>1 when handled, 0 otherwise</return>
2101 int CecAlertCB(void *cbParam
, const CEC::libcec_alert alert
, const CEC::libcec_parameter data
)
2105 size_t iPtr
= (size_t)cbParam
;
2106 PLATFORM::CLockObject
lock(g_callbackMutex
);
2107 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2108 return g_unmanagedCallbacks
[iPtr
].alertCB(alert
, data
);
2114 /// Called by libCEC to send back a menu state change to the application
2116 /// <param name="cbParam">Pointer to the callback struct</param>
2117 /// <param name="newVal">The new menu state</param>
2118 /// <return>1 when handled, 0 otherwise</return>
2119 int CecMenuCB(void *cbParam
, const CEC::cec_menu_state newVal
)
2123 size_t iPtr
= (size_t)cbParam
;
2124 PLATFORM::CLockObject
lock(g_callbackMutex
);
2125 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2126 return g_unmanagedCallbacks
[iPtr
].menuCB(newVal
);
2132 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated
2134 /// <param name="cbParam">Pointer to the callback struct</param>
2135 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2136 /// <param name="activated">True when activated, false when deactivated</param>
2137 void CecSourceActivatedCB(void *cbParam
, const CEC::cec_logical_address logicalAddress
, const uint8_t activated
)
2141 size_t iPtr
= (size_t)cbParam
;
2142 PLATFORM::CLockObject
lock(g_callbackMutex
);
2143 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2144 g_unmanagedCallbacks
[iPtr
].sourceActivatedCB(logicalAddress
, activated
);
2150 /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods
2152 public delegate
int CecLogMessageManagedDelegate(const CEC::cec_log_message
&);
2154 /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods
2156 public delegate
int CecKeyPressManagedDelegate(const CEC::cec_keypress
&);
2158 /// Delegate method for the CecCommandCB callback in CecCallbackMethods
2160 public delegate
int CecCommandManagedDelegate(const CEC::cec_command
&);
2162 /// Delegate method for the CecConfigCB callback in CecCallbackMethods
2164 public delegate
int CecConfigManagedDelegate(const CEC::libcec_configuration
&);
2166 /// Delegate method for the CecAlertCB callback in CecCallbackMethods
2168 public delegate
int CecAlertManagedDelegate(const CEC::libcec_alert
, const CEC::libcec_parameter
&);
2170 /// Delegate method for the CecMenuCB callback in CecCallbackMethods
2172 public delegate
int CecMenuManagedDelegate(const CEC::cec_menu_state
);
2174 /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods
2176 public delegate
void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address
, const uint8_t);
2179 /// Assign the callback methods in the g_cecCallbacks struct
2181 void AssignCallbacks()
2183 g_cecCallbacks
.CBCecLogMessage
= CecLogMessageCB
;
2184 g_cecCallbacks
.CBCecKeyPress
= CecKeyPressCB
;
2185 g_cecCallbacks
.CBCecCommand
= CecCommandCB
;
2186 g_cecCallbacks
.CBCecConfigurationChanged
= CecConfigCB
;
2187 g_cecCallbacks
.CBCecAlert
= CecAlertCB
;
2188 g_cecCallbacks
.CBCecMenuStateChanged
= CecMenuCB
;
2189 g_cecCallbacks
.CBCecSourceActivated
= CecSourceActivatedCB
;
2193 /// The callback methods that libCEC uses
2195 public ref
class CecCallbackMethods
2198 CecCallbackMethods(void)
2200 m_iCallbackPtr
= -1;
2202 m_bHasCallbacks
= false;
2203 m_bDelegatesCreated
= false;
2206 ~CecCallbackMethods(void)
2212 /// Pointer to the callbacks struct entry
2214 size_t GetCallbackPtr(void)
2216 PLATFORM::CLockObject
lock(g_callbackMutex
);
2217 return m_iCallbackPtr
;
2221 !CecCallbackMethods(void)
2228 /// Disable callback methods
2230 virtual void DisableCallbacks(void)
2236 /// Enable callback methods
2238 /// <param name="callbacks">Callback methods to activate</param>
2239 /// <return>true when handled, false otherwise</return>
2240 virtual bool EnableCallbacks(CecCallbackMethods
^ callbacks
)
2243 if (!m_bHasCallbacks
)
2245 m_bHasCallbacks
= true;
2246 m_callbacks
= callbacks
;
2254 /// Called by libCEC to send back a log message to the application.
2255 /// Override in the application to handle this callback.
2257 /// <param name="message">The log message</param>
2258 /// <return>1 when handled, 0 otherwise</return>
2259 virtual int ReceiveLogMessage(CecLogMessage
^ message
)
2265 /// Called by libCEC to send back a key press or release to the application.
2266 /// Override in the application to handle this callback.
2268 /// <param name="key">The key press command that libCEC received</param>
2269 /// <return>1 when handled, 0 otherwise</return>
2270 virtual int ReceiveKeypress(CecKeypress
^ key
)
2276 /// Called by libCEC to send back raw CEC data to the application.
2277 /// Override in the application to handle this callback.
2279 /// <param name="command">The raw CEC data</param>
2280 /// <return>1 when handled, 0 otherwise</return>
2281 virtual int ReceiveCommand(CecCommand
^ command
)
2287 /// Called by libCEC to send back an updated configuration to the application.
2288 /// Override in the application to handle this callback.
2290 /// <param name="config">The new configuration</param>
2291 /// <return>1 when handled, 0 otherwise</return>
2292 virtual int ConfigurationChanged(LibCECConfiguration
^ config
)
2298 /// Called by libCEC to send back an alert message to the application.
2299 /// Override in the application to handle this callback.
2301 /// <param name="data">The alert message</param>
2302 /// <return>1 when handled, 0 otherwise</return>
2303 virtual int ReceiveAlert(CecAlert alert
, CecParameter
^ data
)
2309 /// Called by libCEC to send back a menu state change to the application.
2310 /// Override in the application to handle this callback.
2312 /// <param name="newVal">The new menu state</param>
2313 /// <return>1 when handled, 0 otherwise</return>
2314 virtual int ReceiveMenuStateChange(CecMenuState newVal
)
2320 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated.
2321 /// Override in the application to handle this callback.
2323 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2324 /// <param name="activated">True when activated, false when deactivated</param>
2325 virtual void SourceActivated(CecLogicalAddress logicalAddress
, bool activated
)
2330 // managed callback methods
2331 int CecLogMessageManaged(const CEC::cec_log_message
&message
)
2334 if (m_bHasCallbacks
)
2335 iReturn
= m_callbacks
->ReceiveLogMessage(gcnew
CecLogMessage(gcnew
System::String(message
.message
), (CecLogLevel
)message
.level
, message
.time
));
2339 int CecKeyPressManaged(const CEC::cec_keypress
&key
)
2342 if (m_bHasCallbacks
)
2343 iReturn
= m_callbacks
->ReceiveKeypress(gcnew
CecKeypress((CecUserControlCode
)key
.keycode
, key
.duration
));
2347 int CecCommandManaged(const CEC::cec_command
&command
)
2350 if (m_bHasCallbacks
)
2352 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
);
2353 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
2354 newCommand
->Parameters
->PushBack(command
.parameters
[iPtr
]);
2355 iReturn
= m_callbacks
->ReceiveCommand(newCommand
);
2360 int CecConfigManaged(const CEC::libcec_configuration
&config
)
2363 if (m_bHasCallbacks
)
2365 LibCECConfiguration
^netConfig
= gcnew
LibCECConfiguration();
2366 netConfig
->Update(config
);
2367 iReturn
= m_callbacks
->ConfigurationChanged(netConfig
);
2372 int CecAlertManaged(const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
2375 if (m_bHasCallbacks
)
2377 CecParameterType newType
= (CecParameterType
)data
.paramType
;
2378 if (newType
== CecParameterType::ParameterTypeString
)
2380 System::String
^ newData
= gcnew
System::String((const char *)data
.paramData
, 0, 128);
2381 CecParameter
^ newParam
= gcnew
CecParameter(newType
, newData
);
2382 iReturn
= m_callbacks
->ReceiveAlert((CecAlert
)alert
, newParam
);
2388 int CecMenuManaged(const CEC::cec_menu_state newVal
)
2391 if (m_bHasCallbacks
)
2393 iReturn
= m_callbacks
->ReceiveMenuStateChange((CecMenuState
)newVal
);
2398 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
2400 if (m_bHasCallbacks
)
2401 m_callbacks
->SourceActivated((CecLogicalAddress
)logicalAddress
, bActivated
== 1);
2404 void DestroyDelegates()
2406 m_bHasCallbacks
= false;
2407 if (m_bDelegatesCreated
)
2409 m_bDelegatesCreated
= false;
2410 m_logMessageGCHandle
.Free();
2411 m_keypressGCHandle
.Free();
2412 m_commandGCHandle
.Free();
2413 m_alertGCHandle
.Free();
2414 m_menuGCHandle
.Free();
2415 m_sourceActivatedGCHandle
.Free();
2419 void CreateDelegates()
2423 if (!m_bDelegatesCreated
)
2425 msclr::interop::marshal_context
^ context
= gcnew
msclr::interop::marshal_context();
2427 // create the delegate method for the log message callback
2428 m_logMessageDelegate
= gcnew
CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged
);
2429 m_logMessageGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate
);
2430 m_logMessageCallback
= static_cast<LOGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate
).ToPointer());
2432 // create the delegate method for the keypress callback
2433 m_keypressDelegate
= gcnew
CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged
);
2434 m_keypressGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate
);
2435 m_keypressCallback
= static_cast<KEYCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate
).ToPointer());
2437 // create the delegate method for the command callback
2438 m_commandDelegate
= gcnew
CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged
);
2439 m_commandGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate
);
2440 m_commandCallback
= static_cast<COMMANDCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate
).ToPointer());
2442 // create the delegate method for the configuration change callback
2443 m_configDelegate
= gcnew
CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged
);
2444 m_configGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate
);
2445 m_configCallback
= static_cast<CONFIGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate
).ToPointer());
2447 // create the delegate method for the alert callback
2448 m_alertDelegate
= gcnew
CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged
);
2449 m_alertGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate
);
2450 m_alertCallback
= static_cast<ALERTCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate
).ToPointer());
2452 // create the delegate method for the menu callback
2453 m_menuDelegate
= gcnew
CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged
);
2454 m_menuGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate
);
2455 m_menuCallback
= static_cast<MENUCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate
).ToPointer());
2457 // create the delegate method for the source activated callback
2458 m_sourceActivatedDelegate
= gcnew
CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged
);
2459 m_sourceActivatedGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate
);
2460 m_sourceActivatedCallback
= static_cast<ACTICB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate
).ToPointer());
2464 UnmanagedCecCallbacks unmanagedCallbacks
;
2465 unmanagedCallbacks
.logCB
= m_logMessageCallback
;
2466 unmanagedCallbacks
.keyCB
= m_keypressCallback
;
2467 unmanagedCallbacks
.commandCB
= m_commandCallback
;
2468 unmanagedCallbacks
.configCB
= m_configCallback
;
2469 unmanagedCallbacks
.alertCB
= m_alertCallback
;
2470 unmanagedCallbacks
.menuCB
= m_menuCallback
;
2471 unmanagedCallbacks
.sourceActivatedCB
= m_sourceActivatedCallback
;
2473 PLATFORM::CLockObject
lock(g_callbackMutex
);
2474 g_unmanagedCallbacks
.push_back(unmanagedCallbacks
);
2475 m_iCallbackPtr
= g_unmanagedCallbacks
.size() - 1;
2476 m_bDelegatesCreated
= true;
2480 CecLogMessageManagedDelegate
^ m_logMessageDelegate
;
2481 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle
;
2482 LOGCB m_logMessageCallback
;
2484 CecKeyPressManagedDelegate
^ m_keypressDelegate
;
2485 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle
;
2486 KEYCB m_keypressCallback
;
2488 CecCommandManagedDelegate
^ m_commandDelegate
;
2489 static System::Runtime::InteropServices::GCHandle m_commandGCHandle
;
2490 COMMANDCB m_commandCallback
;
2492 CecConfigManagedDelegate
^ m_configDelegate
;
2493 static System::Runtime::InteropServices::GCHandle m_configGCHandle
;
2494 CONFIGCB m_configCallback
;
2496 CecAlertManagedDelegate
^ m_alertDelegate
;
2497 static System::Runtime::InteropServices::GCHandle m_alertGCHandle
;
2498 ALERTCB m_alertCallback
;
2500 CecMenuManagedDelegate
^ m_menuDelegate
;
2501 static System::Runtime::InteropServices::GCHandle m_menuGCHandle
;
2502 MENUCB m_menuCallback
;
2504 CecSourceActivatedManagedDelegate
^ m_sourceActivatedDelegate
;
2505 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle
;
2506 ACTICB m_sourceActivatedCallback
;
2508 CecCallbackMethods
^ m_callbacks
;
2509 bool m_bHasCallbacks
;
2510 bool m_bDelegatesCreated
;
2511 size_t m_iCallbackPtr
;