mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-10-26 12:27:44 +00:00 
			
		
		
		
	Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
This commit is contained in:
		| @@ -738,6 +738,13 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, | |||||||
|  */ |  */ | ||||||
| extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); | extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  \brief Get a hint | ||||||
|  |  * | ||||||
|  |  *  \return The boolean value of a hint variable. | ||||||
|  |  */ | ||||||
|  | extern DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  *  \brief Add a function to watch a particular hint |  *  \brief Add a function to watch a particular hint | ||||||
|  * |  * | ||||||
|   | |||||||
| @@ -118,6 +118,19 @@ SDL_GetHint(const char *name) | |||||||
|     return env; |     return env; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | SDL_bool | ||||||
|  | SDL_GetHintBoolean(const char *name, SDL_bool default_value) | ||||||
|  | { | ||||||
|  |     const char *hint = SDL_GetHint(name); | ||||||
|  |     if (!hint) { | ||||||
|  |         return default_value; | ||||||
|  |     } | ||||||
|  |     if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) { | ||||||
|  |         return SDL_FALSE; | ||||||
|  |     } | ||||||
|  |     return SDL_TRUE; | ||||||
|  | } | ||||||
|  |  | ||||||
| void | void | ||||||
| SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) | SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -822,13 +822,10 @@ static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args) | |||||||
|     SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK); |     SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK); | ||||||
|     SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK); |     SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK); | ||||||
|  |  | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON); |     if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, SDL_FALSE)) { | ||||||
|     if (hint) { |  | ||||||
|         if (*hint == '1') { |  | ||||||
|         args->Handled = true; |         args->Handled = true; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| } |  | ||||||
|  |  | ||||||
| #if NTDDI_VERSION == NTDDI_WIN10 | #if NTDDI_VERSION == NTDDI_WIN10 | ||||||
| void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) | void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args) | ||||||
| @@ -854,3 +851,5 @@ void SDL_WinRTApp::OnGamepadAdded(Platform::Object ^sender, Windows::Gaming::Inp | |||||||
|     */ |     */ | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | /* vi: set ts=4 sw=4 expandtab: */ | ||||||
|   | |||||||
| @@ -611,3 +611,4 @@ | |||||||
| #define SDL_SetWindowResizable SDL_SetWindowResizable_REAL | #define SDL_SetWindowResizable SDL_SetWindowResizable_REAL | ||||||
| #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL | #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL | ||||||
| #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL | #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL | ||||||
|  | #define SDL_GetHintBoolean SDL_GetHintBoolean_REAL | ||||||
|   | |||||||
| @@ -643,3 +643,4 @@ SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c) | |||||||
| SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),) | SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),) | ||||||
| SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) | SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) | ||||||
| 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) | 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) | ||||||
|  | SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return) | ||||||
|   | |||||||
| @@ -564,21 +564,11 @@ SDL_WarpMouseGlobal(int x, int y) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| ShouldUseRelativeModeWarp(SDL_Mouse *mouse) | ShouldUseRelativeModeWarp(SDL_Mouse *mouse) | ||||||
| { | { | ||||||
|     const char *hint; |  | ||||||
|  |  | ||||||
|     if (!mouse->SetRelativeMouseMode) { |     if (!mouse->SetRelativeMouseMode) { | ||||||
|         return SDL_TRUE; |         return SDL_TRUE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     hint = SDL_GetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP); |     return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); | ||||||
|     if (hint) { |  | ||||||
|         if (*hint == '0') { |  | ||||||
|             return SDL_FALSE; |  | ||||||
|         } else { |  | ||||||
|             return SDL_TRUE; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     return SDL_FALSE; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -91,9 +91,7 @@ SDL_QuitInit_Internal(void) | |||||||
| int | int | ||||||
| SDL_QuitInit(void) | SDL_QuitInit(void) | ||||||
| { | { | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_NO_SIGNAL_HANDLERS); |     if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { | ||||||
|     disable_signals = hint && (SDL_atoi(hint) == 1); |  | ||||||
|     if (!disable_signals) { |  | ||||||
|         return SDL_QuitInit_Internal(); |         return SDL_QuitInit_Internal(); | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
| @@ -44,8 +44,7 @@ static SDL_bool loaded_xinput = SDL_FALSE; | |||||||
| int | int | ||||||
| SDL_XINPUT_HapticInit(void) | SDL_XINPUT_HapticInit(void) | ||||||
| { | { | ||||||
|     const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED); |     if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) { | ||||||
|     if (!env || SDL_atoi(env)) { |  | ||||||
|         loaded_xinput = (WIN_LoadXInputDLL() == 0); |         loaded_xinput = (WIN_LoadXInputDLL() == 0); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -352,11 +352,9 @@ Android_RemoveJoystick(int device_id) | |||||||
| int | int | ||||||
| SDL_SYS_JoystickInit(void) | SDL_SYS_JoystickInit(void) | ||||||
| { | { | ||||||
|     const char *hint; |  | ||||||
|     SDL_SYS_JoystickDetect(); |     SDL_SYS_JoystickDetect(); | ||||||
|      |      | ||||||
|     hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK); |     if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { | ||||||
|     if (!hint || SDL_atoi(hint)) { |  | ||||||
|         /* Default behavior, accelerometer as joystick */ |         /* Default behavior, accelerometer as joystick */ | ||||||
|         Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, SDL_TRUE, 0, 3, 0, 0); |         Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, SDL_TRUE, 0, 3, 0, 0); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -127,13 +127,11 @@ SDL_SYS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *contr | |||||||
|     } |     } | ||||||
| #if TARGET_OS_TV | #if TARGET_OS_TV | ||||||
|     else if (controller.microGamepad) { |     else if (controller.microGamepad) { | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION); |  | ||||||
|  |  | ||||||
|         device->naxes = 2; /* treat the touch surface as two axes */ |         device->naxes = 2; /* treat the touch surface as two axes */ | ||||||
|         device->nhats = 0; /* apparently the touch surface-as-dpad is buggy */ |         device->nhats = 0; /* apparently the touch surface-as-dpad is buggy */ | ||||||
|         device->nbuttons = 3; /* AX, pause button */ |         device->nbuttons = 3; /* AX, pause button */ | ||||||
|  |  | ||||||
|         controller.microGamepad.allowsRotation = (hint != NULL && *hint != '0'); |         controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_FALSE); | ||||||
|     } |     } | ||||||
| #endif /* TARGET_OS_TV */ | #endif /* TARGET_OS_TV */ | ||||||
|  |  | ||||||
| @@ -279,8 +277,7 @@ SDL_SYS_JoystickInit(void) | |||||||
|         NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; |         NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; | ||||||
|  |  | ||||||
| #if !TARGET_OS_TV | #if !TARGET_OS_TV | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK); |         if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { | ||||||
|         if (!hint || SDL_atoi(hint)) { |  | ||||||
|             /* Default behavior, accelerometer as joystick */ |             /* Default behavior, accelerometer as joystick */ | ||||||
|             SDL_SYS_AddJoystickDevice(nil, SDL_TRUE); |             SDL_SYS_AddJoystickDevice(nil, SDL_TRUE); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -40,8 +40,7 @@ SDL_XInputUseOldJoystickMapping() | |||||||
| { | { | ||||||
|     static int s_XInputUseOldJoystickMapping = -1; |     static int s_XInputUseOldJoystickMapping = -1; | ||||||
|     if (s_XInputUseOldJoystickMapping < 0) { |     if (s_XInputUseOldJoystickMapping < 0) { | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING); |         s_XInputUseOldJoystickMapping = SDL_GetHintBoolean(SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING, SDL_FALSE); | ||||||
|         s_XInputUseOldJoystickMapping = (hint && *hint == '1') ? 1 : 0; |  | ||||||
|     } |     } | ||||||
|     return (s_XInputUseOldJoystickMapping > 0); |     return (s_XInputUseOldJoystickMapping > 0); | ||||||
| } | } | ||||||
| @@ -54,10 +53,7 @@ SDL_bool SDL_XINPUT_Enabled(void) | |||||||
| int | int | ||||||
| SDL_XINPUT_JoystickInit(void) | SDL_XINPUT_JoystickInit(void) | ||||||
| { | { | ||||||
|     const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED); |     s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE); | ||||||
|     if (env && !SDL_atoi(env)) { |  | ||||||
|         s_bXInputEnabled = SDL_FALSE; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) { |     if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) { | ||||||
|         s_bXInputEnabled = SDL_FALSE;  /* oh well. */ |         s_bXInputEnabled = SDL_FALSE;  /* oh well. */ | ||||||
|   | |||||||
| @@ -234,12 +234,11 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) | |||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); |     if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) { | ||||||
|     if (hint) { |         if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) { | ||||||
|         if (*hint == '0') { |  | ||||||
|             flags &= ~SDL_RENDERER_PRESENTVSYNC; |  | ||||||
|         } else { |  | ||||||
|             flags |= SDL_RENDERER_PRESENTVSYNC; |             flags |= SDL_RENDERER_PRESENTVSYNC; | ||||||
|  |         } else { | ||||||
|  |             flags &= ~SDL_RENDERER_PRESENTVSYNC; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -512,7 +512,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) | |||||||
|     D3D_RenderData *data; |     D3D_RenderData *data; | ||||||
|     SDL_SysWMinfo windowinfo; |     SDL_SysWMinfo windowinfo; | ||||||
|     HRESULT result; |     HRESULT result; | ||||||
|     const char *hint; |  | ||||||
|     D3DPRESENT_PARAMETERS pparams; |     D3DPRESENT_PARAMETERS pparams; | ||||||
|     IDirect3DSwapChain9 *chain; |     IDirect3DSwapChain9 *chain; | ||||||
|     D3DCAPS9 caps; |     D3DCAPS9 caps; | ||||||
| @@ -607,8 +606,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) | |||||||
|         device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; |         device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE); |     if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) { | ||||||
|     if (hint && SDL_atoi(hint)) { |  | ||||||
|         device_flags |= D3DCREATE_MULTITHREADED; |         device_flags |= D3DCREATE_MULTITHREADED; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1000,7 +1000,6 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) | |||||||
|     IDXGIDevice1 *dxgiDevice = NULL; |     IDXGIDevice1 *dxgiDevice = NULL; | ||||||
|     HRESULT result = S_OK; |     HRESULT result = S_OK; | ||||||
|     UINT creationFlags; |     UINT creationFlags; | ||||||
|     const char *hint; |  | ||||||
|  |  | ||||||
|     /* This array defines the set of DirectX hardware feature levels this app will support. |     /* This array defines the set of DirectX hardware feature levels this app will support. | ||||||
|      * Note the ordering should be preserved. |      * Note the ordering should be preserved. | ||||||
| @@ -1078,8 +1077,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) | |||||||
|     creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; |     creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; | ||||||
|  |  | ||||||
|     /* Make sure Direct3D's debugging feature gets used, if the app requests it. */ |     /* Make sure Direct3D's debugging feature gets used, if the app requests it. */ | ||||||
|     hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG); |     if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE)) { | ||||||
|     if (hint && SDL_atoi(hint) > 0) { |  | ||||||
|         creationFlags |= D3D11_CREATE_DEVICE_DEBUG; |         creationFlags |= D3D11_CREATE_DEVICE_DEBUG; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -390,7 +390,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) | |||||||
| { | { | ||||||
|     SDL_Renderer *renderer; |     SDL_Renderer *renderer; | ||||||
|     GL_RenderData *data; |     GL_RenderData *data; | ||||||
|     const char *hint; |  | ||||||
|     GLint value; |     GLint value; | ||||||
|     Uint32 window_flags; |     Uint32 window_flags; | ||||||
|     int profile_mask = 0, major = 0, minor = 0; |     int profile_mask = 0, major = 0, minor = 0; | ||||||
| @@ -528,8 +527,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Check for shader support */ |     /* Check for shader support */ | ||||||
|     hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS); |     if (SDL_GetHintBoolean(SDL_HINT_RENDER_OPENGL_SHADERS, SDL_TRUE)) { | ||||||
|     if (!hint || *hint != '0') { |  | ||||||
|         data->shaders = GL_CreateShaderContext(); |         data->shaders = GL_CreateShaderContext(); | ||||||
|     } |     } | ||||||
|     SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s", |     SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s", | ||||||
|   | |||||||
| @@ -171,8 +171,7 @@ SDL_SYS_SetupThread(const char *name) | |||||||
|         THREADNAME_INFO inf; |         THREADNAME_INFO inf; | ||||||
|  |  | ||||||
|         /* C# and friends will try to catch this Exception, let's avoid it. */ |         /* C# and friends will try to catch this Exception, let's avoid it. */ | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING); |         if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, SDL_FALSE)) { | ||||||
|         if (hint && *hint == '1') { |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -556,10 +556,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (save32bit) { |     if (save32bit) { | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_BMP_SAVE_LEGACY_FORMAT); |         saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, SDL_FALSE); | ||||||
|         if (hint != NULL && (hint[0] == '1' && hint[1] == 0)) { |  | ||||||
|             saveLegacyBMP = SDL_TRUE; |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (surface && (SDL_LockSurface(surface) == 0)) { |     if (surface && (SDL_LockSurface(surface) == 0)) { | ||||||
|   | |||||||
| @@ -181,7 +181,7 @@ ShouldUseTextureFramebuffer() | |||||||
|     /* See if the user or application wants a specific behavior */ |     /* See if the user or application wants a specific behavior */ | ||||||
|     hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); |     hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); | ||||||
|     if (hint) { |     if (hint) { | ||||||
|         if (*hint == '0') { |         if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) { | ||||||
|             return SDL_FALSE; |             return SDL_FALSE; | ||||||
|         } else { |         } else { | ||||||
|             return SDL_TRUE; |             return SDL_TRUE; | ||||||
| @@ -258,6 +258,8 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f | |||||||
|  |  | ||||||
|         /* Check to see if there's a specific driver requested */ |         /* Check to see if there's a specific driver requested */ | ||||||
|         if (hint && *hint != '0' && *hint != '1' && |         if (hint && *hint != '0' && *hint != '1' && | ||||||
|  |             SDL_strcasecmp(hint, "true") != 0 && | ||||||
|  |             SDL_strcasecmp(hint, "false") != 0 && | ||||||
|             SDL_strcasecmp(hint, "software") != 0) { |             SDL_strcasecmp(hint, "software") != 0) { | ||||||
|             for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) { |             for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) { | ||||||
|                 SDL_RendererInfo info; |                 SDL_RendererInfo info; | ||||||
| @@ -447,10 +449,8 @@ int | |||||||
| SDL_VideoInit(const char *driver_name) | SDL_VideoInit(const char *driver_name) | ||||||
| { | { | ||||||
|     SDL_VideoDevice *video; |     SDL_VideoDevice *video; | ||||||
|     const char *hint; |  | ||||||
|     int index; |     int index; | ||||||
|     int i; |     int i; | ||||||
|     SDL_bool allow_screensaver; |  | ||||||
|  |  | ||||||
|     /* Check to make sure we don't overwrite '_this' */ |     /* Check to make sure we don't overwrite '_this' */ | ||||||
|     if (_this != NULL) { |     if (_this != NULL) { | ||||||
| @@ -538,13 +538,7 @@ SDL_VideoInit(const char *driver_name) | |||||||
|        joystick, or passively watching a movie. Things that use SDL but |        joystick, or passively watching a movie. Things that use SDL but | ||||||
|        function more like a normal desktop app should explicitly reenable the |        function more like a normal desktop app should explicitly reenable the | ||||||
|        screensaver. */ |        screensaver. */ | ||||||
|     hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER); |     if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_FALSE)) { | ||||||
|     if (hint) { |  | ||||||
|         allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE; |  | ||||||
|     } else { |  | ||||||
|         allow_screensaver = SDL_FALSE; |  | ||||||
|     } |  | ||||||
|     if (!allow_screensaver) { |  | ||||||
|         SDL_DisableScreenSaver(); |         SDL_DisableScreenSaver(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -1336,7 +1330,6 @@ SDL_Window * | |||||||
| SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) | SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) | ||||||
| { | { | ||||||
|     SDL_Window *window; |     SDL_Window *window; | ||||||
|     const char *hint; |  | ||||||
|  |  | ||||||
|     if (!_this) { |     if (!_this) { | ||||||
|         /* Initialize the video system if needed */ |         /* Initialize the video system if needed */ | ||||||
| @@ -1384,8 +1377,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) | |||||||
|      * SDL_WINDOW_ALLOW_HIGHDPI flag. |      * SDL_WINDOW_ALLOW_HIGHDPI flag. | ||||||
|      */ |      */ | ||||||
|     if (flags & SDL_WINDOW_ALLOW_HIGHDPI) { |     if (flags & SDL_WINDOW_ALLOW_HIGHDPI) { | ||||||
|         hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED); |         if (SDL_GetHintBoolean(SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_FALSE)) { | ||||||
|         if (hint && SDL_atoi(hint) > 0) { |  | ||||||
|             flags &= ~SDL_WINDOW_ALLOW_HIGHDPI; |             flags &= ~SDL_WINDOW_ALLOW_HIGHDPI; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -2509,8 +2501,6 @@ SDL_OnWindowFocusGained(SDL_Window * window) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| ShouldMinimizeOnFocusLoss(SDL_Window * window) | ShouldMinimizeOnFocusLoss(SDL_Window * window) | ||||||
| { | { | ||||||
|     const char *hint; |  | ||||||
|  |  | ||||||
|     if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) { |     if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) { | ||||||
|         return SDL_FALSE; |         return SDL_FALSE; | ||||||
|     } |     } | ||||||
| @@ -2521,16 +2511,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window) | |||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); |     return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE); | ||||||
|     if (hint) { |  | ||||||
|         if (*hint == '0') { |  | ||||||
|             return SDL_FALSE; |  | ||||||
|         } else { |  | ||||||
|             return SDL_TRUE; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return SDL_TRUE; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -3779,15 +3760,7 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S | |||||||
| SDL_bool | SDL_bool | ||||||
| SDL_ShouldAllowTopmost(void) | SDL_ShouldAllowTopmost(void) | ||||||
| { | { | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST); |     return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE); | ||||||
|     if (hint) { |  | ||||||
|         if (*hint == '0') { |  | ||||||
|             return SDL_FALSE; |  | ||||||
|         } else { |  | ||||||
|             return SDL_TRUE; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     return SDL_TRUE; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -348,8 +348,7 @@ Cocoa_RegisterApp(void) | |||||||
|         [SDLApplication sharedApplication]; |         [SDLApplication sharedApplication]; | ||||||
|         SDL_assert(NSApp != nil); |         SDL_assert(NSApp != nil); | ||||||
|  |  | ||||||
|         const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP); |         if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { | ||||||
|         if (!hint || *hint == '0') { |  | ||||||
|             [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; |             [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | ||||||
|             [NSApp activateIgnoringOtherApps:YES]; |             [NSApp activateIgnoringOtherApps:YES]; | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -150,8 +150,7 @@ Cocoa_VideoInit(_THIS) | |||||||
|     Cocoa_InitKeyboard(_this); |     Cocoa_InitKeyboard(_this); | ||||||
|     Cocoa_InitMouse(_this); |     Cocoa_InitMouse(_this); | ||||||
|  |  | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES); |     data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE)); | ||||||
|     data->allow_spaces = ( (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && (!hint || (*hint != '0')) ); |  | ||||||
|  |  | ||||||
|     /* The IOPM assertion API can disable the screensaver as of 10.7. */ |     /* The IOPM assertion API can disable the screensaver as of 10.7. */ | ||||||
|     data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6; |     data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6; | ||||||
|   | |||||||
| @@ -211,8 +211,7 @@ ScheduleContextUpdates(SDL_WindowData *data) | |||||||
| static int | static int | ||||||
| GetHintCtrlClickEmulateRightClick() | GetHintCtrlClickEmulateRightClick() | ||||||
| { | { | ||||||
| 	const char *hint = SDL_GetHint( SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK ); | 	return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); | ||||||
| 	return hint != NULL && *hint != '0'; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static NSUInteger | static NSUInteger | ||||||
| @@ -1118,12 +1117,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) | |||||||
|  |  | ||||||
| - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent | - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent | ||||||
| { | { | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH); |     if (SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH)) { | ||||||
|     if (!hint) { |         return SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); | ||||||
|         /* Check older hint for backwards compatibility */ |     } else { | ||||||
|         hint = SDL_GetHint("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH"); |         return SDL_GetHintBoolean("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH", SDL_FALSE); | ||||||
|     } |     } | ||||||
|     return hint && *hint != '0'; |  | ||||||
| } | } | ||||||
| @end | @end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -158,7 +158,7 @@ UIKit_SuspendScreenSaver(_THIS) | |||||||
|     @autoreleasepool { |     @autoreleasepool { | ||||||
|         /* Ignore ScreenSaver API calls if the idle timer hint has been set. */ |         /* Ignore ScreenSaver API calls if the idle timer hint has been set. */ | ||||||
|         /* FIXME: The idle timer hint should be deprecated for SDL 2.1. */ |         /* FIXME: The idle timer hint should be deprecated for SDL 2.1. */ | ||||||
|         if (SDL_GetHint(SDL_HINT_IDLE_TIMER_DISABLED) == NULL) { |         if (!SDL_GetHintBoolean(SDL_HINT_IDLE_TIMER_DISABLED, SDL_FALSE)) { | ||||||
|             UIApplication *app = [UIApplication sharedApplication]; |             UIApplication *app = [UIApplication sharedApplication]; | ||||||
|  |  | ||||||
|             /* Prevent the display from dimming and going to sleep. */ |             /* Prevent the display from dimming and going to sleep. */ | ||||||
|   | |||||||
| @@ -201,8 +201,7 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| WIN_ShouldIgnoreFocusClick() | WIN_ShouldIgnoreFocusClick() | ||||||
| { | { | ||||||
|     const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH); |     return !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); | ||||||
|     return (!hint || (*hint == '0')) ? SDL_TRUE : SDL_FALSE; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -340,17 +339,7 @@ WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| ShouldGenerateWindowCloseOnAltF4(void) | ShouldGenerateWindowCloseOnAltF4(void) | ||||||
| { | { | ||||||
|     const char *hint; |     return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE); | ||||||
|      |  | ||||||
|     hint = SDL_GetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4); |  | ||||||
|     if (hint) { |  | ||||||
|         if (*hint == '0') { |  | ||||||
|             return SDL_TRUE; |  | ||||||
|         } else { |  | ||||||
|             return SDL_FALSE; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     return SDL_TRUE; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| LRESULT CALLBACK | LRESULT CALLBACK | ||||||
|   | |||||||
| @@ -1035,8 +1035,7 @@ X11_DispatchEvent(_THIS) | |||||||
|                 if (data->last_focus_event_time) { |                 if (data->last_focus_event_time) { | ||||||
|                     const int X11_FOCUS_CLICK_TIMEOUT = 10; |                     const int X11_FOCUS_CLICK_TIMEOUT = 10; | ||||||
|                     if (!SDL_TICKS_PASSED(SDL_GetTicks(), data->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { |                     if (!SDL_TICKS_PASSED(SDL_GetTicks(), data->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { | ||||||
|                         const char *hint = SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH); |                         ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); | ||||||
|                         ignore_click = (!hint || *hint == '0'); |  | ||||||
|                     } |                     } | ||||||
|                     data->last_focus_event_time = 0; |                     data->last_focus_event_time = 0; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -157,14 +157,12 @@ CheckXinerama(Display * display, int *major, int *minor) | |||||||
| { | { | ||||||
|     int event_base = 0; |     int event_base = 0; | ||||||
|     int error_base = 0; |     int error_base = 0; | ||||||
|     const char *env; |  | ||||||
|  |  | ||||||
|     /* Default the extension not available */ |     /* Default the extension not available */ | ||||||
|     *major = *minor = 0; |     *major = *minor = 0; | ||||||
|  |  | ||||||
|     /* Allow environment override */ |     /* Allow environment override */ | ||||||
|     env = SDL_GetHint(SDL_HINT_VIDEO_X11_XINERAMA); |     if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XINERAMA, SDL_TRUE)) { | ||||||
|     if (env && !SDL_atoi(env)) { |  | ||||||
| #ifdef X11MODES_DEBUG | #ifdef X11MODES_DEBUG | ||||||
|         printf("Xinerama disabled due to hint\n"); |         printf("Xinerama disabled due to hint\n"); | ||||||
| #endif | #endif | ||||||
| @@ -213,22 +211,19 @@ X11_XineramaFailed(Display * d, XErrorEvent * e) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| CheckXRandR(Display * display, int *major, int *minor) | CheckXRandR(Display * display, int *major, int *minor) | ||||||
| { | { | ||||||
|     const char *env; |  | ||||||
|  |  | ||||||
|     /* Default the extension not available */ |     /* Default the extension not available */ | ||||||
|     *major = *minor = 0; |     *major = *minor = 0; | ||||||
|  |  | ||||||
|     /* Allow environment override */ |     /* Allow environment override */ | ||||||
|     env = SDL_GetHint(SDL_HINT_VIDEO_X11_XRANDR); |  | ||||||
| #ifdef XRANDR_DISABLED_BY_DEFAULT | #ifdef XRANDR_DISABLED_BY_DEFAULT | ||||||
|     if (!env || !SDL_atoi(env)) { |     if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_FALSE)) { | ||||||
| #ifdef X11MODES_DEBUG | #ifdef X11MODES_DEBUG | ||||||
|         printf("XRandR disabled by default due to window manager issues\n"); |         printf("XRandR disabled by default due to window manager issues\n"); | ||||||
| #endif | #endif | ||||||
|         return SDL_FALSE; |         return SDL_FALSE; | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
|     if (env && !SDL_atoi(env)) { |     if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_TRUE)) { | ||||||
| #ifdef X11MODES_DEBUG | #ifdef X11MODES_DEBUG | ||||||
|         printf("XRandR disabled due to hint\n"); |         printf("XRandR disabled due to hint\n"); | ||||||
| #endif | #endif | ||||||
| @@ -507,14 +502,11 @@ X11_InitModes_XRandR(_THIS) | |||||||
| static SDL_bool | static SDL_bool | ||||||
| CheckVidMode(Display * display, int *major, int *minor) | CheckVidMode(Display * display, int *major, int *minor) | ||||||
| { | { | ||||||
|     const char *env; |  | ||||||
|  |  | ||||||
|     /* Default the extension not available */ |     /* Default the extension not available */ | ||||||
|     *major = *minor = 0; |     *major = *minor = 0; | ||||||
|  |  | ||||||
|     /* Allow environment override */ |     /* Allow environment override */ | ||||||
|     env = SDL_GetHint(SDL_HINT_VIDEO_X11_XVIDMODE); |     if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XVIDMODE, SDL_TRUE)) { | ||||||
|     if (env && !SDL_atoi(env)) { |  | ||||||
| #ifdef X11MODES_DEBUG | #ifdef X11MODES_DEBUG | ||||||
|         printf("XVidMode disabled due to hint\n"); |         printf("XVidMode disabled due to hint\n"); | ||||||
| #endif | #endif | ||||||
| @@ -622,8 +614,7 @@ X11_InitModes(_THIS) | |||||||
|        we sort out the ramifications of removing XVidMode support outright. |        we sort out the ramifications of removing XVidMode support outright. | ||||||
|        This block should be removed with the XVidMode support. */ |        This block should be removed with the XVidMode support. */ | ||||||
|     { |     { | ||||||
|         const char *env = SDL_GetHint("SDL_VIDEO_X11_REQUIRE_XRANDR"); |         if (SDL_GetHintBoolean("SDL_VIDEO_X11_REQUIRE_XRANDR", SDL_FALSE)) { | ||||||
|         if (env && SDL_atoi(env)) { |  | ||||||
|             #if SDL_VIDEO_DRIVER_X11_XRANDR |             #if SDL_VIDEO_DRIVER_X11_XRANDR | ||||||
|             return SDL_SetError("XRandR support is required but not available"); |             return SDL_SetError("XRandR support is required but not available"); | ||||||
|             #else |             #else | ||||||
|   | |||||||
| @@ -576,14 +576,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) | |||||||
|     { |     { | ||||||
|         Atom protocols[3]; |         Atom protocols[3]; | ||||||
|         int proto_count = 0; |         int proto_count = 0; | ||||||
|         const char *ping_hint; |  | ||||||
|  |  | ||||||
|         protocols[proto_count++] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */ |         protocols[proto_count++] = data->WM_DELETE_WINDOW; /* Allow window to be deleted by the WM */ | ||||||
|         protocols[proto_count++] = data->WM_TAKE_FOCUS; /* Since we will want to set input focus explicitly */ |         protocols[proto_count++] = data->WM_TAKE_FOCUS; /* Since we will want to set input focus explicitly */ | ||||||
|  |  | ||||||
|         ping_hint = SDL_GetHint(SDL_HINT_VIDEO_X11_NET_WM_PING); |  | ||||||
|         /* Default to using ping if there is no hint */ |         /* Default to using ping if there is no hint */ | ||||||
|         if (!ping_hint || SDL_atoi(ping_hint)) { |         if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, SDL_TRUE)) { | ||||||
|             protocols[proto_count++] = data->_NET_WM_PING; /* Respond so WM knows we're alive */ |             protocols[proto_count++] = data->_NET_WM_PING; /* Respond so WM knows we're alive */ | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -1477,7 +1475,6 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) | |||||||
|     Display *display = data->videodata->display; |     Display *display = data->videodata->display; | ||||||
|     SDL_bool oldstyle_fullscreen; |     SDL_bool oldstyle_fullscreen; | ||||||
|     SDL_bool grab_keyboard; |     SDL_bool grab_keyboard; | ||||||
|     const char *hint; |  | ||||||
|  |  | ||||||
|     /* ICCCM2.0-compliant window managers can handle fullscreen windows |     /* ICCCM2.0-compliant window managers can handle fullscreen windows | ||||||
|        If we're using XVidMode to change resolution we need to confine |        If we're using XVidMode to change resolution we need to confine | ||||||
| @@ -1501,8 +1498,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) | |||||||
|         X11_XRaiseWindow(display, data->xwindow); |         X11_XRaiseWindow(display, data->xwindow); | ||||||
|  |  | ||||||
|         /* Now grab the keyboard */ |         /* Now grab the keyboard */ | ||||||
|         hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD); |         if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) { | ||||||
|         if (hint && SDL_atoi(hint)) { |  | ||||||
|             grab_keyboard = SDL_TRUE; |             grab_keyboard = SDL_TRUE; | ||||||
|         } else { |         } else { | ||||||
|             /* We need to do this with the old style override_redirect |             /* We need to do this with the old style override_redirect | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sam Lantinga
					Sam Lantinga