Author Topic: SNES controller support, Linux  (Read 470 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: 24
  • Karma: +12/-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: 24
  • Karma: +12/-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 »

Offline hadess

  • Baby Retrode
  • *
  • Posts: 6
  • Karma: +2/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #3 on: 11/Oct/2017 12:02:33 PM »
Upgrade your kernel!

I wrote a driver for the Retrode which splits off the 4 joysticks into SNES/N64 and Megadrive pairs, along with understandable names. It's upstream now, but you can use this out-of-tree driver if you need:
https://github.com/hadess/retrode

I will not answer questions about the out-of-tree driver, as it's only there for my own development, and helping reviewers. Ask your distribution to add the Retrode driver to their kernel if you run into trouble with the out-of-tree driver.

HTH!

Offline Aleron Ives

  • Junior Retrode
  • **
  • Posts: 43
  • Karma: +2/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #4 on: 13/Oct/2017 12:39:16 AM »
Is there a specific minimum kernel version that would be likely to have it?

Offline Limero

  • Baby Retrode
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #5 on: 13/Oct/2017 04:00:00 PM »
Is there a specific minimum kernel version that would be likely to have it?

4.12
http://www.hadess.net/2017/07/gaming-hardware-support.html

Offline Aleron Ives

  • Junior Retrode
  • **
  • Posts: 43
  • Karma: +2/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #6 on: 14/Oct/2017 01:06:45 AM »
Bummer. Even Fedora 26 only has 4.11, and Debian-based distros are further behind. Linux Mint won't let you get 4.12 from the update manager, so you'd have to manually install it. I guess I don't understand why a special driver is needed, though. I thought the Retrode displayed controllers as HID-compliant devices for the specific purpose of making sure that you wouldn't need a special driver to use them.
« Last Edit: 14/Oct/2017 01:08:30 AM by Aleron Ives »

Offline hadess

  • Baby Retrode
  • *
  • Posts: 6
  • Karma: +2/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #7 on: 15/Nov/2017 12:38:49 AM »
Bummer. Even Fedora 26 only has 4.11, and Debian-based distros are further behind. Linux Mint won't let you get 4.12 from the update manager, so you'd have to manually install it.

Fedora 26's current kernel is a 4.13 kernel. You can see the module right there, in F26's latest kernel update:
https://koji.fedoraproject.org/koji/rpminfo?fileStart=400&rpmID=12007155&fileOrder=name&buildrootOrder=-id&buildrootStart=0#filelist

Quote
I guess I don't understand why a special driver is needed, though. I thought the Retrode displayed controllers as HID-compliant devices for the specific purpose of making sure that you wouldn't need a special driver to use them.

It shows up as a single joypad with tons of buttons without a driver, which works fine if you can remap all the buttons, but not easy to work with, and impossible to do in some games and emulators.

The driver splits it up into 4 separate joypads with nice names and a device for the SNES mouse if you have one, and want to use it for emulating Mario Paint, for maximum immersion :) Is that clearer than my previous comment?

Offline Aleron Ives

  • Junior Retrode
  • **
  • Posts: 43
  • Karma: +2/-0
    • View Profile
Re: SNES controller support, Linux
« Reply #8 on: 15/Nov/2017 09:51:38 AM »
Fedora 26's current kernel is a 4.13 kernel.
I was talking about the kernel Fedora 26 ships with. Kernel updates are, IME, a risky venture, even though you can ostensibly roll back to a previous kernel if something goes wrong with the new one.

Is that clearer than my previous comment?
Yep. Hopefully I can get the driver on github to compile and run under Mint. ;D