SDL_IsGameController() returning false with Xbox controller

Hi all,
I’m trying to detect a genuine Xbox360 controller, but SDL_IsGameController is returning false.

Using Visual studio 2013 community on windows 7 64bit SP1.
I have a genuine xbox controller plugged in one of the USB ports and the system ‘Set up USB game controllers’ shows the pad working OK.

The test project is using SDL_gamecontroller.h and SDL_gamecontroller.c from www.libsdl.org and is using the x86 library on a VC x86 build.

When I build and run the project the console window displays this:

INFO: Joystick 0: XBOX 360 For Windows (Controller) (guid 5e048e0200000000000050
4944564944)
INFO: There are 0 game controller(s) attached (1 joystick(s))

It is the same in my game code. I’ve searched the net and cannot fathom whats going on. I don’t have another controller to try at the moment.

SDL joystick calls work okay but the user would have to redefine the pad buttons etc for their stick, which is what gamecontroller is meant to avoid.

Any ideas? Thanks in advance. :smiley:

Which version of SDL are you using? It sounds like Xinput support isn?t enabled or detected or something.> On Sep 13, 2015, at 3:24 PM, MattRobinson <matt.robinson.mail at gmail.com> wrote:

INFO: Joystick 0: XBOX 360 For Windows (Controller) (guid 5e048e0200000000000050
4944564944)
INFO: There are 0 game controller(s) attached (1 joystick(s))

UPDATE: I also compiled and run testjoystick.c from https://github.com/zielmicha/SDL2/blob/master/test/testjoystick.c and had this result in the console;

There are 1 joysticks attached
Joystick 0: XBOX 360 For Windows (Controller)
axes: 5
balls: 0
hats: 1
buttons: 10
instance id: 0
guid: 5e048e02000000000000504944564944
Press any key to continue . . .

Perhaps you need a gamecontrollerdb.txt file.On 9/13/15, MattRobinson <matt.robinson.mail at gmail.com> wrote:

UPDATE: I also compiled and run testjoystick.c from
https://github.com/zielmicha/SDL2/blob/master/test/testjoystick.c and had
this result in the console;

I was having this issue yesterday,

check_include_file(xinput.h HAVE_XINPUT_H)

is returning 0, I just added this line after it and it worked fine, not sure why cmake can’t find that header file though.

set(HAVE_XINPUT_H 1)> On Sep 13, 2015, at 12:05 PM, Robert Ransom <rransom.8774 at gmail.com> wrote:

On 9/13/15, MattRobinson <matt.robinson.mail at gmail.com> wrote:

UPDATE: I also compiled and run testjoystick.c from
https://github.com/zielmicha/SDL2/blob/master/test/testjoystick.c and had
this result in the console;

Perhaps you need a gamecontrollerdb.txt file.


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

That was a bug in SDL?s cmake file: https://bugzilla.libsdl.org/show_bug.cgi?id=3098 https://bugzilla.libsdl.org/show_bug.cgi?id=3098 which was fixed recently: https://hg.libsdl.org/SDL/rev/3d08cb641cd5 https://hg.libsdl.org/SDL/rev/3d08cb641cd5

If you use the latest source from SDL?s Mercurial repository that issue should be gone.> On Sep 13, 2015, at 4:12 PM, Jonathan Scott wrote:

I was having this issue yesterday,

check_include_file(xinput.h HAVE_XINPUT_H)

is returning 0, I just added this line after it and it worked fine, not sure why cmake can’t find that header file though.

set(HAVE_XINPUT_H 1)


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

@Alex Szpakowski: I’m using SDL 2.0.3

@Robert Ransom: I’ve tried including gamecontrollerdb.txt with no effect

@30jon: Where do you find that code Jon? I can’t find xinput.h in the SDL include files.

@Alex Szpakowski: Thanks the info, I’ll try that tomorrow. ???

UPDATE:

I’m still not getting anywhere with this gamecontroller problem.

Tried this;
Downloaded SDL-2.0.4-9799 from https://www.libsdl.org/hg.php

Ran the VS2010 solution in …SDL-2.0.4-9799\VisualC\SDL.sln using VS2013 Update 4 community on Win 7 Pro 64bit OS.

An upgrade VS compilers warning dialog was displayed - accepted upgrade.

[Image: https://lh3.googleusercontent.com/-akwMah1kWfQ/VfaoPVZs-PI/AAAAAAAAAhY/-CAu3QJlZho/s640-Ic42/upgrade%2520VC%2520compilers.png ]

SDL2, SDL2main, SDL2test all built. SDL2.lib, SDL2main.lib, SDL2test.lib and SDL2.dll all created here; …SDL-2.0.4-9799\VisualC\Win32\Debug

Using the game controller test project SDL_gamecontroller.h and SDL_gamecontroller.c from www.libsdl.org on a x86 build with VS2013 Update 4 community on Win 7 Pro 64bit OS.

GAMECONTROLLER PROJECT CONFIG PROPERTIES::
C/C++ > include and library directory paths set to;
include: …SDL-2.0.4-9799\include
libraries: …SDL-2.0.4-9799\VisualC\Win32\Debug

C/C++ > code generation > runtime libary: multi-threaded DLL (/MD)

Linker > input> additional dependencies: SDL2.lib, SDL2main.lib

linker > system > subsystem: console

New SDL2.dll;
…SDL-2.0.4-9799\VisualC\Win32\Debug\SDL2.dll copied to Visual Studio 2013\Projects\gamecontrollertest\Debug

Rebuilt solution. Same problem.

INFO: Joystick 0: XBOX 360 For Windows (Controller) (guid 5e048e0200000000000050
4944564944)
INFO: There are 0 game controller(s) attached (1 joystick(s))
Press any key to continue . . .

Copied the above project and rebuilt with SDL2-2.0.4.zip from https://www.libsdl.org/tmp/download-2.0.php changing the include / library paths, and using the SDL2-2.0.4.zip SDL2.dll version. Still the same output.

I cannot build the SDL-2.0.4-9799 project with VS2010 (or try it with VS2008) as the express versions do not support solutions and throw lots of build errors.

Thinking of trying VS 2015 community next.

Out of curiosity - do you have the June 2010 DirectX SDK installed?

Off the top of my head SDL loads Xinput at runtime, and doesn?t support version 9.1.0 (which is the version included with Windows 7). It needs the Xinput 1.3 redistributable installed in order to function.

See also: https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx?f=255&MSPPError=-2147217396

-Luke> On Sep 14, 2015, at 5:23 AM, MattRobinson <matt.robinson.mail at gmail.com> wrote:

UPDATE:

I’m still not getting anywhere with this gamecontroller problem.

Tried this;
Downloaded SDL-2.0.4-9799 from https://www.libsdl.org/hg.php https://www.libsdl.org/hg.php

Ran the VS2010 solution in …SDL-2.0.4-9799\VisualC\SDL.sln using VS2013 Update 4 community on Win 7 Pro 64bit OS.

An upgrade VS compilers warning dialog was displayed - accepted upgrade.

SDL2, SDL2main, SDL2test all built. SDL2.lib, SDL2main.lib, SDL2test.lib and SDL2.dll all created here; …SDL-2.0.4-9799\VisualC\Win32\Debug

Using the game controller test project SDL_gamecontroller.h and SDL_gamecontroller.c from www.libsdl.org http://www.libsdl.org/ on a x86 build with VS2013 Update 4 community on Win 7 Pro 64bit OS.

GAMECONTROLLER PROJECT CONFIG PROPERTIES::
C/C++ > include and library directory paths set to;
include: …SDL-2.0.4-9799\include
libraries: …SDL-2.0.4-9799\VisualC\Win32\Debug

C/C++ > code generation > runtime libary: multi-threaded DLL (/MD)

Linker > input> additional dependencies: SDL2.lib, SDL2main.lib

linker > system > subsystem: console

New SDL2.dll;
…SDL-2.0.4-9799\VisualC\Win32\Debug\SDL2.dll copied to Visual Studio 2013\Projects\gamecontrollertest\Debug

Rebuilt solution. Same problem.

INFO: Joystick 0: XBOX 360 For Windows (Controller) (guid 5e048e0200000000000050
4944564944)
INFO: There are 0 game controller(s) attached (1 joystick(s))
Press any key to continue . . .

Copied the above project and rebuilt with SDL2-2.0.4.zip from https://www.libsdl.org/tmp/download-2.0.php https://www.libsdl.org/tmp/download-2.0.php changing the include / library paths, and using the SDL2-2.0.4.zip SDL2.dll version. Still the same output.

I cannot build the SDL-2.0.4-9799 project with VS2010 (or try it with VS2008) as the express versions do not support solutions and throw lots of build errors.

Thinking of trying VS 2015 community next.


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

Luke Groeninger wrote:

Out of curiosity - do you have the June 2010 DirectX SDK installed?
Off the top of my head SDL loads Xinput at runtime, and doesn???t support version 9.1.0 (which is the version included with Windows 7). It needs the Xinput 1.3 redistributable installed in order to function.

See also: https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx?f=255&MSPPError=-2147217396 (https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx?f=255&MSPPError=-2147217396)

-Luke

@Luke: You got it! I couldn’t find the Xinput version so installed DirectX End-User Runtime Web Installer from here http://www.microsoft.com/en-us/download/details.aspx?id=35 and the gamecontrollertest project (using SDL 2.0.4) finds the controller no problem. Same with my game code using SDL 2.0.3.

Looks like I’ll have to make sure that the end user (Gamer) has this update installed.

Thanks again!

Cool! Glad it worked!

IIRC, SDL does the right thing and looks for Xinput 1.4 first, so on
systems running Windows 8 and higher you don’t need to install anything
to make it work. It’s pretty much only a requirement if the machine is
running Windows 7 or Vista.

If you don’t have any other dependency on the DirectX redistributable I
believe you can simply package Xinput1_3.dll alongside the SDL dll in
your game directory. It’s not my preferred way of distributing
libraries, but it’s deprecated at this point and IIRC there are a number
of AAA games that ship it like that.

-Luke

Luke Groeninger wrote:

Out of curiosity - do you have the June 2010 DirectX SDK installed?

Off the top of my head SDL loads Xinput at runtime, and doesn???t
support version 9.1.0 (which is the version included with Windows 7). It
needs the Xinput 1.3 redistributable installed in order to function.

See also:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx?f=255&MSPPError=-2147217396

-Luke

@Luke: You got it! I couldn’t find the Xinput version so installed
DirectX End-User Runtime Web Installer from here
http://www.microsoft.com/en-us/download/details.aspx?id=35 and the
gamecontrollertest project (using SDL 2.0.4) finds the controller no
problem. Same with my game code using SDL 2.0.3.

Looks like I’ll have to make sure that the end user (Gamer) has this
update installed.

Thanks again!On Mon, Sep 14, 2015, at 09:08 AM, MattRobinson wrote:


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

@Luke: Am I right in thinking that SDL needs the xinput 1.4 or 1.3 redist, but because my system had only the the 9.1.0 redist then SDL failed to init Xinput. So updating DX updated xinput to 1.4 which solved the problem?

That’s some strange versioning; 1.4, 9.1.0 then 1.4. What’s that about! :?

I meant 1.3, 9.1.0 then 1.4, doh!

Am I right in thinking that SDL needs the xinput 1.4 or 1.3 redist, but because my system had only the the 9.1.0 redist then SDL failed to init Xinput. So updating DX updated xinput to 1.4 which solved the problem?

Sounds about right. That said, it seems like SDL should try to use Xinput 9.1.0 if no other version is available, and it feels like an oversight that it doesn?t. I?ll look into adding that tonight (barring any unforeseen issues.)

That’s some strange versioning; 1.3, 9.1.0 then 1.4. What’s that about!

Typical Microsoft. :wink:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx

Off the top of my head, Xinput 9.1 isn’t directly compatible with Xinput
1.3 or 1.4. IIRC it has a few semantic differences (both in terms of
function calls and compile-time constants) that makes it difficult to
write a single code path that supports both at runtime.

It would be nice to have it available as a fallback, but I’m not sure
it’s worth the effort it would take to make it work. Especially since
Xinput 1.3 is pretty ubiquitous at this point.On Mon, Sep 14, 2015, at 11:35 AM, Alex Szpakowski wrote:

Am I right in thinking that SDL needs the xinput 1.4 or 1.3 redist,
but because my system had only the the 9.1.0 redist then SDL failed
to init Xinput. So updating DX updated xinput to 1.4 which solved the
problem?

Sounds about right. That said, it seems like SDL should try to use
Xinput 9.1.0 if no other version is available, and it feels like an
oversight that it doesn?t. I?ll look into adding that tonight (barring
any unforeseen issues.)

That’s some strange versioning; 1.3, 9.1.0 then 1.4. What’s that
about!Confused

Typical Microsoft. :wink:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx


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

The documentation at https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx says that 9.1.0 is just missing a few features (which mostly aren?t used by SDL anyway), and the xinput.h header included in the DX 2010 SDK corroborates that - although it could end up being a larger issue than I assume it will be.> On Sep 14, 2015, at 3:32 PM, Luke wrote:

Off the top of my head, Xinput 9.1 isn’t directly compatible with Xinput 1.3 or 1.4. IIRC it has a few semantic differences (both in terms of function calls and compile-time constants) that makes it difficult to write a single code path that supports both at runtime.

I pushed this commit: https://hg.libsdl.org/SDL/rev/c1941443f59a https://hg.libsdl.org/SDL/rev/c1941443f59a which seems to work on my system.

However I was only able to test by temporarily preventing SDL from looking for XInput 1.3 and 1.4 when loading its joystick code, so it?d be great if anyone on a Windows Vista or 7 system that still doesn?t have those XInput versions could test if Xbox 360 controllers are recognized as SDL gamecontrollers with a build of the latest source code!> On Sep 14, 2015, at 2:35 PM, Alex Szpakowski <@Alex_Szpakowski> wrote:

Am I right in thinking that SDL needs the xinput 1.4 or 1.3 redist, but because my system had only the the 9.1.0 redist then SDL failed to init Xinput. So updating DX updated xinput to 1.4 which solved the problem?

Sounds about right. That said, it seems like SDL should try to use Xinput 9.1.0 if no other version is available, and it feels like an oversight that it doesn?t. I?ll look into adding that tonight (barring any unforeseen issues.)

Alex Szpakowski wrote:

I pushed this commit: https://hg.libsdl.org/SDL/rev/c1941443f59a (https://hg.libsdl.org/SDL/rev/c1941443f59a) which seems to work on my system.

However I was only able to test by temporarily preventing SDL from looking for XInput 1.3 and 1.4 when loading its joystick code, so it???d be great if anyone on a Windows Vista or 7 system that still doesn???t have those XInput versions could test if Xbox 360 controllers are recognized as SDL gamecontrollers with a build of the latest source code!

@Alex: I tried to find out way of temporarily uninstalling the DX9 web installer upgrade from my PC (This upgrade that fixed the isgamecontroller() problem) but failed so I can’t test your new build sorry.

Oh cool! I?ll have to find a Windows 7 box and give it a shot.

I have no idea what I was thinking of re: version differences - I migrated from Xinput to SDL a long time ago so it could be anything at this point. My bad!On Sep 14, 2015, at 7:54 PM, Alex Szpakowski wrote:

I pushed this commit: https://hg.libsdl.org/SDL/rev/c1941443f59a https://hg.libsdl.org/SDL/rev/c1941443f59a which seems to work on my system.

However I was only able to test by temporarily preventing SDL from looking for XInput 1.3 and 1.4 when loading its joystick code, so it?d be great if anyone on a Windows Vista or 7 system that still doesn?t have those XInput versions could test if Xbox 360 controllers are recognized as SDL gamecontrollers with a build of the latest source code!

On Sep 14, 2015, at 2:35 PM, Alex Szpakowski <aszpakowski at gmail.com <mailto:aszpakowski at gmail.com>> wrote:

Am I right in thinking that SDL needs the xinput 1.4 or 1.3 redist, but because my system had only the the 9.1.0 redist then SDL failed to init Xinput. So updating DX updated xinput to 1.4 which solved the problem?

Sounds about right. That said, it seems like SDL should try to use Xinput 9.1.0 if no other version is available, and it feels like an oversight that it doesn?t. I?ll look into adding that tonight (barring any unforeseen issues.)


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