o0Zz / sys-con

Nintendo Switch sysmodule that allows support for third-party controllers (XBox, PSX, PC, ...)
GNU General Public License v3.0
74 stars 5 forks source link

support for atomic PSX/PS2 adapter/converter #4

Closed texita closed 5 months ago

texita commented 5 months ago

i'm trying to use this adapter/converter for psx/ps2 pads [12bd-e002]:

images

this this the product sheet (the only one that i can find) https://www.soluzione-ufficio.it/download.php?filename=LP9236-1-scheda-prodotto.pdf

i configured the config.ini but it isn't working. on pc is working perfect.

here some logs, let me know if you need more details

|I|00:03:14.0895| SYS-CON started 1.0.2+0-fdcb419 (Build date: Jun 3 2024 23:18:27) |I|00:03:14.0919| OS version: 17.0.1 |D|00:03:15.0093| Initializing controllers ... |D|00:03:15.0111| Initializing USB stack ... |D|00:03:15.0128| Adding event with filter flag 0x0004... |D|00:03:15.0141| Adding event with filter flag 0x0084... |D|00:03:15.0158| Initializing power supply managment ... |I|00:03:46.0125| New USB device detected, checking for controllers ... |I|00:03:46.0144| Trying to find configuration for USB device: [12bd-e002] ... |D|00:03:46.0161| Loading controller config: 'sdmc:///config/sys-con/config.ini' (default) ... |D|00:03:46.0331| Loading controller config: 'sdmc:///config/sys-con/config.ini' (12bd-e002) ... |D|00:03:46.0510| Loading controller successfull (B=3, A=2, Y=4, X=1, ...) |I|00:03:46.0524| Initializing Generic controller for [12bd-e002] ... |D|00:03:46.0540| BaseController Created for 12bd-e002 |D|00:03:46.0556| GenericHIDController Created for 12bd-e002 |D|00:03:46.0571| SwitchHDLHandler Initializing ... |D|00:03:46.0581| GenericHIDController Initializing ... |D|00:03:46.0596| BaseController Initializing ... |D|00:03:46.0610| BaseController Opening interfaces ... |D|00:03:46.0626| BaseController Opening interface 0 ... |D|00:03:46.0640| SwitchUSBInterface(12bd-e002) Openning ... |D|00:03:46.0655| SwitchUSBInterface(12bd-e002) Input endpoint found 0x81 (Idx: 0) |D|00:03:46.0665| SwitchUSBEndpoint Opening 0x81 (Pkt size: 7)... |D|00:03:46.0679| SwitchUSBEndpoint successfully opened! |I|00:03:46.0693| BaseController successfully opened ! |D|00:03:46.0709| SwitchUSBInterface(12bd-e002) ControlTransferInput (bmRequestType=0x81, bmRequest=0x06, wValue=0x2200, wIndex=0x0000, wLength=512)... |D|00:03:46.0726| GenericHIDController Parsing descriptor ... |D|00:03:46.0743| GenericHIDController Looking for joystick/gamepad profile ... |I|00:03:46.0753| GenericHIDController USB joystick successfully opened (1 inputs detected) ! |D|00:03:46.0765| SwitchHDLHandler Initializing HDL state ... |D|00:03:46.0780| SwitchHDLHandler Initializing HDL device idx: 0 ... |D|00:03:46.0792| SwitchHDLHandler HDL state successfully initialized ! |D|00:03:46.0806| SwitchVirtualGamepadHandler InputThreadLoop running ... |D|00:03:46.0821| SwitchHDLHandler Initialized ! |I|00:03:46.0831| New USB device detected, checking for controllers ... |I|00:03:46.0845| Trying to find configuration for USB device: [12bd-e002] ... |D|00:03:46.0859| Loading controller config: 'sdmc:///config/sys-con/config.ini' (default) ... |D|00:03:47.0028| Loading controller config: 'sdmc:///config/sys-con/config.ini' (12bd-e002) ... |D|00:03:47.0207| Loading controller successfull (B=3, A=2, Y=4, X=1, ...) |I|00:03:47.0222| Initializing Generic controller for [12bd-e002] ... |D|00:03:47.0232| BaseController Created for 12bd-e002 |D|00:03:47.0245| GenericHIDController Created for 12bd-e002 |D|00:03:47.0259| SwitchHDLHandler Initializing ... |D|00:03:47.0275| GenericHIDController Initializing ... |D|00:03:47.0290| BaseController Initializing ... |D|00:03:47.0304| BaseController Opening interfaces ... |D|00:03:47.0314| BaseController Opening interface 0 ... |D|00:03:47.0328| SwitchUSBInterface(12bd-e002) Openning ... |D|00:03:47.0344| SwitchUSBInterface(12bd-e002) Input endpoint found 0x82 (Idx: 1) |D|00:03:47.0359| SwitchUSBEndpoint Opening 0x82 (Pkt size: 7)... |D|00:03:47.0374| SwitchUSBEndpoint successfully opened! |I|00:03:47.0389| BaseController successfully opened ! |D|00:03:47.0398| SwitchUSBInterface(12bd-e002) ControlTransferInput (bmRequestType=0x81, bmRequest=0x06, wValue=0x2201, wIndex=0x0000, wLength=512)... |D|00:03:47.0415| GenericHIDController Parsing descriptor ... |D|00:03:47.0427| GenericHIDController Looking for joystick/gamepad profile ... |I|00:03:47.0442| GenericHIDController USB joystick successfully opened (1 inputs detected) ! |D|00:03:47.0456| SwitchHDLHandler Initializing HDL state ... |D|00:03:47.0468| SwitchHDLHandler Initializing HDL device idx: 0 ... |D|00:03:47.0484| SwitchHDLHandler HDL state successfully initialized ! |D|00:03:47.0497| SwitchVirtualGamepadHandler InputThreadLoop running ... |D|00:03:47.0512| SwitchHDLHandler Initialized ! |I|00:03:49.0387| USB Interface state was changed |D|00:03:49.0404| GenericHIDController DATA: X=-32768, Y=-32768, Z=-32768, Rz=-32768, HatSwitch=0, B1=0, B2=0, B3=0, B4=0, B5=0, B6=0, B7=0, B8=0, B9=0, B10=0 |I|00:03:49.0418| Controller unplugged: 12bd-e002 |D|00:03:49.0429| GenericHIDController DATA: X=-32768, Y=-32768, Z=-32768, Rz=-32768, HatSwitch=0, B1=0, B2=0, B3=0, B4=0, B5=0, B6=0, B7=0, B8=0, B9=0, B10=0 |D|00:03:49.0446| SwitchHDLHandler Attaching device for input: 0 ... |D|00:03:49.0461| SwitchHDLHandler Attaching device for input: 0 ... |D|00:03:49.0475| SwitchHDLHandler Attach - Idx: 0 [NpadId: 0] |D|00:03:49.0488| SwitchHDLHandler Attach - Idx: 0 [NpadId: 1] |D|00:03:49.0501| SwitchHDLHandler UpdateHdlState - Idx: 0 [Button: 0x0000000000002000 LeftX: -32767 LeftY: 32767 RightX: 0 RightY: 0] |D|00:03:49.0521| SwitchHDLHandler UpdateHdlState - Idx: 0 [Button: 0x0000000000002000 LeftX: -32767 LeftY: 32767 RightX: 0 RightY: 0] |D|00:03:49.0621| SwitchVirtualGamepadHandler InputThreadLoop stopped ! |D|00:03:49.0639| SwitchUSBInterface(12bd-e002) Closing... |D|00:03:49.0649| SwitchHDLHandler UninitHdlState .. ! |I|00:03:49.0665| Controller unplugged: 12bd-e002 |D|00:03:49.0731| SwitchVirtualGamepadHandler InputThreadLoop stopped ! |D|00:03:49.0744| SwitchUSBInterface(12bd-e002) Closing... |D|00:03:49.0758| SwitchHDLHandler UninitHdlState .. !

o0Zz commented 5 months ago

From the logs it seems your controller is working perfectly. Could you please describe a bit more what is not working exactly ? At the same time could you please provide the trace log (log_level=0) and attach your config.ini

Important note: When you are in debug or trace level, you will have a big input lag giving you the feeling the controller is not working, be sure to hold a key (for 1s) to make sure the input is took into account .

texita commented 5 months ago

Sure, the adapter simply not work, but if i go to the input test screen, when i remove the adapter i see the input UP. doing the same thing from the joypad sync menu i can see for half a second 2 usb controllers popping up and then disappears. This happen even without connected controllers on the adapter. If you need a better explaination i can send you a video of this.

here my log file and my config

config+log.zip

o0Zz commented 5 months ago

Thank you for the details description, I can see what you describe in the logs, I think there is an issue with the HID parsing, I will have a look of this issue, I will keep you updated.

o0Zz commented 5 months ago

Ok I tried to understand what's wrong with your controller but I'm not sure to understand. I think there is 2 issues at minimum, 1 issue is the incorrect axis on the stick1, this issue should be fixed with the latest release https://github.com/o0Zz/sys-con/releases/tag/1.1.0

However, i'm not sure to understand why the controller disconnect alone, I can clearly see it in logs but can't understand why. So, I added more logs in the latest release in order to debug this issue. Could you please provide the log in trace mode with the latest release (I think you should still see the disconnection).

Thank you

texita commented 5 months ago

clean install with new version, i think worst than before, at least before 2 pads where popping up when i was disconnecting the adapter.

anyway, what i've done for this log file:

log+config.zip

o0Zz commented 5 months ago

Could you try connecting the controllers to the adapter before connecting the adapter to the USB port?

From the logs I see

What you describe as a regression is indeed an improvement ;). In the previous version of sys-con, the controllers were created as soon as the USB was connected. Now sys-con waits to receive data from the controller and then creates it. The reason for this change is exactly for the adapter like yours, where you can connect 2 controller, but if you connect only 1 controller to this adapter, you only want to have 1 controller display in the user interface ;) So on your setup, because your controllers don't send data, no controllers are shown in the switch UI - Now we need to understand why the adapter doesn't send data.

On your PC you said it works perfectly, do you have a driver for this adapter installed on your PC? I'm just trying to understand if the controller is expecting a "startup" sequence.

Thus, If you can try to plug the controller on the adapter then the USB to the console, we will see if it will change things.

texita commented 5 months ago

For the pc part:

image

IMG_20240608_003033.jpg

IMG_20240608_002923.jpg

-->IMG_20240608_002948.jpg

texita commented 5 months ago

Switch part:

log.zip

i think on the switch the behavior should be similar to the pc, so when i connect the adapter even without pads, the switch should show 2 connected controllers, like what was happening in the 1.0.2 version, with the only problem that this was happening when i disconnect the adapter...with pressing UP at the same time, it was the only adapter without pads that was sending the UP command at the moment of usb disconnection XD

o0Zz commented 5 months ago

I agree, it should works exactly the same than your PC. I think we will have to go deeper with a wireshark capture.

Could you please provide a wireshark capture for this controller when you plug it to your PC Here is the procedure if you never played with wireshark -> https://github.com/o0Zz/sys-con/blob/master/doc/WiresharkCapture.md

texita commented 5 months ago

Made this dump:

ws-dump.zip

o0Zz commented 5 months ago

Thank you for the capture. Let's try this version of the sys-con. On your capture I can clearly see the controller send data to windows. The only difference I can notice in the capture is windows send a "SET_IDLE" command to the controller. I mimic this behavior in this new version. My assumption is by default the controller have this timer set to "Infinite" and windows set it 0, while sys-con assume all controllers comes with a "valid" timer. sys-con-1.1.0+5.zip

texita commented 5 months ago

Tried, nothing changed for what i can see on the console screen, here the trace logs

log.zip

o0Zz commented 5 months ago

This version try to respect timing and windows command order. I try to set a USB configuration and to set idle mode before opening the interfaces (I hope it will fix the issue).

if it doesn't works, I will certainly look for a usb sniffer to understand what does exactly the switch because I'm running out of idea here.

sys-con-1.1.0+6.zip

texita commented 5 months ago

Same again :(

log.zip

o0Zz commented 5 months ago

Ok I bougth this adapter -> https://fr.aliexpress.com/item/4000662529384.html - In order to see if I can reproduce this issue. I will receive it in a couple of days, I will let you know.

texita commented 5 months ago

I'm hoping the best! 😂

-653789406-71977411.jpg

o0Zz commented 5 months ago

I'm not too worry, most of the time they don't know what they sell, but I agree it might afraid :D

o0Zz commented 5 months ago

EDIT: In fact, the adaptor is detected and thus it's enough to test what I wanted to test. (The adapter is properly detected by the PC and by the Switch) and it properly send data (I can see data comming from the adaptor on the switch) Thus, at the end this aliexpress adaptor works perfectly with sys-con

So maybe you can try to invest a couple of euro in a new adaptor ;) (Probably a better one because mine cannot detect when I press a button on my controller - but this reference seems to work - I just had no luck there)

texita commented 5 months ago

It appears that you are having my problem. I mean, on switch from the logs everything working, but no buttons.

So...at the end i think if i'll get another adapter i will be with the same problem.

o0Zz commented 5 months ago

No, both problems are differents.

On your version the USB Read function return no data which is very weird. On my version the USB Read function return data and these data are just the default value when the joystick is not pressed (Which is logical since I assume an issue with the connectics).

Another important point here, I bought this adapter but I already have a PSX adapter at home, and the PSX adapter I have at home has exactly the same VID-PID that the one I just bought which means the chipset is indeed exactly the same - they probably only changed the form factor.

So, if you get another adapter (From aliexpress for example) I'm pretty sure it will perfectly works on your side, to me the issue come from the fact your adapter is expecting something unusual from USB stack that Nintendo switch don't provide but windows provide, that's my understanding of this issue.

texita commented 5 months ago

Got it, so it's basically incompatible on the switch. Ok, ill will close this issue. there is no point to leave it opened.

I gonna close the issue with the video of the 2 pads popping up until version 1.0.2 (this was the behavior that was giving me hopes) RIP atomic adapter XD

https://github.com/o0Zz/sys-con/assets/1828679/05ba0068-59e4-4c3f-8ef1-0a307db8af08

o0Zz commented 5 months ago

There is very a small chance it fix your issue, but try anyway this release -> https://github.com/o0Zz/sys-con/releases/tag/1.2.1 It did a change in the Read function that "might" help for your issue (But don't get too many hope there ;))

texita commented 5 months ago

YOU are the man! It's working now! Ok, got some little problems, like L3 and R3 not working (maybe config file, i used the default one), Right analog stick has wrong direction: right=down left=up up=left right=down EDIT: Another thing, but this is general not only for this adapter, is it normal when i go to the sync menu, all controllers disappers and to use them have to unplug and replug them? Can't only press buttons to get them recognized

o0Zz commented 5 months ago

Wow that was totally unexpected. great news ! ;)

Regarding wrong direction, yes it can happen because HID standard don't provide a strong definition on this point thus every vendor do what they want. However, you can easily fix it by changing your configuration -> Troubleshooting

Regarding Sync menu, all controller disapear is a know issue (Or at least it's something i didn't implemented yet) The switch will automatically "disable" controller and thus sys-con should invoke an API to enable them (I didn't implemented this yet, but it will be probably part of futur release ;) )

I'm interressted to have your binding once you got something working.

Regarding L3/R3, Does these button works on windows ? If they works, they should also work on the switch.

o0Zz commented 5 months ago

Ok, let see if this build fix your sync menu ;). You should be able to re-sync the controller by pressing L+R (like any other switch controller) sys-con-1.2.1+1-ATMOSPHERE-1.7.x.zip

texita commented 5 months ago

You added tons of changes to the documentation and config i can see :D well, now everything is really working.

Here my working config:

[12bd-e002]; Dual PSX/PS2 adapter ATOMIC B=3 A=2 Y=4 X=1 L=7 R=8 ZL=5 ZR=6 minus=9 plus=12 lstick_click=10 rstick_click=11 right_stick_x=Rz right_stick_y=Z simulate_home_from_plus_minus=1

texita commented 5 months ago

Ok, let see if this build fix your sync menu ;). You should be able to re-sync the controller by pressing L+R (like any other switch controller) sys-con-1.2.1+1-ATMOSPHERE-1.7.x.zip

hahaha i can't even test the things that you already push a new update, i love you man! :) Anyway, sync menu working aswell :D

o0Zz commented 5 months ago

Thanks for the update ;). I will merge your config to the main branch like that it will be available in the next release. Yep, I added lot of configuration because it's not possible to have an unique configuration for all controllers when we try to support HID generic controllers. Thus I try to be as generic as possible ;)

texita commented 5 months ago

With the sync menu update you even fixed the double controllers that will popup. I mean, i can know use pad on adapter slot 2 as 1 on switch and the 1 will stay "disconnected" until you go again to the sync menu (or press L+R on the controller), wonderful :)

PS: Now waiting you to be listed here https://hb-app.store/ for autoupdates on switch :D (maybe with a different name or people will confuse the old sys-con XD)

o0Zz commented 5 months ago

Ok Nice ;), I will wait a bit to see if any new issue is reported and I will generate a new v1.2.2. I submited syscon to hb-app.store ;), now we just have to wait. Thanks for your help