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 support for Playstation 1 and 2 controllers. #1273

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

FabienTregan
Copy link
Contributor

Analog stick are not supported yet but should be really easy to add, I could read them from the controller outside of GP2040, I just need to plug them in GP2040.

I tested with 3 different controllers, one of them gave inconstant result (left dpad switched between 0 and 1 instead of staying at 1 when pressed). That could be a timing issue, but also can be that the 35 years old controller is not working properly (no Playstation to test it :( )

Copy link
Contributor

@arntsonl arntsonl left a comment

Choose a reason for hiding this comment

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

Couple of changes, but looks straight forward! I would also rename it from psx.h to psx_input.h to match our naming for SNES

src/addons/psx.cpp Outdated Show resolved Hide resolved
gpio_put(25, !(to_ms_since_boot(get_absolute_time()) & (256 | 64)));
*/

takeAttention();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a single gpio read so we can remove this function and just do gpio_read with a comment //takeAttention

src/addons/psx.cpp Outdated Show resolved Hide resolved
src/addons/psx.cpp Outdated Show resolved Hide resolved
uint8_t PsxAddon::readwrite(uint8_t sent) {
uint8_t received = 0;

sleep_us(BYTE_DELAY_US);
Copy link
Contributor

Choose a reason for hiding this comment

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

will byte delay ever change? would it make sense to make it a #DEFINE or should we make it definable in the web config?

Copy link
Contributor Author

@FabienTregan FabienTregan Jan 19, 2025

Choose a reason for hiding this comment

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

I think this value will work everywhere, at least it works with the 3 different controllers I tested, so I think a #define is ok.
On the other hand, I could not find the specification from Sony and could only test with 3 different controllers.

This sets the delay between bytes, I guess the same question stands true for the bit delay (rate) also.

If you think it's safer to add the configuration I will do it.

@@ -1561,6 +1561,14 @@ std::string setAddonOptions()
docToPin(snesOptions.latchPin, doc, "snesPadLatchPin");
docToPin(snesOptions.dataPin, doc, "snesPadDataPin");

PsxOptions& psxOptions = Storage::getInstance().getAddonOptions().psxOptions;
docToValue(psxOptions.enabled, doc, "psxEnabled");
Copy link
Contributor

Choose a reason for hiding this comment

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

we're using 4 spaces here, so switch tabs to spaces (visual studio has a built in for this)

@@ -0,0 +1,9 @@
export default {
'header': 'PSX',
'text': 'blablabla',
Copy link
Contributor

Choose a reason for hiding this comment

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

This text should have something closer to what SNES.jsx translation looks like. Something like this add-on supports Playstation controller input for X controllers.

@mikepparks
Copy link
Contributor

I second the want for renaming from psx to psx_input. Will help avoid people thinking this is for PSX output, and keeps naming consistent with its use.

@FabienTregan
Copy link
Contributor Author

I second the want for renaming from psx to psx_input. Will help avoid people thinking this is for PSX output, and keeps naming consistent with its use.

I am changing that. There are places where the SNES Addon dot not prefix things with _input, should I add it in both PSX and SNES addon ?

  • SNESOptions in the protobuff spec
  • in the json document, SNESOptions becodes SnesPad or SNESpad 👍
    SNESOptions& snesOptions = Storage::getInstance().getAddonOptions().snesOptions;
    docToValue(snesOptions.enabled, doc, "SNESpadAddonEnabled");
    docToPin(snesOptions.clockPin, doc, "snesPadClockPin");
    docToPin(snesOptions.latchPin, doc, "snesPadLatchPin");
    docToPin(snesOptions.dataPin, doc, "snesPadDataPin");

Do I keep this ?

    PsxOptions& psxOptions = Storage::getInstance().getAddonOptions().psxOptions;
    docToValue(psxOptions.enabled, doc, "psxEnabled");
    docToPin(psxOptions.dataPin, doc, "psxDataPin");
    docToPin(psxOptions.commandPin, doc, "psxCommandPin");
    docToPin(psxOptions.attentionPin, doc, "psxAttentionPin");
    docToPin(psxOptions.clockPin, doc, "psxClockPin");
    docToPin(psxOptions.acknowledgePin, doc, "psxAcknowledgePin");
  • The .tsx file for the web configurator is named snes.tsx and not snes_input.tsx, is it wanted ?
  • The snes.tsxfile does not use translation file. I rename minepsx_input.jsx`

@FabienTregan
Copy link
Contributor Author

@arntsonl
Copy link
Contributor

arntsonl commented Jan 24, 2025

Just modify the PSX input addon, don't modify the SNES addon please. For issues on the SNES addon, we can address those in a separate PR. We don't want to lump in fixes with new features

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.

3 participants