Permalink
Browse files

changed: static calls to Keymaploader

  • Loading branch information...
1 parent 7cce1e2 commit 32912048f9a4f30374f777d18328ed58691f4459 @malard malard committed Jun 13, 2011
Showing with 27 additions and 26 deletions.
  1. +22 −21 xbmc/input/KeymapLoader.cpp
  2. +4 −4 xbmc/input/KeymapLoader.h
  3. +1 −1 xbmc/win32/WIN32USBScan.cpp
@@ -33,16 +33,13 @@ static bool parsedMappings = false;
CKeymapLoader::CKeymapLoader()
{
- if (!parsedMappings)
- {
- ParseDeviceMappings();
- }
}
void CKeymapLoader::DeviceAdded(const CStdString& deviceId)
{
+ ParseDeviceMappings();
CStdString keymapName;
- if (FindMappedDevice(deviceId, keymapName))
+ if (CKeymapLoader::FindMappedDevice(deviceId, keymapName))
{
CLog::Log(LOGDEBUG, "Switching Active Keymapping to: %s", keymapName.c_str());
g_settings.m_activeKeyboardMapping = keymapName;
@@ -51,6 +48,7 @@ void CKeymapLoader::DeviceAdded(const CStdString& deviceId)
void CKeymapLoader::DeviceRemoved(const CStdString& deviceId)
{
+ ParseDeviceMappings();
CStdString keymapName;
if (FindMappedDevice(deviceId, keymapName))
{
@@ -61,24 +59,27 @@ void CKeymapLoader::DeviceRemoved(const CStdString& deviceId)
void CKeymapLoader::ParseDeviceMappings()
{
- parsedMappings = true;
- CStdString file("special://xbmc/system/deviceidmappings.xml");
- TiXmlDocument deviceXML;
- if (!CFile::Exists(file) || !deviceXML.LoadFile(file))
- return;
+ if (!parsedMappings)
+ {
+ parsedMappings = true;
+ CStdString file("special://xbmc/system/deviceidmappings.xml");
+ TiXmlDocument deviceXML;
+ if (!CFile::Exists(file) || !deviceXML.LoadFile(file))
+ return;
- TiXmlElement *pRootElement = deviceXML.RootElement();
- if (!pRootElement || strcmpi(pRootElement->Value(), "devicemappings") != 0)
- return;
+ TiXmlElement *pRootElement = deviceXML.RootElement();
+ if (!pRootElement || strcmpi(pRootElement->Value(), "devicemappings") != 0)
+ return;
- TiXmlElement *pDevice = pRootElement->FirstChildElement("device");
- while (pDevice)
- {
- CStdString deviceId(pDevice->Attribute("id"));
- CStdString keymap(pDevice->Attribute("keymap"));
- if (!deviceId.empty() && !keymap.empty())
- deviceMappings.insert(pair<CStdString, CStdString>(deviceId.ToUpper(), keymap));
- pDevice = pDevice->NextSiblingElement("device");
+ TiXmlElement *pDevice = pRootElement->FirstChildElement("device");
+ while (pDevice)
+ {
+ CStdString deviceId(pDevice->Attribute("id"));
+ CStdString keymap(pDevice->Attribute("keymap"));
+ if (!deviceId.empty() && !keymap.empty())
+ deviceMappings.insert(pair<CStdString, CStdString>(deviceId.ToUpper(), keymap));
+ pDevice = pDevice->NextSiblingElement("device");
+ }
}
}
@@ -28,11 +28,11 @@ class CKeymapLoader
{
public:
CKeymapLoader();
- void DeviceRemoved(const CStdString& deviceID);
- void DeviceAdded(const CStdString& deviceID);
+ static void DeviceRemoved(const CStdString& deviceID);
+ static void DeviceAdded(const CStdString& deviceID);
static CStdString ParseWin32HIDName(CStdString deviceLongName);
+ static void ParseDeviceMappings();
private:
- void ParseDeviceMappings();
- bool FindMappedDevice(const CStdString& deviceId, CStdString& keymapName);
+ static bool FindMappedDevice(const CStdString& deviceId, CStdString& keymapName);
};
#endif
@@ -65,7 +65,7 @@ CWIN32USBScan::CWIN32USBScan()
detailResult = SetupDiGetDeviceInterfaceDetail(hDevHandle, &deviceInterfaceData, devicedetailData, nBufferSize , &required, NULL);
- CKeymapLoader().DeviceAdded(CKeymapLoader::ParseWin32HIDName(devicedetailData->DevicePath));
+ CKeymapLoader::DeviceAdded(CKeymapLoader::ParseWin32HIDName(devicedetailData->DevicePath));
if(!detailResult)
continue;

0 comments on commit 3291204

Please sign in to comment.