SDL_JOYBUTTONDOWN/SDL_KEYDOWN not detected when out of focus

It seems that SDL_JOYBUTTONDOWN events are not picked up when the window is out of focus.

This pastebin shows code that proves my theory:
http://pastebin.com/3TsGJdXH

This is what happens if the window is in focus and I press a joystick button, then release it:
Input Detected
Event State: 1
Input Detected
Event State: 0

This is what happens if the window is out of focus:
Input Detected
Event State: 0

So it is detecting the button release, but not the button press.

I also have another application that reads keyboard events from another thread and injects them into SDL, which only seems to detect SDL_KEYUP events, not SDL_KEYDOWN events. So the problem exists elsewhere, but it’s easier to demonstrate with SDL_JOYBUTTONDOWN/SDL_JOYBUTTONUP.

You can enable joystick events when the program isn’t in focus with SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS. It’s disabled by default.On 2013-09-01, at 9:42 PM, tehcloud wrote:

It seems that SDL_JOYBUTTONDOWN events are not picked up when the window is out of focus.

This pastebin shows code that proves my theory:
http://pastebin.com/3TsGJdXH

This is what happens if the window is in focus and I press a joystick button, then release it:
Input Detected
Event State: 1
Input Detected
Event State: 0

This is what happens if the window is out of focus:
Input Detected
Event State: 0

So it is detecting the button release, but not the button press.

I also have another application that reads keyboard events from another thread and injects them into SDL, which only seems to detect SDL_KEYUP events, not SDL_KEYDOWN events. So the problem exists elsewhere, but it’s easier to demonstrate with SDL_JOYBUTTONDOWN/SDL_JOYBUTTONUP.


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

That fixed the problem with the joystick, thanks.