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

Commit

Permalink
Change SetupAPI calls used to grab device information. Needed for fak…
Browse files Browse the repository at this point in the history
…e USB DS4 device

Not my fault after all. No help
  • Loading branch information
Ryochan7 committed Sep 26, 2023
1 parent 244ed4e commit f9338f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions DS4Windows/DS4Control/ScpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,10 @@ internal static string GetStringDeviceProperty(string deviceInstanceId,

Guid hidGuid = new Guid();
NativeMethods.HidD_GetHidGuid(ref hidGuid);
IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(IntPtr.Zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
//IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(IntPtr.Zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
IntPtr deviceInfoSet = NativeMethods.SetupDiCreateDeviceInfoList(IntPtr.Zero, 0);
//NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
NativeMethods.SetupDiOpenDeviceInfo(deviceInfoSet, deviceInstanceId, IntPtr.Zero, 0, ref deviceInfoData);
NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref prop, ref propertyType,
null, 0, ref requiredSize, 0);

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

IntPtr zero = IntPtr.Zero;
IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
//IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(zero, deviceInstanceId, 0, extraFlags | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
IntPtr deviceInfoSet = NativeMethods.SetupDiCreateDeviceInfoList(IntPtr.Zero, 0);
//NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, 0, ref deviceInfoData);
NativeMethods.SetupDiOpenDeviceInfo(deviceInfoSet, deviceInstanceId, IntPtr.Zero, 0, ref deviceInfoData);
NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref prop, ref propertyType,
null, 0, ref requiredSize, 0);

Expand Down
6 changes: 6 additions & 0 deletions DS4Windows/HidLibrary/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,15 @@ public static extern bool SetupDiGetDeviceInterfaceProperty(IntPtr deviceInfo, r
[DllImport("setupapi.dll")]
internal static extern int SetupDiCreateDeviceInfoList(ref Guid classGuid, int hwndParent);

[DllImport("setupapi.dll")]
internal static extern IntPtr SetupDiCreateDeviceInfoList(IntPtr guid, int hwndParent);

[DllImport("setupapi.dll")]
static internal extern int SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);

[DllImport("setupapi.dll")]
internal static extern bool SetupDiOpenDeviceInfo(IntPtr deviceInfoSet, string deviceInstanceId, IntPtr parent, uint flags, ref SP_DEVINFO_DATA deviceInfoData);

[DllImport("setupapi.dll")]
static internal extern bool SetupDiEnumDeviceInterfaces(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData);

Expand Down

0 comments on commit f9338f2

Please sign in to comment.