Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
authorSam Lantinga <slouken@libsdl.org>
Fri, 07 Oct 2016 23:40:44 -0700
changeset 10499363c1c7e7a41
parent 10498 f6f1cc3caa95
child 10500 c3874aa1f2d1
Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
include/SDL_hints.h
src/SDL_hints.c
src/core/winrt/SDL_winrtapp_direct3d.cpp
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/events/SDL_mouse.c
src/events/SDL_quit.c
src/haptic/windows/SDL_xinputhaptic.c
src/joystick/android/SDL_sysjoystick.c
src/joystick/iphoneos/SDL_sysjoystick.m
src/joystick/windows/SDL_xinputjoystick.c
src/render/SDL_render.c
src/render/direct3d/SDL_render_d3d.c
src/render/direct3d11/SDL_render_d3d11.c
src/render/opengl/SDL_render_gl.c
src/thread/windows/SDL_systhread.c
src/video/SDL_bmp.c
src/video/SDL_video.c
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoavideo.m
src/video/cocoa/SDL_cocoawindow.m
src/video/uikit/SDL_uikitvideo.m
src/video/windows/SDL_windowsevents.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11window.c
     1.1 --- a/include/SDL_hints.h	Fri Sep 30 09:26:57 2016 -0400
     1.2 +++ b/include/SDL_hints.h	Fri Oct 07 23:40:44 2016 -0700
     1.3 @@ -739,6 +739,13 @@
     1.4  extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name);
     1.5  
     1.6  /**
     1.7 + *  \brief Get a hint
     1.8 + *
     1.9 + *  \return The boolean value of a hint variable.
    1.10 + */
    1.11 +extern DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value);
    1.12 +
    1.13 +/**
    1.14   *  \brief Add a function to watch a particular hint
    1.15   *
    1.16   *  \param name The hint to watch
     2.1 --- a/src/SDL_hints.c	Fri Sep 30 09:26:57 2016 -0400
     2.2 +++ b/src/SDL_hints.c	Fri Oct 07 23:40:44 2016 -0700
     2.3 @@ -118,6 +118,19 @@
     2.4      return env;
     2.5  }
     2.6  
     2.7 +SDL_bool
     2.8 +SDL_GetHintBoolean(const char *name, SDL_bool default_value)
     2.9 +{
    2.10 +    const char *hint = SDL_GetHint(name);
    2.11 +    if (!hint) {
    2.12 +        return default_value;
    2.13 +    }
    2.14 +    if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
    2.15 +        return SDL_FALSE;
    2.16 +    }
    2.17 +    return SDL_TRUE;
    2.18 +}
    2.19 +
    2.20  void
    2.21  SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
    2.22  {
     3.1 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp	Fri Sep 30 09:26:57 2016 -0400
     3.2 +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp	Fri Oct 07 23:40:44 2016 -0700
     3.3 @@ -822,11 +822,8 @@
     3.4      SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
     3.5      SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
     3.6  
     3.7 -    const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON);
     3.8 -    if (hint) {
     3.9 -        if (*hint == '1') {
    3.10 -            args->Handled = true;
    3.11 -        }
    3.12 +    if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, SDL_FALSE)) {
    3.13 +        args->Handled = true;
    3.14      }
    3.15  }
    3.16  
    3.17 @@ -854,3 +851,5 @@
    3.18      */
    3.19  }
    3.20  #endif
    3.21 +
    3.22 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Fri Sep 30 09:26:57 2016 -0400
     4.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Fri Oct 07 23:40:44 2016 -0700
     4.3 @@ -611,3 +611,4 @@
     4.4  #define SDL_SetWindowResizable SDL_SetWindowResizable_REAL
     4.5  #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
     4.6  #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
     4.7 +#define SDL_GetHintBoolean SDL_GetHintBoolean_REAL
     5.1 --- a/src/dynapi/SDL_dynapi_procs.h	Fri Sep 30 09:26:57 2016 -0400
     5.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Fri Oct 07 23:40:44 2016 -0700
     5.3 @@ -643,3 +643,4 @@
     5.4  SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),)
     5.5  SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
     5.6  SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return)
     5.7 +SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
     6.1 --- a/src/events/SDL_mouse.c	Fri Sep 30 09:26:57 2016 -0400
     6.2 +++ b/src/events/SDL_mouse.c	Fri Oct 07 23:40:44 2016 -0700
     6.3 @@ -564,21 +564,11 @@
     6.4  static SDL_bool
     6.5  ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
     6.6  {
     6.7 -    const char *hint;
     6.8 -
     6.9      if (!mouse->SetRelativeMouseMode) {
    6.10          return SDL_TRUE;
    6.11      }
    6.12  
    6.13 -    hint = SDL_GetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP);
    6.14 -    if (hint) {
    6.15 -        if (*hint == '0') {
    6.16 -            return SDL_FALSE;
    6.17 -        } else {
    6.18 -            return SDL_TRUE;
    6.19 -        }
    6.20 -    }
    6.21 -    return SDL_FALSE;
    6.22 +    return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE);
    6.23  }
    6.24  
    6.25  int
     7.1 --- a/src/events/SDL_quit.c	Fri Sep 30 09:26:57 2016 -0400
     7.2 +++ b/src/events/SDL_quit.c	Fri Oct 07 23:40:44 2016 -0700
     7.3 @@ -91,9 +91,7 @@
     7.4  int
     7.5  SDL_QuitInit(void)
     7.6  {
     7.7 -    const char *hint = SDL_GetHint(SDL_HINT_NO_SIGNAL_HANDLERS);
     7.8 -    disable_signals = hint && (SDL_atoi(hint) == 1);
     7.9 -    if (!disable_signals) {
    7.10 +    if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
    7.11          return SDL_QuitInit_Internal();
    7.12      }
    7.13      return 0;
     8.1 --- a/src/haptic/windows/SDL_xinputhaptic.c	Fri Sep 30 09:26:57 2016 -0400
     8.2 +++ b/src/haptic/windows/SDL_xinputhaptic.c	Fri Oct 07 23:40:44 2016 -0700
     8.3 @@ -44,8 +44,7 @@
     8.4  int
     8.5  SDL_XINPUT_HapticInit(void)
     8.6  {
     8.7 -    const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED);
     8.8 -    if (!env || SDL_atoi(env)) {
     8.9 +    if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) {
    8.10          loaded_xinput = (WIN_LoadXInputDLL() == 0);
    8.11      }
    8.12  
     9.1 --- a/src/joystick/android/SDL_sysjoystick.c	Fri Sep 30 09:26:57 2016 -0400
     9.2 +++ b/src/joystick/android/SDL_sysjoystick.c	Fri Oct 07 23:40:44 2016 -0700
     9.3 @@ -352,11 +352,9 @@
     9.4  int
     9.5  SDL_SYS_JoystickInit(void)
     9.6  {
     9.7 -    const char *hint;
     9.8      SDL_SYS_JoystickDetect();
     9.9      
    9.10 -    hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK);
    9.11 -    if (!hint || SDL_atoi(hint)) {
    9.12 +    if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
    9.13          /* Default behavior, accelerometer as joystick */
    9.14          Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, SDL_TRUE, 0, 3, 0, 0);
    9.15      }
    10.1 --- a/src/joystick/iphoneos/SDL_sysjoystick.m	Fri Sep 30 09:26:57 2016 -0400
    10.2 +++ b/src/joystick/iphoneos/SDL_sysjoystick.m	Fri Oct 07 23:40:44 2016 -0700
    10.3 @@ -127,13 +127,11 @@
    10.4      }
    10.5  #if TARGET_OS_TV
    10.6      else if (controller.microGamepad) {
    10.7 -        const char *hint = SDL_GetHint(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION);
    10.8 -
    10.9          device->naxes = 2; /* treat the touch surface as two axes */
   10.10          device->nhats = 0; /* apparently the touch surface-as-dpad is buggy */
   10.11          device->nbuttons = 3; /* AX, pause button */
   10.12  
   10.13 -        controller.microGamepad.allowsRotation = (hint != NULL && *hint != '0');
   10.14 +        controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_FALSE);
   10.15      }
   10.16  #endif /* TARGET_OS_TV */
   10.17  
   10.18 @@ -279,8 +277,7 @@
   10.19          NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
   10.20  
   10.21  #if !TARGET_OS_TV
   10.22 -        const char *hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK);
   10.23 -        if (!hint || SDL_atoi(hint)) {
   10.24 +        if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) {
   10.25              /* Default behavior, accelerometer as joystick */
   10.26              SDL_SYS_AddJoystickDevice(nil, SDL_TRUE);
   10.27          }
    11.1 --- a/src/joystick/windows/SDL_xinputjoystick.c	Fri Sep 30 09:26:57 2016 -0400
    11.2 +++ b/src/joystick/windows/SDL_xinputjoystick.c	Fri Oct 07 23:40:44 2016 -0700
    11.3 @@ -40,8 +40,7 @@
    11.4  {
    11.5      static int s_XInputUseOldJoystickMapping = -1;
    11.6      if (s_XInputUseOldJoystickMapping < 0) {
    11.7 -        const char *hint = SDL_GetHint(SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING);
    11.8 -        s_XInputUseOldJoystickMapping = (hint && *hint == '1') ? 1 : 0;
    11.9 +        s_XInputUseOldJoystickMapping = SDL_GetHintBoolean(SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING, SDL_FALSE);
   11.10      }
   11.11      return (s_XInputUseOldJoystickMapping > 0);
   11.12  }
   11.13 @@ -54,10 +53,7 @@
   11.14  int
   11.15  SDL_XINPUT_JoystickInit(void)
   11.16  {
   11.17 -    const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED);
   11.18 -    if (env && !SDL_atoi(env)) {
   11.19 -        s_bXInputEnabled = SDL_FALSE;
   11.20 -    }
   11.21 +    s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
   11.22  
   11.23      if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
   11.24          s_bXInputEnabled = SDL_FALSE;  /* oh well. */
    12.1 --- a/src/render/SDL_render.c	Fri Sep 30 09:26:57 2016 -0400
    12.2 +++ b/src/render/SDL_render.c	Fri Oct 07 23:40:44 2016 -0700
    12.3 @@ -234,12 +234,11 @@
    12.4          return NULL;
    12.5      }
    12.6  
    12.7 -    hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
    12.8 -    if (hint) {
    12.9 -        if (*hint == '0') {
   12.10 +    if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) {
   12.11 +        if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
   12.12 +            flags |= SDL_RENDERER_PRESENTVSYNC;
   12.13 +        } else {
   12.14              flags &= ~SDL_RENDERER_PRESENTVSYNC;
   12.15 -        } else {
   12.16 -            flags |= SDL_RENDERER_PRESENTVSYNC;
   12.17          }
   12.18      }
   12.19  
    13.1 --- a/src/render/direct3d/SDL_render_d3d.c	Fri Sep 30 09:26:57 2016 -0400
    13.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Fri Oct 07 23:40:44 2016 -0700
    13.3 @@ -512,7 +512,6 @@
    13.4      D3D_RenderData *data;
    13.5      SDL_SysWMinfo windowinfo;
    13.6      HRESULT result;
    13.7 -    const char *hint;
    13.8      D3DPRESENT_PARAMETERS pparams;
    13.9      IDirect3DSwapChain9 *chain;
   13.10      D3DCAPS9 caps;
   13.11 @@ -607,8 +606,7 @@
   13.12          device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
   13.13      }
   13.14  
   13.15 -    hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE);
   13.16 -    if (hint && SDL_atoi(hint)) {
   13.17 +    if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) {
   13.18          device_flags |= D3DCREATE_MULTITHREADED;
   13.19      }
   13.20  
    14.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Fri Sep 30 09:26:57 2016 -0400
    14.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Fri Oct 07 23:40:44 2016 -0700
    14.3 @@ -1000,7 +1000,6 @@
    14.4      IDXGIDevice1 *dxgiDevice = NULL;
    14.5      HRESULT result = S_OK;
    14.6      UINT creationFlags;
    14.7 -    const char *hint;
    14.8  
    14.9      /* This array defines the set of DirectX hardware feature levels this app will support.
   14.10       * Note the ordering should be preserved.
   14.11 @@ -1078,8 +1077,7 @@
   14.12      creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
   14.13  
   14.14      /* Make sure Direct3D's debugging feature gets used, if the app requests it. */
   14.15 -    hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
   14.16 -    if (hint && SDL_atoi(hint) > 0) {
   14.17 +    if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE)) {
   14.18          creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
   14.19      }
   14.20  
    15.1 --- a/src/render/opengl/SDL_render_gl.c	Fri Sep 30 09:26:57 2016 -0400
    15.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri Oct 07 23:40:44 2016 -0700
    15.3 @@ -390,7 +390,6 @@
    15.4  {
    15.5      SDL_Renderer *renderer;
    15.6      GL_RenderData *data;
    15.7 -    const char *hint;
    15.8      GLint value;
    15.9      Uint32 window_flags;
   15.10      int profile_mask = 0, major = 0, minor = 0;
   15.11 @@ -528,8 +527,7 @@
   15.12      }
   15.13  
   15.14      /* Check for shader support */
   15.15 -    hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS);
   15.16 -    if (!hint || *hint != '0') {
   15.17 +    if (SDL_GetHintBoolean(SDL_HINT_RENDER_OPENGL_SHADERS, SDL_TRUE)) {
   15.18          data->shaders = GL_CreateShaderContext();
   15.19      }
   15.20      SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s",
    16.1 --- a/src/thread/windows/SDL_systhread.c	Fri Sep 30 09:26:57 2016 -0400
    16.2 +++ b/src/thread/windows/SDL_systhread.c	Fri Oct 07 23:40:44 2016 -0700
    16.3 @@ -171,8 +171,7 @@
    16.4          THREADNAME_INFO inf;
    16.5  
    16.6          /* C# and friends will try to catch this Exception, let's avoid it. */
    16.7 -        const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING);
    16.8 -        if (hint && *hint == '1') {
    16.9 +        if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, SDL_FALSE)) {
   16.10              return;
   16.11          }
   16.12  
    17.1 --- a/src/video/SDL_bmp.c	Fri Sep 30 09:26:57 2016 -0400
    17.2 +++ b/src/video/SDL_bmp.c	Fri Oct 07 23:40:44 2016 -0700
    17.3 @@ -556,10 +556,7 @@
    17.4      }
    17.5  
    17.6      if (save32bit) {
    17.7 -        const char *hint = SDL_GetHint(SDL_HINT_BMP_SAVE_LEGACY_FORMAT);
    17.8 -        if (hint != NULL && (hint[0] == '1' && hint[1] == 0)) {
    17.9 -            saveLegacyBMP = SDL_TRUE;
   17.10 -        }
   17.11 +        saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, SDL_FALSE);
   17.12      }
   17.13  
   17.14      if (surface && (SDL_LockSurface(surface) == 0)) {
    18.1 --- a/src/video/SDL_video.c	Fri Sep 30 09:26:57 2016 -0400
    18.2 +++ b/src/video/SDL_video.c	Fri Oct 07 23:40:44 2016 -0700
    18.3 @@ -181,7 +181,7 @@
    18.4      /* See if the user or application wants a specific behavior */
    18.5      hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
    18.6      if (hint) {
    18.7 -        if (*hint == '0') {
    18.8 +        if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
    18.9              return SDL_FALSE;
   18.10          } else {
   18.11              return SDL_TRUE;
   18.12 @@ -258,6 +258,8 @@
   18.13  
   18.14          /* Check to see if there's a specific driver requested */
   18.15          if (hint && *hint != '0' && *hint != '1' &&
   18.16 +            SDL_strcasecmp(hint, "true") != 0 &&
   18.17 +            SDL_strcasecmp(hint, "false") != 0 &&
   18.18              SDL_strcasecmp(hint, "software") != 0) {
   18.19              for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
   18.20                  SDL_RendererInfo info;
   18.21 @@ -447,10 +449,8 @@
   18.22  SDL_VideoInit(const char *driver_name)
   18.23  {
   18.24      SDL_VideoDevice *video;
   18.25 -    const char *hint;
   18.26      int index;
   18.27      int i;
   18.28 -    SDL_bool allow_screensaver;
   18.29  
   18.30      /* Check to make sure we don't overwrite '_this' */
   18.31      if (_this != NULL) {
   18.32 @@ -538,13 +538,7 @@
   18.33         joystick, or passively watching a movie. Things that use SDL but
   18.34         function more like a normal desktop app should explicitly reenable the
   18.35         screensaver. */
   18.36 -    hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER);
   18.37 -    if (hint) {
   18.38 -        allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE;
   18.39 -    } else {
   18.40 -        allow_screensaver = SDL_FALSE;
   18.41 -    }
   18.42 -    if (!allow_screensaver) {
   18.43 +    if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_FALSE)) {
   18.44          SDL_DisableScreenSaver();
   18.45      }
   18.46  
   18.47 @@ -1336,7 +1330,6 @@
   18.48  SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
   18.49  {
   18.50      SDL_Window *window;
   18.51 -    const char *hint;
   18.52  
   18.53      if (!_this) {
   18.54          /* Initialize the video system if needed */
   18.55 @@ -1384,8 +1377,7 @@
   18.56       * SDL_WINDOW_ALLOW_HIGHDPI flag.
   18.57       */
   18.58      if (flags & SDL_WINDOW_ALLOW_HIGHDPI) {
   18.59 -        hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED);
   18.60 -        if (hint && SDL_atoi(hint) > 0) {
   18.61 +        if (SDL_GetHintBoolean(SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_FALSE)) {
   18.62              flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
   18.63          }
   18.64      }
   18.65 @@ -2509,8 +2501,6 @@
   18.66  static SDL_bool
   18.67  ShouldMinimizeOnFocusLoss(SDL_Window * window)
   18.68  {
   18.69 -    const char *hint;
   18.70 -
   18.71      if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
   18.72          return SDL_FALSE;
   18.73      }
   18.74 @@ -2521,16 +2511,7 @@
   18.75      }
   18.76  #endif
   18.77  
   18.78 -    hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
   18.79 -    if (hint) {
   18.80 -        if (*hint == '0') {
   18.81 -            return SDL_FALSE;
   18.82 -        } else {
   18.83 -            return SDL_TRUE;
   18.84 -        }
   18.85 -    }
   18.86 -
   18.87 -    return SDL_TRUE;
   18.88 +    return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
   18.89  }
   18.90  
   18.91  void
   18.92 @@ -3779,15 +3760,7 @@
   18.93  SDL_bool
   18.94  SDL_ShouldAllowTopmost(void)
   18.95  {
   18.96 -    const char *hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST);
   18.97 -    if (hint) {
   18.98 -        if (*hint == '0') {
   18.99 -            return SDL_FALSE;
  18.100 -        } else {
  18.101 -            return SDL_TRUE;
  18.102 -        }
  18.103 -    }
  18.104 -    return SDL_TRUE;
  18.105 +    return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE);
  18.106  }
  18.107  
  18.108  int
    19.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Fri Sep 30 09:26:57 2016 -0400
    19.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Fri Oct 07 23:40:44 2016 -0700
    19.3 @@ -348,8 +348,7 @@
    19.4          [SDLApplication sharedApplication];
    19.5          SDL_assert(NSApp != nil);
    19.6  
    19.7 -        const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
    19.8 -        if (!hint || *hint == '0') {
    19.9 +        if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
   19.10              [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
   19.11              [NSApp activateIgnoringOtherApps:YES];
   19.12  		}
    20.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Fri Sep 30 09:26:57 2016 -0400
    20.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Fri Oct 07 23:40:44 2016 -0700
    20.3 @@ -150,8 +150,7 @@
    20.4      Cocoa_InitKeyboard(_this);
    20.5      Cocoa_InitMouse(_this);
    20.6  
    20.7 -    const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
    20.8 -    data->allow_spaces = ( (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && (!hint || (*hint != '0')) );
    20.9 +    data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
   20.10  
   20.11      /* The IOPM assertion API can disable the screensaver as of 10.7. */
   20.12      data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
    21.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 30 09:26:57 2016 -0400
    21.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Oct 07 23:40:44 2016 -0700
    21.3 @@ -211,8 +211,7 @@
    21.4  static int
    21.5  GetHintCtrlClickEmulateRightClick()
    21.6  {
    21.7 -	const char *hint = SDL_GetHint( SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK );
    21.8 -	return hint != NULL && *hint != '0';
    21.9 +	return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE);
   21.10  }
   21.11  
   21.12  static NSUInteger
   21.13 @@ -1118,12 +1117,11 @@
   21.14  
   21.15  - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
   21.16  {
   21.17 -    const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH);
   21.18 -    if (!hint) {
   21.19 -        /* Check older hint for backwards compatibility */
   21.20 -        hint = SDL_GetHint("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH");
   21.21 +    if (SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH)) {
   21.22 +        return SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE);
   21.23 +    } else {
   21.24 +        return SDL_GetHintBoolean("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH", SDL_FALSE);
   21.25      }
   21.26 -    return hint && *hint != '0';
   21.27  }
   21.28  @end
   21.29  
    22.1 --- a/src/video/uikit/SDL_uikitvideo.m	Fri Sep 30 09:26:57 2016 -0400
    22.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Fri Oct 07 23:40:44 2016 -0700
    22.3 @@ -158,7 +158,7 @@
    22.4      @autoreleasepool {
    22.5          /* Ignore ScreenSaver API calls if the idle timer hint has been set. */
    22.6          /* FIXME: The idle timer hint should be deprecated for SDL 2.1. */
    22.7 -        if (SDL_GetHint(SDL_HINT_IDLE_TIMER_DISABLED) == NULL) {
    22.8 +        if (!SDL_GetHintBoolean(SDL_HINT_IDLE_TIMER_DISABLED, SDL_FALSE)) {
    22.9              UIApplication *app = [UIApplication sharedApplication];
   22.10  
   22.11              /* Prevent the display from dimming and going to sleep. */
    23.1 --- a/src/video/windows/SDL_windowsevents.c	Fri Sep 30 09:26:57 2016 -0400
    23.2 +++ b/src/video/windows/SDL_windowsevents.c	Fri Oct 07 23:40:44 2016 -0700
    23.3 @@ -201,8 +201,7 @@
    23.4  static SDL_bool
    23.5  WIN_ShouldIgnoreFocusClick()
    23.6  {
    23.7 -    const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH);
    23.8 -    return (!hint || (*hint == '0')) ? SDL_TRUE : SDL_FALSE;
    23.9 +    return !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE);
   23.10  }
   23.11  
   23.12  void
   23.13 @@ -340,17 +339,7 @@
   23.14  static SDL_bool
   23.15  ShouldGenerateWindowCloseOnAltF4(void)
   23.16  {
   23.17 -    const char *hint;
   23.18 -    
   23.19 -    hint = SDL_GetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4);
   23.20 -    if (hint) {
   23.21 -        if (*hint == '0') {
   23.22 -            return SDL_TRUE;
   23.23 -        } else {
   23.24 -            return SDL_FALSE;
   23.25 -        }
   23.26 -    }
   23.27 -    return SDL_TRUE;
   23.28 +    return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE);
   23.29  }
   23.30  
   23.31  LRESULT CALLBACK
    24.1 --- a/src/video/x11/SDL_x11events.c	Fri Sep 30 09:26:57 2016 -0400
    24.2 +++ b/src/video/x11/SDL_x11events.c	Fri Oct 07 23:40:44 2016 -0700
    24.3 @@ -1035,8 +1035,7 @@
    24.4                  if (data->last_focus_event_time) {
    24.5                      const int X11_FOCUS_CLICK_TIMEOUT = 10;
    24.6                      if (!SDL_TICKS_PASSED(SDL_GetTicks(), data->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) {
    24.7 -                        const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH);
    24.8 -                        ignore_click = (!hint || *hint == '0');
    24.9 +                        ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE);
   24.10                      }
   24.11                      data->last_focus_event_time = 0;
   24.12                  }
    25.1 --- a/src/video/x11/SDL_x11modes.c	Fri Sep 30 09:26:57 2016 -0400
    25.2 +++ b/src/video/x11/SDL_x11modes.c	Fri Oct 07 23:40:44 2016 -0700
    25.3 @@ -157,14 +157,12 @@
    25.4  {
    25.5      int event_base = 0;
    25.6      int error_base = 0;
    25.7 -    const char *env;
    25.8  
    25.9      /* Default the extension not available */
   25.10      *major = *minor = 0;
   25.11  
   25.12      /* Allow environment override */
   25.13 -    env = SDL_GetHint(SDL_HINT_VIDEO_X11_XINERAMA);
   25.14 -    if (env && !SDL_atoi(env)) {
   25.15 +    if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XINERAMA, SDL_TRUE)) {
   25.16  #ifdef X11MODES_DEBUG
   25.17          printf("Xinerama disabled due to hint\n");
   25.18  #endif
   25.19 @@ -213,22 +211,19 @@
   25.20  static SDL_bool
   25.21  CheckXRandR(Display * display, int *major, int *minor)
   25.22  {
   25.23 -    const char *env;
   25.24 -
   25.25      /* Default the extension not available */
   25.26      *major = *minor = 0;
   25.27  
   25.28      /* Allow environment override */
   25.29 -    env = SDL_GetHint(SDL_HINT_VIDEO_X11_XRANDR);
   25.30  #ifdef XRANDR_DISABLED_BY_DEFAULT
   25.31 -    if (!env || !SDL_atoi(env)) {
   25.32 +    if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_FALSE)) {
   25.33  #ifdef X11MODES_DEBUG
   25.34          printf("XRandR disabled by default due to window manager issues\n");
   25.35  #endif
   25.36          return SDL_FALSE;
   25.37      }
   25.38  #else
   25.39 -    if (env && !SDL_atoi(env)) {
   25.40 +    if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_TRUE)) {
   25.41  #ifdef X11MODES_DEBUG
   25.42          printf("XRandR disabled due to hint\n");
   25.43  #endif
   25.44 @@ -507,14 +502,11 @@
   25.45  static SDL_bool
   25.46  CheckVidMode(Display * display, int *major, int *minor)
   25.47  {
   25.48 -    const char *env;
   25.49 -
   25.50      /* Default the extension not available */
   25.51      *major = *minor = 0;
   25.52  
   25.53      /* Allow environment override */
   25.54 -    env = SDL_GetHint(SDL_HINT_VIDEO_X11_XVIDMODE);
   25.55 -    if (env && !SDL_atoi(env)) {
   25.56 +    if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XVIDMODE, SDL_TRUE)) {
   25.57  #ifdef X11MODES_DEBUG
   25.58          printf("XVidMode disabled due to hint\n");
   25.59  #endif
   25.60 @@ -622,8 +614,7 @@
   25.61         we sort out the ramifications of removing XVidMode support outright.
   25.62         This block should be removed with the XVidMode support. */
   25.63      {
   25.64 -        const char *env = SDL_GetHint("SDL_VIDEO_X11_REQUIRE_XRANDR");
   25.65 -        if (env && SDL_atoi(env)) {
   25.66 +        if (SDL_GetHintBoolean("SDL_VIDEO_X11_REQUIRE_XRANDR", SDL_FALSE)) {
   25.67              #if SDL_VIDEO_DRIVER_X11_XRANDR
   25.68              return SDL_SetError("XRandR support is required but not available");
   25.69              #else
    26.1 --- a/src/video/x11/SDL_x11window.c	Fri Sep 30 09:26:57 2016 -0400
    26.2 +++ b/src/video/x11/SDL_x11window.c	Fri Oct 07 23:40:44 2016 -0700
    26.3 @@ -576,14 +576,12 @@
    26.4      {
    26.5          Atom protocols[3];
    26.6          int proto_count = 0;
    26.7 -        const char *ping_hint;
    26.8  
    26.9          protocols[proto_count++] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */
   26.10          protocols[proto_count++] = data->WM_TAKE_FOCUS; /* Since we will want to set input focus explicitly */
   26.11  
   26.12 -        ping_hint = SDL_GetHint(SDL_HINT_VIDEO_X11_NET_WM_PING);
   26.13          /* Default to using ping if there is no hint */
   26.14 -        if (!ping_hint || SDL_atoi(ping_hint)) {
   26.15 +        if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, SDL_TRUE)) {
   26.16              protocols[proto_count++] = data->_NET_WM_PING; /* Respond so WM knows we're alive */
   26.17          }
   26.18  
   26.19 @@ -1477,7 +1475,6 @@
   26.20      Display *display = data->videodata->display;
   26.21      SDL_bool oldstyle_fullscreen;
   26.22      SDL_bool grab_keyboard;
   26.23 -    const char *hint;
   26.24  
   26.25      /* ICCCM2.0-compliant window managers can handle fullscreen windows
   26.26         If we're using XVidMode to change resolution we need to confine
   26.27 @@ -1501,8 +1498,7 @@
   26.28          X11_XRaiseWindow(display, data->xwindow);
   26.29  
   26.30          /* Now grab the keyboard */
   26.31 -        hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD);
   26.32 -        if (hint && SDL_atoi(hint)) {
   26.33 +        if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) {
   26.34              grab_keyboard = SDL_TRUE;
   26.35          } else {
   26.36              /* We need to do this with the old style override_redirect