| Summary: | SDL2 lacks joystick capture (grab) support | ||
|---|---|---|---|
| Product: | SDL | Reporter: | SD-Snatcher <sdsnatcheralpha> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | cameron.gutman |
| Version: | 2.0.10 | ||
| Hardware: | All | ||
| OS: | All | ||
This sounds like what SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS does. Does that not work for your scenario? SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS is what you want here. Whoops, meant to mark this as not a bug. |
In SDL1, joystick events were received even when the window had no focus. This behaviour was explicitly changed on SDL2 to receive/ignore the events based on the windows focus state: static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent() { if (SDL_joystick_allows_background_events) { return SDL_FALSE; } if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) { /* We have windows but we don't have focus, ignore the event. */ return SDL_TRUE; } return SDL_FALSE; } But when developing games, usually the IDE is an external program. This means that step-by-step debugging of a game with joystick support got quite more convoluted. A simple solution to this problem would be to implement a SDL_CaptureJoystick function, similar (but not identical) to the existing SDL_CaptureMouse. The idea would be just to be able to change the behaviour of the SDL_PrivateJoystickShouldIgnoreEvent to keep receiving joystick events without windows focus, or ignore them.