diff --git a/DS4Windows/DS4Control/HidHideAPIDevice.cs b/DS4Windows/DS4Control/HidHideAPIDevice.cs index 884ba5d57d..dd2635560e 100644 --- a/DS4Windows/DS4Control/HidHideAPIDevice.cs +++ b/DS4Windows/DS4Control/HidHideAPIDevice.cs @@ -52,6 +52,28 @@ public bool GetActiveState() return result; } + public bool SetActiveState(bool state) + { + bool result = false; + + unsafe + { + int bytesReturned = 0; + NativeMethods.DeviceIoControl(hidHideHandle.DangerousGetHandle(), + HidHideAPIDevice.IOCTL_SET_ACTIVE, + new IntPtr(&state), + 1, + IntPtr.Zero, + 0, + ref bytesReturned, + IntPtr.Zero); + + //int error = Marshal.GetLastWin32Error(); + } + + return result; + } + public List GetBlacklist() { List instances = new List(); @@ -94,6 +116,29 @@ public List GetBlacklist() return instances; } + public bool SetBlacklist(List instances) + { + bool result = false; + int bytesReturned = 0; + IntPtr inBuffer = + StringListToMultiSzPointer(instances, out int inBufferLength); + + result = NativeMethods.DeviceIoControl(hidHideHandle.DangerousGetHandle(), + IOCTL_SET_BLACKLIST, + inBuffer, + inBufferLength, + IntPtr.Zero, + 0, + ref bytesReturned, + IntPtr.Zero); + + //int error = Marshal.GetLastWin32Error(); + // Free buffer returned from StringListToMultiSzPointer + Marshal.FreeHGlobal(inBuffer); + + return result; + } + public List GetWhitelist() { List instances = new List(); @@ -153,6 +198,7 @@ public bool SetWhitelist(List instances) IntPtr.Zero); //int error = Marshal.GetLastWin32Error(); + // Free buffer returned from StringListToMultiSzPointer Marshal.FreeHGlobal(inBuffer); return result;