Remove unnecessary try-catch block in HidLibrary

Newer HidLibrary did not work out.
Related to issue #180.
This commit is contained in:
Travis Nickles 2018-01-11 22:31:49 -06:00
parent b71b3ec820
commit fda67e7fba
2 changed files with 6 additions and 12 deletions

View File

@ -448,21 +448,15 @@ namespace DS4Windows
{ {
SafeFileHandle hidHandle; SafeFileHandle hidHandle;
try if (isExclusive)
{ {
if (isExclusive) hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
{
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
}
else
{
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
}
} }
catch (Exception) else
{ {
throw; hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
} }
return hidHandle; return hidHandle;
} }

View File

@ -11,7 +11,7 @@ C++ test application before attempting to work it into DS4Windows.~~
Currently used to delay hotplug routine Currently used to delay hotplug routine
* Attempt to remove more unused components * Attempt to remove more unused components
* ~~Tweak layout of some forms~~ * ~~Tweak layout of some forms~~
* Look into updating HidLibrary * ~~Look into updating HidLibrary~~
* ~~Trim code execution for touchpad data. Remove unneeded new calls for Touch * ~~Trim code execution for touchpad data. Remove unneeded new calls for Touch
instances. Make permanent instances and reuse those instances.~~ instances. Make permanent instances and reuse those instances.~~
* ~~Tweak SixAxis code to attempt to improve steering wheel performance * ~~Tweak SixAxis code to attempt to improve steering wheel performance