RetroUSB joystick behaviour different in Windows and OSX/Linux

I originally reported this issue in 2007 (!) and then eventually forgot
about it. Now it’s popped up again, both in SDL1.2 and still present in
SDL2.0.

The adaptor I’m using is RetroUSB SNES controller, but others have
reported similar issues with the Genesis controller. The following output
from Stella (multi-platform Atari 2600 emulator) is as follows:

For Windows:
Joystick name: SNES
Attributes: 2 axes, 4 buttons, 0 hats

For OSX/Linux:
Joystick name: RetroUSB.com SNES RetroPort
Attributes: 2 axes, 8 buttons, 0 hats

Note that the device actually does have 8 buttons, and that the reported
USB names are different. So it seems that Windows isn’t properly/fully
detecting the device, and assigning the standard 2 axis/4 buttons??

Note that this is also confirmed in testjoystick in SDL1.2 and SDL2.0, so
it isn’t an app-specific problem. And I’ve seen similar reports through
Googling, but no solution.

Any advice on how to proceed? I’m willing to attempt to debug this, but
would like some idea on where to start. I have fairly extensive
experience with debugging SDL in Linux, but not in Windows at all. I have
access to all compilers and WIndows versions from XP onward (MSDNAA).

Thanks in advance for any info,
Steve A.
Stella maintainer

First of all, what do non-SDL programs say? Because I wouldn’t be
surprised if Windows picks up something completely different than
other systems do. If that’s the case there’s nothing SDL can do about
it.

Does it have an installable driver on Windows and just rely on USB
support on other systems? If so, get rid of the driver on Windows and
let USB as-is handle it. If you get the same layout as in the other
systems, you know what the culprit is.

Also I wonder if there are any gaps in the Windows layout. Maybe
there’s a gap in how buttons are assigned (e.g. buttons 4 and 5 are
missing or something like that) and that cuts short what SDL detects?
Doubt it though…

First of all, what do non-SDL programs say? Because I wouldn’t be
surprised if Windows picks up something completely different than
other systems do. If that’s the case there’s nothing SDL can do about
it.

Windows control panel shows 8 buttons, and it works in other emulators
that don’t use SDL. A user reported that older versions of FCEU (an
NES/SNES emulator based on SDL) also didn’t work with this adaptor, and
then suddenly it did after a specific release. I did a diff on the
releases between before and after it started working, and noticed that
the developer basically added platform-specific code to deal with
joysticks. That is, they added an DX5 component for Windows, joydev
code for LInux, etc. It looks like they ripped out specific parts of
SDL code and added it to their project.

I really want to avoid this unless absolutely necessary, since the
whole point of using SDL is to specifically not have to deal with
platform-specific issues.

Does it have an installable driver on Windows and just rely on USB
support on other systems? If so, get rid of the driver on Windows and
let USB as-is handle it. If you get the same layout as in the other
systems, you know what the culprit is.

No driver, just a standard HID controller, just as it is in OSX and Linux.

Also I wonder if there are any gaps in the Windows layout. Maybe
there’s a gap in how buttons are assigned (e.g. buttons 4 and 5 are
missing or something like that) and that cuts short what SDL detects?
Doubt it though…

That part I will have to check. I will also check with the original bug
reporter, as they seem to have a technical background and know a little
about how this device works.

But I still wonder why the reported USB name is different for Windows
compared to OSX/Linux. It almost seems as if SDL in Windows is using a
different joystick API to detect the stick, and is not successfully
doing so.

This is a pretty big bug for emulators, since the RetroUSB devices are
specifically created for such apps.

Thanks,
Steve A.
Stella maintainerOn 2013-09-25 1:26 AM, Sik the hedgehog wrote:

Windows control panel shows 8 buttons, and it works in other
emulators that don’t use SDL. A user reported that older versions of
FCEU (an NES/SNES emulator based on SDL) also didn’t work with this
adaptor, and then suddenly it did after a specific release. I did a
diff on the releases between before and after it started working, and
noticed that the developer basically added platform-specific code to
deal with joysticks. That is, they added an DX5 component for
Windows, joydev code for LInux, etc. It looks like they ripped out
specific parts of SDL code and added it to their project.

I really want to avoid this unless absolutely necessary, since the
whole point of using SDL is to specifically not have to deal with
platform-specific issues.

That’s very interesting. I must have misread you saying that
Windows itself sees only four of the eight buttons. But if it’s only
SDL that’s not seeing it, I’m more curious.

Actually, I may have stumbled across a similar problem:

http://www.3dconnexion.de/forum/viewtopic.php?t=4417

It seems that other controllers have issues using this same API. I
assume that is what SDL is using for your SNES controller, since you
note that it works properly under DirectInput-using software and that
a few projects have rolled their own DInput support.

SDL does have DInput support. If it is not the default, perhaps
someone can better explain why not than I.

SDL can of course be configured via its environment, but that’s
sub-optimal. I can’t say I understand joysticks under Windows enough
for more intelligent thought. As of DirectX 5.0, Microsoft
recommended using DirectInput for joystick support. As of 2005, they
recommend XInput?but XInput is basically an API for the XBox 360
controller or perhaps any other device that can be considered a close
cousin. Without any real analog controls, the SNES controller would
be excluded. :slight_smile: My slightly older Logitech Dual Action might not
even qualify since its L2/R2 are digital buttons rather than analog.

I also note that most of the PS3 controllers’ buttons are analog.
Far more than the XBox 360 controller. :wink: I suppose I can poke at
this later, though I’m limited to Windows XP at the moment. I’m
supposed to have a Windows 7 around here somewhere, but it hasn’t
happened yet.

No driver, just a standard HID controller, just as it is in OSX and Linux.

That pretty much shreds my notion of a driver initialization issue.
If the buttons I thought might be reported actually are, it would
likely be quite coincidental. Interesting, but coincidental.

Also I wonder if there are any gaps in the Windows layout. Maybe
there’s a gap in how buttons are assigned (e.g. buttons 4 and 5 are
missing or something like that) and that cuts short what SDL detects?
Doubt it though…

That part I will have to check. I will also check with the original
bug reporter, as they seem to have a technical background and know a
little about how this device works.

The first link I pasted above talks about other sticks using the same
driver not reporting things?but specifically with one of the THREE
joystick APIs used under Windows.

As I said, DInput used to be the right way to do it, but as of 2005,
Microsoft wants to push everyone into XInput. That’s very Apple of
them, actually, but it provides a consistent user experience without
much fiddling. That’s a good thing generally. :slight_smile: But your SNES
controller isn’t going to automatically map to XInput. There’s stuff
like x360ce out there, but ? yeah.

But SDL has DInput support, and SDL will give you a nice XInput-style
API for any controller you’ve got a mapping for, with anything XInput
being already pre-configured for you.

I don’t do enough gaming anywhere near Windows to know why
DInput/XInput would not be what SDL uses by default on Windows. It
seems the obvious choice to me.

But I still wonder why the reported USB name is different for Windows
compared to OSX/Linux. It almost seems as if SDL in Windows is using
a different joystick API to detect the stick, and is not successfully
doing so.

I’m actually pretty sure that’s exactly what’s happening since things
that use DirectInput seem to work.

JosephOn Wed, Sep 25, 2013 at 05:11:44AM -0230, Stephen Anthony wrote:

But I still wonder why the reported USB name is different for Windows
compared to OSX/Linux. It almost seems as if SDL in Windows is using
a different joystick API to detect the stick, and is not successfully
doing so.

I’m actually pretty sure that’s exactly what’s happening since things
that use DirectInput seem to work.

OK, now that we’ve (sort of) determined that the issue is related to how
SDL queries the stick, and that another API seems to work, how do I go
about testing this? Is there a way to force SDL to use another joystick
API? And longer term, can this be fixed in SDL proper?

Again, I’m not opposed to actually attempting it myself, I just need to
know where to begin. Sam, Ryan, anyone, can you provide some info??

Thanks,
Steve A.
Stella maintainerOn September 25, 2013 9:44:12 AM T. Joseph Carter wrote:

On Wed, Sep 25, 2013 at 05:11:44AM -0230, Stephen Anthony wrote:

Success! The RetroUSB works in SDL2 after all. I just realized my error.
I compiled SDL2 in MinGW, but since I didn’t have DirectX9 installed, I
guess it didn’t include DirectInput support. When I used the SDL2.dll
downloaded from the official website, the testjoystick program correctly
recognizes all buttons.

Now it won’t work in SDL1.2, but as I’m in the process of porting Stella
to SDL2, that doesn’t bother me too much.

So sorry for the confusion. It looks like the new DirectInput
functionality in SDL2 is working great, and that is a big load off my
shoulders.

Thanks,
Steve A.
Stella maintainer

…I suppose my “doesn’t have DirectInput” guess was right after all
(argh, why is this thread split in two in the mailing list?).

And yeah, avoid MinGW like the plague, stick to MinGW-w64 if possible.
That should include good DirectX support in it.

I don’t typically use MinGW at all, and usually stick to Visual Studio
2012. It just seemed to be the quickest way to get the testjoystick app
compiled and tested. Lesson learned :slight_smile:

Thanks,
Steve A.
Stella maintainerOn September 25, 2013 6:04:15 PM Sik the hedgehog wrote:

…I suppose my “doesn’t have DirectInput” guess was right after all
(argh, why is this thread split in two in the mailing list?).

And yeah, avoid MinGW like the plague, stick to MinGW-w64 if possible.
That should include good DirectX support in it.

I suppose someone could port the DirectInput driver to SDL 1.2 easily
enough if Sam ever intends to push out a 1.2.16 to fix any niggling
bugs. It doesn’t look like it’d be too hard or take too long to do
the port.

The major differences appear to be making the old code conform to
SDL’s coding standards, adding joystick add/remove support, and
little else. The SDL joystick API is largely unchanged from 1.2 to
2.0, as noted in the migration guide. Since the DirectInput/XInput
driver is based upon the old multimedia driver, you’d just undo those
API changes and do the associated autoconf, cmake, Visual Studio,
etc. changes to make the new driver get used if possible.

I could take a few minutes to make the changes?mostly because I’ve
been spending a fair bit of time getting to know that section of
SDL’s code in the past week or so. Getting it to compile and work
would be up to you if you’re up to the challenge. :smiley: I just don’t
have the toolchain set up for it here. You might just want to spend
the effort on SDL 2.0 porting though.

JosephOn Wed, Sep 25, 2013 at 01:47:40PM -0230, Stephen Anthony wrote:

On September 25, 2013 9:44:12 AM T. Joseph Carter wrote:

On Wed, Sep 25, 2013 at 05:11:44AM -0230, Stephen Anthony wrote:

But I still wonder why the reported USB name is different for Windows
compared to OSX/Linux. It almost seems as if SDL in Windows is using
a different joystick API to detect the stick, and is not successfully
doing so.

I’m actually pretty sure that’s exactly what’s happening since things
that use DirectInput seem to work.

OK, now that we’ve (sort of) determined that the issue is related to how
SDL queries the stick, and that another API seems to work, how do I go
about testing this? Is there a way to force SDL to use another joystick
API? And longer term, can this be fixed in SDL proper?

Again, I’m not opposed to actually attempting it myself, I just need to
know where to begin. Sam, Ryan, anyone, can you provide some info??

Thanks,
Steve A.
Stella maintainer


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

FYI, there aren’t any future SDL 1.2 releases planned. That’s not to say
it won’t happen, but I wouldn’t spend too much time on 1.2 code at this
point.

Cheers,
–SamOn Wed, Sep 25, 2013 at 7:59 PM, T. Joseph Carter < tjcarter at spiritsubstance.com> wrote:

I suppose someone could port the DirectInput driver to SDL 1.2 easily
enough if Sam ever intends to push out a 1.2.16 to fix any niggling bugs.
It doesn’t look like it’d be too hard or take too long to do the port.

The major differences appear to be making the old code conform to SDL’s
coding standards, adding joystick add/remove support, and little else. The
SDL joystick API is largely unchanged from 1.2 to 2.0, as noted in the
migration guide. Since the DirectInput/XInput driver is based upon the old
multimedia driver, you’d just undo those API changes and do the associated
autoconf, cmake, Visual Studio, etc. changes to make the new driver get
used if possible.

I could take a few minutes to make the changes?mostly because I’ve been
spending a fair bit of time getting to know that section of SDL’s code in
the past week or so. Getting it to compile and work would be up to you if
you’re up to the challenge. :smiley: I just don’t have the toolchain set up for
it here. You might just want to spend the effort on SDL 2.0 porting though.

Joseph

On Wed, Sep 25, 2013 at 01:47:40PM -0230, Stephen Anthony wrote:

On September 25, 2013 9:44:12 AM T. Joseph Carter wrote:

On Wed, Sep 25, 2013 at 05:11:44AM -0230, Stephen Anthony wrote:

But I still wonder why the reported USB name is different for Windows

compared to OSX/Linux. It almost seems as if SDL in Windows is using
a different joystick API to detect the stick, and is not successfully
doing so.

I’m actually pretty sure that’s exactly what’s happening since things
that use DirectInput seem to work.

OK, now that we’ve (sort of) determined that the issue is related to how
SDL queries the stick, and that another API seems to work, how do I go
about testing this? Is there a way to force SDL to use another joystick
API? And longer term, can this be fixed in SDL proper?

Again, I’m not opposed to actually attempting it myself, I just need to
know where to begin. Sam, Ryan, anyone, can you provide some info??

Thanks,
Steve A.
Stella maintainer

_____________**

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I agree. My intent was to add it to SDL2, since I thought it wasn’t
present (a mistake on my part, obviously). I have no interest to work
on SDL1.2. In fact, I’m in the process of porting Stella to SDL2 right
now. So I can just tell the end-user that it will be fixed with the
next release.

Thanks,
Steve A.
Stella maintainerOn 26/09/13 02:11 AM, Sam Lantinga wrote:

FYI, there aren’t any future SDL 1.2 releases planned. That’s not to
say it won’t happen, but I wouldn’t spend too much time on 1.2 code at
this point.

Huh, I thought the issue was that MinGW didn’t include DirectInput so
SDL2 was built without it…

Which means the bug is with MingW, not SDL. :wink:

JosephOn Thu, Sep 26, 2013 at 03:41:15PM -0300, Sik the hedgehog wrote:

Huh, I thought the issue was that MinGW didn’t include DirectInput so
SDL2 was built without it…

Thereby MinGW-w64 :stuck_out_tongue_winking_eye: (that version does include DirectInput)

2013/9/26, T. Joseph Carter :> On Thu, Sep 26, 2013 at 03:41:15PM -0300, Sik the hedgehog wrote:

Huh, I thought the issue was that MinGW didn’t include DirectInput so
SDL2 was built without it…

Which means the bug is with MingW, not SDL. :wink:

Joseph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org