strHexString.Format("%04X", iVal);
};
};
+
+ class PeripheralScanResult
+ {
+ public:
+ PeripheralScanResult(const PeripheralBusType busType) :
+ m_type(PERIPHERAL_UNKNOWN),
+ m_iVendorId(0),
+ m_iProductId(0),
+ m_mappedType(PERIPHERAL_UNKNOWN),
+ m_busType(busType) {}
+
+ PeripheralScanResult(void) :
+ m_type(PERIPHERAL_UNKNOWN),
+ m_iVendorId(0),
+ m_iProductId(0),
+ m_mappedType(PERIPHERAL_UNKNOWN),
+ m_busType(PERIPHERAL_BUS_UNKNOWN) {}
+
+ bool operator ==(const PeripheralScanResult& right) const
+ {
+ return m_iVendorId == right.m_iVendorId &&
+ m_iProductId == right.m_iProductId &&
+ m_type == right.m_type &&
+ m_busType == right.m_busType &&
+ m_strLocation.Equals(right.m_strLocation);
+ }
+
+ bool operator !=(const PeripheralScanResult& right) const
+ {
+ return !(*this == right);
+ }
+
+ PeripheralType m_type;
+ CStdString m_strLocation;
+ int m_iVendorId;
+ int m_iProductId;
+ PeripheralType m_mappedType;
+ CStdString m_strDeviceName;
+ PeripheralBusType m_busType;
+ };
+
+ struct PeripheralScanResults
+ {
+ bool GetDeviceOnLocation(const CStdString& strLocation, PeripheralScanResult* result) const
+ {
+ for (std::vector<PeripheralScanResult>::const_iterator it = m_results.begin(); it != m_results.end(); it++)
+ {
+ if ((*it).m_strLocation == strLocation)
+ {
+ *result = *it;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool ContainsResult(const PeripheralScanResult& result) const
+ {
+ return std::find(m_results.begin(), m_results.end(), result) != m_results.end();
+ }
+
+ std::vector<PeripheralScanResult> m_results;
+ };
}
switch(mappedResult.m_mappedType)
{
case PERIPHERAL_HID:
- peripheral = new CPeripheralHID(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralHID(mappedResult);
break;
case PERIPHERAL_NIC:
- peripheral = new CPeripheralNIC(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralNIC(mappedResult);
break;
case PERIPHERAL_DISK:
- peripheral = new CPeripheralDisk(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralDisk(mappedResult);
break;
case PERIPHERAL_NYXBOARD:
- peripheral = new CPeripheralNyxboard(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralNyxboard(mappedResult);
break;
case PERIPHERAL_TUNER:
- peripheral = new CPeripheralTuner(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralTuner(mappedResult);
break;
case PERIPHERAL_BLUETOOTH:
- peripheral = new CPeripheralBluetooth(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralBluetooth(mappedResult);
break;
case PERIPHERAL_CEC:
#if defined(HAVE_LIBCEC)
if (bus.Type() == PERIPHERAL_BUS_CEC)
- peripheral = new CPeripheralCecAdapter(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralCecAdapter(mappedResult);
#else
if (!m_bMissingLibCecWarningDisplayed)
{
break;
case PERIPHERAL_IMON:
- peripheral = new CPeripheralImon(mappedResult.m_mappedType, mappedResult.m_busType, mappedResult.m_strLocation, mappedResult.m_strDeviceName, mappedResult.m_iVendorId, mappedResult.m_iProductId);
+ peripheral = new CPeripheralImon(mappedResult);
break;
default:
#define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 1000
-PeripheralScanResult::PeripheralScanResult(const PeripheralBusType busType)
-{
- m_iVendorId = 0;
- m_iProductId = 0;
- m_type = PERIPHERAL_UNKNOWN;
- m_mappedType = PERIPHERAL_UNKNOWN;
- m_busType = busType;
-}
-
-PeripheralScanResult::PeripheralScanResult(void)
-{
- m_iVendorId = 0;
- m_iProductId = 0;
- m_type = PERIPHERAL_UNKNOWN;
- m_mappedType = PERIPHERAL_UNKNOWN;
- m_busType = PERIPHERAL_BUS_UNKNOWN;
-}
-
-bool PeripheralScanResult::operator ==(const PeripheralScanResult &right) const
-{
- return m_iVendorId == right.m_iVendorId &&
- m_iProductId == right.m_iProductId &&
- m_type == right.m_type &&
- m_strLocation.Equals(right.m_strLocation) &&
- m_busType == right.m_busType;
-}
-
-bool PeripheralScanResult::operator !=(const PeripheralScanResult &right) const
-{
- return !(*this == right);
-}
-
-bool PeripheralScanResult::operator ==(const CPeripheral &right) const
-{
- return m_iVendorId == right.VendorId() &&
- m_iProductId == right.ProductId() &&
- m_type == right.Type() &&
- m_strLocation.Equals(right.Location()) &&
- m_busType == right.GetBusType();
-}
-
-bool PeripheralScanResult::operator !=(const CPeripheral &right) const
-{
- return !(*this == right);
-}
-
-bool PeripheralScanResults::GetDeviceOnLocation(const CStdString &strLocation, PeripheralScanResult *result) const
-{
- bool bReturn(false);
-
- for (unsigned int iDevicePtr = 0; iDevicePtr < m_results.size(); iDevicePtr++)
- {
- if (m_results.at(iDevicePtr).m_strLocation == strLocation)
- {
- *result = m_results.at(iDevicePtr);
- bReturn = true;
- break;
- }
- }
-
- return bReturn;
-}
-
-bool PeripheralScanResults::ContainsResult(const PeripheralScanResult &result) const
-{
- bool bReturn(false);
-
- for (unsigned int iDevicePtr = 0; iDevicePtr < m_results.size(); iDevicePtr++)
- {
- if (m_results.at(iDevicePtr) == result)
- {
- bReturn = true;
- break;
- }
- }
-
- return bReturn;
-}
-
CPeripheralBus::CPeripheralBus(CPeripherals *manager, PeripheralBusType type) :
CThread("XBMC Peripherals"),
m_iRescanTime(PERIPHERAL_DEFAULT_RESCAN_INTERVAL),
CPeripheral *peripheral = m_peripherals.at(iDevicePtr);
PeripheralScanResult updatedDevice(m_type);
if (!results.GetDeviceOnLocation(peripheral->Location(), &updatedDevice) ||
- updatedDevice != *peripheral)
+ *peripheral != updatedDevice)
{
/* device removed */
removedPeripherals.push_back(peripheral);
{
class CPeripherals;
- struct PeripheralScanResult
- {
- PeripheralScanResult(const PeripheralBusType busType);
- PeripheralScanResult(void);
- bool operator ==(const PeripheralScanResult &right) const;
- bool operator !=(const PeripheralScanResult &right) const;
-
- bool operator ==(const CPeripheral &right) const;
- bool operator !=(const CPeripheral &right) const;
-
- PeripheralType m_type;
- CStdString m_strLocation;
- int m_iVendorId;
- int m_iProductId;
- PeripheralType m_mappedType;
- CStdString m_strDeviceName;
- PeripheralBusType m_busType;
- };
-
- struct PeripheralScanResults
- {
- bool GetDeviceOnLocation(const CStdString &strLocation, PeripheralScanResult *result) const;
- bool ContainsResult(const PeripheralScanResult &result) const;
-
- std::vector<PeripheralScanResult> m_results;
- };
-
/*!
* @class CPeripheralBus
* This represents a bus on the system. By default, this bus instance will scan for changes every second.
}
};
-CPeripheral::CPeripheral(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- m_type(type),
- m_busType(busType),
- m_strLocation(strLocation),
- m_strDeviceName(strDeviceName),
+CPeripheral::CPeripheral(const PeripheralScanResult& scanResult) :
+ m_type(scanResult.m_mappedType),
+ m_busType(scanResult.m_busType),
+ m_strLocation(scanResult.m_strLocation),
+ m_strDeviceName(scanResult.m_strDeviceName),
m_strFileLocation(StringUtils::EmptyString),
- m_iVendorId(iVendorId),
- m_iProductId(iProductId),
+ m_iVendorId(scanResult.m_iVendorId),
+ m_iProductId(scanResult.m_iProductId),
m_strVersionInfo(g_localizeStrings.Get(13205)), // "unknown"
m_bInitialised(false),
m_bHidden(false),
m_bError(false)
{
- PeripheralTypeTranslator::FormatHexString(iVendorId, m_strVendorId);
- PeripheralTypeTranslator::FormatHexString(iProductId, m_strProductId);
- m_strFileLocation.Format("peripherals://%s/%s.dev", PeripheralTypeTranslator::BusTypeToString(busType), strLocation.c_str());
+ PeripheralTypeTranslator::FormatHexString(scanResult.m_iVendorId, m_strVendorId);
+ PeripheralTypeTranslator::FormatHexString(scanResult.m_iProductId, m_strProductId);
+ m_strFileLocation.Format("peripherals://%s/%s.dev", PeripheralTypeTranslator::BusTypeToString(scanResult.m_busType), scanResult.m_strLocation.c_str());
}
CPeripheral::~CPeripheral(void)
}
m_settings.clear();
}
+
+bool CPeripheral::operator ==(const PeripheralScanResult& right) const
+{
+ return m_iVendorId == right.m_iVendorId &&
+ m_iProductId == right.m_iProductId &&
+ m_type == right.m_type &&
+ m_busType == right.m_busType &&
+ m_strLocation.Equals(right.m_strLocation);
+}
+
+bool CPeripheral::operator !=(const PeripheralScanResult& right) const
+{
+ return !(*this == right);
+}
friend class CGUIDialogPeripheralSettings;
public:
- CPeripheral(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheral(const PeripheralScanResult& scanResult);
virtual ~CPeripheral(void);
bool operator ==(const CPeripheral &right) const;
bool operator !=(const CPeripheral &right) const;
+ bool operator ==(const PeripheralScanResult& right) const;
+ bool operator !=(const PeripheralScanResult& right) const;
const CStdString &FileLocation(void) const { return m_strFileLocation; }
const CStdString &Location(void) const { return m_strLocation; }
using namespace PERIPHERALS;
-CPeripheralBluetooth::CPeripheralBluetooth(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheral(type, busType, strLocation, strDeviceName, iVendorId, iProductId)
+CPeripheralBluetooth::CPeripheralBluetooth(const PeripheralScanResult& scanResult) :
+ CPeripheral(scanResult)
{
m_features.push_back(FEATURE_BLUETOOTH);
}
class CPeripheralBluetooth : public CPeripheral
{
public:
- CPeripheralBluetooth(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralBluetooth(const PeripheralScanResult& scanResult);
virtual ~CPeripheralBluetooth(void) {};
};
}
END_METHOD_RESOLVE()
};
-CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheralHID(type, busType, strLocation, strDeviceName, iVendorId, iProductId),
+CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralScanResult& scanResult) :
+ CPeripheralHID(scanResult),
CThread("CEC Adapter"),
m_dll(NULL),
m_cecAdapter(NULL)
friend class CPeripheralCecAdapterUpdateThread;
public:
- CPeripheralCecAdapter(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralCecAdapter(const PeripheralScanResult& scanResult);
virtual ~CPeripheralCecAdapter(void);
void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data);
using namespace PERIPHERALS;
-CPeripheralDisk::CPeripheralDisk(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheral(type, busType, strLocation, strDeviceName.IsEmpty() ? g_localizeStrings.Get(35003) : strDeviceName, iVendorId, iProductId)
+CPeripheralDisk::CPeripheralDisk(const PeripheralScanResult& scanResult) :
+ CPeripheral(scanResult)
{
+ m_strDeviceName = scanResult.m_strDeviceName.IsEmpty() ? g_localizeStrings.Get(35003) : scanResult.m_strDeviceName;
m_features.push_back(FEATURE_DISK);
}
class CPeripheralDisk : public CPeripheral
{
public:
- CPeripheralDisk(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralDisk(const PeripheralScanResult& scanResult);
virtual ~CPeripheralDisk(void) {};
};
}
using namespace PERIPHERALS;
using namespace std;
-CPeripheralHID::CPeripheralHID(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheral(type, busType, strLocation, strDeviceName.IsEmpty() ? g_localizeStrings.Get(35001) : strDeviceName, iVendorId, iProductId),
+CPeripheralHID::CPeripheralHID(const PeripheralScanResult& scanResult) :
+ CPeripheral(scanResult),
m_bInitialised(false)
{
+ m_strDeviceName = scanResult.m_strDeviceName.IsEmpty() ? g_localizeStrings.Get(35001) : scanResult.m_strDeviceName;
m_features.push_back(FEATURE_HID);
}
class CPeripheralHID : public CPeripheral
{
public:
- CPeripheralHID(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralHID(const PeripheralScanResult& scanResult);
virtual ~CPeripheralHID(void);
virtual bool InitialiseFeature(const PeripheralFeature feature);
virtual bool LookupSymAndUnicode(XBMC_keysym &keysym, uint8_t *key, char *unicode) { return false; }
volatile long CPeripheralImon::m_lCountOfImonsConflictWithDInput = 0;
-CPeripheralImon::CPeripheralImon(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheralHID(type, busType, strLocation, strDeviceName.IsEmpty() ? g_localizeStrings.Get(35001) : strDeviceName, iVendorId, iProductId)
+CPeripheralImon::CPeripheralImon(const PeripheralScanResult& scanResult) :
+ CPeripheralHID(scanResult)
{
m_features.push_back(FEATURE_IMON);
m_bImonConflictsWithDInput = false;
class CPeripheralImon : public CPeripheralHID
{
public:
- CPeripheralImon(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralImon(const PeripheralScanResult& scanResult);
virtual ~CPeripheralImon(void) {}
virtual bool InitialiseFeature(const PeripheralFeature feature);
virtual void OnSettingChanged(const CStdString &strChangedSetting);
using namespace PERIPHERALS;
using namespace std;
-CPeripheralNIC::CPeripheralNIC(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheral(type, busType, strLocation, strDeviceName.IsEmpty() ? g_localizeStrings.Get(35002) : strDeviceName, iVendorId, iProductId)
+CPeripheralNIC::CPeripheralNIC(const PeripheralScanResult& scanResult) :
+ CPeripheral(scanResult)
{
+ m_strDeviceName = scanResult.m_strDeviceName.IsEmpty() ? g_localizeStrings.Get(35002) : scanResult.m_strDeviceName;
m_features.push_back(FEATURE_NIC);
}
class CPeripheralNIC : public CPeripheral
{
public:
- CPeripheralNIC(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralNIC(const PeripheralScanResult& scanResult);
virtual ~CPeripheralNIC(void) {};
};
}
using namespace PERIPHERALS;
using namespace std;
-CPeripheralNyxboard::CPeripheralNyxboard(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheralHID(type, busType, strLocation, strDeviceName, iVendorId, iProductId)
+CPeripheralNyxboard::CPeripheralNyxboard(const PeripheralScanResult& scanResult) :
+ CPeripheralHID(scanResult)
{
m_features.push_back(FEATURE_NYXBOARD);
}
class CPeripheralNyxboard : public CPeripheralHID
{
public:
- CPeripheralNyxboard(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralNyxboard(const PeripheralScanResult& scanResult);
virtual ~CPeripheralNyxboard(void) {};
virtual bool LookupSymAndUnicode(XBMC_keysym &keysym, uint8_t *key, char *unicode);
};
using namespace PERIPHERALS;
-CPeripheralTuner::CPeripheralTuner(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- CPeripheral(type, busType, strLocation, strDeviceName, iVendorId, iProductId)
+CPeripheralTuner::CPeripheralTuner(const PeripheralScanResult& scanResult) :
+ CPeripheral(scanResult)
{
m_features.push_back(FEATURE_TUNER);
}
class CPeripheralTuner : public CPeripheral
{
public:
- CPeripheralTuner(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
+ CPeripheralTuner(const PeripheralScanResult& scanResult);
virtual ~CPeripheralTuner(void) {};
};
}