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
This commit is contained in:
Eric Kohl 2010-02-09 22:54:02 +00:00
parent 29200c4aa6
commit 5095fd3746
5 changed files with 87 additions and 47 deletions

View file

@ -1405,7 +1405,8 @@ GetParentNode:
} }
/* set the device location edit control text */ /* set the device location edit control text */
if (GetDeviceLocationString(DeviceInfoData->DevInst, if (GetDeviceLocationString(DeviceInfoSet,
DeviceInfoData,
dap->ParentDevInst, dap->ParentDevInst,
dap->szTemp, dap->szTemp,
sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))

View file

@ -181,7 +181,8 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
} }
/* get the location string */ /* get the location string */
if (GetDeviceLocationString(HwDevInfo->DevInfoData.DevInst, if (GetDeviceLocationString(HwDevInfo->ClassDevInfo->hDevInfo,
&HwDevInfo->DevInfoData,
0, 0,
szBuffer, szBuffer,
sizeof(szBuffer) / sizeof(szBuffer[0])) && sizeof(szBuffer) / sizeof(szBuffer[0])) &&

View file

@ -317,7 +317,8 @@ GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
BOOL BOOL
GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL, GetDeviceLocationString(IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN DEVINST dnParentDevInst OPTIONAL, IN DEVINST dnParentDevInst OPTIONAL,
OUT LPWSTR szBuffer, OUT LPWSTR szBuffer,
IN DWORD BufferSize) IN DWORD BufferSize)
@ -326,68 +327,104 @@ GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL,
ULONG DataSize; ULONG DataSize;
CONFIGRET cRet; CONFIGRET cRet;
LPWSTR szFormatted; LPWSTR szFormatted;
HKEY hKey;
DWORD dwSize, dwType;
BOOL Ret = FALSE; BOOL Ret = FALSE;
DataSize = BufferSize * sizeof(WCHAR); DataSize = BufferSize * sizeof(WCHAR);
szBuffer[0] = L'\0'; szBuffer[0] = L'\0';
if (dnParentDevInst != 0)
hKey = SetupDiOpenDevRegKey(DeviceInfoSet,
DeviceInfoData,
DICS_FLAG_GLOBAL,
0,
DIREG_DRV,
KEY_QUERY_VALUE);
if (hKey != INVALID_HANDLE_VALUE)
{ {
/* query the parent node name */ /* query the LocationInformationOverride value */
if (CM_Get_DevNode_Registry_Property(dnParentDevInst, dwSize = BufferSize;
CM_DRP_DEVICEDESC, if (RegQueryValueEx(hKey,
&RegDataType, L"LocationInformationOverride",
szBuffer, NULL,
&DataSize, &dwType,
0) == CR_SUCCESS && (LPBYTE)szBuffer,
RegDataType == REG_SZ && &dwSize) == ERROR_SUCCESS &&
LoadAndFormatString(hDllInstance, dwType == REG_SZ &&
IDS_DEVONPARENT, szBuffer[0] != L'\0')
&szFormatted,
szBuffer) != 0)
{ {
wcsncpy(szBuffer,
szFormatted,
BufferSize - 1);
szBuffer[BufferSize - 1] = L'\0';
LocalFree((HLOCAL)szFormatted);
Ret = TRUE; Ret = TRUE;
} }
} else
else if (dnDevInst != 0)
{
cRet = CM_Get_DevNode_Registry_Property(dnDevInst,
CM_DRP_LOCATION_INFORMATION,
&RegDataType,
szBuffer,
&DataSize,
0);
if (cRet == CR_SUCCESS && RegDataType == REG_SZ)
{ {
/* FIXME - check string for NULL termination! */ szBuffer[0] = L'\0';
Ret = TRUE;
} }
if (Ret && szBuffer[0] >= L'0' && szBuffer[0] <= L'9') RegCloseKey(hKey);
}
if (!Ret)
{
if (dnParentDevInst != 0)
{ {
/* convert the string to an integer value and create a /* query the parent node name */
formatted string */ if (CM_Get_DevNode_Registry_Property(dnParentDevInst,
ULONG ulLocation = (ULONG)wcstoul(szBuffer, CM_DRP_DEVICEDESC,
NULL, &RegDataType,
10); szBuffer,
if (LoadAndFormatString(hDllInstance, &DataSize,
IDS_LOCATIONSTR, 0) == CR_SUCCESS &&
&szFormatted, RegDataType == REG_SZ &&
ulLocation, LoadAndFormatString(hDllInstance,
szBuffer) != 0) IDS_DEVONPARENT,
&szFormatted,
szBuffer) != 0)
{ {
wcsncpy(szBuffer, wcsncpy(szBuffer,
szFormatted, szFormatted,
BufferSize - 1); BufferSize - 1);
szBuffer[BufferSize - 1] = L'\0'; szBuffer[BufferSize - 1] = L'\0';
LocalFree((HLOCAL)szFormatted); LocalFree((HLOCAL)szFormatted);
Ret = TRUE;
}
}
else if (DeviceInfoData->DevInst != 0)
{
cRet = CM_Get_DevNode_Registry_Property(DeviceInfoData->DevInst,
CM_DRP_LOCATION_INFORMATION,
&RegDataType,
szBuffer,
&DataSize,
0);
if (cRet == CR_SUCCESS && RegDataType == REG_SZ)
{
/* FIXME - check string for NULL termination! */
Ret = TRUE;
}
if (Ret && szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
{
/* convert the string to an integer value and create a
formatted string */
ULONG ulLocation = (ULONG)wcstoul(szBuffer,
NULL,
10);
if (LoadAndFormatString(hDllInstance,
IDS_LOCATIONSTR,
&szFormatted,
ulLocation,
szBuffer) != 0)
{
wcsncpy(szBuffer,
szFormatted,
BufferSize - 1);
szBuffer[BufferSize - 1] = L'\0';
LocalFree((HLOCAL)szFormatted);
}
else
Ret = FALSE;
} }
else
Ret = FALSE;
} }
} }

View file

@ -70,7 +70,8 @@ GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
IN DWORD BufferSize); IN DWORD BufferSize);
BOOL BOOL
GetDeviceLocationString(IN DEVINST dnDevInst OPTIONAL, GetDeviceLocationString(IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN DEVINST dnParentDevInst OPTIONAL, IN DEVINST dnParentDevInst OPTIONAL,
OUT LPWSTR szBuffer, OUT LPWSTR szBuffer,
IN DWORD BufferSize); IN DWORD BufferSize);

Binary file not shown.