mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 02:54:20 +01:00
First step to change how ScpVBus installation is checked
Related to issue #147.
This commit is contained in:
parent
b10b7af7d1
commit
618c139607
@ -293,6 +293,37 @@ namespace DS4Windows
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
public static bool IsScpVBusInstalled()
|
||||
{
|
||||
bool result = false;
|
||||
Guid sysGuid = Guid.Parse("{4d36e97d-e325-11ce-bfc1-08002be10318}");
|
||||
NativeMethods.SP_DEVINFO_DATA deviceInfoData = new NativeMethods.SP_DEVINFO_DATA();
|
||||
deviceInfoData.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(deviceInfoData);
|
||||
var dataBuffer = new byte[4096];
|
||||
ulong propertyType = 0;
|
||||
var requiredSize = 0;
|
||||
IntPtr deviceInfoSet = NativeMethods.SetupDiGetClassDevs(ref sysGuid, "", 0, NativeMethods.DIGCF_PRESENT | NativeMethods.DIGCF_DEVICEINTERFACE | NativeMethods.DIGCF_ALLCLASSES);
|
||||
for (int i = 0; !result && NativeMethods.SetupDiEnumDeviceInfo(deviceInfoSet, i, ref deviceInfoData); i++)
|
||||
{
|
||||
if (NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref NativeMethods.DEVPKEY_Device_HardwareIds, ref propertyType,
|
||||
dataBuffer, dataBuffer.Length, ref requiredSize, 0))
|
||||
{
|
||||
string hardwareId = dataBuffer.ToUTF16String();
|
||||
//if (hardwareIds.Contains("Scp Virtual Bus Driver"))
|
||||
// result = true;
|
||||
if (hardwareId.Equals(@"root\ScpVBus"))
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceInfoSet.ToInt64() != NativeMethods.INVALID_HANDLE_VALUE)
|
||||
{
|
||||
NativeMethods.SetupDiDestroyDeviceInfoList(deviceInfoSet);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static event EventHandler<EventArgs> ControllerStatusChange; // called when a controller is added/removed/battery or touchpad mode changes/etc.
|
||||
public static void ControllerStatusChanged(object sender)
|
||||
{
|
||||
|
@ -709,7 +709,8 @@ namespace DS4Windows
|
||||
bool deriverinstalled = false;
|
||||
try
|
||||
{
|
||||
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");
|
||||
deriverinstalled = Global.IsScpVBusInstalled();
|
||||
/*ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");
|
||||
|
||||
foreach (ManagementObject obj in searcher.Get())
|
||||
{
|
||||
@ -723,6 +724,7 @@ namespace DS4Windows
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
*/
|
||||
|
||||
if (!deriverinstalled)
|
||||
{
|
||||
|
@ -229,7 +229,10 @@ namespace DS4Windows
|
||||
internal static DEVPROPKEY DEVPKEY_Device_BusReportedDeviceDesc =
|
||||
new DEVPROPKEY { fmtid = new Guid(0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2), pid = 4 };
|
||||
|
||||
[DllImport("setupapi.dll", EntryPoint = "SetupDiGetDeviceRegistryProperty")]
|
||||
internal static DEVPROPKEY DEVPKEY_Device_HardwareIds =
|
||||
new DEVPROPKEY { fmtid = new Guid(0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0), pid = 3 };
|
||||
|
||||
[DllImport("setupapi.dll", EntryPoint = "SetupDiGetDeviceRegistryProperty")]
|
||||
public static extern bool SetupDiGetDeviceRegistryProperty(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, int propertyVal, ref int propertyRegDataType, byte[] propertyBuffer, int propertyBufferSize, ref int requiredSize);
|
||||
|
||||
[DllImport("setupapi.dll", EntryPoint = "SetupDiGetDevicePropertyW", SetLastError = true)]
|
||||
|
Loading…
Reference in New Issue
Block a user