mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-29 01:51:37 +00:00
Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool. Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test: @ bool_return_type @ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$"; @@ ( func( ... ) - == 0 | - func( + !func( ... ) - < 0 | - func( + !func( ... ) - != 0 | - func( + !func( ... ) - == -1 )
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#include "SDL_androidclipboard.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
int Android_SetClipboardText(SDL_VideoDevice *_this, const char *text)
|
||||
bool Android_SetClipboardText(SDL_VideoDevice *_this, const char *text)
|
||||
{
|
||||
return Android_JNI_SetClipboardText(text);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef SDL_androidclipboard_h_
|
||||
#define SDL_androidclipboard_h_
|
||||
|
||||
extern int Android_SetClipboardText(SDL_VideoDevice *_this, const char *text);
|
||||
extern bool Android_SetClipboardText(SDL_VideoDevice *_this, const char *text);
|
||||
extern char *Android_GetClipboardText(SDL_VideoDevice *_this);
|
||||
extern bool Android_HasClipboardText(SDL_VideoDevice *_this);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ static void android_egl_context_restore(SDL_Window *window)
|
||||
SDL_Event event;
|
||||
SDL_WindowData *data = window->internal;
|
||||
SDL_GL_MakeCurrent(window, NULL);
|
||||
if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) {
|
||||
if (!SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context)) {
|
||||
// The context is no longer valid, create a new one
|
||||
data->egl_context = (EGLContext)SDL_GL_CreateContext(window);
|
||||
SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context);
|
||||
@@ -65,7 +65,7 @@ static void android_egl_context_backup(SDL_Window *window)
|
||||
data->egl_context = SDL_GL_GetCurrentContext();
|
||||
|
||||
// Save/Restore the swap interval / vsync
|
||||
if (SDL_GL_GetSwapInterval(&interval) == 0) {
|
||||
if (SDL_GL_GetSwapInterval(&interval)) {
|
||||
data->has_swap_interval = 1;
|
||||
data->swap_interval = interval;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ void Android_PumpEvents(Sint64 timeoutNS)
|
||||
}
|
||||
}
|
||||
|
||||
int Android_WaitActiveAndLockActivity(void)
|
||||
bool Android_WaitActiveAndLockActivity(void)
|
||||
{
|
||||
while (Android_Paused && !Android_Destroyed) {
|
||||
Android_PumpEvents(-1);
|
||||
@@ -253,11 +253,11 @@ int Android_WaitActiveAndLockActivity(void)
|
||||
|
||||
if (Android_Destroyed) {
|
||||
SDL_SetError("Android activity has been destroyed");
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
Android_LockActivityMutex();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Android_QuitEvents(void)
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
|
||||
extern void Android_InitEvents(void);
|
||||
extern void Android_PumpEvents(Sint64 timeoutNS);
|
||||
extern int Android_WaitActiveAndLockActivity(void);
|
||||
extern bool Android_WaitActiveAndLockActivity(void);
|
||||
extern void Android_QuitEvents(void);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
int Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
|
||||
bool Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
|
||||
{
|
||||
if (window && context) {
|
||||
return SDL_EGL_MakeCurrent(_this, window->internal->egl_surface, context);
|
||||
@@ -47,22 +47,22 @@ int Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLC
|
||||
|
||||
SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_GLContext ret;
|
||||
SDL_GLContext result;
|
||||
|
||||
if (Android_WaitActiveAndLockActivity() < 0) {
|
||||
if (!Android_WaitActiveAndLockActivity()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = SDL_EGL_CreateContext(_this, window->internal->egl_surface);
|
||||
result = SDL_EGL_CreateContext(_this, window->internal->egl_surface);
|
||||
|
||||
Android_UnlockActivityMutex();
|
||||
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
int Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
int retval;
|
||||
bool result;
|
||||
|
||||
Android_LockActivityMutex();
|
||||
|
||||
@@ -73,14 +73,14 @@ int Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
_this->egl_data->eglWaitGL();*/
|
||||
retval = SDL_EGL_SwapBuffers(_this, window->internal->egl_surface);
|
||||
result = SDL_EGL_SwapBuffers(_this, window->internal->egl_surface);
|
||||
|
||||
Android_UnlockActivityMutex();
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
int Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#ifndef SDL_androidgl_h_
|
||||
#define SDL_androidgl_h_
|
||||
|
||||
SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
int Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
extern SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern bool Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
|
||||
extern bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
|
||||
#endif // SDL_androidgl_h_
|
||||
|
||||
@@ -368,14 +368,14 @@ static SDL_Scancode TranslateKeycode(int keycode)
|
||||
return scancode;
|
||||
}
|
||||
|
||||
int Android_OnKeyDown(int keycode)
|
||||
void Android_OnKeyDown(int keycode)
|
||||
{
|
||||
return SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), SDL_PRESSED);
|
||||
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), SDL_PRESSED);
|
||||
}
|
||||
|
||||
int Android_OnKeyUp(int keycode)
|
||||
void Android_OnKeyUp(int keycode)
|
||||
{
|
||||
return SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), SDL_RELEASED);
|
||||
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), SDL_RELEASED);
|
||||
}
|
||||
|
||||
bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this)
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "SDL_androidvideo.h"
|
||||
|
||||
extern int Android_OnKeyDown(int keycode);
|
||||
extern int Android_OnKeyUp(int keycode);
|
||||
extern void Android_OnKeyDown(int keycode);
|
||||
extern void Android_OnKeyUp(int keycode);
|
||||
|
||||
extern bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this);
|
||||
extern void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "SDL_androidmessagebox.h"
|
||||
#include "../../core/android/SDL_android.h"
|
||||
|
||||
int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
bool Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
{
|
||||
return Android_JNI_ShowMessageBox(messageboxdata, buttonID);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||
extern bool Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||
|
||||
#endif // SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
@@ -132,7 +132,7 @@ static void Android_DestroyEmptyCursor(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int Android_ShowCursor(SDL_Cursor *cursor)
|
||||
static bool Android_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
if (!cursor) {
|
||||
cursor = Android_CreateEmptyCursor();
|
||||
@@ -148,14 +148,14 @@ static int Android_ShowCursor(SDL_Cursor *cursor)
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
} else {
|
||||
// SDL error set inside Android_CreateEmptyCursor()
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static int Android_SetRelativeMouseMode(bool enabled)
|
||||
static bool Android_SetRelativeMouseMode(bool enabled)
|
||||
{
|
||||
if (!Android_JNI_SupportsRelativeMouse()) {
|
||||
return SDL_Unsupported();
|
||||
@@ -165,7 +165,7 @@ static int Android_SetRelativeMouseMode(bool enabled)
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Android_InitMouse(void)
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#define ANDROID_VID_DRIVER_NAME "android"
|
||||
|
||||
// Initialization/Query functions
|
||||
static int Android_VideoInit(SDL_VideoDevice *_this);
|
||||
static bool Android_VideoInit(SDL_VideoDevice *_this);
|
||||
static void Android_VideoQuit(SDL_VideoDevice *_this);
|
||||
|
||||
#include "../SDL_egl_c.h"
|
||||
@@ -51,7 +51,7 @@ static void Android_VideoQuit(SDL_VideoDevice *_this);
|
||||
#define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
|
||||
#define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
#define Android_GLES_DeleteContext SDL_EGL_DeleteContext
|
||||
#define Android_GLES_DestroyContext SDL_EGL_DestroyContext
|
||||
|
||||
// Android driver bootstrap functions
|
||||
|
||||
@@ -65,7 +65,7 @@ float Android_ScreenDensity = 1.0f;
|
||||
static float Android_ScreenRate = 0.0f;
|
||||
static SDL_SystemTheme Android_SystemTheme;
|
||||
|
||||
static int Android_SuspendScreenSaver(SDL_VideoDevice *_this)
|
||||
static bool Android_SuspendScreenSaver(SDL_VideoDevice *_this)
|
||||
{
|
||||
return Android_JNI_SuspendScreenSaver(_this->suspend_screensaver);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ static SDL_VideoDevice *Android_CreateDevice(void)
|
||||
device->GL_SetSwapInterval = Android_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = Android_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = Android_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = Android_GLES_DeleteContext;
|
||||
device->GL_DestroyContext = Android_GLES_DestroyContext;
|
||||
#endif
|
||||
|
||||
#ifdef SDL_VIDEO_VULKAN
|
||||
@@ -155,7 +155,7 @@ VideoBootStrap Android_bootstrap = {
|
||||
Android_ShowMessageBox
|
||||
};
|
||||
|
||||
int Android_VideoInit(SDL_VideoDevice *_this)
|
||||
bool Android_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *videodata = _this->internal;
|
||||
SDL_DisplayID displayID;
|
||||
@@ -173,7 +173,7 @@ int Android_VideoInit(SDL_VideoDevice *_this)
|
||||
|
||||
displayID = SDL_AddBasicVideoDisplay(&mode);
|
||||
if (displayID == 0) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
display = SDL_GetVideoDisplay(displayID);
|
||||
display->natural_orientation = Android_JNI_GetDisplayNaturalOrientation();
|
||||
@@ -185,7 +185,7 @@ int Android_VideoInit(SDL_VideoDevice *_this)
|
||||
Android_InitMouse();
|
||||
|
||||
// We're done!
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Android_VideoQuit(SDL_VideoDevice *_this)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "SDL_androidvulkan.h"
|
||||
|
||||
|
||||
int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
{
|
||||
VkExtensionProperties *extensions = NULL;
|
||||
Uint32 i, extensionCount = 0;
|
||||
@@ -56,7 +56,7 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
}
|
||||
_this->vulkan_config.loader_handle = SDL_LoadObject(path);
|
||||
if (!_this->vulkan_config.loader_handle) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
||||
SDL_arraysize(_this->vulkan_config.loader_path));
|
||||
@@ -94,12 +94,12 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
||||
SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "extension");
|
||||
goto fail;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
|
||||
@@ -116,13 +116,13 @@ char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
||||
static const char *const extensionsForAndroid[] = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
|
||||
};
|
||||
if(count) {
|
||||
if (count) {
|
||||
*count = SDL_arraysize(extensionsForAndroid);
|
||||
}
|
||||
return extensionsForAndroid;
|
||||
}
|
||||
|
||||
int Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
const struct VkAllocationCallbacks *allocator,
|
||||
@@ -155,7 +155,7 @@ int Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
if (result != VK_SUCCESS) {
|
||||
return SDL_SetError("vkCreateAndroidSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this,
|
||||
|
||||
@@ -34,19 +34,18 @@
|
||||
|
||||
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID)
|
||||
|
||||
int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
||||
Uint32 *count);
|
||||
int Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
const struct VkAllocationCallbacks *allocator,
|
||||
VkSurfaceKHR *surface);
|
||||
void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR surface,
|
||||
const struct VkAllocationCallbacks *allocator);
|
||||
extern bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||
extern void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
||||
extern char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
||||
extern bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
const struct VkAllocationCallbacks *allocator,
|
||||
VkSurfaceKHR *surface);
|
||||
extern void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR surface,
|
||||
const struct VkAllocationCallbacks *allocator);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,17 +36,17 @@
|
||||
// Currently only one window
|
||||
SDL_Window *Android_Window = NULL;
|
||||
|
||||
int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
bool Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *data;
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
|
||||
if (Android_WaitActiveAndLockActivity() < 0) {
|
||||
return -1;
|
||||
if (!Android_WaitActiveAndLockActivity()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Android_Window) {
|
||||
retval = SDL_SetError("Android only supports one window");
|
||||
result = SDL_SetError("Android only supports one window");
|
||||
goto endfunction;
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
|
||||
|
||||
data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
retval = -1;
|
||||
result = SDL_FALSE;
|
||||
goto endfunction;
|
||||
}
|
||||
|
||||
data->native_window = Android_JNI_GetNativeWindow();
|
||||
if (!data->native_window) {
|
||||
SDL_free(data);
|
||||
retval = SDL_SetError("Could not fetch native window");
|
||||
result = SDL_SetError("Could not fetch native window");
|
||||
goto endfunction;
|
||||
}
|
||||
SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER, data->native_window);
|
||||
@@ -86,7 +86,7 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
|
||||
if (data->egl_surface == EGL_NO_SURFACE) {
|
||||
ANativeWindow_release(data->native_window);
|
||||
SDL_free(data);
|
||||
retval = -1;
|
||||
result = SDL_FALSE;
|
||||
goto endfunction;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ endfunction:
|
||||
|
||||
Android_UnlockActivityMutex();
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
@@ -108,7 +108,7 @@ void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
Android_JNI_SetActivityTitle(window->title);
|
||||
}
|
||||
|
||||
int Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen)
|
||||
SDL_FullscreenResult Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen)
|
||||
{
|
||||
Android_LockActivityMutex();
|
||||
|
||||
@@ -157,7 +157,8 @@ int Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_
|
||||
endfunction:
|
||||
|
||||
Android_UnlockActivityMutex();
|
||||
return 0;
|
||||
|
||||
return SDL_FULLSCREEN_SUCCEEDED;
|
||||
}
|
||||
|
||||
void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#include "../../core/android/SDL_android.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
|
||||
extern int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern bool Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen);
|
||||
extern SDL_FullscreenResult Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen);
|
||||
extern void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user