Ryochan7 / DS4Windows

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

Feature Request: Option for Joy-Cons as a single controller #1892

Closed TheNewClassics closed 3 years ago

TheNewClassics commented 3 years ago

Hi DS4Windows team,

I'd like to request a feature that another program was able to implement. Is there any way to combine two joycons into being seen as one Xbox 360 controller? It's a feature that BetterJoy uses that's helpful for using the joy-cons in certain games.

Thanks for the great program!

Ryochan7 commented 3 years ago

It would be a useful option sometimes. I have never thought of a way to make merging the JoyCon data work with the current DS4Windows mapping infrastructure. I mainly use the JoyCon controllers to play games mapped to KB+M. For playing games with Xbox 360 support, I would use the Switch Pro controller instead.

For now, you would be better off disabling JoyCon support in DS4Windows (Settings > Device Options > JoyCon Controller Support) and using BetterJoy. Each JoyCon would be seen as one half of an Xbox 360 controller. BetterJoy seems to only support 4 input devices so you could only emulate 2 Xbox 360 controllers when using JoyCons.

Ryochan7 commented 3 years ago

Testing some random ideas now. Got some very basic JoyCon data merging going and I can play Metal Gear Rising: Revengeance using two JoyCons hooked to the Charging Grip. Seems okay so far. One related problem I had not thought about until starting gameplay was sending feedback data from the virtual Xbox 360 controller back to the JoyCons. As it is now, only one JoyCon vibrates. Need to find out how to split that feedback data between the two sides.

TheNewClassics commented 3 years ago

Thanks so much for taking a look. Really appreciate it! I actually didn't know you could disable JoyCon support from within the program, but I'd like to see how your testing comes along.

Ryochan7 commented 3 years ago

The force feedback issue was fairly easy to change although a better fix would be to just use multiple callbacks added to the feedback event. Gyro controls really present a big problem that I don't think can be addressed. It especially presents a big problem with a common use case that I would want with unified JoyCon support: Gyro Mouse Joystick support. When playing Halo games on the Master Chief Collection, the common control scheme was XInput mapping with Gyro mapped to Mouse Joystick outputting to RS.

Here is a diff showing what small changes I was testing.

https://gist.github.com/Ryochan7/736cbd9c488e6b6409fa4757b08f0aaf

TheNewClassics commented 3 years ago

Thanks for the continued testing. Apologies for being not more tech savy, but the issue is that the gyro controls don't work properly when the joy-cons are seen as unified?

Ryochan7 commented 3 years ago

The more I mess with it, the worse it gets. Messy messy messy.

messy_messy_messy

Got a better prototype working but it would be kind of jank as is. The gyro controls workaround would be to only run the mapper routine for one JoyCon controller and just merge the current state of the other JoyCon in that device's input thread; that is pretty much what BetterJoy does anyway. That allows all Gyro output modes to work as expected including Gyro Mouse Joystick. In most cases, the Gyro data would likely be read from JoyCon L though it would not matter when both JoyCon controllers are placed in the Charging Grip. Also, enforcing one output controller and using two force feedback loops is a pain in the butt but the current hack works; many hacks implemented in the code to make it work.

Performance feels quite a bit more snappy than BetterJoy unified JoyCon support. Unfortunately, at this point, I am doubting it would get merged in to the main code base.

Updated Gist: https://gist.github.com/Ryochan7/736cbd9c488e6b6409fa4757b08f0aaf

Ryochan7 commented 3 years ago

Cleaned up the code a bit but still don't like it much. Now support can be changed with a couple of different flags. Also, either JoyCon (L) or JoyCon (R) can be set to provide Gyro data; the current test code is set to use JoyCon (R) to provide Gyro data. It would be useful for using unified JoyCon support even while still playing with spilt controllers outside of the Charging Grip. Haven't had to play around with Gyro support in any game since starting this.

Updated Gist: https://gist.github.com/Ryochan7/736cbd9c488e6b6409fa4757b08f0aaf

Ryochan7 commented 3 years ago

Update for the day. Mostly just bug fixes and making sure merge states are used in the external Gyro routines; needed if Gyro triggers are not on JoyCon (L). Playing some Senran Kagura: Peach Beach Splash with the recent changes.

Updated Gist: https://gist.github.com/Ryochan7/736cbd9c488e6b6409fa4757b08f0aaf

Ryochan7 commented 3 years ago

Throwing caution to the wind. The changes have been merged into the jay branch. The JoyCon default is now to map both controllers to one virtual Xbox 360 or DS4 controller; BetterJoy uses Joined mode by default if it detects more than 1 JoyCon. There is still an option to use each JoyCon separately (Split link mode) that can be found in the Device Options section. When using Joined link mode, JoyCon R is used to provide Gyro data by default but you can change it to allow JoyCon L to provide Gyro data instead.

With these changes in place, at some point, I should play Halo ODST and Halo 4 from the Master Chief Collection.

TheNewClassics commented 3 years ago

Thanks so much Ryochan, really appreciate you taking the time and energy to make this happen!

Ryochan7 commented 3 years ago

This issue can now be closed. Ended up playing through Story mode in Peach Beach Splash. Made a short video just showing off some gameplay. Mixed input with Gyro Mouse worked out pretty well.

Peach Beach Splash played with Joined JoyCons: https://www.youtube.com/watch?v=bko0I6idhCI

AnufrievDE commented 3 years ago

Apologies if was inattentive, but I can't find any guide elsewhere:

How to configure joycons pair to show up as xinput device in ds4windows? How to achive motion control(gyro data) captured from both left and right joycons and transmitted via udp server? (to be able to play games with motion control at switch emulators)