Author Topic: SNES controller support, Linux  (Read 174 times)

Offline datastry

  • Baby Retrode
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
SNES controller support, Linux
« on: 13/Aug/2017 01:31:06 AM »
I'm a brand new user (received my Retrode 2 in the mail this morning... thank you DragonBox!) but I'm running into some issues with controller support.

I'm testing with one SNES controller on two different PCs, one Windows 7 and one Linux Xubuntu (XFCE desktop).
I also have an SNES-to-USB adapter cable from Tomee.    I'll include my testing with this adapter as a comparison with the Retrode.

Before posting this, I did a search of the forum.   The latest relevant post that I could find was this one from 2015:
http://forum.retrode.org/index.php/topic,296.msg2027/topicseen.html#msg2027

The last post in the thread references issues with Linux support of controller.   It states:

Quote
HID Mode 1:
"4 USB game controllers plus mouse"

The devices are NOT reporting themselves as joysticks / joypads.
Therefore, only the mouse is found - and the rest appears
as /dev/input/eventx in Linux. They should appear as /dev/input/jsx,
but apparently Linux does not recognize them as joystick.

This matches my experience in Linux.
When I attach my controller using the Retrode and open jstest-gtk, I don't see any available joysticks listed.
When I open up http://html5gamepad.com/, it doesn't find any gamepads either.
The only feedback that I get from the controller is moving the cursor when I press on the D-pad.
Left stick = x position 0%, y position 50%,  Right = 100%, 50%, Up = 50%,0%, Down = 50%,100%

If I compare this to my experience with the SNES-to-USB adapter cable, I see an "SNES PC Game Pad" device available in  jstest-gtk.    At the HTML5 Gamepad page, the controller is recognized and all the axes and buttons are recognized correctly.

I'm interested in support under Linux.   However, since I have a Windows machine that I tested on, I'll describe my testing.

When the Retrode is attached to the Windows 7 machine, it recognizes 4 controllers in both the Windows' Game Controllers dialog box and in the HTML5 Gamepad page.   At the Gamepad page, button presses are recognized but axis movements are not recognized.   The Windows cursor is not affected (not surprisingly).

By contrast, the controller's behavior with the SNES-to-USB adapter cable matches its behavior under Linux.



Does anyone know anything about these issues with Linux support?
Has there been any development since the 2015 post?

Any help is appreciated!    Thanks!



Offline ssokolow

  • Baby Retrode
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #1 on: 31/Aug/2017 02:13:32 PM »
Bear in mind that /dev/input/jsX is the legacy joystick interface, which a lot of modern, SDL2-based games don't support, so it's not a reliable indicator of whether the problem has been fixed.

That said, I've confirmed the problem with my Retrode and started poking at "aftermarket" fixes.

I haven't managed to unhook the mouse handler from it yet, nor get it to appear as a jsX node, but I did manage to get the eventX node to show up as a joystick in AntiMicro (a superior, cross-platform joy2key competitor which uses SDL2 for its backend that I sometimes prefer over games' internal joystick support).

To replicate my progress so far, create a file named /etc/udev/rules.d/99-retrode-controller.rules and put this line into it:

Code: [Select]
SUBSYSTEM=="input", ATTRS{name}=="Retrode UG Retrode", MODE="0666", ENV{ID_INPUT_MOUSE}="0", ENV{ID_INPUT_TABLET}="0", ENV{ID_INPUT_JOYSTICK}="1"
(the ENV{ID_INPUT_JOYSTICK}="1" is something I figured out after buying a Chinese NES controller adapter that wasn't showing up as a joystick.)

...then run this command...

Code: [Select]
sudo udevadm control --reload
...and then disconnect and reconnect your Retrode.

Normally, I wouldn't post until I'd finished experimenting, but I have to go AFK for several hours, so I thought I might as well give a status update now.
« Last Edit: 31/Aug/2017 02:15:28 PM by ssokolow »

Offline ssokolow

  • Baby Retrode
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #2 on: 31/Aug/2017 05:53:54 PM »
OK, here's what progress I've made.

I'm still trying to figure out the proper way to trigger generation of a /dev/input/jsX device node in [HIDMode] 1;, but I've figured out how to keep it from waggling the mouse around if you want the "4Joy+Mouse" mode without the mouse. (I wasn't thinking "shell script" enough. Using ="" rather than ="0" to disable the "is a mouse" indicators works.)

Here's the updated udev rule...

Code: [Select]
SUBSYSTEM=="input", ATTRS{name}=="Retrode UG Retrode", MODE="0666", ENV{ID_INPUT_MOUSE}="", ENV{ID_INPUT_TABLET}="", ENV{ID_INPUT_JOYSTICK}="1"
...and here's what I tested with it:
  • A Super Famicom controller with AntiMicro (an example of something based on SDL2)
  • An N64 controller with Blast Corps in Project64 (an example of a Windows application in Wine)
  • A Super Famicom controller with Super Mario World in Snes9x-GTK (because it's a combination you might actually want to use)

I couldn't test under Retroarch because I have no idea how I got it configured in the first place (it's ignoring input from mouse, keyboard, and unrecognized joysticks for me).

As for mednafen, it doesn't recognize /dev/input/eventX input, but it should be possible to work around that by using xboxdrv in the mode where it acts as a Linux equivalent to x360ce. (Raw /dev/input/eventX in, fake XBox 360 controller /dev/input/jsX and /dev/input/eventX out.)

I'd offer a config to do that, but I'd like to see if I can come up with a proper fix before I resort to that. (I have dedicated NES, SNES, Genesis, N64, etc. controller adapters that I normally use because I can mount them to the underside of my desk, and a genuine Microsoft XBox 360 controller, so I've never bothered to learn how to configure xboxdrv to remap things.)

That said, I thought I remembered the Retrode working as a non-bothersome way to use a Genesis controller with mednafen and it turns out that switching to [HIDMode] 2; (2Joy) produces the working /dev/input/jsX that I remembered. (If you want a simple way to edit it, Leafpad works for me.)

HIDMode 2 also works with the http://html5gamepad.com/ link you posted, so I can only assume that browsers are depending on the legacy interface on Linux.

Finally, I did test [HIDMode] 1;'s /dev/input/eventX nodes with a Genesis controller and it appears that, while the raw input is detected by SDL2 and does show up in AntiMicro's joystick-mapping UI, everything but the D-Pad is on such high button numbers (eg. 50) that neither the Wine joystick control panel nor AntiMicro itself are compatible. (xboxdrv may be a solution, though I haven't tested it.)
« Last Edit: 31/Aug/2017 06:15:40 PM by ssokolow »