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 PulseEight
= 0x001582,
798 Panasonic
= 0x008045,
810 HarmanKardon
= 0x9C645E,
815 /// Audio status of audio system / AVR devices
817 public enum class CecAudioStatus
822 MuteStatusMask
= 0x80,
824 /// Not muted, volume status mask
826 VolumeStatusMask
= 0x7F,
838 VolumeStatusUnknown
= 0x7F
842 /// CEC opcodes, as described in the HDMI CEC specification
844 public enum class CecOpcode
851 /// Image view on: power on display for image display
855 /// Text view on: power on display for text display
859 /// Device no longer is the active source
861 InactiveSource
= 0x9D,
863 /// Request which device has the active source status
865 RequestActiveSource
= 0x85,
867 /// Routing change for HDMI switches
869 RoutingChange
= 0x80,
871 /// Routing information for HDMI switches
873 RoutingInformation
= 0x81,
875 /// Change the stream path to the given physical address
877 SetStreamPath
= 0x86,
879 /// Inform that a device went into standby mode
891 /// Recording status information
895 /// Record current display
897 RecordTvScreen
= 0x0F,
899 /// Clear analogue timer
901 ClearAnalogueTimer
= 0x33,
903 /// Clear digital timer
905 ClearDigitalTimer
= 0x99,
907 /// Clear external timer
909 ClearExternalTimer
= 0xA1,
911 /// Set analogue timer
913 SetAnalogueTimer
= 0x34,
915 /// Set digital timer
917 SetDigitalTimer
= 0x97,
919 /// Set external timer
921 SetExternalTimer
= 0xA2,
923 /// Set program title of a timer
925 SetTimerProgramTitle
= 0x67,
927 /// Timer status cleared
929 TimerClearedStatus
= 0x43,
931 /// Timer status information
935 /// CEC version used by a device
939 /// Request CEC version of a device
941 GetCecVersion
= 0x9F,
943 /// Request physical address of a device
945 GivePhysicalAddress
= 0x83,
947 /// Request language code of the menu language of a device
948 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
950 GetMenuLanguage
= 0x91,
952 /// Report the physical address
954 ReportPhysicalAddress
= 0x84,
956 /// Report the language code of the menu language
957 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
959 SetMenuLanguage
= 0x32,
961 /// Deck control for playback and recording devices
965 /// Deck status for playback and recording devices
969 /// Request deck status from playback and recording devices
971 GiveDeckStatus
= 0x1A,
973 /// Start playback on playback and recording devices
977 /// Request tuner status
979 GiveTunerDeviceStatus
= 0x08,
981 /// Select analogue service on a tuner
983 SelectAnalogueService
= 0x92,
985 /// Select digital service on a tuner
987 SelectDigtalService
= 0x93,
989 /// Report tuner device status
991 TunerDeviceStatus
= 0x07,
993 /// Tuner step decrement
995 TunerStepDecrement
= 0x06,
997 /// Tuner step increment
999 TunerStepIncrement
= 0x05,
1001 /// Report device vendor ID
1003 DeviceVendorId
= 0x87,
1005 /// Request device vendor ID
1007 GiveDeviceVendorId
= 0x8C,
1009 /// Vendor specific command
1011 VendorCommand
= 0x89,
1013 /// Vendor specific command with vendor ID
1015 VendorCommandWithId
= 0xA0,
1017 /// Vendor specific remote button pressed
1019 VendorRemoteButtonDown
= 0x8A,
1021 /// Vendor specific remote button released
1023 VendorRemoteButtonUp
= 0x8B,
1025 /// Display / clear OSD string
1027 SetOsdString
= 0x64,
1029 /// Request device OSD name
1033 /// Report device OSD name
1037 /// Request device menu status
1041 /// Report device menu status
1045 /// Remote button pressed
1047 UserControlPressed
= 0x44,
1049 /// Remote button released
1051 UserControlRelease
= 0x45,
1053 /// Request device power status
1055 GiveDevicePowerStatus
= 0x8F,
1057 /// Report device power status
1059 ReportPowerStatus
= 0x90,
1061 /// Feature abort / unsupported command
1063 FeatureAbort
= 0x00,
1069 /// Give audio status
1071 GiveAudioStatus
= 0x71,
1073 /// Give audiosystem mode
1075 GiveSystemAudioMode
= 0x7D,
1077 /// Report device audio status
1079 ReportAudioStatus
= 0x7A,
1081 /// Set audiosystem mode
1083 SetSystemAudioMode
= 0x72,
1085 /// Request audiosystem mode
1087 SystemAudioModeRequest
= 0x70,
1089 /// Report audiosystem mode
1091 SystemAudioModeStatus
= 0x7E,
1093 /// Set audio bitrate
1095 SetAudioRate
= 0x9A,
1097 /// When this opcode is set, no opcode will be sent to the device / poll message
1098 /// This is one of the reserved numbers
1104 /// Audiosystem status
1106 public enum class CecSystemAudioStatus
1119 /// libCEC client application version
1121 public enum class CecClientVersion
1130 Version1_5_0
= 0x1500,
1134 Version1_5_1
= 0x1501,
1138 Version1_5_2
= 0x1502,
1142 Version1_5_3
= 0x1503,
1146 Version1_6_0
= 0x1600,
1150 Version1_6_1
= 0x1601,
1154 Version1_6_2
= 0x1602,
1158 Version1_6_3
= 0x1603,
1162 Version1_7_0
= 0x1700,
1166 Version1_7_1
= 0x1701,
1170 Version1_7_2
= 0x1702,
1174 Version1_8_0
= 0x1800,
1178 Version1_8_1
= 0x1801,
1182 Version1_8_2
= 0x1802,
1186 Version1_9_0
= 0x1900,
1190 Version1_99_0
= 0x1990,
1194 Version2_0_0
= 0x2000,
1198 Version2_0_1
= 0x2001,
1202 Version2_0_2
= 0x2002,
1206 Version2_0_3
= 0x2003,
1210 Version2_0_4
= 0x2004,
1214 Version2_0_5
= 0x2005,
1218 Version2_1_0
= 0x2100,
1222 Version2_1_1
= 0x2101,
1226 Version2_1_2
= 0x2102,
1230 Version2_1_3
= 0x2103,
1234 Version2_1_4
= 0x2104,
1236 /// The current version
1238 CurrentVersion
= 0x2104
1244 public enum class CecServerVersion
1253 Version1_5_0
= 0x1500,
1257 Version1_5_1
= 0x1501,
1261 Version1_5_2
= 0x1502,
1265 Version1_5_3
= 0x1503,
1269 Version1_6_0
= 0x1600,
1273 Version1_6_1
= 0x1601,
1277 Version1_6_2
= 0x1602,
1281 Version1_6_3
= 0x1603,
1285 Version1_7_0
= 0x1700,
1289 Version1_7_1
= 0x1701,
1293 Version1_7_2
= 0x1702,
1297 Version1_8_0
= 0x1800,
1301 Version1_8_1
= 0x1801,
1305 Version1_8_2
= 0x1802,
1309 Version1_9_0
= 0x1900,
1313 Version1_99_0
= 0x1990,
1317 Version2_0_0
= 0x2000,
1321 Version2_0_1
= 0x2001,
1325 Version2_0_2
= 0x2002,
1329 Version2_0_3
= 0x2003,
1333 Version2_0_4
= 0x2004,
1337 Version2_0_5
= 0x2005,
1341 Version2_1_0
= 0x2100,
1345 Version2_1_1
= 0x2101,
1349 Version2_1_2
= 0x2102,
1353 Version2_1_3
= 0x2103,
1357 Version2_1_4
= 0x2104,
1359 /// The current version
1361 CurrentVersion
= 0x2104
1365 /// Type of adapter to which libCEC is connected
1367 public enum class CecAdapterType
1370 /// Unknown adapter type
1374 /// Pulse-Eight USB-CEC adapter
1376 PulseEightExternal
= 0x1,
1378 /// Pulse-Eight CEC daughterboard
1380 PulseEightDaughterboard
= 0x2,
1384 RaspberryPi
= 0x100,
1392 /// Descriptor of a CEC adapter, returned when scanning for adapters that are connected to the system
1394 public ref
class CecAdapter
1398 /// Create a new CEC adapter descriptor
1400 /// <param name="path"> The path descriptor for this CEC adapter</param>
1401 /// <param name="comPort">The COM port of this CEC adapter</param>
1402 CecAdapter(System::String
^ path
, System::String
^ comPort
)
1409 /// The path descriptor for this CEC adapter
1411 property
System::String
^ Path
;
1414 /// The COM port of this CEC adapter
1416 property
System::String
^ ComPort
;
1420 /// A list of CEC device types
1422 public ref
class CecDeviceTypeList
1426 /// Create a new empty list of CEC device types
1428 CecDeviceTypeList(void)
1430 Types
= gcnew array
<CecDeviceType
>(5);
1431 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1432 Types
[iPtr
] = CecDeviceType::Reserved
;
1436 /// The array with CecDeviceType instances in this list.
1438 property array
<CecDeviceType
> ^ Types
;
1442 /// A list of logical addresses
1444 public ref
class CecLogicalAddresses
1448 /// Create a new empty list of logical addresses
1450 CecLogicalAddresses(void)
1452 Addresses
= gcnew array
<CecLogicalAddress
>(16);
1457 /// Clears this list
1461 Primary
= CecLogicalAddress::Unknown
;
1462 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
1463 Addresses
[iPtr
] = CecLogicalAddress::Unknown
;
1467 /// Checks whether a logical address is set in this list.
1469 /// <param name="address">The address to check.</param>
1470 /// <returns>True when set, false otherwise</returns>
1471 bool IsSet(CecLogicalAddress address
)
1473 return Addresses
[(unsigned int)address
] != CecLogicalAddress::Unknown
;
1477 /// Add a logical address to this list (if it's not set already)
1479 /// <param name="address">The address to add.</param>
1480 void Set(CecLogicalAddress address
)
1482 Addresses
[(unsigned int)address
] = address
;
1483 if (Primary
== CecLogicalAddress::Unknown
)
1488 /// The primary (first) address in this list
1490 property CecLogicalAddress Primary
;
1493 /// The list of addresses
1495 property array
<CecLogicalAddress
> ^ Addresses
;
1500 /// Byte array used for CEC command parameters
1502 public ref
class CecDatapacket
1506 /// Create a new byte array with maximum size 100
1510 Data
= gcnew array
<uint8_t>(100);
1515 /// Adds a byte to this byte array
1517 /// <param name="data">The byte to add.</param>
1518 void PushBack(uint8_t data
)
1530 property array
<uint8_t> ^ Data
;
1533 /// Current data size
1535 property
uint8_t Size
;
1539 /// A CEC command that is received or transmitted over the CEC bus
1541 public ref
class CecCommand
1545 /// Create a new CEC command instance
1547 /// <param name="initiator">The initiator of the command</param>
1548 /// <param name="destination">The receiver of the command</param>
1549 /// <param name="ack">True when the ack bit is set, false otherwise</param>
1550 /// <param name="eom">True when the eom bit is set, false otherwise</param>
1551 /// <param name="opcode">The CEC opcode of this command</param>
1552 /// <param name="transmitTimeout">The timeout to use when transmitting a command</param>
1553 CecCommand(CecLogicalAddress initiator
, CecLogicalAddress destination
, bool ack
, bool eom
, CecOpcode opcode
, int32_t transmitTimeout
)
1555 Initiator
= initiator
;
1556 Destination
= destination
;
1561 TransmitTimeout
= transmitTimeout
;
1562 Parameters
= gcnew CecDatapacket
;
1567 /// Create a new empty CEC command instance
1571 Initiator
= CecLogicalAddress::Unknown
;
1572 Destination
= CecLogicalAddress::Unknown
;
1575 Opcode
= CecOpcode::None
;
1577 TransmitTimeout
= 0;
1578 Parameters
= gcnew CecDatapacket
;
1583 /// Pushes a byte of data to this CEC command
1585 /// <param name="data">The byte to add</param>
1586 void PushBack(uint8_t data
)
1588 if (Initiator
== CecLogicalAddress::Unknown
&& Destination
== CecLogicalAddress::Unknown
)
1590 Initiator
= (CecLogicalAddress
) (data
>> 4);
1591 Destination
= (CecLogicalAddress
) (data
& 0xF);
1593 else if (!OpcodeSet
)
1596 Opcode
= (CecOpcode
)data
;
1600 Parameters
->PushBack(data
);
1605 /// True when this command is empty, false otherwise.
1607 property
bool Empty
;
1609 /// The initiator of the command
1611 property CecLogicalAddress Initiator
;
1613 /// The destination of the command
1615 property CecLogicalAddress Destination
;
1617 /// True when the ack bit is set, false otherwise
1621 /// True when the eom bit is set, false otherwise
1625 /// The CEC opcode of the command
1627 property CecOpcode Opcode
;
1629 /// The parameters of this command
1631 property CecDatapacket
^ Parameters
;
1633 /// True when an opcode is set, false otherwise (poll message)
1635 property
bool OpcodeSet
;
1637 /// The timeout to use when transmitting a command
1639 property
int32_t TransmitTimeout
;
1643 /// A key press that was received
1645 public ref
class CecKeypress
1649 /// Create a new key press instance
1651 /// <param name="keycode">The key code of this key press</param>
1652 /// <param name="duration">The duration of this key press in milliseconds</param>
1653 CecKeypress(CecUserControlCode keycode
, unsigned int duration
)
1656 Duration
= duration
;
1661 /// Create a new empty key press instance
1665 Keycode
= CecUserControlCode::Unknown
;
1671 /// True when empty, false otherwise
1673 property
bool Empty
;
1675 /// The key code of this key press
1677 property CecUserControlCode Keycode
;
1679 /// The duration of this key press in milliseconds
1681 property
unsigned int Duration
;
1685 /// A log message that libCEC generated
1687 public ref
class CecLogMessage
1691 /// Create a new log message
1693 /// <param name="message">The actual message</param>
1694 /// <param name="level">The log level, so the application can choose what type information to display</param>
1695 /// <param name="time">The timestamp of this message, in milliseconds after connecting</param>
1696 CecLogMessage(System::String
^ message
, CecLogLevel level
, int64_t time
)
1705 /// Create a new empty log message
1710 Level
= CecLogLevel::None
;
1716 /// True when empty, false otherwise.
1718 property
bool Empty
;
1720 /// The actual message
1722 property
System::String
^Message
;
1724 /// The log level, so the application can choose what type information to display
1726 property CecLogLevel Level
;
1728 /// The timestamp of this message, in milliseconds after connecting
1730 property
int64_t Time
;
1733 ref
class CecCallbackMethods
; //forward declaration
1736 /// The configuration that libCEC uses.
1738 public ref
class LibCECConfiguration
1742 /// Create a new configuration instance with default settings.
1744 LibCECConfiguration(void)
1747 DeviceTypes
= gcnew
CecDeviceTypeList();
1748 AutodetectAddress
= true;
1749 PhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
1750 BaseDevice
= (CecLogicalAddress
)CEC_DEFAULT_BASE_DEVICE
;
1751 HDMIPort
= CEC_DEFAULT_HDMI_PORT
;
1752 ClientVersion
= CecClientVersion::CurrentVersion
;
1753 ServerVersion
= CecServerVersion::CurrentVersion
;
1754 TvVendor
= CecVendorId::Unknown
;
1756 GetSettingsFromROM
= false;
1757 UseTVMenuLanguage
= CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE
== 1;
1758 ActivateSource
= CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1;
1760 WakeDevices
= gcnew
CecLogicalAddresses();
1761 if (CEC_DEFAULT_SETTING_ACTIVATE_SOURCE
== 1)
1762 WakeDevices
->Set(CecLogicalAddress::Tv
);
1764 PowerOffDevices
= gcnew
CecLogicalAddresses();
1765 if (CEC_DEFAULT_SETTING_POWER_OFF_SHUTDOWN
== 1)
1766 PowerOffDevices
->Set(CecLogicalAddress::Broadcast
);
1768 PowerOffScreensaver
= CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER
== 1;
1769 PowerOffOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY
== 1;
1771 SendInactiveSource
= CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE
== 1;
1772 LogicalAddresses
= gcnew
CecLogicalAddresses();
1773 FirmwareVersion
= 1;
1774 PowerOffDevicesOnStandby
= CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY
== 1;
1775 ShutdownOnStandby
= CEC_DEFAULT_SETTING_SHUTDOWN_ON_STANDBY
== 1;
1776 DeviceLanguage
= "";
1777 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1778 CECVersion
= (CecVersion
)CEC_DEFAULT_SETTING_CEC_VERSION
;
1779 AdapterType
= CecAdapterType::Unknown
;
1783 /// Change the callback method pointers in this configuration instance.
1785 /// <param name="callbacks">The new callbacks</param>
1786 void SetCallbacks(CecCallbackMethods
^callbacks
)
1788 Callbacks
= callbacks
;
1792 /// Update this configuration with data received from libCEC
1794 /// <param name="config">The configuration that was received from libCEC</param>
1795 void Update(const CEC::libcec_configuration
&config
)
1797 DeviceName
= gcnew
System::String(config
.strDeviceName
);
1799 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
1800 DeviceTypes
->Types
[iPtr
] = (CecDeviceType
)config
.deviceTypes
.types
[iPtr
];
1802 AutodetectAddress
= config
.bAutodetectAddress
== 1;
1803 PhysicalAddress
= config
.iPhysicalAddress
;
1804 BaseDevice
= (CecLogicalAddress
)config
.baseDevice
;
1805 HDMIPort
= config
.iHDMIPort
;
1806 ClientVersion
= (CecClientVersion
)config
.clientVersion
;
1807 ServerVersion
= (CecServerVersion
)config
.serverVersion
;
1808 TvVendor
= (CecVendorId
)config
.tvVendor
;
1810 // player specific settings
1811 GetSettingsFromROM
= config
.bGetSettingsFromROM
== 1;
1812 UseTVMenuLanguage
= config
.bUseTVMenuLanguage
== 1;
1813 ActivateSource
= config
.bActivateSource
== 1;
1815 WakeDevices
->Clear();
1816 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1817 if (config
.wakeDevices
[iPtr
])
1818 WakeDevices
->Set((CecLogicalAddress
)iPtr
);
1820 PowerOffDevices
->Clear();
1821 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1822 if (config
.powerOffDevices
[iPtr
])
1823 PowerOffDevices
->Set((CecLogicalAddress
)iPtr
);
1825 PowerOffScreensaver
= config
.bPowerOffScreensaver
== 1;
1826 PowerOffOnStandby
= config
.bPowerOffOnStandby
== 1;
1828 if (ServerVersion
>= CecServerVersion::Version1_5_1
)
1829 SendInactiveSource
= config
.bSendInactiveSource
== 1;
1831 if (ServerVersion
>= CecServerVersion::Version1_5_3
)
1833 LogicalAddresses
->Clear();
1834 for (uint8_t iPtr
= 0; iPtr
<= 16; iPtr
++)
1835 if (config
.logicalAddresses
[iPtr
])
1836 LogicalAddresses
->Set((CecLogicalAddress
)iPtr
);
1839 if (ServerVersion
>= CecServerVersion::Version1_6_0
)
1841 FirmwareVersion
= config
.iFirmwareVersion
;
1842 PowerOffDevicesOnStandby
= config
.bPowerOffDevicesOnStandby
== 1;
1843 ShutdownOnStandby
= config
.bShutdownOnStandby
== 1;
1846 if (ServerVersion
>= CecServerVersion::Version1_6_2
)
1848 DeviceLanguage
= gcnew
System::String(config
.strDeviceLanguage
);
1849 FirmwareBuildDate
= gcnew
System::DateTime(1970,1,1,0,0,0,0);
1850 FirmwareBuildDate
= FirmwareBuildDate
->AddSeconds(config
.iFirmwareBuildDate
);
1853 if (ServerVersion
>= CecServerVersion::Version1_6_3
)
1854 MonitorOnlyClient
= config
.bMonitorOnly
== 1;
1856 if (ServerVersion
>= CecServerVersion::Version1_8_0
)
1857 CECVersion
= (CecVersion
)config
.cecVersion
;
1859 if (ServerVersion
>= CecServerVersion::Version1_8_2
)
1860 AdapterType
= (CecAdapterType
)config
.adapterType
;
1862 if (ServerVersion
>= CecServerVersion::Version2_1_0
)
1863 PowerOnScreensaver
= config
.bPowerOnScreensaver
== 1;
1867 /// The device name to use on the CEC bus
1869 property
System::String
^ DeviceName
;
1872 /// The device type(s) to use on the CEC bus for libCEC
1874 property CecDeviceTypeList
^ DeviceTypes
;
1877 /// (read only) set to true by libCEC when the physical address was autodetected
1879 property
bool AutodetectAddress
;
1882 /// The physical address of the CEC adapter
1884 property
uint16_t PhysicalAddress
;
1887 /// 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
1889 property CecLogicalAddress BaseDevice
;
1892 /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection
1894 property
uint8_t HDMIPort
;
1897 /// The client API version to use
1899 property CecClientVersion ClientVersion
;
1902 /// The version of libCEC
1904 property CecServerVersion ServerVersion
;
1907 /// Override the vendor ID of the TV. Leave this untouched to autodetect
1909 property CecVendorId TvVendor
;
1912 /// True to read the settings from the EEPROM, which possibly override the settings passed here
1914 property
bool GetSettingsFromROM
;
1917 /// Use the language setting of the TV in the client application. Must be implemented by the client application.
1918 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1920 property
bool UseTVMenuLanguage
;
1923 /// Make libCEC the active source when starting the client application
1925 property
bool ActivateSource
;
1928 /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter.
1930 property CecLogicalAddresses
^WakeDevices
;
1933 /// List of devices to power off when calling StandbyDevices() without any parameter.
1935 property CecLogicalAddresses
^PowerOffDevices
;
1938 /// Send standby commands when the client application activates the screensaver. Must be implemented by the client application.
1940 property
bool PowerOffScreensaver
;
1943 /// Power off the PC when the TV powers off. Must be implemented by the client application.
1945 property
bool PowerOffOnStandby
;
1948 /// Send an inactive source message when exiting the client application.
1950 property
bool SendInactiveSource
;
1953 /// The list of logical addresses that libCEC is using
1955 property CecLogicalAddresses
^LogicalAddresses
;
1958 /// The firmware version of the adapter to which libCEC is connected
1960 property
uint16_t FirmwareVersion
;
1963 /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
1965 property
bool PowerOffDevicesOnStandby
;
1968 /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false
1970 property
bool ShutdownOnStandby
;
1973 /// True to start a monitor-only client, false to start a standard client.
1975 property
bool MonitorOnlyClient
;
1978 /// The language code of the menu language that libCEC reports to other devices.
1979 /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
1981 property
System::String
^ DeviceLanguage
;
1984 /// The callback methods to use.
1986 property CecCallbackMethods
^ Callbacks
;
1989 /// The build date of the firmware.
1991 property
System::DateTime
^ FirmwareBuildDate
;
1994 /// The CEC version that libCEC uses.
1996 property CecVersion CECVersion
;
1999 /// The type of adapter that libCEC is connected to.
2001 property CecAdapterType AdapterType
;
2004 /// True to power on when quitting the screensaver.
2006 property
bool PowerOnScreensaver
;
2009 // the callback methods are called by unmanaged code, so we need some delegates for this
2011 // unmanaged callback methods
2012 typedef int (__stdcall
*LOGCB
) (const CEC::cec_log_message
&message
);
2013 typedef int (__stdcall
*KEYCB
) (const CEC::cec_keypress
&key
);
2014 typedef int (__stdcall
*COMMANDCB
)(const CEC::cec_command
&command
);
2015 typedef int (__stdcall
*CONFIGCB
) (const CEC::libcec_configuration
&config
);
2016 typedef int (__stdcall
*ALERTCB
) (const CEC::libcec_alert
, const CEC::libcec_parameter
&data
);
2017 typedef int (__stdcall
*MENUCB
) (const CEC::cec_menu_state newVal
);
2018 typedef void (__stdcall
*ACTICB
) (const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
);
2021 /// libCEC callback methods. Unmanaged code.
2026 /// Log message callback
2030 /// Key press/release callback
2034 /// Raw CEC data callback
2036 COMMANDCB commandCB
;
2038 /// Updated configuration callback
2042 /// Alert message callback
2046 /// Menu status change callback
2050 /// Source (de)activated callback
2052 ACTICB sourceActivatedCB
;
2053 } UnmanagedCecCallbacks
;
2055 static PLATFORM::CMutex g_callbackMutex
;
2056 static std::vector
<UnmanagedCecCallbacks
> g_unmanagedCallbacks
;
2057 static CEC::ICECCallbacks g_cecCallbacks
;
2060 /// Called by libCEC to send back a log message to the application
2062 /// <param name="cbParam">Pointer to the callback struct</param>
2063 /// <param name="message">The log message</param>
2064 /// <return>1 when handled, 0 otherwise</return>
2065 int CecLogMessageCB(void *cbParam
, const CEC::cec_log_message message
)
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
].logCB(message
);
2078 /// Called by libCEC to send back a key press or release to the application
2080 /// <param name="cbParam">Pointer to the callback struct</param>
2081 /// <param name="key">The key press command that libCEC received</param>
2082 /// <return>1 when handled, 0 otherwise</return>
2083 int CecKeyPressCB(void *cbParam
, const CEC::cec_keypress key
)
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
].keyCB(key
);
2096 /// Called by libCEC to send back raw CEC data to the application
2098 /// <param name="cbParam">Pointer to the callback struct</param>
2099 /// <param name="command">The raw CEC data</param>
2100 /// <return>1 when handled, 0 otherwise</return>
2101 int CecCommandCB(void *cbParam
, const CEC::cec_command command
)
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
].commandCB(command
);
2114 /// Called by libCEC to send back an updated configuration to the application
2116 /// <param name="cbParam">Pointer to the callback struct</param>
2117 /// <param name="config">The new configuration</param>
2118 /// <return>1 when handled, 0 otherwise</return>
2119 int CecConfigCB(void *cbParam
, const CEC::libcec_configuration config
)
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
].configCB(config
);
2132 /// Called by libCEC to send back an alert message to the application
2134 /// <param name="cbParam">Pointer to the callback struct</param>
2135 /// <param name="data">The alert message</param>
2136 /// <return>1 when handled, 0 otherwise</return>
2137 int CecAlertCB(void *cbParam
, const CEC::libcec_alert alert
, const CEC::libcec_parameter data
)
2141 size_t iPtr
= (size_t)cbParam
;
2142 PLATFORM::CLockObject
lock(g_callbackMutex
);
2143 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2144 return g_unmanagedCallbacks
[iPtr
].alertCB(alert
, data
);
2150 /// Called by libCEC to send back a menu state change to the application
2152 /// <param name="cbParam">Pointer to the callback struct</param>
2153 /// <param name="newVal">The new menu state</param>
2154 /// <return>1 when handled, 0 otherwise</return>
2155 int CecMenuCB(void *cbParam
, const CEC::cec_menu_state newVal
)
2159 size_t iPtr
= (size_t)cbParam
;
2160 PLATFORM::CLockObject
lock(g_callbackMutex
);
2161 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2162 return g_unmanagedCallbacks
[iPtr
].menuCB(newVal
);
2168 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated
2170 /// <param name="cbParam">Pointer to the callback struct</param>
2171 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2172 /// <param name="activated">True when activated, false when deactivated</param>
2173 void CecSourceActivatedCB(void *cbParam
, const CEC::cec_logical_address logicalAddress
, const uint8_t activated
)
2177 size_t iPtr
= (size_t)cbParam
;
2178 PLATFORM::CLockObject
lock(g_callbackMutex
);
2179 if (iPtr
>= 0 && iPtr
< g_unmanagedCallbacks
.size())
2180 g_unmanagedCallbacks
[iPtr
].sourceActivatedCB(logicalAddress
, activated
);
2186 /// Delegate method for the CecLogMessageCB callback in CecCallbackMethods
2188 public delegate
int CecLogMessageManagedDelegate(const CEC::cec_log_message
&);
2190 /// Delegate method for the CecKeyPressCB callback in CecCallbackMethods
2192 public delegate
int CecKeyPressManagedDelegate(const CEC::cec_keypress
&);
2194 /// Delegate method for the CecCommandCB callback in CecCallbackMethods
2196 public delegate
int CecCommandManagedDelegate(const CEC::cec_command
&);
2198 /// Delegate method for the CecConfigCB callback in CecCallbackMethods
2200 public delegate
int CecConfigManagedDelegate(const CEC::libcec_configuration
&);
2202 /// Delegate method for the CecAlertCB callback in CecCallbackMethods
2204 public delegate
int CecAlertManagedDelegate(const CEC::libcec_alert
, const CEC::libcec_parameter
&);
2206 /// Delegate method for the CecMenuCB callback in CecCallbackMethods
2208 public delegate
int CecMenuManagedDelegate(const CEC::cec_menu_state
);
2210 /// Delegate method for the CecSourceActivatedCB callback in CecCallbackMethods
2212 public delegate
void CecSourceActivatedManagedDelegate(const CEC::cec_logical_address
, const uint8_t);
2215 /// Assign the callback methods in the g_cecCallbacks struct
2217 void AssignCallbacks()
2219 g_cecCallbacks
.CBCecLogMessage
= CecLogMessageCB
;
2220 g_cecCallbacks
.CBCecKeyPress
= CecKeyPressCB
;
2221 g_cecCallbacks
.CBCecCommand
= CecCommandCB
;
2222 g_cecCallbacks
.CBCecConfigurationChanged
= CecConfigCB
;
2223 g_cecCallbacks
.CBCecAlert
= CecAlertCB
;
2224 g_cecCallbacks
.CBCecMenuStateChanged
= CecMenuCB
;
2225 g_cecCallbacks
.CBCecSourceActivated
= CecSourceActivatedCB
;
2229 /// The callback methods that libCEC uses
2231 public ref
class CecCallbackMethods
2234 CecCallbackMethods(void)
2236 m_iCallbackPtr
= -1;
2238 m_bHasCallbacks
= false;
2239 m_bDelegatesCreated
= false;
2242 ~CecCallbackMethods(void)
2248 /// Pointer to the callbacks struct entry
2250 size_t GetCallbackPtr(void)
2252 PLATFORM::CLockObject
lock(g_callbackMutex
);
2253 return m_iCallbackPtr
;
2257 !CecCallbackMethods(void)
2264 /// Disable callback methods
2266 virtual void DisableCallbacks(void)
2272 /// Enable callback methods
2274 /// <param name="callbacks">Callback methods to activate</param>
2275 /// <return>true when handled, false otherwise</return>
2276 virtual bool EnableCallbacks(CecCallbackMethods
^ callbacks
)
2279 if (!m_bHasCallbacks
)
2281 m_bHasCallbacks
= true;
2282 m_callbacks
= callbacks
;
2290 /// Called by libCEC to send back a log message to the application.
2291 /// Override in the application to handle this callback.
2293 /// <param name="message">The log message</param>
2294 /// <return>1 when handled, 0 otherwise</return>
2295 virtual int ReceiveLogMessage(CecLogMessage
^ message
)
2301 /// Called by libCEC to send back a key press or release to the application.
2302 /// Override in the application to handle this callback.
2304 /// <param name="key">The key press command that libCEC received</param>
2305 /// <return>1 when handled, 0 otherwise</return>
2306 virtual int ReceiveKeypress(CecKeypress
^ key
)
2312 /// Called by libCEC to send back raw CEC data to the application.
2313 /// Override in the application to handle this callback.
2315 /// <param name="command">The raw CEC data</param>
2316 /// <return>1 when handled, 0 otherwise</return>
2317 virtual int ReceiveCommand(CecCommand
^ command
)
2323 /// Called by libCEC to send back an updated configuration to the application.
2324 /// Override in the application to handle this callback.
2326 /// <param name="config">The new configuration</param>
2327 /// <return>1 when handled, 0 otherwise</return>
2328 virtual int ConfigurationChanged(LibCECConfiguration
^ config
)
2334 /// Called by libCEC to send back an alert message to the application.
2335 /// Override in the application to handle this callback.
2337 /// <param name="data">The alert message</param>
2338 /// <return>1 when handled, 0 otherwise</return>
2339 virtual int ReceiveAlert(CecAlert alert
, CecParameter
^ data
)
2345 /// Called by libCEC to send back a menu state change to the application.
2346 /// Override in the application to handle this callback.
2348 /// <param name="newVal">The new menu state</param>
2349 /// <return>1 when handled, 0 otherwise</return>
2350 virtual int ReceiveMenuStateChange(CecMenuState newVal
)
2356 /// Called by libCEC to notify the application that the source that is handled by libCEC was (de)activated.
2357 /// Override in the application to handle this callback.
2359 /// <param name="logicalAddress">The logical address that was (de)activated</param>
2360 /// <param name="activated">True when activated, false when deactivated</param>
2361 virtual void SourceActivated(CecLogicalAddress logicalAddress
, bool activated
)
2366 // managed callback methods
2367 int CecLogMessageManaged(const CEC::cec_log_message
&message
)
2370 if (m_bHasCallbacks
)
2371 iReturn
= m_callbacks
->ReceiveLogMessage(gcnew
CecLogMessage(gcnew
System::String(message
.message
), (CecLogLevel
)message
.level
, message
.time
));
2375 int CecKeyPressManaged(const CEC::cec_keypress
&key
)
2378 if (m_bHasCallbacks
)
2379 iReturn
= m_callbacks
->ReceiveKeypress(gcnew
CecKeypress((CecUserControlCode
)key
.keycode
, key
.duration
));
2383 int CecCommandManaged(const CEC::cec_command
&command
)
2386 if (m_bHasCallbacks
)
2388 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
);
2389 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
2390 newCommand
->Parameters
->PushBack(command
.parameters
[iPtr
]);
2391 iReturn
= m_callbacks
->ReceiveCommand(newCommand
);
2396 int CecConfigManaged(const CEC::libcec_configuration
&config
)
2399 if (m_bHasCallbacks
)
2401 LibCECConfiguration
^netConfig
= gcnew
LibCECConfiguration();
2402 netConfig
->Update(config
);
2403 iReturn
= m_callbacks
->ConfigurationChanged(netConfig
);
2408 int CecAlertManaged(const CEC::libcec_alert alert
, const CEC::libcec_parameter
&data
)
2411 if (m_bHasCallbacks
)
2413 CecParameterType newType
= (CecParameterType
)data
.paramType
;
2414 if (newType
== CecParameterType::ParameterTypeString
)
2416 System::String
^ newData
= gcnew
System::String(data
.paramData
? (const char *)data
.paramData
: "", 0, 128);
2417 CecParameter
^ newParam
= gcnew
CecParameter(newType
, newData
);
2418 iReturn
= m_callbacks
->ReceiveAlert((CecAlert
)alert
, newParam
);
2424 int CecMenuManaged(const CEC::cec_menu_state newVal
)
2427 if (m_bHasCallbacks
)
2429 iReturn
= m_callbacks
->ReceiveMenuStateChange((CecMenuState
)newVal
);
2434 void CecSourceActivatedManaged(const CEC::cec_logical_address logicalAddress
, const uint8_t bActivated
)
2436 if (m_bHasCallbacks
)
2437 m_callbacks
->SourceActivated((CecLogicalAddress
)logicalAddress
, bActivated
== 1);
2440 void DestroyDelegates()
2442 m_bHasCallbacks
= false;
2443 if (m_bDelegatesCreated
)
2445 m_bDelegatesCreated
= false;
2446 m_logMessageGCHandle
.Free();
2447 m_keypressGCHandle
.Free();
2448 m_commandGCHandle
.Free();
2449 m_alertGCHandle
.Free();
2450 m_menuGCHandle
.Free();
2451 m_sourceActivatedGCHandle
.Free();
2455 void CreateDelegates()
2459 if (!m_bDelegatesCreated
)
2461 msclr::interop::marshal_context
^ context
= gcnew
msclr::interop::marshal_context();
2463 // create the delegate method for the log message callback
2464 m_logMessageDelegate
= gcnew
CecLogMessageManagedDelegate(this, &CecCallbackMethods::CecLogMessageManaged
);
2465 m_logMessageGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_logMessageDelegate
);
2466 m_logMessageCallback
= static_cast<LOGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_logMessageDelegate
).ToPointer());
2468 // create the delegate method for the keypress callback
2469 m_keypressDelegate
= gcnew
CecKeyPressManagedDelegate(this, &CecCallbackMethods::CecKeyPressManaged
);
2470 m_keypressGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_keypressDelegate
);
2471 m_keypressCallback
= static_cast<KEYCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_keypressDelegate
).ToPointer());
2473 // create the delegate method for the command callback
2474 m_commandDelegate
= gcnew
CecCommandManagedDelegate(this, &CecCallbackMethods::CecCommandManaged
);
2475 m_commandGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_commandDelegate
);
2476 m_commandCallback
= static_cast<COMMANDCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_commandDelegate
).ToPointer());
2478 // create the delegate method for the configuration change callback
2479 m_configDelegate
= gcnew
CecConfigManagedDelegate(this, &CecCallbackMethods::CecConfigManaged
);
2480 m_configGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_configDelegate
);
2481 m_configCallback
= static_cast<CONFIGCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_configDelegate
).ToPointer());
2483 // create the delegate method for the alert callback
2484 m_alertDelegate
= gcnew
CecAlertManagedDelegate(this, &CecCallbackMethods::CecAlertManaged
);
2485 m_alertGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_alertDelegate
);
2486 m_alertCallback
= static_cast<ALERTCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_alertDelegate
).ToPointer());
2488 // create the delegate method for the menu callback
2489 m_menuDelegate
= gcnew
CecMenuManagedDelegate(this, &CecCallbackMethods::CecMenuManaged
);
2490 m_menuGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_menuDelegate
);
2491 m_menuCallback
= static_cast<MENUCB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_menuDelegate
).ToPointer());
2493 // create the delegate method for the source activated callback
2494 m_sourceActivatedDelegate
= gcnew
CecSourceActivatedManagedDelegate(this, &CecCallbackMethods::CecSourceActivatedManaged
);
2495 m_sourceActivatedGCHandle
= System::Runtime::InteropServices::GCHandle::Alloc(m_sourceActivatedDelegate
);
2496 m_sourceActivatedCallback
= static_cast<ACTICB
>(System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(m_sourceActivatedDelegate
).ToPointer());
2500 UnmanagedCecCallbacks unmanagedCallbacks
;
2501 unmanagedCallbacks
.logCB
= m_logMessageCallback
;
2502 unmanagedCallbacks
.keyCB
= m_keypressCallback
;
2503 unmanagedCallbacks
.commandCB
= m_commandCallback
;
2504 unmanagedCallbacks
.configCB
= m_configCallback
;
2505 unmanagedCallbacks
.alertCB
= m_alertCallback
;
2506 unmanagedCallbacks
.menuCB
= m_menuCallback
;
2507 unmanagedCallbacks
.sourceActivatedCB
= m_sourceActivatedCallback
;
2509 PLATFORM::CLockObject
lock(g_callbackMutex
);
2510 g_unmanagedCallbacks
.push_back(unmanagedCallbacks
);
2511 m_iCallbackPtr
= g_unmanagedCallbacks
.size() - 1;
2512 m_bDelegatesCreated
= true;
2516 CecLogMessageManagedDelegate
^ m_logMessageDelegate
;
2517 static System::Runtime::InteropServices::GCHandle m_logMessageGCHandle
;
2518 LOGCB m_logMessageCallback
;
2520 CecKeyPressManagedDelegate
^ m_keypressDelegate
;
2521 static System::Runtime::InteropServices::GCHandle m_keypressGCHandle
;
2522 KEYCB m_keypressCallback
;
2524 CecCommandManagedDelegate
^ m_commandDelegate
;
2525 static System::Runtime::InteropServices::GCHandle m_commandGCHandle
;
2526 COMMANDCB m_commandCallback
;
2528 CecConfigManagedDelegate
^ m_configDelegate
;
2529 static System::Runtime::InteropServices::GCHandle m_configGCHandle
;
2530 CONFIGCB m_configCallback
;
2532 CecAlertManagedDelegate
^ m_alertDelegate
;
2533 static System::Runtime::InteropServices::GCHandle m_alertGCHandle
;
2534 ALERTCB m_alertCallback
;
2536 CecMenuManagedDelegate
^ m_menuDelegate
;
2537 static System::Runtime::InteropServices::GCHandle m_menuGCHandle
;
2538 MENUCB m_menuCallback
;
2540 CecSourceActivatedManagedDelegate
^ m_sourceActivatedDelegate
;
2541 static System::Runtime::InteropServices::GCHandle m_sourceActivatedGCHandle
;
2542 ACTICB m_sourceActivatedCallback
;
2544 CecCallbackMethods
^ m_callbacks
;
2545 bool m_bHasCallbacks
;
2546 bool m_bDelegatesCreated
;
2547 size_t m_iCallbackPtr
;