Permalink
Browse files

added: static method to convert DevicePath into 'standardised' HIDNam…

…e for Win32
  • Loading branch information...
1 parent 942afac commit 7cce1e2a97b08df7beb06872e353005ceab3299b @malard malard committed Jun 13, 2011
@@ -91,4 +91,9 @@ bool CKeymapLoader::FindMappedDevice(const CStdString& deviceId, CStdString& key
keymapName = deviceIdIt->second;
return true;
+}
+
+CStdString CKeymapLoader::ParseWin32HIDName(CStdString deviceLongName)
+{
+ return deviceLongName.Mid(deviceLongName.find_last_of('\\')+1, deviceLongName.find_last_of('#') - deviceLongName.find_last_of('\\'));
}
@@ -22,13 +22,17 @@
#include <map>
#include "utils/StdString.h"
+#ifndef KEYMAP_LOADER
+#define KEYMAP_LOADER
class CKeymapLoader
{
public:
CKeymapLoader();
void DeviceRemoved(const CStdString& deviceID);
void DeviceAdded(const CStdString& deviceID);
+ static CStdString ParseWin32HIDName(CStdString deviceLongName);
private:
void ParseDeviceMappings();
bool FindMappedDevice(const CStdString& deviceId, CStdString& keymapName);
-};
+};
+#endif
@@ -65,10 +65,7 @@ CWIN32USBScan::CWIN32USBScan()
detailResult = SetupDiGetDeviceInterfaceDetail(hDevHandle, &deviceInterfaceData, devicedetailData, nBufferSize , &required, NULL);
- CStdString dbcc_name(devicedetailData->DevicePath);
- dbcc_name = dbcc_name.Mid(dbcc_name.find_last_of('\\')+1, dbcc_name.find_last_of('#') - dbcc_name.find_last_of('\\'));
-
- CKeymapLoader().DeviceAdded(dbcc_name);
+ CKeymapLoader().DeviceAdded(CKeymapLoader::ParseWin32HIDName(devicedetailData->DevicePath));
if(!detailResult)
continue;
@@ -32,6 +32,7 @@
#include "windowing/WindowingFactory.h"
#include <dbt.h>
#include "guilib/LocalizeStrings.h"
+#include "input/KeymapLoader.h"
#include "input/KeyboardStat.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/GUIControl.h" // for EVENT_RESULT
@@ -653,7 +654,7 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
{
PDEV_BROADCAST_DEVICEINTERFACE b = (PDEV_BROADCAST_DEVICEINTERFACE) lParam;
CStdString dbcc_name(b->dbcc_name);
- dbcc_name = dbcc_name.Mid(dbcc_name.find_last_of('\\')+1, dbcc_name.find_last_of('#') - dbcc_name.find_last_of('\\'));
+ dbcc_name = CKeymapLoader::ParseWin32HIDName(b->dbcc_name);
switch (wParam)
{
case DBT_DEVICEARRIVAL:

0 comments on commit 7cce1e2

Please sign in to comment.