Re: SDL2 Windows Joysticks failing to load on start-up
D B <buckyballreaction <at> gmail.com>
2012-08-01 05:39:46 GMT
Please forgive me for replying to myself. I have new information.
One of our Windows developers found that initializing the joystick
system after the video system will make the error go away. Is this
what is supposed to happen with SDL2? or is just good or common
practice anyways? Having to load the subsystems in a specific order
wasn't something we had to worry about with SDL 1.2.
Also, I found this old mailing list patch for 1.2 that looks like it
may be the same problem:
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2004-October/046575.html
Maybe?
Thanks,
D
On Mon, Jul 30, 2012 at 8:07 PM, D B <buckyballreaction <at> gmail.com> wrote:
> Hi,
>
> In Windows (tested both in XP and 7), if I have a USB controller
> plugged in before starting my SDL2-based game, the game fails to
> detect the joystick upon start-up. I've traced the error to
> SDL_dxjoystick.c line 405:
>
> ---snip---
> result =
> IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata->
> InputDevice, SDL_HelperWindow,
> DISCL_EXCLUSIVE |
> DISCL_BACKGROUND);
> ---snap
>
> The above call fails when starting the game; however, it works when
> called again in the options menu of the game. The method I am calling
> in my game is Joystick::initJoystick(), and fails at
> SDL_JoystickOpen() at:
>
> https://code.google.com/p/bitfighter/source/browse/zap/Joystick.cpp#160
>
> Would anyone know why this is failing on start-up of the game, but not
> when it is loaded?
>
> I'm afraid I am not familiar with Windows programming (much less DX).
> Also, I do not have this problem in Mac OS X or Linux.
>
> Thanks for any help!
> D