komefai / PS4Macro

Automation utility for PS4 Remote Play written in C#
http://blog.komefai.com
MIT License
375 stars 89 forks source link

Touchpad PS4Macro #14

Open grill2010 opened 6 years ago

grill2010 commented 6 years ago

I'm currently writing my own PS4 Remote interceptor which is able to stream content to an Android Smartphone and also injects gamepad inputs by using your logic of the PS4RemotePlayInterceptor. However, I'm not able to emulate the Touchpad. Clicks are working but movements will not be detected or just be ignored. The PS4Macro is also not able to record Touchpad movements or is this just not implemented yet? Do you have any experience with this issue?

komefai commented 6 years ago

Hi, touchpad support has already been implemented since v0.2.2 (PS4RemotePlayInterceptor v0.4.0) using parts of the code from DS4Windows. However, since v0.5.0, you need to disable "Record On Touch" feature (enabled by default) by going to Playback->Record On Touch to record the touchpad movements in PS4 Macro.

grill2010 commented 6 years ago

Okay I will check. Yes I've already tried with the newest version and I also disabled the "Record On Touch" however clicks worked correctly and also the button pressed were recognized successfully but not the touchpad moves. But could be also my mistake, will let you know about the results.

grill2010 commented 6 years ago

I've tested it so far and unfortunately it is not working. Every button click gets replayed correctly but not the touchpad movements. I've tested it in the PS4 menu

Messages -> All -> "select random message" ->Enter Message (O for Cancel so that I can use the touchpad)

Everything worked, even the touchpad clicks but not the movements. I've doubled checked and it seems that the values are present in the recorded xml file because I've entries like

<Touch1>
  <TouchID>3</TouchID>
  <IsTouched>true</IsTouched>
  <X>1093</X>
  <Y>435</Y>
</Touch1>
<Touch2>
  <TouchID>0</TouchID>
  <IsTouched>false</IsTouched>
  <X>0</X>
  <Y>0</Y>
</Touch2>

I have the same issue in my code, the touchpads movements aren't working but the touchpad clicks. Could you try to reproduce the scenario? I've tested in on two PCs with PS4 Macro - v0.5.2 (BETA)

komefai commented 6 years ago

Hmm, I've never had this problem before but I'll try to reproduce it. Thanks for the report!

grill2010 commented 6 years ago

Thank you. Let me know what are your results. I will also investigate this issue, I think that there is maybe a mistake in the conversion from the DulashockState to the byte array because it seems to be correct until this point. But it's just a guess.

komefai commented 6 years ago

Sure, I don't have any other PC to test on but I have a spare PS4 controller. I agree about the mistake in the data conversion but I also think that different controllers might react to the data differently during recording. I'll let you know.

You might want to take a look at DS4Windows.DS4Touchpad class because this feature is taken directly from that project.

grill2010 commented 6 years ago

Yes, that could indeed also be possible.

Thank you, I will have a look.

komefai commented 6 years ago

I tested touchpad recording on another PS4 controller (by recording on one and playback on the other). The touchpad movements work as expected on both controller. HOWEVER, I found out that touchpad movements does not work at all in an emulated controller! This is new to me because I've never tested this before, but I think I know the fix for that.

Anyways, I assumed that in your case you are not using the emulated controllers, so I guess the issue has to remain open for now.

grill2010 commented 6 years ago

Hi, sounds great but I have to say that I'm just using the emulated controller all the time because I send the gamepad inputs from the smartphone. Sorry if that wasn't clear enough in my previous questions. As I said I could record gamepad inputs and touchpad movements correctly but during reply (emulated controller) touchpad movements didn't work. I had no time to dig into this issue yet but if you have a solution or an idea how to solve this, it would be great. Thank for your time and your reply.

grill2010 commented 6 years ago

Any news regarding to this issue? You mentioned that you maybe know a fix for that strange problem, did you have any success?

komefai commented 6 years ago

Hi, I've been very busy and haven't made any progress. I think that TouchID has to somehow be emulated but I'm not sure yet how it changes each frame. Feel free to play around with it and let me know the results.

grill2010 commented 6 years ago

What I found out so far is that the TouchId gets increased whenever you lift up a pointer. E.g. place a finger on the touch pad and move around then TouchId will be 1, lift up the finger and place it again on the touchpad the TouchId will be increased by 1. Unfortunately it seems that even if you are doing it the exact same way, and even in you reply scenario it should be working then correctly, it doesn't work at all. So either the problem is more low level e.g. as I already mentioned that it has somehow something to do with data conversion or it is a completely different problem.

komefai commented 6 years ago

Thanks for the update. I will definitely revisit this issue and take some time analyzing how the TouchID really works. I think there is a possibility that the TouchID was generated with the help of the receiver side (in this case PS4 Remote Play).