11#include " InputConfig.h"
22
33#include " Log.h"
4+ #include " utils/StringUtil.h"
45#include < pugixml/src/pugixml.hpp>
56
67// some util functions
@@ -39,19 +40,10 @@ InputType stringToInputType(const std::string& type)
3940}
4041
4142
42- std::string toLower (std::string str)
43- {
44- for (unsigned int i = 0 ; i < str.length (); i++)
45- {
46- str[i] = (char )tolower (str[i]);
47- }
48-
49- return str;
50- }
51- // end util functions
52-
5343InputConfig::InputConfig (int deviceId, const std::string& deviceName, const std::string& deviceGUID) : mDeviceId(deviceId), mDeviceName(deviceName), mDeviceGUID(deviceGUID)
5444{
45+ mVendorId = 0 ;
46+ mProductId = 0 ;
5547}
5648
5749void InputConfig::clear ()
@@ -66,19 +58,19 @@ bool InputConfig::isConfigured()
6658
6759void InputConfig::mapInput (const std::string& name, Input input)
6860{
69- mNameMap [toLower (name)] = input;
61+ mNameMap [Utils::String:: toLower (name)] = input;
7062}
7163
7264void InputConfig::unmapInput (const std::string& name)
7365{
74- auto it = mNameMap .find (toLower (name));
66+ auto it = mNameMap .find (Utils::String:: toLower (name));
7567 if (it != mNameMap .cend ())
7668 mNameMap .erase (it);
7769}
7870
7971bool InputConfig::getInputByName (const std::string& name, Input* result)
8072{
81- auto it = mNameMap .find (toLower (name));
73+ auto it = mNameMap .find (Utils::String:: toLower (name));
8274 if (it != mNameMap .cend ())
8375 {
8476 *result = it->second ;
@@ -188,7 +180,7 @@ void InputConfig::loadFromXML(pugi::xml_node& node)
188180 if (value == 0 )
189181 LOG (LogWarning) << " WARNING: InputConfig value is 0 for " << type << " " << id << " !\n " ;
190182
191- mNameMap [toLower (name)] = Input (mDeviceId , typeEnum, id, value, true );
183+ mNameMap [Utils::String:: toLower (name)] = Input (mDeviceId , typeEnum, id, value, true );
192184 }
193185}
194186
@@ -210,6 +202,11 @@ void InputConfig::writeToXML(pugi::xml_node& parent)
210202 {
211203 cfg.append_attribute (" type" ) = " joystick" ;
212204 cfg.append_attribute (" deviceName" ) = mDeviceName .c_str ();
205+ if (mVendorId && mProductId )
206+ {
207+ cfg.append_attribute (" vendorId" ) = mVendorId ;
208+ cfg.append_attribute (" productId" ) = mProductId ;
209+ }
213210 }
214211
215212 cfg.append_attribute (" deviceGUID" ) = mDeviceGUID .c_str ();
0 commit comments