aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ellis <malard@gmail.com>2011-06-13 23:58:56 +0100
committerMartin Ellis <malard@gmail.com>2011-06-28 17:49:01 +0100
commit32912048f9a4f30374f777d18328ed58691f4459 (patch)
tree9bca78f1f9982fa5c7c317b7fabcebd17024905e
parent7cce1e2a97b08df7beb06872e353005ceab3299b (diff)
changed: static calls to Keymaploader
-rw-r--r--xbmc/input/KeymapLoader.cpp43
-rw-r--r--xbmc/input/KeymapLoader.h8
-rw-r--r--xbmc/win32/WIN32USBScan.cpp2
3 files changed, 27 insertions, 26 deletions
diff --git a/xbmc/input/KeymapLoader.cpp b/xbmc/input/KeymapLoader.cpp
index d408a114a3..529be0d777 100644
--- a/xbmc/input/KeymapLoader.cpp
+++ b/xbmc/input/KeymapLoader.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");
+ }
}
}
diff --git a/xbmc/input/KeymapLoader.h b/xbmc/input/KeymapLoader.h
index aadf6e3a5e..b731c62361 100644
--- a/xbmc/input/KeymapLoader.h
+++ b/xbmc/input/KeymapLoader.h
@@ -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 \ No newline at end of file
diff --git a/xbmc/win32/WIN32USBScan.cpp b/xbmc/win32/WIN32USBScan.cpp
index fdb5279fba..b382c3161e 100644
--- a/xbmc/win32/WIN32USBScan.cpp
+++ b/xbmc/win32/WIN32USBScan.cpp
@@ -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;