r57zone / DualShock4-emulator

DualShock4 emulation for Xbox controllers or keyboard and mouse / Эмуляция DualShock4 для Xbox контроллеров или клавиатуры и мыши
https://youtu.be/17hY1zTqoYQ
The Unlicense
189 stars 30 forks source link

Joy con gyro xbox button #35

Closed Okoken closed 2 years ago

Okoken commented 2 years ago

Hi r57zone! Am new to Github and also not that good at coding, but just owning an GPD Win3 and playing around with your project to see if can add more useful functions while using Steam. (sorry when I started in my local the version was still 1.7.2...)

Basically I added below 2 logics, with support of SDL (and a wrapper borrowed from JoyShockMapper):

  1. Getting gyro source from a JoyCon.
  2. Binding Xbox button to touchpad pressing, which allows me to have an extra button while using Steam. (surely we can also bind it to PS button)

*3. Also commented out button combination for Share/Start buttons, since in Steam a single button is much more useful than button combination. Not really a change, but if you can provide an option for normal 1-to-1 button mapping would be very appreciated:)

r57zone commented 2 years ago

Hi, thanks for the Pull Request, I need some time to study it.

Okoken commented 2 years ago

Hi, thank you for the reply. May I know how you got those factors "1638.35" and "2376.7" for converting Accel/Gyro from Freepie IMU to ViGEm?

I found they are not accurate to be used directly while replacing Freepie input with SDL. Adjusted to below now in my newest branch and confirmed they are working perfectly when playing GTA V with Steam.

BTW the definition of SDL (mentioned in SDL_sensor.h) output is as the same as Android IMU, so guessing Freepie IMU shall use the same.

r57zone commented 2 years ago

Hi I took the min and max values that were coming from the application and just converted them to DS4 values (SHORT). I'm not sure if this is correct, but it seems to work.

r57zone commented 2 years ago

Hi, I've added some of your fixes, thanks a lot for them!

I also found a trick that allows you to use the Xbox button without the SDL library.

Unfortunately, I can't accept your full Pull Request, because it seems a bit redundant to me and I can't test it at the moment. Sorry about that.

Maybe it would be possible to use UDP sending to app for joycons? I can send an example of sending UDP if needed. So you could use this and have the latest version of DS4 Emulator.

I can also specify your project in the readme so that other people using a similar configuration can see it.

r57zone commented 2 years ago

Also in recent releases, a critical bug was fixed that unnecessarily loaded the process when reading the WinSock stream, it was necessary to add Sleep, probably in your fork it also needs to be added or turned off reading.

if (bytes_read > 0) {
...
} else
  Sleep(SleepTimeOutMotion); // Don't overload the CPU with reading

https://github.com/r57zone/DualShock4-emulator/blob/master/Source/DS4Emulator.cpp#L137-L138

Okoken commented 2 years ago

Also in recent releases, a critical bug was fixed that unnecessarily loaded the process when reading the WinSock stream, it was necessary to add Sleep, probably in your fork it also needs to be added or turned off reading.

if (bytes_read > 0) {
...
} else
  Sleep(SleepTimeOutMotion); // Don't overload the CPU with reading

https://github.com/r57zone/DualShock4-emulator/blob/master/Source/DS4Emulator.cpp#L137-L138

Hi, yes noticed this actually, since even I changed the sleep time the cpu load was always around 13%. Was about to report this but good that you fixed it 🙂

Also good that my pull request help! Yeah also feel that my need is not the same as yours and not all the things are good to be merged. Maybe I will creat a formal project separately. Thank you for all the replies!

r57zone commented 2 years ago

Hi, I've added a link to your fork in the project description. Thanks for your edits! I apologize that I could not accept it in full (don't want to use so many dependencies yet).

r57zone commented 2 years ago

Fixes for Accel and Gyro have also been added in the latest release.