We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2322 - SDL_CONTROLLERDEVICEADDED not fired for Xbox360 controller
Summary: SDL_CONTROLLERDEVICEADDED not fired for Xbox360 controller
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.0
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-22 22:48 UTC by BurnSpamAddress
Modified: 2014-01-05 19:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description BurnSpamAddress 2013-12-22 22:48:09 UTC
I am testing the new gamecontroller API with an Xbox360 controller.

When I initialize the JOYSTICK and GAMECONTROLLER subsystems, I only receive JOYDEVICEADDED and JOYDEVICEREMOVED events but no CONTROLLERDEVICEADDED or CONTROLLERDEVICEREMOVED. If I call SDL.IsGameController() in the JOYDEVICEADDED event it returns false, even though this a Xbox360 controller and it's the only controller connected to the system! 

This is on Windows 7 64bit with Visual Studio 2013 installed. I am using SDL 2.0.1 downloaded from libsdl.org (x64 version).

Do I need to install something else in order to use the Xbox360 controller through the GameController API?
Comment 1 BurnSpamAddress 2013-12-22 22:53:53 UTC
Querying the device through the joystick API gives:

'XInput Controller #1' has 6 axes, 15 buttons, 0 hats, 0 balls

The JOYSTICK and GAMECONTROLLER subsystems are initialized without error.
Comment 2 BurnSpamAddress 2013-12-22 23:11:04 UTC
More information: if I connect the device after my application is up and running, then I correctly receive CONTROLLERDEVICEADDED/REMOVED events.

If the device is connected before I start my application, then CONTROLLERDEVICEADDED/REMOVED events are *not* fired until I unplug&replug the device.

Is this a bug in SDL2?
Comment 3 BurnSpamAddress 2013-12-22 23:26:16 UTC
If I ignore the fact that SDL.IsGameController() returns false and I open the device with SDL.GameControllerOpen() anyway, then SDL.GetError() returns the following message:

"Couldn't find mapping for device (0)"

If I unplug and replug the device then SDL.GameControllerOpen() works correctly.

Please let me know if you need more information to trace this issue.
Comment 4 BurnSpamAddress 2013-12-23 00:10:32 UTC
This issue is also reproducible in hg 8064.
Comment 5 Sam Lantinga 2013-12-23 23:12:11 UTC
Added events should be generated at init for supported controllers with this commit:
http://hg.libsdl.org/SDL/rev/8314a9008bf1

What is the output of testgamecontroller 0 with that controller plugged in?
Comment 6 BurnSpamAddress 2013-12-24 17:12:27 UTC
Thanks, with this patch the controller name is reported correctly when the controller is already connected. However, I am now getting random initialization errors:

"CoInitialize() DirectX error -2147417850"

This probably belongs to a different report.
Comment 7 Sam Lantinga 2014-01-05 19:21:39 UTC
I also fixed the CoInitialize() errors.