darthcloud / BlueRetro

Multiplayer Bluetooth controllers adapter for retro video game consoles
https://blueretro.io
Apache License 2.0
1.23k stars 103 forks source link

Add JOYSTICK_SERIAL_OUT system for outputting joystick data #978

Closed GrumpyGopher closed 2 months ago

GrumpyGopher commented 2 months ago

For consideration: Added new JOYSTICK_SERIAL_OUT system for outputting data via BlueRetro's serial port so that you can interface to other devices like the Arduino Pro Micro.

The data is outputted as a 30 character string beginning with the [ character and ending with the ] character. This was done to allow for validation on the receiving side that the whole message was received.

Use Cases: I'm using a BlueRetro HW1 Universal adapter. This would allow me to use the same adapter for PC removing the need to resysnc controllers when switching back and forth between consoles and PC. With this new feature I would be able to send the data to an Arduino Pro Micro which can emulate joysticks in Windows.

GrumpyGopher commented 2 months ago

I also put together a couple Arduino sketches for the Arduino Pro Micro that go with this update. The both utilize Arduino Joystick Library to emulate multiple joysticks with a single Arduino Pro Micro. I made a 6 player and 4 player version. I know BlueRetro can handle 7 controllers but I don't know if Arduino could handle that and I couldn't think of any 7 player games. The 6 player version requires disabling CDC which some people may not want to do but the 4 player version will work even if CDC is enabled.

After uploading the 6 player version and setting up the controllers in Steam I was able to run TMNT: Shredder's Revenge with all 6 controllers.

Github for the sketches: https://github.com/GrumpyGopher/BlueRetroToArduinoJoystick

darthcloud commented 2 months ago

Thanks for sharing!

I'm planning to define a SPI interface for interfacing with other MCU or FPGA sometimes this year. That will be the official way to integrate with BlueRetro.

I'm very sorry but for that reason I will not merge this PR. I don't want to start documenting and supporting this if I'm going to replace it anyway soon.

But I'm glad that you dig into BlueRetro code and made something useful.

GrumpyGopher commented 2 months ago

It was fun to put together but I look forward to seeing the SPI implementation. In the meantime is there a way I can either run the web config locally so I can add the system option for myself or maybe a way to add my system to the auto config? It would just make it easier for me to toggle between console and PC while waiting for SPI to be released.

Thanks

darthcloud commented 2 months ago

Yes but it's a bit complex to setup: https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll

The easiest way is to fork the repo https://github.com/darthcloud/BlueRetroWebCfg and simply publish your own github page in the repo setting.

GrumpyGopher commented 2 months ago

Thank you so much, forking the repo worked perfectly