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/
207 /// The type of parameter that is sent with the CecAlert callback
209 public enum class CecParameterType
212 /// The parameter is a string
214 ParameterTypeString
= 1
218 /// A parameter for the CecAlert callback
220 public ref
class CecParameter
224 /// Create a new parameter
226 /// <param name="type">The type of this parameter.</param>
227 /// <param name="data">The value of this parameter.</param>
228 CecParameter(CecParameterType type
, System::String
^ data
)
235 /// The type of this parameter
237 property CecParameterType Type
;
239 /// The value of this parameter
241 property
System::String
^ Data
;
245 /// The power status of a CEC device
247 public enum class CecPowerStatus
258 /// In transition from standby to on
260 InTransitionStandbyToOn
= 0x02,
262 /// In transition from on to standby
264 InTransitionOnToStandby
= 0x03,
272 /// The CEC version of a CEC device
274 public enum class CecVersion
303 /// Parameter for OSD string display, that controls how to display the string
305 public enum class CecDisplayControl
308 /// Display for the default time
310 DisplayForDefaultTime
= 0x00,
312 /// Display until it is cleared by ClearPreviousMessage
314 DisplayUntilCleared
= 0x40,
316 /// Clear message displayed by DisplayUntilCleared
318 ClearPreviousMessage
= 0x80,
320 /// Reserved / do not use
322 ReservedForFutureUse
= 0xC0
326 /// The menu state of a CEC device
328 public enum class CecMenuState
341 /// Deck control mode for playback and recording devices
343 public enum class CecDeckControlMode
346 /// Skip forward / wind
350 /// Skip reverse / rewind
352 SkipReverseRewind
= 2,
364 /// Deck status for playback and recording devices
366 public enum class CecDeckInfo
381 /// Showing still frame
389 /// Playing slow reverse
401 /// No media detected
405 /// Stop / not playing
409 /// Skip forward / wind
411 SkipForwardWind
= 0x1B,
413 /// Skip reverse / rewind
415 SkipReverseRewind
= 0x1C,
417 /// Index search forward
419 IndexSearchForward
= 0x1D,
421 /// Index search reverse
423 IndexSearchReverse
= 0x1E,
425 /// Other / unknown status
431 /// User control code, the key code when the user presses or releases a button on the remote.
432 /// Used by SendKeypress() and the CecKey callback.
434 public enum class CecUserControlCode
457 /// Direction right + up
461 /// Direction right + down
465 /// Direction left + up
469 /// Direction left + down
559 PreviousChannel
= 0x32,
561 /// Select sound track
569 /// Display information
571 DisplayInformation
= 0x35,
585 /// Toggle powered on / standby
649 /// Toggle sub picture
653 /// Toggle video on demand
655 VideoOnDemand
= 0x52,
657 /// Toggle electronic program guide (EPG)
659 ElectronicProgramGuide
= 0x53,
661 /// Toggle timer programming
663 TimerProgramming
= 0x54,
665 /// Set initial configuration
667 InitialConfiguration
= 0x55,
669 /// Start playback function
673 /// Pause playback function
675 PausePlayFunction
= 0x61,
677 /// Toggle recording function
679 RecordFunction
= 0x62,
681 /// Pause recording function
683 PauseRecordFunction
= 0x63,
685 /// Stop playback function
689 /// Mute audio function
693 /// Restore volume function
695 RestoreVolumeFunction
= 0x66,
701 /// Select media function
703 SelectMediaFunction
= 0x68,
705 /// Select AV input function
707 SelectAVInputFunction
= 0x69,
709 /// Select audio input function
711 SelectAudioInputFunction
= 0x6A,
713 /// Toggle powered on / standby function
715 PowerToggleFunction
= 0x6B,
717 /// Power off function
719 PowerOffFunction
= 0x6C,
721 /// Power on function
723 PowerOnFunction
= 0x6D,
733 /// F3 / green button
737 /// F4 / yellow button
749 /// Max. valid key code for standard buttons
753 /// Extra return button on Samsung remotes
755 SamsungReturn
= 0x91,
757 /// Unknown / invalid key code
763 /// Vendor IDs for CEC devices
765 public enum class CecVendorId
775 Panasonic
= 0x008045,
791 /// Audio status of audio system / AVR devices
793 public enum class CecAudioStatus
798 MuteStatusMask
= 0x80,
800 /// Not muted, volume status mask
802 VolumeStatusMask
= 0x7F,
814 VolumeStatusUnknown
= 0x7F
818 /// CEC opcodes, as described in the HDMI CEC specification
820 public enum class CecOpcode
827 /// Image view on: power on display for image display
831 /// Text view on: power on display for text display
835 /// Device no longer is the active source
837 InactiveSource
= 0x9D,
839 /// Request which device has the active source status
841 RequestActiveSource
= 0x85,
843 /// Routing change for HDMI switches
845 RoutingChange
= 0x80,
847 /// Routing information for HDMI switches
849 RoutingInformation
= 0x81,
851 /// Change the stream path to the given physical address
853 SetStreamPath
= 0x86,
855 /// Inform that a device went into standby mode
867 /// Recording status information
871 /// Record current display
873 RecordTvScreen
= 0x0F,
875 /// Clear analogue timer
877 ClearAnalogueTimer
= 0x33,
879 /// Clear digital timer
881 ClearDigitalTimer
= 0x99,
883 /// Clear external timer
885 ClearExternalTimer
= 0xA1,
887 /// Set analogue timer
889 SetAnalogueTimer
= 0x34,
891 /// Set digital timer
893 SetDigitalTimer
= 0x97,
895 /// Set external timer
897 SetExternalTimer
= 0xA2,
899 /// Set program title of a timer
901 SetTimerProgramTitle
= 0x67,
903 /// Timer status cleared
905 TimerClearedStatus
= 0x43,
907 /// Timer status information
911 /// CEC version used by a device
915 /// Request CEC version of a device
917 GetCecVersion
= 0x9F,
919 /// Request physical address of a device
921 GivePhysicalAddress
= 0x83,
923 /// Request language code of the menu language of a device
924 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
926 GetMenuLanguage
= 0x91,
928 /// Report the physical address
930 ReportPhysicalAddress
= 0x84,
932 /// Report the language code of the menu language
933 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
935 SetMenuLanguage
= 0x32,
937 /// Deck control for playback and recording devices
941 /// Deck status for playback and recording devices
945 /// Request deck status from playback and recording devices
947 GiveDeckStatus
= 0x1A,
949 /// Start playback on playback and recording devices
953 /// Request tuner status
955 GiveTunerDeviceStatus
= 0x08,
957 /// Select analogue service on a tuner
959 SelectAnalogueService
= 0x92,
961 /// Select digital service on a tuner
963 SelectDigtalService
= 0x93,
965 /// Report tuner device status
967 TunerDeviceStatus
= 0x07,
969 /// Tuner step decrement
971 TunerStepDecrement
= 0x06,
973 /// Tuner step increment
975 TunerStepIncrement
= 0x05,
977 /// Report device vendor ID
979 DeviceVendorId
= 0x87,
981 /// Request device vendor ID
983 GiveDeviceVendorId
= 0x8C,
985 /// Vendor specific command
987 VendorCommand
= 0x89,
989 /// Vendor specific command with vendor ID
991 VendorCommandWithId
= 0xA0,
993 /// Vendor specific remote button pressed
995 VendorRemoteButtonDown
= 0x8A,
997 /// Vendor specific remote button released
999 VendorRemoteButtonUp
= 0x8B,
1001 /// Display / clear OSD string
1003 SetOsdString
= 0x64,
1005 /// Request device OSD name
1009 /// Report device OSD name
1013 /// Request device menu status
1017 /// Report device menu status
1021 /// Remote button pressed
1023 UserControlPressed
= 0x44,
1025 /// Remote button released
1027 UserControlRelease
= 0x45,
1029 /// Request device power status
1031 GiveDevicePowerStatus
= 0x8F,
1033 /// Report device power status
1035 ReportPowerStatus
= 0x90,
1037 /// Feature abort / unsupported command
1039 FeatureAbort
= 0x00,
1045 /// Give audio status
1047 GiveAudioStatus
= 0x71,
1049 /// Give audiosystem mode
1051 GiveSystemAudioMode
= 0x7D,
1053 /// Report device audio status
1055 ReportAudioStatus
= 0x7A,
1057 /// Set audiosystem mode
1059 SetSystemAudioMode
= 0x72,
1061 /// Request audiosystem mode
1063 SystemAudioModeRequest
= 0x70,
1065 /// Report audiosystem mode
1067 SystemAudioModeStatus
= 0x7E,
1069 /// Set audio bitrate
1071 SetAudioRate
= 0x9A,
1073 /// When this opcode is set, no opcode will be sent to the device / poll message
1074 /// This is one of the reserved numbers
1080 /// Audiosystem status
1082 public enum class CecSystemAudioStatus
1095 /// libCEC client application version
1097 public enum class CecClientVersion
1106 Version1_5_0
= 0x1500,
1110 Version1_5_1
= 0x1501,
1114 Version1_5_2
= 0x1502,
1118 Version1_5_3
= 0x1503,
1122 Version1_6_0
= 0x1600,
1126 Version1_6_1
= 0x1601,
1130 Version1_6_2
= 0x1602,
1134 Version1_6_3
= 0x1603,
1138 Version1_7_0
= 0x1700,
1142 Version1_7_1
= 0x1701,
1146 Version1_7_2
= 0x1702,
1150 Version1_8_0
= 0x1800,
1154 Version1_8_1
= 0x1801,
1158 Version1_8_2
= 0x1802,
1162 Version1_9_0
= 0x1900,
1166 Version1_99_0
= 0x1990,
1170 Version2_0_0
= 0x2000,
1174 Version2_0_1
= 0x2001,
1178 Version2_0_2
= 0x2002,
1182 Version2_0_3
= 0x2003,
1186 Version2_0_4
= 0x2004,
1190 Version2_0_5
= 0x2005,
1194 Version2_1_0
= 0x2100,
1198 Version2_1_1
= 0x2101
1204 public enum class CecServerVersion
1213 Version1_5_0
= 0x1500,
1217 Version1_5_1
= 0x1501,
1221 Version1_5_2
= 0x1502,
1225 Version1_5_3
= 0x1503,
1229 Version1_6_0
= 0x1600,
1233 Version1_6_1
= 0x1601,
1237 Version1_6_2
= 0x1602,
1241 Version1_6_3
= 0x1603,
1245 Version1_7_0
= 0x1700,
1249 Version1_7_1
= 0x1701,
1253 Version1_7_2
= 0x1702,
1257 Version1_8_0
= 0x1800,
1261 Version1_8_1
= 0x1801,
1265 Version1_8_2
= 0x1802,
1269 Version1_9_0
= 0x1900,
1273 Version1_99_0
= 0x1990,
1277 Version2_0_0
= 0x2000,
1281 Version2_0_1
= 0x2001,
1285 Version2_0_2
= 0x2002,
1289 Version2_0_3
= 0x2003,
1293 Version2_0_4
= 0x2004,
1297 Version2_0_5
= 0x2005,
1301 Version2_1_0
= 0x2100,
1305 Version2_1_1
= 0x2101
1309 /// Type of adapter to which libCEC is connected
1311 public enum class CecAdapterType
1314 /// Unknown adapter type
1318 /// Pulse-Eight USB-CEC adapter
1320 PulseEightExternal
= 0x1,
1322 /// Pulse-Eight CEC daughterboard
1324 PulseEightDaughterboard
= 0x2,
1328 RaspberryPi
= 0x100,
1336 /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system
1338 public ref
class CecAdapter
1342 /// Create a new CEC adapter descriptor
1344 /// <param name="path"> The path descriptor for this CEC adapter</param>
1345 /// <param name="comPort">The COM port of this CEC adapter</param>
1346 CecAdapter(System::String
^ path
, System::String
^ comPort
)
1353 /// The path descriptor for this CEC adapter
1355 property
System::String
^ Path
;
1358 /// The COM port of this CEC adapter
1360 property
System::String
^ ComPort
;
1364 /// A list of CEC device types
1366 public ref
class CecDeviceTypeList
1370 /// Create a new empty list of CEC device types
1372 CecDeviceTypeList(void)
1374 Types
= gcnew array
<CecDeviceType
>(5);
1375 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1376 Types
[iPtr
] = CecDeviceType::Reserved
;
1380 /// The array with CecDeviceType instances in this list.
1382 property array
<CecDeviceType
> ^ Types
;
1386 /// A list of logical addresses
1388 public ref
class CecLogicalAddresses
1392 /// Create a new empty list of logical addresses
1394 CecLogicalAddresses(void)
1396 Addresses
= gcnew array
<CecLogicalAddress
>(16);
1401 /// Clears this list
1405 Primary
= CecLogicalAddress::Unknown
;
1406 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
1407 Addresses
[iPtr
] = CecLogicalAddress::Unknown
;
1411 /// Checks whether a logical address is set in this list.
1413 /// <param name="address">The address to check.</param>
1414 /// <returns>True when set, false otherwise</returns>
1415 bool IsSet(CecLogicalAddress address
)
1417 return Addresses
[(unsigned int)address
] != CecLogicalAddress::Unknown
;
1421 /// Add a logical address to this list (if it's not set already)
1423 /// <param name="address">The address to add.</param>
1424 void Set(CecLogicalAddress address
)
1426 Addresses
[(unsigned int)address
] = address
;
1427 if (Primary
== CecLogicalAddress::Unknown
)
1432 /// The primary (first) address in this list
1434 property CecLogicalAddress Primary
;
1437 /// The list of addresses
1439 property array
<CecLogicalAddress
> ^ Addresses
;
1444 /// Byte array used for CEC command parameters
1446 public ref
class CecDatapacket
1450 /// Create a new byte array with maximum size 100
1454 Data
= gcnew array
<uint8_t>(100);
1459 /// Adds a byte to this byte array
1461 /// <param name="data">The byte to add.</param>
1462 void PushBack(uint8_t data
)
1474 property array
<uint8_t> ^ Data
;
1477 /// Current data size
1479 property
uint8_t Size
;
1483 /// A CEC command that is received or transmitted over the CEC bus
1485 public ref
class CecCommand
1489 /// Create a new CEC command instance
1491 /// <param name="initiator">The initiator of the command</param>
1492 /// <param name="destination">The receiver of the command</param>
1493 /// <param name="ack">True when the ack bit is set, false otherwise</param>
1494 /// <param name="eom">True when the eom bit is set, false otherwise</param>
1495 /// <param name="opcode">The CEC opcode of this command</param>
1496 /// <param name="transmitTimeout">The timeout to use when transmitting a command</param>
1497 CecCommand(CecLogicalAddress initiator
, CecLogicalAddress destination
, bool ack
, bool eom
, CecOpcode opcode
, int32_t transmitTimeout
)
1499 Initiator
= initiator
;
1500 Destination
= destination
;
1505 TransmitTimeout
= transmitTimeout
;
1506 Parameters
= gcnew CecDatapacket
;
1511 /// Create a new empty CEC command instance
1515 Initiator
= CecLogicalAddress::Unknown
;
1516 Destination
= CecLogicalAddress::Unknown
;
1519 Opcode
= CecOpcode::None
;
1521 TransmitTimeout
= 0;
1522 Parameters
= gcnew CecDatapacket
;
1527 /// Pushes a byte of data to this CEC command
1529 /// <param name="data">The byte to add</param>
1530 void PushBack(uint8_t data
)
1532 if (Initiator
== CecLogicalAddress::Unknown
&& Destination
== CecLogicalAddress::Unknown
)
1534 Initiator
= (CecLogicalAddress
) (data
>> 4);
1535 Destination
= (CecLogicalAddress
) (data
& 0xF);
1537 else if (!OpcodeSet
)
1540 Opcode
= (CecOpcode
)data
;
1544 Parameters
->PushBack(data
);
1549 /// True when this command is empty, false otherwise.
1551 property
bool Empty
;
1553 /// The initiator of the command
1555 property CecLogicalAddress Initiator
;
1557 /// The destination of the command
1559 property CecLogicalAddress Destination
;
1561 /// True when the ack bit is set, false otherwise
1565 /// True when the eom bit is set, false otherwise
1569 /// The CEC opcode of the command
1571 property CecOpcode Opcode
;
1573 /// The parameters of this command
1575 property CecDatapacket
^ Parameters
;
1577 /// True when an opcode is set, false otherwise (poll message)
1579 property
bool OpcodeSet
;
1581 /// The timeout to use when transmitting a command
1583 property
int32_t TransmitTimeout
;
1587 /// A key press that was received
1589 public ref
class CecKeypress
1593 /// Create a new key press instance
1595 /// <param name="keycode">The key code of this key press</param>
1596 /// <param name="duration">The duration of this key press in milliseconds</param>
1597 CecKeypress(CecUserControlCode keycode
, unsigned int duration
)
1600 Duration
= duration
;
1605 /// Create a new empty key press instance
1609 Keycode
= CecUserControlCode::Unknown
;
1615 /// True when empty, false otherwise
1617 property
bool Empty
;
1619 /// The key code of this key press
1621 property CecUserControlCode Keycode
;
1623 /// The duration of this key press in milliseconds
1625 property
unsigned int Duration
;
1629 /// A log message that libCEC generated
1631 public ref
class CecLogMessage
1635 /// Create a new log message
1637 /// <param name="message">The actual message</param>
1638 /// <param name="level">The log level, so the application can choose what type information to display</param>
1639 /// <param name="time">The timestamp of this message, in milliseconds after connecting</param>
1640 CecLogMessage(System::String
^ message
, CecLogLevel level
, int64_t time
)
1649 /// Create a new empty log message
1654 Level
= CecLogLevel::None
;
1660 /// True when empty, false otherwise.
1662 property
bool Empty
;
1664 /// The actual message
1666 property
System::String
^Message
;
1668 /// The log level, so the application can choose what type information to display
1670 property CecLogLevel Level
;
1672 /// The timestamp of this message, in milliseconds after connecting
1674 property
int64_t Time
;
1677 ref
class CecCallbackMethods
; //forward declaration
1680 /// The configuration that libCEC uses.
1682 public ref
class LibCECConfiguration
1686 /// Create a new configuration instance with default settings.
1688 LibCECConfiguration(void)
1691 DeviceTypes
= gcnew
CecDeviceTypeList();
1692 AutodetectAddress
= true;
1693 PhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
1694 BaseDevice
= (CecLogicalAddress
)CEC_DEFAULT_BASE_DEVICE
;
1695 HDMIPort
= CEC_DEFAULT_HDMI_PORT
;
1696 ClientVersion
= CecClientVersion::Version2_1_1
;
1697 ServerVersion
= CecServerVersion::Version2_1_1
;
1698 TvVendor
= CecVendorId::Unknown
;
1700 GetSettingsFromROM
= false;
1701 UseTVMenuLanguage
= CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE
== 1;
1702 ActivateSource
= CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1;
1704 WakeDevices
= gcnew
CecLogicalAddresses();
1705 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1)
1706 WakeDevices
->Set(CecLogicalAddress::Tv
);
1708 PowerOffDevices
= gcnew
CecLogicalAddresses();
1709 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN
== 1)
1710 PowerOffDevices
->Set(CecLogicalAddress::Broadcast
);
1712 PowerOffScreensaver
= CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER
== 1;
1713 PowerOffOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY
== 1;
1715 SendInactiveSource
= CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE
== 1;
1716 LogicalAddresses
= gcnew
CecLogicalAddresses();
1717 FirmwareVersion
= 1;
1718 PowerOffDevicesOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY
== 1;
1719 ShutdownOnStandby
= CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY
== 1;
1720 DeviceLanguage
= "";
1721 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1722 CECVersion
= (CecVersion
)CEC_DEFAULT_SETTING_CEC_VERSION
;
1723 AdapterType
= CecAdapterType::Unknown
;
1727 /// Change the callback method pointers in this configuration instance.
1729 /// <param name="callbacks">The new callbacks</param>
1730 void SetCallbacks(CecCallbackMethods
^callbacks
)
1732 Callbacks
= callbacks
;
1736 /// Update this configuration with data received from libCEC
1738 /// <param name="config">The configuration that was received from libCEC</param>
1739 void Update(const CEC::libcec_configuration
&config
)
1741 DeviceName
= gcnew
System::String(config
.strDeviceName
);
1743 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1744 DeviceTypes
->Types
[iPtr
] = (CecDeviceType
)config
.deviceTypes
.types
[iPtr
];
1746 AutodetectAddress
= config
.bAutodetectAddress
== 1;
1747 PhysicalAddress
= config
.iPhysicalAddress
;
1748 BaseDevice
= (CecLogicalAddress
)config
.baseDevice
;
1749 HDMIPort
= config
.iHDMIPort
;
1750 ClientVersion
= (CecClientVersion
)config
.clientVersion
;
1751 ServerVersion
= (CecServerVersion
)config
.serverVersion
;
1752 TvVendor
= (CecVendorId
)config
.tvVendor
;
1754 // player specific settings
1755 GetSettingsFromROM
= config
.bGetSettingsFromROM
== 1;
1756 UseTVMenuLanguage
= config
.bUseTVMenuLanguage
== 1;
1757 ActivateSource
= config
.bActivateSource
== 1;
1759 WakeDevices
->Clear();
1760 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1761 if (config
.wakeDevices
[iPtr
])
1762 WakeDevices
->Set((CecLogicalAddress
)iPtr
);
1764 PowerOffDevices
->Clear();
1765 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1766 if (config
.powerOffDevices
[iPtr
])
1767 PowerOffDevices
->Set((CecLogicalAddress
)iPtr
);
1769 PowerOffScreensaver
= config
.bPowerOffScreensaver
== 1;
1770 PowerOffOnStandby
= config
.bPowerOffOnStandby
== 1;
1772 if (ServerVersion
>= CecServerVersion::Version1_5_1
)
1773 SendInactiveSource
= config
.bSendInactiveSource
== 1;
1775 if (ServerVersion
>= CecServerVersion::Version1_5_3
)
1777 LogicalAddresses
->Clear();
1778 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1779 if (config
.logicalAddresses
[iPtr
])
1780 LogicalAddresses
->Set((CecLogicalAddress
)iPtr
);
1783 if (ServerVersion
>= CecServerVersion::Version1_6_0
)
1785 FirmwareVersion
= config
.iFirmwareVersion
;
1786 PowerOffDevicesOnStandby
= config
.bPowerOffDevicesOnStandby
== 1;
1787 ShutdownOnStandby
= config
.bShutdownOnStandby
== 1;
1790 if (ServerVersion
>= CecServerVersion::Version1_6_2
)
1792 DeviceLanguage
= gcnew
System::String(config
.strDeviceLanguage
);
1793 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1794 FirmwareBuildDate
= FirmwareBuildDate
->AddSeconds(config
.iFirmwareBuildDate
);
1797 if (ServerVersion
>= CecServerVersion::Version1_6_3
)
1798 MonitorOnlyClient
= config
.bMonitorOnly
== 1;
1800 if (ServerVersion
>= CecServerVersion::Version1_8_0
)
1801 CECVersion
= (CecVersion
)config
.cecVersion
;
1803 if (ServerVersion
>= CecServerVersion::Version1_8_2
)
1804 AdapterType
= (CecAdapterType
)config
.adapterType
;
1806 if (ServerVersion
>= CecServerVersion::Version2_1_0
)
1807 PowerOnScreensaver
= config
.bPowerOnScreensaver
== 1;
1811 /// The device name to use on the CEC bus
1813 property
System::String
^ DeviceName
;
1816 /// The device type(s) to use on the CEC bus for libCEC
1818 property CecDeviceTypeList
^ DeviceTypes
;
1821 /// (read only) set to true by libCEC when the physical address was autodetected
1823 property
bool AutodetectAddress
;
1826 /// The physical address of the CEC adapter
1828 property
uint16_t PhysicalAddress
;
1831 /// 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
1833 property CecLogicalAddress BaseDevice
;
1836 /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection
1838 property
uint8_t HDMIPort
;
1841 /// The client API version to use
1843 property CecClientVersion ClientVersion
;
1846 /// The version of libCEC
1848 property CecServerVersion ServerVersion
;
1851 /// Override the vendor ID of the TV. Leave this untouched to autodetect
1853 property CecVendorId TvVendor
;
1856 /// True to read the settings from the EEPROM, which possibly override the settings passed here
1858 property
bool GetSettingsFromROM
;
1861 /// Use the language setting of the TV in the client application. Must be implemented by the client application.
1862 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1864 property
bool UseTVMenuLanguage
;
1867 /// Make libCEC the active source when starting the client application
1869 property
bool ActivateSource
;
1872 /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter.
1874 property CecLogicalAddresses
^WakeDevices
;
1877 /// List of devices to power off when calling StandbyDevices() without any parameter.
1879 property CecLogicalAddresses
^PowerOffDevices
;
1882 /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application.
1884 property
bool PowerOffScreensaver
;
1887 /// Power off the PC when the TV powers off. Must be implemented by the client application.
1889 property
bool PowerOffOnStandby
;
1892 /// Send an inactive source message when exiting the client application.
1894 property
bool SendInactiveSource
;
1897 /// The list of logical addresses that libCEC is using
1899 property CecLogicalAddresses
^LogicalAddresses
;
1902 /// The firmware version of the adapter to which libCEC is connected
1904 property
uint16_t FirmwareVersion
;
1907 /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
1909 property
bool PowerOffDevicesOnStandby
;
1912 /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false
1914 property
bool ShutdownOnStandby
;
1917 /// True to start a monitor-only client, false to start a standard client.
1919 property
bool MonitorOnlyClient
;
1922 /// The language code of the menu language that libCEC reports to other devices.
1923 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1925 property
System::String
^ DeviceLanguage
;
1928 /// The callback methods to use.
1930 property CecCallbackMethods
^ Callbacks
;
1933 /// The build date of the firmware.
1935 property
System::DateTime
^ FirmwareBuildDate
;
1938 /// The CEC version that libCEC uses.
1940 property CecVersion CECVersion
;
1943 /// The type of adapter that libCEC is connected to.
1945 property CecAdapterType AdapterType
;
1948 /// True to power on when quitting the screensaver.
1950 property
bool PowerOnScreensaver
;
1953 // the callback methods are called by unmanaged code, so we need some delegates for this
1955 // unmanaged callback methods
1956 typedef int (__stdcall
*LOGCB
) (const CEC::cec_log_message
&message
);
1957 typedef int (__stdcall
*KEYCB
) (const CEC::cec_keypress
&key
);
1958 typedef int (__stdcall
*COMMANDCB
)(const CEC::cec_command
&command
);
1959 typedef int (__stdcall
*CONFIGCB
) (const CEC::libcec_configuration
&config
);
1960 typedef int (__stdcall
*ALERTCB
) (const CEC::libcec_alert
, const CEC::libcec_parameter
&data
);
1961 typedef int (__stdcall
*MENUCB
) (const CEC::cec_menu_state newVal
);
1962 typedef void (__stdcall
*ACTICB
) (const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
1965 /// libCEC callback methods. Unmanaged code.
1970 /// Log message callback
1974 /// Key press/release callback
1978 /// Raw CEC data callback
1980 COMMANDCB commandCB
;
1982 /// Updated configuration callback
1986 /// Alert message callback
1990 /// Menu status change callback
1994 /// Source (de)activated callback
1996 ACTICB sourceActivatedCB
;
1997 } UnmanagedCecCallbacks
;
1999 static PLATFORM::CMutex g_callbackMutex
;
2000 static std::vector
<UnmanagedCecCallbacks
> g_unmanagedCallbacks
;
2001 static CEC::ICECCallbacks g_cecCallbacks
;
2004 /// Called by libCEC to send back a log message to the application
2006 /// <param name="cbParam">Pointer to the callback struct</param>
2007 /// <param name="message">The log message</param>
2008 /// <return>1 when handled, 0 otherwise</return>
2009 int CecLogMessageCB(void *cbParam
, const CEC::cec_log_message message
)
2013 size_t iPtr
= (size_t)cbParam
;
2014 PLATFORM::CLockObject
lock(g_callbackMutex
);
2015 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2016 return g_unmanagedCallbacks
[iPtr
].logCB(message
);
2022 /// Called by libCEC to send back a key press or release to the application
2024 /// <param name="cbParam">Pointer to the callback struct</param>
2025 /// <param name="key">The key press command that libCEC received</param>
2026 /// <return>1 when handled, 0 otherwise</return>
2027 int CecKeyPressCB(void *cbParam
, const CEC::cec_keypress key
)
2031 size_t iPtr
= (size_t)cbParam
;
2032 PLATFORM::CLockObject
lock(g_callbackMutex
);
2033 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2034 return g_unmanagedCallbacks
[iPtr
].keyCB(key
);
2040 /// Called by libCEC to send back raw CEC data to the application
2042 /// <param name="cbParam">Pointer to the callback struct</param>
2043 /// <param name="command">The raw CEC data</param>
2044 /// <return>1 when handled, 0 otherwise</return>
2045 int CecCommandCB(void *cbParam
, const CEC::cec_command command
)
2049 size_t iPtr
= (size_t)cbParam
;
2050 PLATFORM::CLockObject
lock(g_callbackMutex
);
2051 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2052 return g_unmanagedCallbacks
[iPtr
].commandCB(command
);
2058 /// Called by libCEC to send back an updated configuration to the application
2060 /// <param name="cbParam">Pointer to the callback struct</param>
2061 /// <param name="config">The new configuration</param>
2062 /// <return>1 when handled, 0 otherwise</return>
2063 int CecConfigCB(void *cbParam
, const CEC::libcec_configuration config
)
2067 size_t iPtr
= (size_t)cbParam
;
2068 PLATFORM::CLockObject
lock(g_callbackMutex
);
2069 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2070 return g_unmanagedCallbacks
[iPtr
].configCB(config
);
2076 /// Called by libCEC to send back an alert message to the application
2078 /// <param name="cbParam">Pointer to the callback struct</param>
2079 /// <param name="data">The alert message</param>
2080 /// <return>1 when handled, 0 otherwise</return>
2081 int CecAlertCB(void *cbParam
, const CEC::libcec_alert alert
, const CEC::libcec_parameter data
)
2085 size_t iPtr
= (size_t)cbParam
;
2086 PLATFORM::CLockObject
lock(g_callbackMutex
);
2087 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2088 return g_unmanagedCallbacks
[iPtr
].alertCB(alert
, data
);
2094 /// Called by libCEC to send back a menu state change to the application
2096 /// <param name="cbParam">Pointer to the callback struct</param>
2097 /// <param name="newVal">The new menu state</param>
2098 /// <return>1 when handled, 0 otherwise</return>
2099 int CecMenuCB(void *cbParam
, const CEC::cec_menu_state newVal
)
2103 size_t iPtr
= (size_t)cbParam
;
2104 PLATFORM::CLockObject
lock(g_callbackMutex
);
2105 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2106 return g_unmanagedCallbacks
[iPtr
].menuCB(newVal
);
2112 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated
2114 /// <param name="cbParam">Pointer to the callback struct</param>
2115 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2116 /// <param name="activated">True when activated, false when deactivated</param>
2117 void CecSourceActivatedCB(void *cbParam
, const CEC::cec_logical_address logicalAddress
, const uint8_t activated
)
2121 size_t iPtr
= (size_t)cbParam
;
2122 PLATFORM::CLockObject
lock(g_callbackMutex
);
2123 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2124 g_unmanagedCallbacks
[iPtr
].sourceActivatedCB(logicalAddress
, activated
);
2130 /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods
2132 public delegate
int CecLogMessageManagedDelegate(const CEC::cec_log_message
&);
2134 /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods
2136 public delegate
int CecKeyPressManagedDelegate(const CEC::cec_keypress
&);
2138 /// Delegate method for the CecCommandCB callback in CecCallbackMethods
2140 public delegate
int CecCommandManagedDelegate(const CEC::cec_command
&);
2142 /// Delegate method for the CecConfigCB callback in CecCallbackMethods
2144 public delegate
int CecConfigManagedDelegate(const CEC::libcec_configuration
&);
2146 /// Delegate method for the CecAlertCB callback in CecCallbackMethods
2148 public delegate
int CecAlertManagedDelegate(const CEC::libcec_alert
, const CEC::libcec_parameter
&);
2150 /// Delegate method for the CecMenuCB callback in CecCallbackMethods
2152 public delegate
int CecMenuManagedDelegate(const CEC::cec_menu_state
);
2154 /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods
2156 public delegate
void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address
, const uint8_t);
2159 /// Assign the callback methods in the g_cecCallbacks struct
2161 void AssignCallbacks()
2163 g_cecCallbacks
.CBCecLogMessage
= CecLogMessageCB
;
2164 g_cecCallbacks
.CBCecKeyPress
= CecKeyPressCB
;
2165 g_cecCallbacks
.CBCecCommand
= CecCommandCB
;
2166 g_cecCallbacks
.CBCecConfigurationChanged
= CecConfigCB
;
2167 g_cecCallbacks
.CBCecAlert
= CecAlertCB
;
2168 g_cecCallbacks
.CBCecMenuStateChanged
= CecMenuCB
;
2169 g_cecCallbacks
.CBCecSourceActivated
= CecSourceActivatedCB
;
2173 /// The callback methods that libCEC uses
2175 public ref
class CecCallbackMethods
2178 CecCallbackMethods(void)
2180 m_iCallbackPtr
= -1;
2182 m_bHasCallbacks
= false;
2183 m_bDelegatesCreated
= false;
2186 ~CecCallbackMethods(void)
2192 /// Pointer to the callbacks struct entry
2194 size_t GetCallbackPtr(void)
2196 PLATFORM::CLockObject
lock(g_callbackMutex
);
2197 return m_iCallbackPtr
;
2201 !CecCallbackMethods(void)
2208 /// Disable callback methods
2210 virtual void DisableCallbacks(void)
2216 /// Enable callback methods
2218 /// <param name="callbacks">Callback methods to activate</param>
2219 /// <return>true when handled, false otherwise</return>
2220 virtual bool EnableCallbacks(CecCallbackMethods
^ callbacks
)
2223 if (!m_bHasCallbacks
)
2225 m_bHasCallbacks
= true;
2226 m_callbacks
= callbacks
;
2234 /// Called by libCEC to send back a log message to the application.
2235 /// Override in the application to handle this callback.
2237 /// <param name="message">The log message</param>
2238 /// <return>1 when handled, 0 otherwise</return>
2239 virtual int ReceiveLogMessage(CecLogMessage
^ message
)
2245 /// Called by libCEC to send back a key press or release to the application.
2246 /// Override in the application to handle this callback.
2248 /// <param name="key">The key press command that libCEC received</param>
2249 /// <return>1 when handled, 0 otherwise</return>
2250 virtual int ReceiveKeypress(CecKeypress
^ key
)
2256 /// Called by libCEC to send back raw CEC data to the application.
2257 /// Override in the application to handle this callback.
2259 /// <param name="command">The raw CEC data</param>
2260 /// <return>1 when handled, 0 otherwise</return>
2261 virtual int ReceiveCommand(CecCommand
^ command
)
2267 /// Called by libCEC to send back an updated configuration to the application.
2268 /// Override in the application to handle this callback.
2270 /// <param name="config">The new configuration</param>
2271 /// <return>1 when handled, 0 otherwise</return>
2272 virtual int ConfigurationChanged(LibCECConfiguration
^ config
)
2278 /// Called by libCEC to send back an alert message to the application.
2279 /// Override in the application to handle this callback.
2281 /// <param name="data">The alert message</param>
2282 /// <return>1 when handled, 0 otherwise</return>
2283 virtual int ReceiveAlert(CecAlert alert
, CecParameter
^ data
)
2289 /// Called by libCEC to send back a menu state change to the application.
2290 /// Override in the application to handle this callback.
2292 /// <param name="newVal">The new menu state</param>
2293 /// <return>1 when handled, 0 otherwise</return>
2294 virtual int ReceiveMenuStateChange(CecMenuState newVal
)
2300 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated.
2301 /// Override in the application to handle this callback.
2303 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2304 /// <param name="activated">True when activated, false when deactivated</param>
2305 virtual void SourceActivated(CecLogicalAddress logicalAddress
, bool activated
)
2310 // managed callback methods
2311 int CecLogMessageManaged(const CEC::cec_log_message
&message
)
2314 if (m_bHasCallbacks
)
2315 iReturn
= m_callbacks
->ReceiveLogMessage(gcnew
CecLogMessage(gcnew
System::String(message
.message
), (CecLogLevel
)message
.level
, message
.time
));
2319 int CecKeyPressManaged(const CEC::cec_keypress
&key
)
2322 if (m_bHasCallbacks
)
2323 iReturn
= m_callbacks
->ReceiveKeypress(gcnew
CecKeypress((CecUserControlCode
)key
.keycode
, key
.duration
));
2327 int CecCommandManaged(const CEC::cec_command
&command
)
2330 if (m_bHasCallbacks
)
2332 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
);
2333 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
2334 newCommand
->Parameters
->PushBack(command
.parameters
[iPtr
]);
2335 iReturn
= m_callbacks
->ReceiveCommand(newCommand
);
2340 int CecConfigManaged(const CEC::libcec_configuration
&config
)
2343 if (m_bHasCallbacks
)
2345 LibCECConfiguration
^netConfig
= gcnew
LibCECConfiguration();
2346 netConfig
->Update(config
);
2347 iReturn
= m_callbacks
->ConfigurationChanged(netConfig
);
2352 int CecAlertManaged(const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
2355 if (m_bHasCallbacks
)
2357 CecParameterType newType
= (CecParameterType
)data
.paramType
;
2358 if (newType
== CecParameterType::ParameterTypeString
)
2360 System::String
^ newData
= gcnew
System::String((const char *)data
.paramData
, 0, 128);
2361 CecParameter
^ newParam
= gcnew
CecParameter(newType
, newData
);
2362 iReturn
= m_callbacks
->ReceiveAlert((CecAlert
)alert
, newParam
);
2368 int CecMenuManaged(const CEC::cec_menu_state newVal
)
2371 if (m_bHasCallbacks
)
2373 iReturn
= m_callbacks
->ReceiveMenuStateChange((CecMenuState
)newVal
);
2378 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
2380 if (m_bHasCallbacks
)
2381 m_callbacks
->SourceActivated((CecLogicalAddress
)logicalAddress
, bActivated
== 1);
2384 void DestroyDelegates()
2386 m_bHasCallbacks
= false;
2387 if (m_bDelegatesCreated
)
2389 m_bDelegatesCreated
= false;
2390 m_logMessageGCHandle
.Free();
2391 m_keypressGCHandle
.Free();
2392 m_commandGCHandle
.Free();
2393 m_alertGCHandle
.Free();
2394 m_menuGCHandle
.Free();
2395 m_sourceActivatedGCHandle
.Free();
2399 void CreateDelegates()
2403 if (!m_bDelegatesCreated
)
2405 msclr::interop::marshal_context
^ context
= gcnew
msclr::interop::marshal_context();
2407 // create the delegate method for the log message callback
2408 m_logMessageDelegate
= gcnew
CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged
);
2409 m_logMessageGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate
);
2410 m_logMessageCallback
= static_cast<LOGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate
).ToPointer());
2412 // create the delegate method for the keypress callback
2413 m_keypressDelegate
= gcnew
CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged
);
2414 m_keypressGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate
);
2415 m_keypressCallback
= static_cast<KEYCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate
).ToPointer());
2417 // create the delegate method for the command callback
2418 m_commandDelegate
= gcnew
CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged
);
2419 m_commandGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate
);
2420 m_commandCallback
= static_cast<COMMANDCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate
).ToPointer());
2422 // create the delegate method for the configuration change callback
2423 m_configDelegate
= gcnew
CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged
);
2424 m_configGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate
);
2425 m_configCallback
= static_cast<CONFIGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate
).ToPointer());
2427 // create the delegate method for the alert callback
2428 m_alertDelegate
= gcnew
CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged
);
2429 m_alertGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate
);
2430 m_alertCallback
= static_cast<ALERTCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate
).ToPointer());
2432 // create the delegate method for the menu callback
2433 m_menuDelegate
= gcnew
CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged
);
2434 m_menuGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate
);
2435 m_menuCallback
= static_cast<MENUCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate
).ToPointer());
2437 // create the delegate method for the source activated callback
2438 m_sourceActivatedDelegate
= gcnew
CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged
);
2439 m_sourceActivatedGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate
);
2440 m_sourceActivatedCallback
= static_cast<ACTICB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate
).ToPointer());
2444 UnmanagedCecCallbacks unmanagedCallbacks
;
2445 unmanagedCallbacks
.logCB
= m_logMessageCallback
;
2446 unmanagedCallbacks
.keyCB
= m_keypressCallback
;
2447 unmanagedCallbacks
.commandCB
= m_commandCallback
;
2448 unmanagedCallbacks
.configCB
= m_configCallback
;
2449 unmanagedCallbacks
.alertCB
= m_alertCallback
;
2450 unmanagedCallbacks
.menuCB
= m_menuCallback
;
2451 unmanagedCallbacks
.sourceActivatedCB
= m_sourceActivatedCallback
;
2453 PLATFORM::CLockObject
lock(g_callbackMutex
);
2454 g_unmanagedCallbacks
.push_back(unmanagedCallbacks
);
2455 m_iCallbackPtr
= g_unmanagedCallbacks
.size() - 1;
2456 m_bDelegatesCreated
= true;
2460 CecLogMessageManagedDelegate
^ m_logMessageDelegate
;
2461 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle
;
2462 LOGCB m_logMessageCallback
;
2464 CecKeyPressManagedDelegate
^ m_keypressDelegate
;
2465 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle
;
2466 KEYCB m_keypressCallback
;
2468 CecCommandManagedDelegate
^ m_commandDelegate
;
2469 static System::Runtime::InteropServices::GCHandle m_commandGCHandle
;
2470 COMMANDCB m_commandCallback
;
2472 CecConfigManagedDelegate
^ m_configDelegate
;
2473 static System::Runtime::InteropServices::GCHandle m_configGCHandle
;
2474 CONFIGCB m_configCallback
;
2476 CecAlertManagedDelegate
^ m_alertDelegate
;
2477 static System::Runtime::InteropServices::GCHandle m_alertGCHandle
;
2478 ALERTCB m_alertCallback
;
2480 CecMenuManagedDelegate
^ m_menuDelegate
;
2481 static System::Runtime::InteropServices::GCHandle m_menuGCHandle
;
2482 MENUCB m_menuCallback
;
2484 CecSourceActivatedManagedDelegate
^ m_sourceActivatedDelegate
;
2485 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle
;
2486 ACTICB m_sourceActivatedCallback
;
2488 CecCallbackMethods
^ m_callbacks
;
2489 bool m_bHasCallbacks
;
2490 bool m_bDelegatesCreated
;
2491 size_t m_iCallbackPtr
;