dsremap icon indicating copy to clipboard operation
dsremap copied to clipboard

Arduino Library

Open bsperryn opened this issue 4 years ago • 8 comments

Using an Arduino I'd like to be able send the ps4 custom reports and be able to decide which buttons are pressed and which aren't using my Arduino code while only having the security checks proxied back and forth to the controller.

Is there any chance of you putting up an Arduino only library which is capable of the above that can just be added to an Arduino sketch that doesn't need to be compiled with python?

bsperryn avatar Apr 10 '21 21:04 bsperryn

I'd like to make something a bit more "modular" but the Arduino dev environment does not make this easy. I'll see if I can factor out the proxy code in a library, but I'm busy on another project right now.

fraca7 avatar Apr 11 '21 09:04 fraca7

As far as I can tell the biggest blockage is that it is the Bytecode changing the report back to the PS4. How difficult would it be to change that byte code into code you could add yourself in the Arduino IDE?

bsperryn avatar Apr 11 '21 10:04 bsperryn

I just pushed a new commit on master, adding the generated header files, so you should be able to build the code directly now. You should first uncomment the #define DISABLE_REMAPPING in Config.h; this will prevent the whole VM/configuration stuff from building.

If you want to hook you own code you should do so in Host.cpp around line 197; that's when a new report from the Dualshock is available. You can change it on the fly there, it will be forwarded to the PS4 at line 233.

At some point I'll refactor this so it's easier to hook custom code :)

fraca7 avatar Apr 11 '21 11:04 fraca7

Thank you so much! I've now gotten this to compile.

I haven't made any alteration to Host.cpp yet and when I upload dsremap.ino and plug it into the PS4, the controller has a slow yellow light and it doesn't appear that the PS4 recognises it.

Is this the expected behaviour?

bsperryn avatar Apr 12 '21 16:04 bsperryn

You have to plug the Dualshock to the controller and press PS IIRC; nothing can happen before that.

fraca7 avatar Apr 12 '21 16:04 fraca7

Ah by "controller" you meant the Dualshock :) No, it should turn blue. Sometimes there are race conditions in the various responses to USB round-trips; try plugging the setup after plugging the DualShock to it ?

fraca7 avatar Apr 12 '21 16:04 fraca7

Brilliant! Thats working now! It doesn't ever turn blue though. It flashes yellow once and then once I hit the PS button it connects but the light on the DS stays off.

bsperryn avatar Apr 12 '21 17:04 bsperryn

Mmmh, that's strange. It may be symptomatic of a problem on the OUT interrupt endpoint. We'll see I guess.

fraca7 avatar Apr 13 '21 07:04 fraca7