return iVal;
};
- static char *IntToHexString(int iVal)
+ static void FormatHexString(int iVal, CStdString &strHexString)
{
if (iVal < 0)
iVal = 0;
if (iVal > 65536)
iVal = 65536;
- char *buf = new char[4];
- sprintf(buf, "%04X", iVal);
- return buf;
+ strHexString.Format("%04X", iVal);
};
};
}
if (bBusMatch && bVendorMatch && bProductMatch && bClassMatch)
{
- CLog::Log(LOGDEBUG, "%s - device (%s:%s) mapped to %s (type = %s)", __FUNCTION__, PeripheralTypeTranslator::IntToHexString(iVendorId), PeripheralTypeTranslator::IntToHexString(iProductId), mapping.m_strDeviceName.c_str(), PeripheralTypeTranslator::TypeToString(mapping.m_mappedTo));
+ CStdString strVendorId, strProductId;
+ PeripheralTypeTranslator::FormatHexString(iVendorId, strVendorId);
+ PeripheralTypeTranslator::FormatHexString(iProductId, strProductId);
+ CLog::Log(LOGDEBUG, "%s - device (%s:%s) mapped to %s (type = %s)", __FUNCTION__, strVendorId.c_str(), strProductId.c_str(), mapping.m_strDeviceName.c_str(), PeripheralTypeTranslator::TypeToString(mapping.m_mappedTo));
return iMappingPtr;
}
}
m_strDeviceName(strDeviceName),
m_strFileLocation(StringUtils::EmptyString),
m_iVendorId(iVendorId),
- m_strVendorId(PeripheralTypeTranslator::IntToHexString(iVendorId)),
m_iProductId(iProductId),
- m_strProductId(PeripheralTypeTranslator::IntToHexString(iProductId)),
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());
}
m_strDeviceName(StringUtils::EmptyString),
m_strFileLocation(StringUtils::EmptyString),
m_iVendorId(0),
- m_strVendorId(PeripheralTypeTranslator::IntToHexString(0)),
+ m_strVendorId("0000"),
m_iProductId(0),
- m_strProductId(PeripheralTypeTranslator::IntToHexString(0)),
+ m_strProductId("0000"),
m_bInitialised(false),
m_bHidden(false)
{
return bReturn;
g_peripherals.GetSettingsFromMapping(*this);
- m_strSettingsFile.Format("special://profile/peripheral_data/%s_%s_%s.xml", PeripheralTypeTranslator::BusTypeToString(m_busType), m_strVendorId, m_strProductId);
+ m_strSettingsFile.Format("special://profile/peripheral_data/%s_%s_%s.xml", PeripheralTypeTranslator::BusTypeToString(m_busType), m_strVendorId.c_str(), m_strProductId.c_str());
LoadPersistedSettings();
for (unsigned int iFeaturePtr = 0; iFeaturePtr < m_features.size(); iFeaturePtr++)
const CStdString &FileLocation(void) const { return m_strFileLocation; }
const CStdString &Location(void) const { return m_strLocation; }
int VendorId(void) const { return m_iVendorId; }
- const char *VendorIdAsString(void) const { return m_strVendorId; }
+ const char *VendorIdAsString(void) const { return m_strVendorId.c_str(); }
int ProductId(void) const { return m_iProductId; }
- const char *ProductIdAsString(void) const { return m_strProductId; }
+ const char *ProductIdAsString(void) const { return m_strProductId.c_str(); }
const PeripheralType Type(void) const { return m_type; }
const PeripheralBusType GetBusType(void) const { return m_busType; };
const CStdString &DeviceName(void) const { return m_strDeviceName; }
CStdString m_strSettingsFile;
CStdString m_strFileLocation;
int m_iVendorId;
- char * m_strVendorId;
+ CStdString m_strVendorId;
int m_iProductId;
- char * m_strProductId;
+ CStdString m_strProductId;
bool m_bInitialised;
bool m_bHidden;
bool m_bError;
}
}
- CLog::Log(LOGDEBUG, "%s - initialised HID device (%s:%s)", __FUNCTION__, m_strVendorId, m_strProductId);
+ CLog::Log(LOGDEBUG, "%s - initialised HID device (%s:%s)", __FUNCTION__, m_strVendorId.c_str(), m_strProductId.c_str());
}
return CPeripheral::InitialiseFeature(feature);