Support for XInput on Windows

Hey everybody,

On the windows platform the 360 controller is becoming more and more the
standard controller for games. Not very surprising as Microsoft is
providing the XInput API pretty much exclusively for it and I suppose
GFWL is sortof required to utilize it.

The problem with the 360 controller is that it does not work with the
old DirectInput API properly. Only one analog stick will show up and
vibration does not work.

Has anyone already attempted to extend the SDL joystick implementation
to support XInput.

Regards,
Armin

As far as I know nobody has looked into this, but you’re more than welcome
to contribute it. :slight_smile:

See ya!On Mon, Apr 11, 2011 at 2:15 AM, Armin Ronacher <armin.ronacher at active-4.com wrote:

Hey everybody,

On the windows platform the 360 controller is becoming more and more the
standard controller for games. Not very surprising as Microsoft is
providing the XInput API pretty much exclusively for it and I suppose
GFWL is sortof required to utilize it.

The problem with the 360 controller is that it does not work with the
old DirectInput API properly. Only one analog stick will show up and
vibration does not work.

Has anyone already attempted to extend the SDL joystick implementation
to support XInput.

Regards,
Armin


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

Hi,On 2011-04-11 5:14 PM, Sam Lantinga wrote:

As far as I know nobody has looked into this, but you’re more than
welcome to contribute it. :slight_smile:
I actually wasted four hours today trying to get it running and did a hg
checkout --clean in agony afterwards. Partially because I tried to
interface WMI for figuring out if a DirectInput device is an XInput
device via C and not C++ to stick to the established code style in SDL,
but also partially because SDL for whatever reason disables the stdlib.

Is there a guide to SDL development somewhere I missed and the reasoning
for the unavailability of things like wcsstr in the windows build of SDL
and how to cope with that?

Regards,
Armin

The reason stock SDL doesn’t use the C library is to avoid the various C
runtime issues between different versions of MSVCRT.

It’s less of an issue with the zlib license since you no longer have to
dynamically link with a precompiled SDL library, so if you want to submit a
patch using the C routines that’s fine.

I think you can enable it by changing SDL_config_windows.h, just look for
HAVE_LIBC. I haven’t enabled this in a while, so you might have to fix a
few things if you turn that on.

See ya!On Wed, Apr 13, 2011 at 12:12 PM, Armin Ronacher < armin.ronacher at active-4.com> wrote:

Hi,

On 2011-04-11 5:14 PM, Sam Lantinga wrote:

As far as I know nobody has looked into this, but you’re more than
welcome to contribute it. :slight_smile:

I actually wasted four hours today trying to get it running and did a hg
checkout --clean in agony afterwards. Partially because I tried to
interface WMI for figuring out if a DirectInput device is an XInput device
via C and not C++ to stick to the established code style in SDL, but also
partially because SDL for whatever reason disables the stdlib.

Is there a guide to SDL development somewhere I missed and the reasoning
for the unavailability of things like wcsstr in the windows build of SDL and
how to cope with that?

Regards,
Armin


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

Hi,On 2011-04-14 7:53 PM, Sam Lantinga wrote:

The reason stock SDL doesn’t use the C library is to avoid the various C
runtime issues between different versions of MSVCRT.
Alright, guess that makes sense. I can just implement the few missing
functions myself and cut it down to the necessary minimum.

Unfortunately there are a few other small problems with XInput support
in SDL. The 360 controller encourages hot plugging of controllers which
seems to be hard to implement on top of the current API. I suppose it
would make sense to register 4 controllers automatically and provide
functions to check if they are indeed connected:

SDL_JoystickIsConnected(joystick);
Returns true if the joystick is not only present but also connected.

Does this make any sense?

Regards,
Armin

Armin Ronacher wrote:

Hi,

The reason stock SDL doesn’t use the C library is to avoid the various C
runtime issues between different versions of MSVCRT.

Alright, guess that makes sense. I can just implement the few missing
functions myself and cut it down to the necessary minimum.

Unfortunately there are a few other small problems with XInput support
in SDL. The 360 controller encourages hot plugging of controllers which
seems to be hard to implement on top of the current API. I suppose it
would make sense to register 4 controllers automatically and provide
functions to check if they are indeed connected:

SDL_JoystickIsConnected(joystick);
Returns true if the joystick is not only present but also connected.

Does this make any sense?

Regards,
Armin


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

Or you could abstract SDL_JoystickIsConnected() away and just say “if it’s not connected, it doesn’t exist”.> On 2011-04-14 7:53 PM, Sam Lantinga wrote:


EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

Hi,On 4/15/11 10:55 AM, Nathaniel J Fries wrote:

Or you could abstract SDL_JoystickIsConnected() away and just say “if
it’s not connected, it doesn’t exist”.
Not possible because joystick ids are in order and an xbox controller
can go away and come back during runtime.

Regards,
Armin