Using PS2 USB Dual Controller Adapter with snes9x-gtk

If you're having problems with Snes9x, or think you've found a bug, this is the place to be.
Post Reply
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

Hi, all. I'm new to Snes9x on Linux. I have a PS2 USB adapter and a cheap wireless PS2 controller. The two PS2 ports on the USB adapter map to /dev/input/js1 and to /dev/input/js2. (Apparently, js0 is the MacBook's gyroscope.) The output of cat /dev/input/js1 gets longer when I press buttons on the controller, and the controller shows reasonable output in jstest-gtk. The PS2 USB adapter and this controller work on another computer as well (though that's a Mac).

Mapping the keyboard seems to work.

I'm really not sure how to get snes9x-gtk to use the controller. A few examples said to edit a conf file, but I have a snes9x.xml file that gets updated when I change my keyboard mapping. Other examples I saw said to use -paddev1, but it looks like that doesn't work with snes9x-gtk.

Is there a way to get snes9x-gtk to directly use the controller, or is the only option to use QJoyPad?

Thanks!
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

I tried running snes9x (not snes9x-gtk) and saw the output line about loading /etc/snes9x/snes9x.conf. I set up the controller there, and it works in snes9x. I started snes9x-gtk and saw the same line about loading /etc/snes9x/snes9x.conf, but it's not working in snes9x-gtk. Thoughts?
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

So snes9x-gtk uses SDL for controllers. I installed libsdl2-2.0. The suggestion on GitHub is to set SDL_JOYSTICK_DEVICE. To what, it doesn't say, but some searching suggested the path to my input device, so I tried export SDL_JOYSTICK_DEVICE=/dev/input/js1. This did not help. Any ideas?
odditude
Snes9x Green Belt
Posts: 445
Joined: Tue May 03, 2011 2:35 pm

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by odditude »

disclaimer: i do not currently have a linux box to test on.

does this SDL joystick test program see your adapter?
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

Hi, odditude. Thanks for the reply.

jstest-sdl is able to see the adapter and controller. Here's some output:

Code: Select all

$ jstest-sdl -l
Found 2 joystick(s)

Joystick Name:     'Twin USB Joystick'
Joystick GUID:     03000000100800000100000010010000
Joystick Number:    0
Number of Axes:     4
Number of Buttons: 12
Number of Hats:     1
Number of Balls:    0
GameController:
  not a gamepad

Joystick Name:     'Twin USB Joystick'
Joystick GUID:     03000000100800000100000010010000
Joystick Number:    1
Number of Axes:     4
Number of Buttons: 12
Number of Hats:     1
Number of Balls:    0
GameController:
  not a gamepad
If I run jstest-sdl -t 0, it picks up the button presses and the analog stick.

I was curious to see what that "not a gamepad" thing was about, so I borrowed a line from the sample code at https://wiki.libsdl.org/SDL_GameControllerOpen and this added this around line 164 in the c source downloaded from github.

Code: Select all

else {
    fprintf(stderr, "Could not open gamecontroller %s\n", SDL_GetError());
}
That resulted in the extra line

Code: Select all

Could not open gamecontroller Couldn't find mapping for device (0)
in each output (with 1 instead of 0 for the second device).

I'm going to keep trying. Any thoughts?
odditude
Snes9x Green Belt
Posts: 445
Joined: Tue May 03, 2011 2:35 pm

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by odditude »

as far as SDL is concerned, it's not a gamepad; it's a joystick with a bunch of buttons, a hat switch, and a few more analog axes. don't worry about that.

given that you're seeing results with -t 0, try defining SDL_JOYSTICK_DEVICE=/dev/input/js0.
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

So this may be weird, but js0 is sometimes the laptop's IMU and sometimes it's not. Right now, if I pick up the laptop and move it around in the air, output gets generated on js0, even though the output of jstest-sdl -t 0 works with the controller.

Regardless, cat $(echo $SDL_JOYSTICK_DEVICE) shows output when I mash keys on the controller, so it seems that SDL_JOYSTICK_DEVICE is set correctly, but snes9x-gtk doesn't respond to it.

Is there something I need to do to tell snes9x-gtk to use SDL? Is there some package or module that needs to be installed?
odditude
Snes9x Green Belt
Posts: 445
Joined: Tue May 03, 2011 2:35 pm

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by odditude »

just checking, since you haven't said so explicitly - did you (try to) configure input from the snes9x-gtk gui?
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

It's not clear to me what it means to configure input from within the GTK GUI. What I did try was going to Options:Preferences:Joypads, clicking in various boxes and mashing buttons on the controller. Pressing keyboard keys works. Pressing controller buttons does not work.

Both $ jstest-sdl -t 0 and cat $SDL_JOYSTICK_DEVICE still respond to input on my controller.

Thoughts?
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

So I hadn't mentioned this, but it probably is worth mentioning that all of the UI elements under Options: Preferences: Joypads: Joystick Options are grayed out and disabled. I thought to mention this after reading this quick thread on a similar issue. The suggestion there was to calibrate. I don't have that option. Obviously, my controller is on in order to produce output elsewhere!
IslandDon
Snes9x White Belt
Posts: 8
Joined: Sun May 10, 2020 5:01 am

Re: Using PS2 USB Dual Controller Adapter with snes9x-gtk

Post by IslandDon »

Is is still true that running snes9x-gtk from the console should output the list of joysticks? I saw that in a discussion on github:
bearoso commented on Dec 6, 2017 wrote:Coincidentally, I just updated the GTK+ port to use SDL 2.0 for better joystick support. If you compile the git version it'll list the joysticks on the console when you run it.
If that's still being output, I'm not seeing it. All I see is a line about reading the configuration file and a bunch of messages about audio output.

Code: Select all

$ snes9x-gtk 
Reading config file /etc/snes9x/snes9x.conf.
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Sound buffer size: 4100 (1025 samples)
PortAudio sound driver initializing...
    --> (ALSA : default, latency 32ms)...OK
Any ideas?
Post Reply