*/
virtual void InitVideoStandalone(void) = 0;
+ /*!
+ * @return The (virtual) USB vendor id
+ */
+ virtual uint16_t GetAdapterVendorId(void) const = 0;
+
+ /*!
+ * @return The (virtual) USB product id
+ */
+ virtual uint16_t GetAdapterProductId(void) const = 0;
+
virtual const char *ToString(const cec_menu_state state) = 0;
virtual const char *ToString(const cec_version version) = 0;
virtual const char *ToString(const cec_power_status status) = 0;
extern DECLSPEC void cec_init_video_standalone(void);
+extern DECLSPEC uint16_t cec_get_adapter_vendor_id(void);
+
+extern DECLSPEC uint16_t cec_get_adapter_product_id(void);
+
#ifdef __cplusplus
};
#endif
m_libCec->InitVideoStandalone();
}
+ /// <summary>
+ /// Get the (virtual) USB vendor id
+ /// </summary>
+ /// <returns>The (virtual) USB vendor id</returns>
+ uint16_t GetAdapterVendorId()
+ {
+ return m_libCec->GetAdapterVendorId();
+ }
+
+ /// <summary>
+ /// Get the (virtual) USB product id
+ /// </summary>
+ /// <returns>The (virtual) USB product id</returns>
+ uint16_t GetAdapterProductId()
+ {
+ return m_libCec->GetAdapterProductId();
+ }
+
private:
!LibCecSharp(void)
{
get { return Lib.ToString(Config.ClientVersion); }
}
- /// <summary>
- /// Get the usb vid:prod descriptor
- /// </summary>
- public string USBDescriptor
- {
- get
- {
- DateTime checkDate = new DateTime(1970, 1, 1, 0, 0, 0, 0);
- checkDate = checkDate.AddSeconds(0x5045dbf5);
-
- return string.Format("2548:100{0}", ((DateTime)Config.FirmwareBuildDate >= checkDate ? "2" : "1"));
- }
- }
-
/// <summary>
/// libCEC
/// </summary>
}
public bool LoadXMLConfiguration()
- {
- var xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
- return LoadXMLConfiguration(xbmcDir + @"\usb_2548_1001.xml") || LoadXMLConfiguration(xbmcDir + @"\usb_2548_1002.xml");
- }
-
- public bool LoadXMLConfiguration(string filename)
{
bool gotConfig = false;
- if (File.Exists(filename))
+ string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
+ string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+ string file = defaultDir + @"\usb_2548_1001.xml";
+ if (File.Exists(xbmcDir + @"\usb_2548_1001.xml"))
+ file = xbmcDir + @"\usb_2548_1001.xml";
+
+ if (File.Exists(file))
{
- XmlTextReader reader = new XmlTextReader(filename);
+ XmlTextReader reader = new XmlTextReader(file);
while (reader.Read())
{
gotConfig = true;
{
Settings.Persist();
- var xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
- if (!Directory.Exists(xbmcDir))
- Directory.CreateDirectory(xbmcDir);
-
- if (!Directory.Exists(xbmcDir))
- {
- // couldn't create directory
- MessageBox.Show(string.Format(Resources.could_not_create_directory, xbmcDir), Resources.error,
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
+ string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
+ string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
SaveFileDialog dialog = new SaveFileDialog
- {
+ {
Title = Resources.store_settings_where,
- InitialDirectory = xbmcDir,
- FileName = string.Format("usb_{0}.xml", Program.Instance.Controller.USBDescriptor.Replace(':', '_')),
+ InitialDirectory = Directory.Exists(xbmcDir) ? xbmcDir : defaultDir,
+ FileName = "usb_2548_1001.xml",
Filter = Resources.xml_file_filter,
FilterIndex = 1
};
}
}
+uint16_t CCECProcessor::GetAdapterVendorId(void) const
+{
+ return m_communication ? m_communication->GetAdapterVendorId() : 0;
+}
+
+uint16_t CCECProcessor::GetAdapterProductId(void) const
+{
+ return m_communication ? m_communication->GetAdapterProductId() : 0;
+}
+
CCECAllocateLogicalAddress::CCECAllocateLogicalAddress(CCECProcessor* processor, CCECClient* client) :
m_processor(processor),
m_client(client) { }
void SwitchMonitoring(bool bSwitchTo);
bool AllocateLogicalAddresses(CCECClient* client);
+
+ uint16_t GetAdapterVendorId(void) const;
+ uint16_t GetAdapterProductId(void) const;
private:
bool OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening = true);
void SetCECInitialised(bool bSetTo = true);
{
CAdapterFactory::InitVideoStandalone();
}
+uint16_t CLibCEC::GetAdapterVendorId(void) const
+{
+ return m_cec && m_cec->IsRunning() ? m_cec->GetAdapterVendorId() : 0;
+}
+
+uint16_t CLibCEC::GetAdapterProductId(void) const
+{
+ return m_cec && m_cec->IsRunning() ? m_cec->GetAdapterProductId() : 0;
+}
CLibCEC(void);
virtual ~CLibCEC(void);
- /*!
- * ICECAdapter implementation
- */
- //@{
bool Open(const char *strPort, uint32_t iTimeout = CEC_DEFAULT_CONNECT_TIMEOUT);
void Close(void);
bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks);
static uint16_t GetMaskForType(cec_device_type type);
bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT);
- //@}
void AddLog(const cec_log_level level, const char *strFormat, ...);
void AddCommand(const cec_command &command);
std::vector<CCECClient *> GetClients(void) { return m_clients; };
const char *GetLibInfo(void);
void InitVideoStandalone(void);
+ uint16_t GetAdapterVendorId(void) const;
+ uint16_t GetAdapterProductId(void) const;
CCECProcessor * m_cec;
cec_parser->InitVideoStandalone();
}
+uint16_t cec_get_adapter_vendor_id(void)
+{
+ return cec_parser ? cec_parser->GetAdapterVendorId() : NULL;
+}
+
+uint16_t cec_get_adapter_product_id(void)
+{
+ return cec_parser ? cec_parser->GetAdapterProductId() : NULL;
+}
+
//@}
*/
virtual cec_adapter_type GetAdapterType(void) = 0;
+ /*!
+ * @return The (virtual) USB vendor id
+ */
+ virtual uint16_t GetAdapterVendorId(void) const = 0;
+
+ /*!
+ * @return The (virtual) USB product id
+ */
+ virtual uint16_t GetAdapterProductId(void) const = 0;
+
IAdapterCommunicationCallback *m_callback;
};
};
#include "USBCECAdapterCommands.h"
#include "USBCECAdapterMessageQueue.h"
#include "USBCECAdapterMessage.h"
+#include "USBCECAdapterDetection.h"
#include "lib/platform/sockets/serialport.h"
#include "lib/platform/util/timeutils.h"
#include "lib/platform/util/util.h"
#define CEC_LATEST_ADAPTER_FW_DATE 0x501a4b0c
#define CEC_FW_DATE_EXTENDED_RESPONSE 0x501a4b0c
+#define CEC_FW_DATE_DESCRIPTOR2 0x5045dbf5
#define LIB_CEC m_callback->GetLib()
return iBuildDate >= CEC_FW_DATE_EXTENDED_RESPONSE;
}
+uint16_t CUSBCECAdapterCommunication::GetAdapterVendorId(void) const
+{
+ return CEC_VID;
+}
+
+uint16_t CUSBCECAdapterCommunication::GetAdapterProductId(void) const
+{
+ uint32_t iBuildDate(0);
+ if (m_commands)
+ iBuildDate = m_commands->GetPersistedBuildDate();
+
+ return iBuildDate >= CEC_FW_DATE_DESCRIPTOR2 ? CEC_PID2 : CEC_PID;
+}
+
bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void)
{
return GetFirmwareBuildDate() >= CEC_LATEST_ADAPTER_FW_DATE &&
cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; }
bool SupportsSourceLogicalAddress(const cec_logical_address UNUSED(address)) { return true; }
cec_adapter_type GetAdapterType(void);
+ uint16_t GetAdapterVendorId(void) const;
+ uint16_t GetAdapterProductId(void) const;
///}
bool ProvidesExtendedResponse(void);
namespace CEC
{
+ #define CEC_VID 0x2548
+ #define CEC_PID 0x1001
+ #define CEC_PID2 0x1002
+
class CUSBCECAdapterDetection
{
public:
#include "lib/adapter/AdapterCommunication.h"
#include "lib/platform/threads/threads.h"
+#define RPI_ADAPTER_VID 0x2708
+#define RPI_ADAPTER_PID 0x1001
+
extern "C" {
#include <interface/vmcs_host/vc_cecservice.h>
#include <interface/vchiq_arm/vchiq_if.h>
cec_vendor_id GetVendorId(void) { return CEC_VENDOR_BROADCOM; }
bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address < CECDEVICE_BROADCAST; }
cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_RPI; };
+ uint16_t GetAdapterVendorId(void) const { return RPI_ADAPTER_VID; }
+ uint16_t GetAdapterProductId(void) const { return RPI_ADAPTER_PID; }
///}
bool IsInitialised(void);
#endif
#define snprintf _snprintf
+#define strdup _strdup
#if defined(_MSC_VER)
#pragma warning (push)