Added a hint to control the Windows timer resolution: SDL_HINT_TIMER_RESOLUTION

Added an API to watch hint changes: SDL_AddHintCallback(), SDL_DelHintCallback()
You can now dynamically set the joystick background event hint.
This commit is contained in:
Sam Lantinga 2013-07-13 03:13:41 -07:00
parent 9102ff84ca
commit 6956070880
7 changed files with 212 additions and 89 deletions

View file

@ -36,17 +36,24 @@ static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE;
static SDL_Joystick *SDL_joysticks = NULL;
static SDL_Joystick *SDL_updating_joystick = NULL;
static void
SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
if (hint && *hint == '1') {
SDL_joystick_allows_background_events = SDL_TRUE;
} else {
SDL_joystick_allows_background_events = SDL_FALSE;
}
}
int
SDL_JoystickInit(void)
{
const char *hint;
int status;
/* Check to see if we should allow joystick events while in the background */
hint = SDL_GetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS);
if (hint && *hint == '1') {
SDL_joystick_allows_background_events = SDL_TRUE;
}
/* See if we should allow joystick events while in the background */
SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
SDL_JoystickAllowBackgroundEventsChanged, NULL);
#if !SDL_EVENTS_DISABLED
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) {