Skip to content

Commit 5095fd3

Browse files
committed
Implement device location information override support and add the location override value for PS/2 mice. PS/2 keyboards be added next.
Please translate the location override string. svn path=/trunk/; revision=45541
1 parent 29200c4 commit 5095fd3

File tree

5 files changed

+87
-47
lines changed

5 files changed

+87
-47
lines changed

reactos/dll/win32/devmgr/advprop.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,8 @@ UpdateDevInfo(IN HWND hwndDlg,
14051405
}
14061406

14071407
/* set the device location edit control text */
1408-
if (GetDeviceLocationString(DeviceInfoData->DevInst,
1408+
if (GetDeviceLocationString(DeviceInfoSet,
1409+
DeviceInfoData,
14091410
dap->ParentDevInst,
14101411
dap->szTemp,
14111412
sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))

reactos/dll/win32/devmgr/hwpage.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
181181
}
182182

183183
/* get the location string */
184-
if (GetDeviceLocationString(HwDevInfo->DevInfoData.DevInst,
184+
if (GetDeviceLocationString(HwDevInfo->ClassDevInfo->hDevInfo,
185+
&HwDevInfo->DevInfoData,
185186
0,
186187
szBuffer,
187188
sizeof(szBuffer) / sizeof(szBuffer[0])) &&

reactos/dll/win32/devmgr/misc.c

Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
317317

318318

319319
BOOL
320-
GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL,
320+
GetDeviceLocationString(IN HDEVINFO DeviceInfoSet,
321+
IN PSP_DEVINFO_DATA DeviceInfoData,
321322
IN DEVINST dnParentDevInst OPTIONAL,
322323
OUT LPWSTR szBuffer,
323324
IN DWORD BufferSize)
@@ -326,68 +327,104 @@ GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL,
326327
ULONG DataSize;
327328
CONFIGRET cRet;
328329
LPWSTR szFormatted;
330+
HKEY hKey;
331+
DWORD dwSize, dwType;
329332
BOOL Ret = FALSE;
330333

331334
DataSize = BufferSize * sizeof(WCHAR);
332335
szBuffer[0] = L'\0';
333-
if (dnParentDevInst != 0)
336+
337+
hKey = SetupDiOpenDevRegKey(DeviceInfoSet,
338+
DeviceInfoData,
339+
DICS_FLAG_GLOBAL,
340+
0,
341+
DIREG_DRV,
342+
KEY_QUERY_VALUE);
343+
if (hKey != INVALID_HANDLE_VALUE)
334344
{
335-
/* query the parent node name */
336-
if (CM_Get_DevNode_Registry_Property(dnParentDevInst,
337-
CM_DRP_DEVICEDESC,
338-
&RegDataType,
339-
szBuffer,
340-
&DataSize,
341-
0) == CR_SUCCESS &&
342-
RegDataType == REG_SZ &&
343-
LoadAndFormatString(hDllInstance,
344-
IDS_DEVONPARENT,
345-
&szFormatted,
346-
szBuffer) != 0)
345+
/* query the LocationInformationOverride value */
346+
dwSize = BufferSize;
347+
if (RegQueryValueEx(hKey,
348+
L"LocationInformationOverride",
349+
NULL,
350+
&dwType,
351+
(LPBYTE)szBuffer,
352+
&dwSize) == ERROR_SUCCESS &&
353+
dwType == REG_SZ &&
354+
szBuffer[0] != L'\0')
347355
{
348-
wcsncpy(szBuffer,
349-
szFormatted,
350-
BufferSize - 1);
351-
szBuffer[BufferSize - 1] = L'\0';
352-
LocalFree((HLOCAL)szFormatted);
353356
Ret = TRUE;
354357
}
355-
}
356-
else if (dnDevInst != 0)
357-
{
358-
cRet = CM_Get_DevNode_Registry_Property(dnDevInst,
359-
CM_DRP_LOCATION_INFORMATION,
360-
&RegDataType,
361-
szBuffer,
362-
&DataSize,
363-
0);
364-
if (cRet == CR_SUCCESS && RegDataType == REG_SZ)
358+
else
365359
{
366-
/* FIXME - check string for NULL termination! */
367-
Ret = TRUE;
360+
szBuffer[0] = L'\0';
368361
}
369362

370-
if (Ret && szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
363+
RegCloseKey(hKey);
364+
}
365+
366+
367+
if (!Ret)
368+
{
369+
if (dnParentDevInst != 0)
371370
{
372-
/* convert the string to an integer value and create a
373-
formatted string */
374-
ULONG ulLocation = (ULONG)wcstoul(szBuffer,
375-
NULL,
376-
10);
377-
if (LoadAndFormatString(hDllInstance,
378-
IDS_LOCATIONSTR,
379-
&szFormatted,
380-
ulLocation,
381-
szBuffer) != 0)
371+
/* query the parent node name */
372+
if (CM_Get_DevNode_Registry_Property(dnParentDevInst,
373+
CM_DRP_DEVICEDESC,
374+
&RegDataType,
375+
szBuffer,
376+
&DataSize,
377+
0) == CR_SUCCESS &&
378+
RegDataType == REG_SZ &&
379+
LoadAndFormatString(hDllInstance,
380+
IDS_DEVONPARENT,
381+
&szFormatted,
382+
szBuffer) != 0)
382383
{
383384
wcsncpy(szBuffer,
384385
szFormatted,
385386
BufferSize - 1);
386387
szBuffer[BufferSize - 1] = L'\0';
387388
LocalFree((HLOCAL)szFormatted);
389+
Ret = TRUE;
390+
}
391+
}
392+
else if (DeviceInfoData->DevInst != 0)
393+
{
394+
cRet = CM_Get_DevNode_Registry_Property(DeviceInfoData->DevInst,
395+
CM_DRP_LOCATION_INFORMATION,
396+
&RegDataType,
397+
szBuffer,
398+
&DataSize,
399+
0);
400+
if (cRet == CR_SUCCESS && RegDataType == REG_SZ)
401+
{
402+
/* FIXME - check string for NULL termination! */
403+
Ret = TRUE;
404+
}
405+
406+
if (Ret && szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
407+
{
408+
/* convert the string to an integer value and create a
409+
formatted string */
410+
ULONG ulLocation = (ULONG)wcstoul(szBuffer,
411+
NULL,
412+
10);
413+
if (LoadAndFormatString(hDllInstance,
414+
IDS_LOCATIONSTR,
415+
&szFormatted,
416+
ulLocation,
417+
szBuffer) != 0)
418+
{
419+
wcsncpy(szBuffer,
420+
szFormatted,
421+
BufferSize - 1);
422+
szBuffer[BufferSize - 1] = L'\0';
423+
LocalFree((HLOCAL)szFormatted);
424+
}
425+
else
426+
Ret = FALSE;
388427
}
389-
else
390-
Ret = FALSE;
391428
}
392429
}
393430

reactos/dll/win32/devmgr/precomp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
7070
IN DWORD BufferSize);
7171

7272
BOOL
73-
GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL,
73+
GetDeviceLocationString(IN HDEVINFO DeviceInfoSet,
74+
IN PSP_DEVINFO_DATA DeviceInfoData,
7475
IN DEVINST dnParentDevInst OPTIONAL,
7576
OUT LPWSTR szBuffer,
7677
IN DWORD BufferSize);

reactos/media/inf/msmouse.inf

334 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)