Ryochan7 / DS4Windows

Like those other ds4tools, but sexier
https://ryochan7.github.io/ds4windows-site/
GNU General Public License v3.0
6.95k stars 807 forks source link

ds4 exclusive issue #118

Closed Joonleumas closed 6 years ago

Joonleumas commented 7 years ago

checked log file still having issue with it any solution. noobie here..

Ryochan7 commented 7 years ago

Getting exclusive access to the DS4 has always been a bit finicky. Do you have any gaming applications open while using DS4Windows such as Steam, UPlay, Origin, Nvidia Share, etc.? I normally don't have problems with exclusive mode working while Steam is open but there is the odd occasion that exclusive access cannot be obtained without having to disconnect and then re-connect.

apoklyps3 commented 7 years ago

Ryochan can you please add close app/apps after disconnection of the pad to work around this? For example we disable Steam at startup and we set it up to launch with a profile. Once we disconnect the pad steam.exe get's killed in order to gain exclusive mode when we connect the controller.

Ryochan7 commented 7 years ago

That seems like it would be a bit intrusive. What I would like to try instead is just attempt to obtain the exclusive lock multiple times before giving up. Also having an option in the GUI to attempt obtaining exclusive access might be helpful.

TristanYoung commented 7 years ago

It's too bad there's no way to determine what exactly has an exclusive lock on the gamepad. Would help us figure out what is behaving badly.

While I have Steam and Origin installed on my machine, they aren't running automatically, and I still get this warning. I suspect a recent change Microsoft has made, perhaps to make Windows 10 more into an OS favorable to gaming is to blame. Perhaps Windows 10's game bar - the one where you can activate game mode, turn on the screen recording, etc.

I'm running Windows 10 insider preview on the fast ring, so my OS is a bit more up-to-date (read: broken) than the average user's.

TristanYoung commented 6 years ago

Maybe there's a solution to get exclusive access reliably.

Currently we run ds4windows as a program upon startup. Unless we load it first, other programs can potentially open the DS4 and we lose exclusivity.

What if we could take care of DS4 exclusive access at the service level?

I was checking out the inputmapper project, and notice they are now using something called HID Guardian, which I believe may attempt to lock the DS4 for exclusive access early on in the system boot, and maybe even after the DS4 has been disconnected/turned off.

I imagine there is some sort of hand-off of the DS4 occurring when the main binary is being executed.

What do you think Ryochan7?

evilC commented 6 years ago

Are you guys trying to stop everything but DS4Windows from being able to see the DS4?
HidGuardian can do this.
I have a simple little utility written in AHK that can do the HG install and handle the whitelisting for you, you can find it here

Ryochan7 commented 6 years ago

The old method of disabling and re-enabling a device is being used when exclusive access cannot be obtained the first time. A couple of months ago, I tried HIDGuardian with WhiteKnight. It did its job during testing. However, using HIDGuardian for the HID device added unwanted input lag. I don't know if HIDGuardian is not carrying over parameters passed to CreateFile or what might be causing that behavior.

One standard that I have maintained while working on DS4Windows is that any potential feature that will add noticeable input lag is a feature not worth adding. I will have to test HIDGuardian again soon but any possible use of HIDGuardian will not happen if the input lag issue is not resolved.

nefarius commented 6 years ago

Maybe it really needs some more tweaks, I can't really tell since it's been month since I benched it last.

TristanYoung commented 6 years ago

I still get exclusive access issues, not every time though.

What about writing our own service that loads early on in the boot to open and lock the devices, only giving them up when it gets the signal to release, and then taking them back when getting the re-lock signal? If possible, shouldn't introduce in-game latency.

I don't know if such a thing can be done (not a coder). I'm just trying to think of a solution that doesn't involve HIDGuardian, of course without even knowing how it work ;)

Ryochan7 commented 6 years ago

I just tried that latest stable release of HIDGuardian. This time, I did not install HidCerberus and I did not need to use WhiteKnight because I now know where the whitelist registry keys are stored. I still ran into the same added input lag while HIDGuardian is active. The input lag went away once I removed a controller from AffectedDevices and hotplugged the device.

evilC commented 6 years ago

Let's hope @nefarius can find some time to look at it. Thanks for the heads up.

nefarius commented 6 years ago

Keep me reminded, I tend to... well... forget 😬

Ryochan7 commented 6 years ago

I fiddled around with the HidGuardian source code a bit and I think I got performance more in line with what I would want. More testing will need to be done.

https://gist.github.com/Ryochan7/94e1f73631b637e46f62f3a791520d28

nefarius commented 6 years ago

Oh f00p me, how could I forget that call... Thanks, will commit it on my end. HidGuardian was a bit of a rushed job and it shows.

Ryochan7 commented 6 years ago

I am still not sure why the use of WdfRequestFormatRequestUsingCurrentType was needed in Queue.c but it seems to be necessary. My main test apps lately have been the PC port of Gex from GOG and Dead or Alive 5: Last Round. Looking forward to trying this out while playing .hack//G.U. Last Recode when it finally releases.

nefarius commented 6 years ago

It is necessary because of IRP stack voodoo. Nice to see an active use-case.

Ryochan7 commented 6 years ago

HidGuardian has been working fine so far. Creating the whitelist key when DS4Windows is started would make the process a bit more convenient. It is a little inconvenient to get the PID from Task Manager and rename the whitelist key manually.

nefarius commented 6 years ago

That's what the Cerberus service is for :P

Ryochan7 commented 6 years ago

Cerberus is a good service but I don't think I want to have DS4Windows depend on it. I ended up creating a couple of small methods to handle managing the whitelist key.

nefarius commented 6 years ago

I've fixed the driver. Any suggestions on black/white-list improvements which may simplify your goals?

Ryochan7 commented 6 years ago

I don't have any suggestions. Right now, I am not sure if HidCerberus should be used in DS4Windows or if I will just require DS4Windows to run as admin in future releases. I almost always run DS4Windows as the admin.

On Nov 12, 2017 2:52 PM, "Benjamin Höglinger" notifications@github.com wrote:

I've fixed the driver. Any suggestions on black/white-list improvements which may simplify your goals?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/Ryochan7/DS4Windows/issues/118#issuecomment-343766680, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjhUKFecGDEfFd1cFg1GplIG60ntO44ks5s11p7gaJpZM4PacQc .

Ryochan7 commented 6 years ago

Some better end user documentation would be extremely useful for people who want to use HidGuardian. People using InputMapper have experienced continued exclusive mode problems because the users did not know how to customize HidGuardian and Wobbles being MIA for the most part. Luckily IM users ended up working out their own problems to include support for the DS4 version 2 controller in the included AffectedDevices key.

nefarius commented 6 years ago

Even BETTER documentation!? I don't think that's possible 🤣

Ryochan7 commented 6 years ago

https://github.com/nefarius/ViGEm/issues/65

https://inputmapper.com/forum/inputmapper-1-5-support/723-exclusive-mode-ps4-version-2-controller-problems

Here are a couple of links showing that your theory is not correct. Honestly, just posting the full default locations of the registry keys used by HidGuardian, mainly so that it can indexed by search engines, would be a good addition. I looked through the available documentation before but I had to look through the source code to find the key locations.

On Nov 24, 2017 1:43 PM, "Benjamin Höglinger" notifications@github.com wrote:

Even BETTER documentation!? I don't think that's possible 🤣

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Ryochan7/DS4Windows/issues/118#issuecomment-346888222, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjhUC1CQZ39FmFYJj_irMbmpBddjhZDks5s5xxegaJpZM4PacQc .

nefarius commented 6 years ago

I was joking. I know my docs are terrible.

SeemsFishy commented 6 years ago

So, as far as I can understand your conversation...

New HidGuardian version does not add any additional input lag? How can I update HidGuardian if I am using evilC tool, which he linked earlier - https://autohotkey.com/boards/viewtopic.php?t=34890

Sorry about that stupid questions, I am noob at this "compiling from source and installing" on Windows. Used to do that on Linux and it was way more friendly without any needs to install massive stuff like VStudio.

Anyways, I am just trying to get my Official Wireless Adapter works on the last Windows 10 build.

And thank you very much for you hard job that makes as happy!

evilC commented 6 years ago

If using WhiteKnight, in the Resources folder there is a HidGuardian folder. First you should probably uninstall HG using WK, then overwrite the HG files in the resources folder with new ones, then reinstall. However, I see no official release from Nefarius yet, so I would imagine if you wanted latest changes, you would need to build it yourself in VS.

On 28 November 2017 at 09:32, SeemsFishy notifications@github.com wrote:

So, as far as I can understand your conversation...

New HidGuardian version does not add any additional input lag? How can I update HidGuardian if I am using evilC tool, which he linked earlier - https://autohotkey.com/boards/viewtopic.php?t=34890

Sorry for stupid questions, I am noob at this "compiling from source and installing" on Windows. Used to do that on Linux and it was way more friendly without any needs to install massive stuff like VStudio.

Anyways, I am just trying to get my Official Wireless Adapter works on the last Windows 10 build.

And thank you very much for you hard job that makes as happy!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Ryochan7/DS4Windows/issues/118#issuecomment-347464814, or mute the thread https://github.com/notifications/unsubscribe-auth/ABo8hDa74YmcTzq-RwRUMFs4IDIjHdvoks5s69MQgaJpZM4PacQc .

SeemsFishy commented 6 years ago

That is exactly what I was thinking. The source files are updated, but that is all.

evilC commented 6 years ago

I am pinging Nefarius now in our Discord channel, will see if we can get something sorted today one way or another.

Ryochan7 commented 6 years ago

To use it now, you would have to compile the driver and run Windows in test mode.

SeemsFishy commented 6 years ago

Ok. Thank you very much for your answers. I guess I should wait for release for now.

Ryochan7, can you explain please how exactly did you measure input lag and how much additional lag HIDGuardian adds?

Ryochan7 commented 6 years ago

Other than the input delay time posted in the interface, the main test that I usually use to test input lag is just a matter of launching a game and finding out how quickly an action occurs from a button press. I don't have any decent method to quantify how much input lag was added with HidGuardian initially. It seemed like several frames of input lag and it was enough added lag for me to not want to use HidGuardian before.

Two main games that I have been using for input lag testing is the PC version of Gex and Dead or Alive 5. I end up having to play test often since even some minor changes in the DS4Windows source code can impact performance enough to feel it.

paulo-lima-dev commented 6 years ago

I'm a bit out of the loop here so is HidGuardian a future part of DS4Windows, or is it a standalone app? I found more them one HidGuardian application on the web so not sure if they are all the same thing.

SeemsFishy commented 6 years ago

Current DS4Windows release does not use HidGuardian driver.

Ryochan7 commented 6 years ago

DS4Windows has minimal support for HidGuardian when it is run as admin. At some point, the CheckDrivers routine should get updated to check for HidGuardian and DS4Windows should write a default AffectedDevices file if the registry key cannot be found.

https://downloads.vigem.org

https://github.com/nefarius/ViGEm/tree/master/Sys/HidGuardian

ceedveed commented 6 years ago

Is this exclusive mode issue what I've been experiencing when uPlay games and Cuphead freeze when launched? I'm using 1.4.108 and I need to close DS4Windows before launching a uPlay game and Cuphead. I suppose other games may have this problem as well.

Ryochan7 commented 6 years ago

The only games that I have that utilize uPlay are Rocksmith 2014 and Assassin's Creed 3. For me, the exclusive mode hack has worked out fine so I have not had problems with either game. I can take a look and see if anything happens in shared mode beyond duplicate button presses. If that isn't the issue, the problem might be with ScpVBus.

You might want to try to use shared mode instead and see if the problem might be due to the quick disabling and re-enabling of the HID device rather than two devices being present.

Ryusennin commented 6 years ago

I have a similar issue since J2K's versions.

UPlay's launcher will freeze for several seconds when DS4Windows is running in exclusive mode. I can either wait or unplug/replug the controller to cut down on the freezing duration.

Even more stranger, the same happens with any web browser and kickstarter.com. When accessing this site, not only the browser but the whole OS interface will freeze until I unplug the controller. It doesn't happen if DS4Windows is not running.

Ryochan7 commented 6 years ago

Tried this out. Can't get exclusive mode to work while uPlay is active. I did not run into any freezing problems though.

I have not run into any freezing problems with DS4Windows ever since implementing overlapped IO in the early days of this fork.

djanthony93 commented 6 years ago

Any exclusive mode fix? No matter how many times I Start/Stop or re-open DS4W, It won't go out of Shared mode

GingerAdonis commented 6 years ago

@djanthony93 Make sure to run DS4Windows as administrator and that the 'Hide DS4 controller' setting is enabled.

Ryusennin commented 6 years ago

Just a note to mention that HID Guardian completely solved my freezing issues with the UPlay launcher and also Kickstarter.com (why would this website call the gamepad browser API in the first place is still a mystery). I haven't noticed any additional lag compared to the old exclusive hack.

Ryochan7 commented 6 years ago

Are you using Firefox as your primary browser? I think I have encountered times when Firefox would keep exclusive mode from working in DS4Windows a fair time after closing HTML5 Gamepad Tester. It has been a while since I have run into a problem like that though. Also, I primarily use Brave nowadays.

Ryochan7 commented 6 years ago

I just tried this and the same problem was experienced when using either Firefox or Brave. I have experimented with the exclusive mode routine a little bit and I might have something that could work around this problem. The change made was removing the delay between disabling and re-enabling a device and then adding a delay after the re-enable step. It needs more testing to see if the change would work with game applications but it has worked with Steam so far.

Ryochan7 commented 6 years ago

Test build:

http://ryochan7.xyz/ds4windows/test/DS4Windows_Test_x64_20180227.zip

anphetamina commented 6 years ago

I use Chrome. I'm wondering if Parsec gaming and its 360 virtual drivers will cause conflict with the Scp ones. I get input lags issues every update, I need to re-done the entire clean installation procedure (even driver install) to make it work as before.