Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Commit f9338f2

Browse files
committed
Change SetupAPI calls used to grab device information. Needed for fake USB DS4 device
Not my fault after all. No help
1 parent 244ed4e commit f9338f2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

DS4Windows/DS4Control/ScpUtil.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,10 @@ internal static string GetStringDeviceProperty(string deviceInstanceId,
11021102

11031103
Guid hidGuid = new Guid();
11041104
NativeMethods.HidD_GetHidGuid(ref hidGuid);
1105-
IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(IntPtr.Zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
1106-
NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
1105+
//IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(IntPtr.Zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
1106+
IntPtr deviceInfoSet = NativeMethods.SetupDiCreateDeviceInfoList(IntPtr.Zero, 0);
1107+
//NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
1108+
NativeMethods.SetupDiOpenDeviceInfo(deviceInfoSet, deviceInstanceId, IntPtr.Zero, 0, ref deviceInfoData);
11071109
NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref prop, ref propertyType,
11081110
null, 0, ref requiredSize, 0);
11091111

@@ -1244,8 +1246,10 @@ internal static string[] GetStringArrayDeviceProperty(string deviceInstanceId,
12441246
var requiredSize = 0;
12451247

12461248
IntPtr zero = IntPtr.Zero;
1247-
IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
1248-
NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
1249+
//IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
1250+
IntPtr deviceInfoSet = NativeMethods.SetupDiCreateDeviceInfoList(IntPtr.Zero, 0);
1251+
//NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
1252+
NativeMethods.SetupDiOpenDeviceInfo(deviceInfoSet, deviceInstanceId, IntPtr.Zero, 0, ref deviceInfoData);
12491253
NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref prop, ref propertyType,
12501254
null, 0, ref requiredSize, 0);
12511255

DS4Windows/HidLibrary/NativeMethods.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,15 @@ public static extern bool SetupDiGetDeviceInterfaceProperty(IntPtr deviceInfo, r
339339
[DllImport("setupapi.dll")]
340340
internal static extern int SetupDiCreateDeviceInfoList(ref Guid classGuid, int hwndParent);
341341

342+
[DllImport("setupapi.dll")]
343+
internal static extern IntPtr SetupDiCreateDeviceInfoList(IntPtr guid, int hwndParent);
344+
342345
[DllImport("setupapi.dll")]
343346
static internal extern int SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
344347

348+
[DllImport("setupapi.dll")]
349+
internal static extern bool SetupDiOpenDeviceInfo(IntPtr deviceInfoSet, string deviceInstanceId, IntPtr parent, uint flags, ref SP_DEVINFO_DATA deviceInfoData);
350+
345351
[DllImport("setupapi.dll")]
346352
static internal extern bool SetupDiEnumDeviceInterfaces(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData);
347353

0 commit comments

Comments
 (0)