From: Lars Op den Kamp Date: Thu, 29 Mar 2012 11:08:26 +0000 (+0200) Subject: cec: sync C and .NET interfaces with C++ X-Git-Tag: upstream/2.2.0~1^2~31^2~32 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bd624ba8248a39d6ab7752d8764683a0cbc1e422;p=deb_libcec.git cec: sync C and .NET interfaces with C++ --- diff --git a/include/cecc.h b/include/cecc.h index 7e3512f..779f211 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -296,6 +296,12 @@ extern DECLSPEC void cec_rescan_devices(void); extern DECLSPEC int cec_is_libcec_active_source(void); +#ifdef __cplusplus +extern DECLSPEC int cec_get_device_information(const char *strPort, CEC::libcec_configuration *config, uint32_t iTimeoutMs); +#else +extern DECLSPEC int cec_get_device_information(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs); +#endif + #ifdef __cplusplus }; #endif diff --git a/src/LibCecSharp/LibCecSharp.cpp b/src/LibCecSharp/LibCecSharp.cpp index 76dd006..0737dbb 100644 --- a/src/LibCecSharp/LibCecSharp.cpp +++ b/src/LibCecSharp/LibCecSharp.cpp @@ -481,6 +481,31 @@ namespace CecSharp return bReturn; } + bool IsLibCECActiveSource() + { + return m_libCec->IsLibCECActiveSource(); + } + + bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs) + { + bool bReturn(false); + marshal_context ^ context = gcnew marshal_context(); + + libcec_configuration config; + config.Clear(); + + const char* strPortC = port->Length > 0 ? context->marshal_as(port) : NULL; + + if (m_libCec->GetDeviceInformation(strPortC, &config, timeoutMs)) + { + configuration->Update(config); + bReturn = true; + } + + delete context; + return bReturn; + } + String ^ ToString(CecLogicalAddress iAddress) { const char *retVal = m_libCec->ToString((cec_logical_address)iAddress); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index 29b08fd..4a7e0be 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -421,4 +421,9 @@ int cec_is_libcec_active_source(void) return cec_parser ? (cec_parser->IsLibCECActiveSource() ? 1 : 0) : -1; } +int cec_get_device_information(const char *strPort, CEC::libcec_configuration *config, uint32_t iTimeoutMs) +{ + return cec_parser ? (cec_parser->GetDeviceInformation(strPort, config, iTimeoutMs) ? 1 : 0) : -1; +} + //@}