Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JOYSTICK_SERIAL_OUT system for outputting joystick data #978

Closed

Conversation

GrumpyGopher
Copy link
Contributor

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.

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.

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.
@@ -21,7 +21,7 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
# Can't use SRAM1 for IRAM as it conflict with un-updatable bootloaders in the wild :@ .
# CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
CONFIG_ESP_CONSOLE_UART_BAUDRATE=921600
CONFIG_ESP_CONSOLE_UART_BAUDRATE=1000000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default baud rate of 921600 does not play nice with Arduino Pro Micro. The data comes across all garbled. Tested with the following baud rates and had no problems connecting Arduino.
115200
250000
500000
1000000

@@ -140,6 +141,24 @@ enum {
PAD_RJ,
};

enum {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this enum was added so I could minimize the number of characters needed to represent the 15 buttons of the controller. With this new enum only 5 characters are needed.

remove invalid reference
@GrumpyGopher
Copy link
Contributor Author

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
Copy link
Owner

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.

@darthcloud darthcloud closed this Apr 26, 2024
@GrumpyGopher
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

Thank you so much, forking the repo worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants