-
Notifications
You must be signed in to change notification settings - Fork 356
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
gpio_put(25, !(to_ms_since_boot(get_absolute_time()) & (256 | 64))); | ||
*/ | ||
|
||
takeAttention(); |
There was a problem hiding this comment.
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
uint8_t PsxAddon::readwrite(uint8_t sent) { | ||
uint8_t received = 0; | ||
|
||
sleep_us(BYTE_DELAY_US); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/configs/webconfig.cpp
Outdated
@@ -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"); |
There was a problem hiding this comment.
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)
www/src/Locales/en/Addons/PSX.jsx
Outdated
@@ -0,0 +1,9 @@ | |||
export default { | |||
'header': 'PSX', | |||
'text': 'blablabla', |
There was a problem hiding this comment.
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.
I second the want for renaming from |
I am changing that. There are places where the SNES Addon dot not prefix things with
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");
|
also : create and integrate the C++ part of the addon.
- L2 is turned on/off every two seconds for test/debug - Pin number are hard coded - There a TODOs - Data pin is reinitialised at each read
PR for the documentation is here : https://github.com/OpenStickCommunity/Site/compare/main...FabienTregan:gp2040-ce-site:psx?expand=1 |
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 |
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 :( )