-
Notifications
You must be signed in to change notification settings - Fork 297
Add touchscreen support for the Dualshock 4 touchpad #11
Comments
Hi! |
No news. Driver needs to be modified as well for this, probably API-breaking changes for existing users, a new round of testing, WHQL etc. this isn't trivial to implement and currently not promising with my available resources. |
Hi) Can you please add the ability to emulate the full touch pad and gyro, for playstation now? |
Oh crap, I thought that only the report needed changes. I understand now if you can't implement it. |
I thought I was going crazy when RPCS3 didn't detect any gyro movement from the Virtual DS4 so yeah this would be really useful! |
See my previous comments. I'm aware this is a useful request but I don't have the capacity nor the motivation to touch this in the near future. |
R I P |
@musikid @nefarius There is meant to be another byte ( To test this, I implemented two new methods - SetIMUValue and SetTimestampValue into ViGEm.NET and then used them in my project BetterJoy. I ran tests using a modified version of DS4Windows that allowed emulated controllers to be picked up, and then visualised the gyro/accel in PadTest. The test setup works quite well, so it would be viable to test and implement the touch API through this as well. DS4Windows has the full DS4 report break-down. |
@Davidobot nice work! Now I just need a way to not completely nuke backwards compatibility... 🤔 |
@nefarius I was toying around with the idea of having a separate 'special' DS4Report structure that gets appended onto the main DS4Report. There are quite a few references to DS4Report in the code though, so I'll have to carefully comb through that. I was wondering - do you know why there is no need for the |
@Davidobot actually despite the report structure coming in from the API being shorter, I actually initialize the full size report with default values so it matches the size in the HID Report Descriptor. If we compare your modification to this documentation of the report structure, there should be a 3 byte padding required separating the Right Trigger byte and the Gyro X byte. If we ignore the remaining data, the report structure of yours with the battery commented out has a size of 23 bytes (ignoring the one always reserved for Report ID), which according to the docs would be one missing. Are you sure you're testing with the version that has the battery commented out? Happened to me a lot debugging outdated binaries and wondering WTF was going on 😆 |
I looked into the unspeakable horrors of the past and it appears that battery level info sits at byte 30 (like with the DS3). |
Yup! I have a
I just looked over it again, and sure enough, if I have the battery byte there between the timestamp and gyroX, then I start getting offset errors (as in assigning to gyroZ will actually change accelX when looking at the report).
That does indeed seem to be the case, judging by DS4Windows as well. Strange - does that mean the report layout on eleccelerator is wrong? Though the gyro/accel data does indeed seem to start at byte 13 (not 12), so there is something at 12, but it's not being read at least in DS4Windows. I'll dump the reports that the Bus sends and the ones DS4Windows picks up. To see what is going on with that missing byte. |
@Davidobot FWIW, I got the report by comparing with Linux HID driver parsing. It seems that the report provided by Eleccelerator is wrong. |
If in doubt I'd trust the Linux sources, I did that too after abandoning the SCP sources wich were full of misleading legacy sections. According to them, Gyro X is indeed read at byte 13, as seen here. |
I've quickly captured a DS4 Rev1 USB HID Input Report how it looks on the wire (report data in bold): 0000 1b 00 a0 d9 16 ba 8a d7 ff ff 00 00 00 00 09 00 ................ 0010 01 02 00 03 00 84 01 40 00 00 00 01 80 82 7f 7f .......@........ 0020 08 00 94 00 00 5b 58 06 5d fb 3e fc f6 fa 9c 05 .....[X.].>..... 0030 b3 18 e9 eb 00 00 00 00 00 12 00 00 01 af 02 48 ...............H 0040 d3 06 80 00 00 00 00 80 00 00 00 80 00 00 00 00 ................ 0050 80 00 00 00 80 00 00 00 00 80 00 ........... Where it looks like that byte 13 is indeed the correct offset (careful with endianness):
Byte 30 is battery level with value |
Ah, figured out why removing that battery byte made the gyro/accel data line up properly. There is an off-by-one error (somewhy) in transposing the data from DS4Report into the buffer. ie after the trigger bytes there is a single always-0 byte, and THEN the extra 7 elements get copied in. So the report it outputs looks like this
Not sure where this comes from as the |
@Davidobot hihi, it's hidden in plain sight 😆 Tell you what, add (Hint: the compiler outsmarted us) |
Why of course! This is great revision for my |
Bam, implemented and tested the touch data segments. Code here. This means that ViGEm can now fully emulate the full HID USB packet! Since this is USB, there is a max of 3 touch packets at any one time. You can set the current one with DS4_SET_TOUCHPAD and "preset" (ie copy current into old and increment packet counter) with eg (setting all 3 touchdata packets, for both fingers):
EDIT: Added and tested .NET bindings. @nefarius I'd love to see this integrated into the main master project. Do you need to do any clean-up or anything else? |
Great work, I have an idea on how to integrate while maintaining backwards compatibility, I'll keep you posted. |
So here's the first draft of my plan/suggestion (backwards compatibility with existing software in mind):
So far so good 😎 |
Nice! I was playing around with a very similar idea (/w additional struct) but didn't get too far because I 'm not too familiar with the Bus and what I would have to edit to get it working properly. I'll give it another shot if I find the time. Thanks! |
For now it would be help enough if you could simply thoroughly test what you've built, the rest I can take a spin on. Be my guest on Discord if that helps. |
@nefarius Hey i have been desperately searching for the link for V 1.17. i cannot find any help? |
There is none. It's work-in-progress 🙄 |
Need to merge the SDK and .NET lib branches to master, then this issue is done ✨ |
It's done and live for both native and managed SDK. |
I use ViGEm for using a tablet with game controls for remote play, which is better than Vita except clicking the touchscreen doesn't send touchpad events to the PS4. Could you please add this?
The text was updated successfully, but these errors were encountered: