Fixed bug 3456 - SDL_GameControllerOpen fails if the joystick subsystem isn't initialized
authorSam Lantinga <slouken@libsdl.org>
Mon, 17 Oct 2016 21:44:32 -0700
changeset 105491dfa58e94f88
parent 10548 aea47b61c640
child 10550 d8a72d273dd2
Fixed bug 3456 - SDL_GameControllerOpen fails if the joystick subsystem isn't initialized

Philipp Wiesemann

Maybe the fault is in the SDL_VIDEO_DRIVER_WINDOWS section in SDL_InitSubSystem() of "src/SDL.c". Because there only SDL_INIT_JOYSTICK is checked. The flags are adapted for SDL_INIT_GAMECONTROLLER afterwards.
src/SDL.c
     1.1 --- a/src/SDL.c	Mon Oct 17 21:37:26 2016 -0700
     1.2 +++ b/src/SDL.c	Mon Oct 17 21:44:32 2016 -0700
     1.3 @@ -115,6 +115,16 @@
     1.4      /* Clear the error message */
     1.5      SDL_ClearError();
     1.6  
     1.7 +    if ((flags & SDL_INIT_GAMECONTROLLER)) {
     1.8 +        /* game controller implies joystick */
     1.9 +        flags |= SDL_INIT_JOYSTICK;
    1.10 +    }
    1.11 +
    1.12 +    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
    1.13 +        /* video or joystick implies events */
    1.14 +        flags |= SDL_INIT_EVENTS;
    1.15 +    }
    1.16 +
    1.17  #if SDL_VIDEO_DRIVER_WINDOWS
    1.18  	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
    1.19  		if (SDL_HelperWindowCreate() < 0) {
    1.20 @@ -127,16 +137,6 @@
    1.21      SDL_TicksInit();
    1.22  #endif
    1.23  
    1.24 -    if ((flags & SDL_INIT_GAMECONTROLLER)) {
    1.25 -        /* game controller implies joystick */
    1.26 -        flags |= SDL_INIT_JOYSTICK;
    1.27 -    }
    1.28 -
    1.29 -    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
    1.30 -        /* video or joystick implies events */
    1.31 -        flags |= SDL_INIT_EVENTS;
    1.32 -    }
    1.33 -
    1.34      /* Initialize the event subsystem */
    1.35      if ((flags & SDL_INIT_EVENTS)) {
    1.36  #if !SDL_EVENTS_DISABLED