mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-09 01:14:24 +02: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:
@@ -31,16 +31,16 @@ void SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata)
|
||||
|
||||
#ifndef SDL_PLATFORM_LINUX
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
|
||||
int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
|
||||
SDL_bool SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
{
|
||||
(void)threadID;
|
||||
(void)priority;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
||||
int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
||||
SDL_bool SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
{
|
||||
(void)threadID;
|
||||
(void)sdlPriority;
|
||||
@@ -58,8 +58,8 @@ void SDL_GDKSuspendComplete(void)
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_GetGDKDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */
|
||||
int SDL_GetGDKDefaultUser(void *outUserHandle)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKDefaultUser(void *outUserHandle); /* XUserHandle *outUserHandle */
|
||||
SDL_bool SDL_GetGDKDefaultUser(void *outUserHandle)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -68,8 +68,8 @@ int SDL_GetGDKDefaultUser(void *outUserHandle)
|
||||
|
||||
#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK))
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
|
||||
SDL_bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
{
|
||||
(void)name;
|
||||
(void)style;
|
||||
@@ -163,8 +163,8 @@ void *SDL_GetAndroidJNIEnv(void)
|
||||
}
|
||||
|
||||
typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, bool granted);
|
||||
SDL_DECLSPEC int SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
|
||||
int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
|
||||
SDL_bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
|
||||
{
|
||||
(void)permission;
|
||||
(void)cb;
|
||||
@@ -172,16 +172,16 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
|
||||
int SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
|
||||
SDL_bool SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
{
|
||||
(void)command;
|
||||
(void)param;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
SDL_DECLSPEC int SDLCALL SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
|
||||
int SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
|
||||
SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset);
|
||||
SDL_bool SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
|
||||
{
|
||||
(void)message;
|
||||
(void)duration;
|
||||
|
||||
@@ -268,11 +268,11 @@ static JNINativeMethod SDLAudioManager_tab[] = {
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(
|
||||
JNIEnv *env, jclass jcls);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode);
|
||||
|
||||
@@ -284,33 +284,33 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint hat_id, jint x, jint y);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id,
|
||||
jint button_mask, jint naxes, jint axis_mask, jint nhats, jboolean can_rumble);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jstring device_name);
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id);
|
||||
|
||||
static JNINativeMethod SDLControllerManager_tab[] = {
|
||||
{ "nativeSetupJNI", "()I", SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI) },
|
||||
{ "onNativePadDown", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) },
|
||||
{ "onNativePadUp", "(II)I", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) },
|
||||
{ "onNativePadDown", "(II)Z", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown) },
|
||||
{ "onNativePadUp", "(II)Z", SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp) },
|
||||
{ "onNativeJoy", "(IIF)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy) },
|
||||
{ "onNativeHat", "(IIII)V", SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat) },
|
||||
{ "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIIIIIZ)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
|
||||
{ "nativeRemoveJoystick", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) },
|
||||
{ "nativeAddHaptic", "(ILjava/lang/String;)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) },
|
||||
{ "nativeRemoveHaptic", "(I)I", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
|
||||
{ "nativeAddJoystick", "(ILjava/lang/String;Ljava/lang/String;IIIIIIZ)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick) },
|
||||
{ "nativeRemoveJoystick", "(I)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick) },
|
||||
{ "nativeAddHaptic", "(ILjava/lang/String;)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic) },
|
||||
{ "nativeRemoveHaptic", "(I)V", SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic) }
|
||||
};
|
||||
|
||||
// Uncomment this to log messages entering and exiting methods in this file
|
||||
@@ -434,13 +434,14 @@ static int Android_NumLifecycleEvents;
|
||||
*/
|
||||
|
||||
// Set local storage value
|
||||
static int Android_JNI_SetEnv(JNIEnv *env)
|
||||
static bool Android_JNI_SetEnv(JNIEnv *env)
|
||||
{
|
||||
int status = pthread_setspecific(mThreadKey, env);
|
||||
if (status < 0) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed pthread_setspecific() in Android_JNI_SetEnv() (err=%d)", status);
|
||||
return false;
|
||||
}
|
||||
return status;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get local storage value
|
||||
@@ -467,7 +468,7 @@ JNIEnv *Android_JNI_GetEnv(void)
|
||||
}
|
||||
|
||||
// Save JNIEnv into the Thread local storage
|
||||
if (Android_JNI_SetEnv(env) < 0) {
|
||||
if (!Android_JNI_SetEnv(env)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -476,7 +477,7 @@ JNIEnv *Android_JNI_GetEnv(void)
|
||||
}
|
||||
|
||||
// Set up an external thread for using JNI with Android_JNI_GetEnv()
|
||||
int Android_JNI_SetupThread(void)
|
||||
bool Android_JNI_SetupThread(void)
|
||||
{
|
||||
JNIEnv *env;
|
||||
int status;
|
||||
@@ -484,7 +485,7 @@ int Android_JNI_SetupThread(void)
|
||||
// There should be a JVM
|
||||
if (!mJavaVM) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Attach the current thread to the JVM and get a JNIEnv.
|
||||
@@ -492,15 +493,15 @@ int Android_JNI_SetupThread(void)
|
||||
status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL);
|
||||
if (status < 0) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to attach current thread (err=%d)", status);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save JNIEnv into the Thread local storage
|
||||
if (Android_JNI_SetEnv(env) < 0) {
|
||||
return 0;
|
||||
if (!Android_JNI_SetEnv(env)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Destructor called for each thread where mThreadKey is not NULL
|
||||
@@ -642,9 +643,9 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
||||
midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass, "isTablet", "()Z");
|
||||
midManualBackButton = (*env)->GetStaticMethodID(env, mActivityClass, "manualBackButton", "()V");
|
||||
midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass, "minimizeWindow", "()V");
|
||||
midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)I");
|
||||
midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)Z");
|
||||
midRequestPermission = (*env)->GetStaticMethodID(env, mActivityClass, "requestPermission", "(Ljava/lang/String;I)V");
|
||||
midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)I");
|
||||
midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)Z");
|
||||
midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z");
|
||||
midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass, "setActivityTitle", "(Ljava/lang/String;)Z");
|
||||
midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z");
|
||||
@@ -960,7 +961,7 @@ bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeout
|
||||
{
|
||||
bool got_event = false;
|
||||
|
||||
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS) == 0) {
|
||||
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS)) {
|
||||
SDL_LockMutex(Android_LifecycleMutex);
|
||||
{
|
||||
if (Android_NumLifecycleEvents > 0) {
|
||||
@@ -1117,26 +1118,26 @@ SDL_JAVA_AUDIO_INTERFACE(removeAudioDevice)(JNIEnv *env, jclass jcls, jboolean r
|
||||
}
|
||||
|
||||
// Paddown
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
return Android_OnPadDown(device_id, keycode);
|
||||
#else
|
||||
return -1;
|
||||
return false;
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
// Padup
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jint keycode)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
return Android_OnPadUp(device_id, keycode);
|
||||
#else
|
||||
return -1;
|
||||
return false;
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
@@ -1160,61 +1161,49 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id, jstring device_name, jstring device_desc,
|
||||
jint vendor_id, jint product_id,
|
||||
jint button_mask, jint naxes, jint axis_mask, jint nhats, jboolean can_rumble)
|
||||
{
|
||||
int retval;
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
|
||||
const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL);
|
||||
|
||||
retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, button_mask, naxes, axis_mask, nhats, can_rumble);
|
||||
Android_AddJoystick(device_id, name, desc, vendor_id, product_id, button_mask, naxes, axis_mask, nhats, can_rumble);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, device_name, name);
|
||||
(*env)->ReleaseStringUTFChars(env, device_desc, desc);
|
||||
#else
|
||||
retval = -1;
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
return retval;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint device_id)
|
||||
{
|
||||
#ifdef SDL_JOYSTICK_ANDROID
|
||||
return Android_RemoveJoystick(device_id);
|
||||
#else
|
||||
return -1;
|
||||
Android_RemoveJoystick(device_id);
|
||||
#endif // SDL_JOYSTICK_ANDROID
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
|
||||
JNIEnv *env, jclass jcls, jint device_id, jstring device_name)
|
||||
{
|
||||
int retval;
|
||||
#ifdef SDL_HAPTIC_ANDROID
|
||||
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
|
||||
|
||||
retval = Android_AddHaptic(device_id, name);
|
||||
Android_AddHaptic(device_id, name);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, device_name, name);
|
||||
#else
|
||||
retval = -1;
|
||||
#endif // SDL_HAPTIC_ANDROID
|
||||
return retval;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
|
||||
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
|
||||
JNIEnv *env, jclass jcls, jint device_id)
|
||||
{
|
||||
#ifdef SDL_HAPTIC_ANDROID
|
||||
return Android_RemoveHaptic(device_id);
|
||||
#else
|
||||
return -1;
|
||||
Android_RemoveHaptic(device_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1650,7 +1639,7 @@ bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
|
||||
|
||||
bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||
{
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
if (bHasNewData) {
|
||||
int i;
|
||||
@@ -1658,10 +1647,10 @@ bool Android_JNI_GetAccelerometerValues(float values[3])
|
||||
values[i] = fLastAccelerometer[i];
|
||||
}
|
||||
bHasNewData = false;
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1789,7 +1778,7 @@ static void Internal_Android_Destroy_AssetManager(void)
|
||||
}
|
||||
}
|
||||
|
||||
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode)
|
||||
bool Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode)
|
||||
{
|
||||
SDL_assert(puserdata != NULL);
|
||||
|
||||
@@ -1810,7 +1799,7 @@ int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mod
|
||||
}
|
||||
|
||||
*puserdata = (void *)asset;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status)
|
||||
@@ -1825,7 +1814,8 @@ size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOSta
|
||||
|
||||
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status)
|
||||
{
|
||||
return SDL_SetError("Cannot write to Android package filesystem");
|
||||
SDL_SetError("Cannot write to Android package filesystem");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Sint64 Android_JNI_FileSize(void *userdata)
|
||||
@@ -1838,19 +1828,19 @@ Sint64 Android_JNI_FileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence)
|
||||
return (Sint64) AAsset_seek64((AAsset *)userdata, offset, (int)whence);
|
||||
}
|
||||
|
||||
int Android_JNI_FileClose(void *userdata)
|
||||
SDL_bool Android_JNI_FileClose(void *userdata)
|
||||
{
|
||||
AAsset_close((AAsset *)userdata);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int Android_JNI_SetClipboardText(const char *text)
|
||||
bool Android_JNI_SetClipboardText(const char *text)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jstring string = (*env)->NewStringUTF(env, text);
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midClipboardSetText, string);
|
||||
(*env)->DeleteLocalRef(env, string);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
char *Android_JNI_GetClipboardText(void)
|
||||
@@ -2038,24 +2028,22 @@ void Android_JNI_HapticStop(int device_id)
|
||||
// See SDLActivity.java for constants.
|
||||
#define COMMAND_SET_KEEP_SCREEN_ON 5
|
||||
|
||||
int SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
SDL_bool SDL_SendAndroidMessage(Uint32 command, int param)
|
||||
{
|
||||
if (command >= 0x8000) {
|
||||
return Android_JNI_SendMessage(command, param);
|
||||
if (command < 0x8000) {
|
||||
return SDL_InvalidParamError("command");
|
||||
}
|
||||
return -1;
|
||||
return Android_JNI_SendMessage(command, param);
|
||||
}
|
||||
|
||||
// sends message to be handled on the UI event dispatch thread
|
||||
int Android_JNI_SendMessage(int command, int param)
|
||||
bool Android_JNI_SendMessage(int command, int param)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jboolean success;
|
||||
success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midSendMessage, command, param);
|
||||
return success ? 0 : -1;
|
||||
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSendMessage, command, param);
|
||||
}
|
||||
|
||||
int Android_JNI_SuspendScreenSaver(bool suspend)
|
||||
bool Android_JNI_SuspendScreenSaver(bool suspend)
|
||||
{
|
||||
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == false) ? 0 : 1);
|
||||
}
|
||||
@@ -2086,7 +2074,7 @@ bool Android_JNI_IsScreenKeyboardShown(void)
|
||||
return is_shown;
|
||||
}
|
||||
|
||||
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
{
|
||||
JNIEnv *env;
|
||||
jclass clazz;
|
||||
@@ -2176,7 +2164,7 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
(*env)->DeleteLocalRef(env, button_texts);
|
||||
(*env)->DeleteLocalRef(env, colors);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2431,7 +2419,7 @@ const char *SDL_GetAndroidCachePath(void)
|
||||
return s_AndroidCachePath;
|
||||
}
|
||||
|
||||
int SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
|
||||
SDL_bool SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
|
||||
{
|
||||
return Android_JNI_ShowToast(message, duration, gravity, xOffset, yOffset);
|
||||
}
|
||||
@@ -2530,7 +2518,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)(
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
|
||||
SDL_bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata)
|
||||
{
|
||||
if (!permission) {
|
||||
return SDL_InvalidParamError("permission");
|
||||
@@ -2540,13 +2528,13 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
|
||||
|
||||
NativePermissionRequestInfo *info = (NativePermissionRequestInfo *) SDL_calloc(1, sizeof (NativePermissionRequestInfo));
|
||||
if (!info) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
info->permission = SDL_strdup(permission);
|
||||
if (!info->permission) {
|
||||
SDL_free(info);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static SDL_AtomicInt next_request_code;
|
||||
@@ -2565,13 +2553,13 @@ int SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermi
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midRequestPermission, jpermission, info->request_code);
|
||||
(*env)->DeleteLocalRef(env, jpermission);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Show toast notification
|
||||
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
|
||||
bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset)
|
||||
{
|
||||
int result = 0;
|
||||
bool result;
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jstring jmessage = (*env)->NewStringUTF(env, message);
|
||||
result = (*env)->CallStaticIntMethod(env, mActivityClass, midShowToast, jmessage, duration, gravity, xOffset, yOffset);
|
||||
@@ -2579,7 +2567,7 @@ int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xO
|
||||
return result;
|
||||
}
|
||||
|
||||
int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
bool Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
{
|
||||
AConfiguration *cfg;
|
||||
|
||||
@@ -2593,12 +2581,12 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
}
|
||||
|
||||
if (!asset_manager) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cfg = AConfiguration_new();
|
||||
if (!cfg) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2634,16 +2622,17 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
|
||||
|
||||
AConfiguration_delete(cfg);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int Android_JNI_OpenURL(const char *url)
|
||||
bool Android_JNI_OpenURL(const char *url)
|
||||
{
|
||||
bool result;
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
jstring jurl = (*env)->NewStringUTF(env, url);
|
||||
const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl);
|
||||
result = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl);
|
||||
(*env)->DeleteLocalRef(env, jurl);
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode)
|
||||
|
||||
@@ -80,19 +80,19 @@ extern void Android_AudioThreadInit(SDL_AudioDevice *device);
|
||||
extern bool Android_IsDeXMode(void);
|
||||
extern bool Android_IsChromebook(void);
|
||||
|
||||
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
|
||||
bool Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
|
||||
Sint64 Android_JNI_FileSize(void *userdata);
|
||||
Sint64 Android_JNI_FileSeek(void *userdata, Sint64 offset, SDL_IOWhence whence);
|
||||
size_t Android_JNI_FileRead(void *userdata, void *buffer, size_t size, SDL_IOStatus *status);
|
||||
size_t Android_JNI_FileWrite(void *userdata, const void *buffer, size_t size, SDL_IOStatus *status);
|
||||
int Android_JNI_FileClose(void *userdata);
|
||||
SDL_bool Android_JNI_FileClose(void *userdata);
|
||||
|
||||
// Environment support
|
||||
void Android_JNI_GetManifestEnvironmentVariables(void);
|
||||
int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
|
||||
|
||||
// Clipboard support
|
||||
int Android_JNI_SetClipboardText(const char *text);
|
||||
bool Android_JNI_SetClipboardText(const char *text);
|
||||
char *Android_JNI_GetClipboardText(void);
|
||||
bool Android_JNI_HasClipboardText(void);
|
||||
|
||||
@@ -109,7 +109,7 @@ void Android_JNI_HapticRumble(int device_id, float low_frequency_intensity, floa
|
||||
void Android_JNI_HapticStop(int device_id);
|
||||
|
||||
// Video
|
||||
int Android_JNI_SuspendScreenSaver(bool suspend);
|
||||
bool Android_JNI_SuspendScreenSaver(bool suspend);
|
||||
|
||||
// Touch support
|
||||
void Android_JNI_InitTouch(void);
|
||||
@@ -117,16 +117,16 @@ void Android_JNI_InitTouch(void);
|
||||
// Threads
|
||||
#include <jni.h>
|
||||
JNIEnv *Android_JNI_GetEnv(void);
|
||||
int Android_JNI_SetupThread(void);
|
||||
bool Android_JNI_SetupThread(void);
|
||||
|
||||
// Locale
|
||||
int Android_JNI_GetLocale(char *buf, size_t buflen);
|
||||
bool Android_JNI_GetLocale(char *buf, size_t buflen);
|
||||
|
||||
// Generic messages
|
||||
int Android_JNI_SendMessage(int command, int param);
|
||||
bool Android_JNI_SendMessage(int command, int param);
|
||||
|
||||
// MessageBox
|
||||
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||
bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
|
||||
|
||||
// Cursor support
|
||||
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
|
||||
@@ -139,9 +139,9 @@ bool Android_JNI_SupportsRelativeMouse(void);
|
||||
bool Android_JNI_SetRelativeMouseEnabled(bool enabled);
|
||||
|
||||
// Show toast notification
|
||||
int Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
|
||||
bool Android_JNI_ShowToast(const char *message, int duration, int gravity, int xOffset, int yOffset);
|
||||
|
||||
int Android_JNI_OpenURL(const char *url);
|
||||
bool Android_JNI_OpenURL(const char *url);
|
||||
|
||||
int SDL_GetAndroidSDKVersion(void);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ struct SDL_EVDEV_keyboard_state
|
||||
unsigned int text_len;
|
||||
};
|
||||
|
||||
static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd)
|
||||
static bool SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd)
|
||||
{
|
||||
return ioctl(kbd->keyboard_fd, GIO_KEYMAP, kbd->key_map) >= 0;
|
||||
}
|
||||
@@ -408,7 +408,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
|
||||
static bool vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
|
||||
{
|
||||
return (kbd->ledflagstate & flag) != 0;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ PAPPCONSTRAIN_REGISTRATION hCPLM = {};
|
||||
HANDLE plmSuspendComplete = nullptr;
|
||||
|
||||
extern "C"
|
||||
int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
|
||||
SDL_bool SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
|
||||
{
|
||||
// If this is the first call, first create the global task queue.
|
||||
if (!GDK_GlobalTaskQueue) {
|
||||
@@ -57,7 +57,7 @@ int SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -74,13 +74,12 @@ void GDK_DispatchTaskQueue(void)
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int GDK_RegisterChangeNotifications(void)
|
||||
bool GDK_RegisterChangeNotifications(void)
|
||||
{
|
||||
// Register suspend/resume handling
|
||||
plmSuspendComplete = CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
|
||||
if (!plmSuspendComplete) {
|
||||
SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
|
||||
return -1;
|
||||
return SDL_SetError("[GDK] Unable to create plmSuspendComplete event");
|
||||
}
|
||||
auto rascn = [](BOOLEAN quiesced, PVOID context) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppStateChangeNotification handler");
|
||||
@@ -98,8 +97,7 @@ int GDK_RegisterChangeNotifications(void)
|
||||
}
|
||||
};
|
||||
if (RegisterAppStateChangeNotification(rascn, NULL, &hPLM)) {
|
||||
SDL_SetError("[GDK] Unable to call RegisterAppStateChangeNotification");
|
||||
return -1;
|
||||
return SDL_SetError("[GDK] Unable to call RegisterAppStateChangeNotification");
|
||||
}
|
||||
|
||||
// Register constrain/unconstrain handling
|
||||
@@ -115,11 +113,10 @@ int GDK_RegisterChangeNotifications(void)
|
||||
}
|
||||
};
|
||||
if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) {
|
||||
SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
|
||||
return -1;
|
||||
return SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -142,7 +139,7 @@ void SDL_GDKSuspendComplete()
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
|
||||
SDL_bool SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
|
||||
{
|
||||
XAsyncBlock block = { 0 };
|
||||
HRESULT result;
|
||||
@@ -158,5 +155,5 @@ int SDL_GetGDKDefaultUser(XUserHandle *outUserHandle)
|
||||
return WIN_SetErrorFromHRESULT("XUserAddResult", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,5 @@
|
||||
// This is called from WIN_PumpEvents on GDK
|
||||
extern void GDK_DispatchTaskQueue(void);
|
||||
|
||||
extern int GDK_RegisterChangeNotifications(void);
|
||||
|
||||
extern bool GDK_RegisterChangeNotifications(void);
|
||||
extern void GDK_UnregisterChangeNotifications(void);
|
||||
|
||||
@@ -104,7 +104,7 @@ static int StartBeApp(void *unused)
|
||||
}
|
||||
|
||||
|
||||
static int StartBeLooper()
|
||||
static bool StartBeLooper()
|
||||
{
|
||||
if (!be_app) {
|
||||
SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
|
||||
@@ -119,16 +119,18 @@ static int StartBeLooper()
|
||||
|
||||
SDL_Looper = new SDL_BLooper("SDLLooper");
|
||||
SDL_Looper->Run();
|
||||
return (0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Initialize the Be Application, if it's not already started
|
||||
int SDL_InitBeApp(void)
|
||||
bool SDL_InitBeApp(void)
|
||||
{
|
||||
// Create the BApplication that handles appserver interaction
|
||||
if (SDL_BeAppActive <= 0) {
|
||||
StartBeLooper();
|
||||
if (!StartBeLooper()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mark the application active
|
||||
SDL_BeAppActive = 0;
|
||||
@@ -138,7 +140,7 @@ int SDL_InitBeApp(void)
|
||||
++SDL_BeAppActive;
|
||||
|
||||
// The app is running, and we're ready to go
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Quit the Be Application, if there's nothing left to do
|
||||
|
||||
@@ -26,7 +26,7 @@ extern "C" {
|
||||
// Handle the BeApp specific portions of the application
|
||||
|
||||
// Initialize the Be Application, if it's not already started
|
||||
extern int SDL_InitBeApp(void);
|
||||
extern bool SDL_InitBeApp(void);
|
||||
|
||||
// Quit the Be Application, if there's nothing left to do
|
||||
extern void SDL_QuitBeApp(void);
|
||||
|
||||
@@ -31,14 +31,14 @@ static char *inhibit_handle = NULL;
|
||||
static unsigned int screensaver_cookie = 0;
|
||||
static SDL_DBusContext dbus;
|
||||
|
||||
static int LoadDBUSSyms(void)
|
||||
static bool LoadDBUSSyms(void)
|
||||
{
|
||||
#define SDL_DBUS_SYM2_OPTIONAL(TYPE, x, y) \
|
||||
dbus.x = (TYPE)SDL_LoadFunction(dbus_handle, #y)
|
||||
|
||||
#define SDL_DBUS_SYM2(TYPE, x, y) \
|
||||
if (!(dbus.x = (TYPE)SDL_LoadFunction(dbus_handle, #y))) \
|
||||
return -1
|
||||
return false
|
||||
|
||||
#define SDL_DBUS_SYM_OPTIONAL(TYPE, x) \
|
||||
SDL_DBUS_SYM2_OPTIONAL(TYPE, x, dbus_##x)
|
||||
@@ -93,7 +93,7 @@ static int LoadDBUSSyms(void)
|
||||
#undef SDL_DBUS_SYM
|
||||
#undef SDL_DBUS_SYM2
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void UnloadDBUSLibrary(void)
|
||||
@@ -104,23 +104,22 @@ static void UnloadDBUSLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int LoadDBUSLibrary(void)
|
||||
static bool LoadDBUSLibrary(void)
|
||||
{
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
if (!dbus_handle) {
|
||||
dbus_handle = SDL_LoadObject(dbus_library);
|
||||
if (!dbus_handle) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
} else {
|
||||
retval = LoadDBUSSyms();
|
||||
if (retval < 0) {
|
||||
result = LoadDBUSSyms();
|
||||
if (!result) {
|
||||
UnloadDBUSLibrary();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_SpinLock spinlock_dbus_init = 0;
|
||||
@@ -136,7 +135,7 @@ static void SDL_DBus_Init_Spinlocked(void)
|
||||
if (!dbus.session_conn) {
|
||||
DBusError err;
|
||||
|
||||
if (LoadDBUSLibrary() == -1) {
|
||||
if (!LoadDBUSLibrary()) {
|
||||
is_dbus_available = false; // can't load at all? Don't keep trying.
|
||||
return;
|
||||
}
|
||||
@@ -209,7 +208,7 @@ SDL_DBusContext *SDL_DBus_GetContext(void)
|
||||
|
||||
static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
||||
{
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
if (conn) {
|
||||
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
||||
@@ -237,7 +236,7 @@ static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node,
|
||||
}
|
||||
firstarg = va_arg(ap_reply, int);
|
||||
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
dbus.message_unref(reply);
|
||||
}
|
||||
@@ -247,32 +246,32 @@ static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node,
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
||||
{
|
||||
bool retval;
|
||||
bool result;
|
||||
va_list ap;
|
||||
va_start(ap, method);
|
||||
retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
|
||||
result = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
||||
{
|
||||
bool retval;
|
||||
bool result;
|
||||
va_list ap;
|
||||
va_start(ap, method);
|
||||
retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||
result = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
|
||||
{
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
if (conn) {
|
||||
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
|
||||
@@ -281,7 +280,7 @@ static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *no
|
||||
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
|
||||
if (dbus.connection_send(conn, msg, NULL)) {
|
||||
dbus.connection_flush(conn);
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +288,7 @@ static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *no
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
|
||||
@@ -319,22 +318,22 @@ static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg,
|
||||
|
||||
bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
|
||||
{
|
||||
bool retval;
|
||||
bool result;
|
||||
va_list ap;
|
||||
va_start(ap, method);
|
||||
retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
|
||||
result = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
|
||||
{
|
||||
bool retval;
|
||||
bool result;
|
||||
va_list ap;
|
||||
va_start(ap, method);
|
||||
retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||
result = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
|
||||
@@ -449,7 +448,7 @@ bool SDL_DBus_ScreensaverInhibit(bool inhibit)
|
||||
|
||||
if (inhibit) {
|
||||
DBusMessage *msg;
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
const char *key = "reason";
|
||||
const char *reply = NULL;
|
||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||
@@ -477,11 +476,11 @@ bool SDL_DBus_ScreensaverInhibit(bool inhibit)
|
||||
|
||||
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
|
||||
inhibit_handle = SDL_strdup(reply);
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
dbus.message_unref(msg);
|
||||
return retval;
|
||||
return result;
|
||||
} else {
|
||||
if (!SDL_DBus_CallVoidMethod(bus_name, inhibit_handle, "org.freedesktop.portal.Request", "Close", DBUS_TYPE_INVALID)) {
|
||||
return false;
|
||||
|
||||
@@ -132,9 +132,8 @@ static SDL_EVDEV_PrivateData *_this = NULL;
|
||||
|
||||
static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode);
|
||||
static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item);
|
||||
static int SDL_EVDEV_device_removed(const char *dev_path);
|
||||
|
||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
||||
static bool SDL_EVDEV_device_removed(const char *dev_path);
|
||||
static bool SDL_EVDEV_device_added(const char *dev_path, int udev_class);
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path);
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
@@ -150,10 +149,10 @@ static Uint8 EVDEV_MouseButtons[] = {
|
||||
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
|
||||
};
|
||||
|
||||
static int SDL_EVDEV_SetRelativeMouseMode(bool enabled)
|
||||
static bool SDL_EVDEV_SetRelativeMouseMode(bool enabled)
|
||||
{
|
||||
// Mice already send relative events through this interface
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_UpdateKeyboardMute(void)
|
||||
@@ -165,27 +164,27 @@ static void SDL_EVDEV_UpdateKeyboardMute(void)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_EVDEV_Init(void)
|
||||
SDL_bool SDL_EVDEV_Init(void)
|
||||
{
|
||||
if (!_this) {
|
||||
_this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
|
||||
if (!_this) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
if (SDL_UDEV_Init() < 0) {
|
||||
if (!SDL_UDEV_Init()) {
|
||||
SDL_free(_this);
|
||||
_this = NULL;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up the udev callback
|
||||
if (SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) {
|
||||
if (!SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback)) {
|
||||
SDL_UDEV_Quit();
|
||||
SDL_free(_this);
|
||||
_this = NULL;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force a scan to build the initial device list
|
||||
@@ -226,7 +225,7 @@ int SDL_EVDEV_Init(void)
|
||||
|
||||
_this->ref_count += 1;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_EVDEV_Quit(void)
|
||||
@@ -603,7 +602,7 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode)
|
||||
return scancode;
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
|
||||
static bool SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
char name[128];
|
||||
|
||||
@@ -612,7 +611,7 @@ static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
|
||||
|
||||
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, true);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
|
||||
@@ -620,7 +619,7 @@ static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
|
||||
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, true);
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
static bool SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
char name[128];
|
||||
int ret;
|
||||
@@ -634,7 +633,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
item->min_x = abs_info.minimum;
|
||||
item->max_x = abs_info.maximum;
|
||||
@@ -643,13 +642,13 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_Y), &abs_info);
|
||||
if (ret < 0) {
|
||||
// no absolute mode info, continue
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
item->min_y = abs_info.minimum;
|
||||
item->max_y = abs_info.maximum;
|
||||
item->range_y = abs_info.maximum - abs_info.minimum;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
|
||||
@@ -657,7 +656,7 @@ static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
|
||||
SDL_RemoveMouse((SDL_MouseID)item->fd, true);
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
{
|
||||
int ret;
|
||||
unsigned long xreq, yreq;
|
||||
@@ -665,12 +664,12 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
struct input_absinfo abs_info;
|
||||
|
||||
if (!item->is_touchscreen) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
|
||||
if (!item->touchscreen_data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
|
||||
@@ -682,7 +681,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
item->touchscreen_data->name = SDL_strdup(name);
|
||||
if (!item->touchscreen_data->name) {
|
||||
SDL_free(item->touchscreen_data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info);
|
||||
@@ -738,7 +737,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
if (!item->touchscreen_data->slots) {
|
||||
SDL_free(item->touchscreen_data->name);
|
||||
SDL_free(item->touchscreen_data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = SDL_AddTouch(item->fd, // I guess our fd is unique enough
|
||||
@@ -748,10 +747,10 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
|
||||
SDL_free(item->touchscreen_data->slots);
|
||||
SDL_free(item->touchscreen_data->name);
|
||||
SDL_free(item->touchscreen_data);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item *item)
|
||||
@@ -891,7 +890,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
|
||||
#endif // EVIOCGMTSLOTS
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
static bool SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
{
|
||||
SDL_evdevlist_item *item;
|
||||
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
|
||||
@@ -899,13 +898,13 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
// Check to make sure it's not already in list.
|
||||
for (item = _this->first; item; item = item->next) {
|
||||
if (SDL_strcmp(dev_path, item->path) == 0) {
|
||||
return -1; // already have this one
|
||||
return false; // already have this one
|
||||
}
|
||||
}
|
||||
|
||||
item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
|
||||
if (!item) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
item->fd = open(dev_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
@@ -918,7 +917,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
if (!item->path) {
|
||||
close(item->fd);
|
||||
SDL_free(item);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
item->udev_class = udev_class;
|
||||
@@ -931,30 +930,26 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
|
||||
// For now, we just treat a touchpad like a touchscreen
|
||||
if (udev_class & (SDL_UDEV_DEVICE_TOUCHSCREEN | SDL_UDEV_DEVICE_TOUCHPAD)) {
|
||||
int ret;
|
||||
item->is_touchscreen = true;
|
||||
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
|
||||
if (ret < 0) {
|
||||
if (!SDL_EVDEV_init_touchscreen(item, udev_class)) {
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
SDL_free(item);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
} else if (udev_class & SDL_UDEV_DEVICE_MOUSE) {
|
||||
int ret = SDL_EVDEV_init_mouse(item, udev_class);
|
||||
if (ret < 0) {
|
||||
if (!SDL_EVDEV_init_mouse(item, udev_class)) {
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
SDL_free(item);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
} else if (udev_class & SDL_UDEV_DEVICE_KEYBOARD) {
|
||||
int ret = SDL_EVDEV_init_keyboard(item, udev_class);
|
||||
if (ret < 0) {
|
||||
if (!SDL_EVDEV_init_keyboard(item, udev_class)) {
|
||||
close(item->fd);
|
||||
SDL_free(item->path);
|
||||
SDL_free(item);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,10 +964,11 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
|
||||
|
||||
SDL_EVDEV_UpdateKeyboardMute();
|
||||
|
||||
return _this->num_devices++;
|
||||
++_this->num_devices;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_device_removed(const char *dev_path)
|
||||
static bool SDL_EVDEV_device_removed(const char *dev_path)
|
||||
{
|
||||
SDL_evdevlist_item *item;
|
||||
SDL_evdevlist_item *prev = NULL;
|
||||
@@ -1001,12 +997,12 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
|
||||
SDL_free(item);
|
||||
SDL_EVDEV_UpdateKeyboardMute();
|
||||
_this->num_devices--;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
prev = item;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
struct input_event;
|
||||
|
||||
extern int SDL_EVDEV_Init(void);
|
||||
extern SDL_bool SDL_EVDEV_Init(void);
|
||||
extern void SDL_EVDEV_Quit(void);
|
||||
extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
||||
void (*acquire_callback)(void*), void *acquire_callback_data);
|
||||
|
||||
@@ -378,7 +378,7 @@ static void kbd_vt_quit(int console_fd)
|
||||
ioctl(console_fd, VT_SETMODE, &mode);
|
||||
}
|
||||
|
||||
static int kbd_vt_init(int console_fd)
|
||||
static bool kbd_vt_init(int console_fd)
|
||||
{
|
||||
struct vt_mode mode;
|
||||
|
||||
@@ -386,7 +386,7 @@ static int kbd_vt_init(int console_fd)
|
||||
vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action);
|
||||
if (!vt_release_signal || !vt_acquire_signal ) {
|
||||
kbd_vt_quit(console_fd);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_zero(mode);
|
||||
@@ -396,9 +396,9 @@ static int kbd_vt_init(int console_fd)
|
||||
mode.frsig = SIGIO;
|
||||
if (ioctl(console_fd, VT_SETMODE, &mode) < 0) {
|
||||
kbd_vt_quit(console_fd);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void kbd_vt_update(SDL_EVDEV_keyboard_state *state)
|
||||
@@ -618,7 +618,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
|
||||
static bool vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
|
||||
{
|
||||
return (kbd->ledflagstate & flag) != 0;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
|
||||
static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
|
||||
{
|
||||
const char *program = "program";
|
||||
bool retval = false;
|
||||
bool result = false;
|
||||
|
||||
if (dbus && dbus->session_conn) {
|
||||
DBusMessage *msg = dbus->message_new_method_call(FCITX_DBUS_SERVICE, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateInputContext");
|
||||
@@ -269,14 +269,14 @@ static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname,
|
||||
reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL);
|
||||
if (reply) {
|
||||
if (dbus->message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, ic_path, DBUS_TYPE_INVALID)) {
|
||||
retval = true;
|
||||
result = true;
|
||||
}
|
||||
dbus->message_unref(reply);
|
||||
}
|
||||
dbus->message_unref(msg);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool FcitxClientCreateIC(FcitxClient *client)
|
||||
|
||||
@@ -249,13 +249,13 @@ static bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
|
||||
#endif // threads
|
||||
|
||||
// this is a public symbol, so it has to exist even if threads are disabled.
|
||||
int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
SDL_bool SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
{
|
||||
#ifdef SDL_THREADS_DISABLED
|
||||
return SDL_Unsupported();
|
||||
#else
|
||||
if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SDL_USE_LIBDBUS
|
||||
@@ -272,7 +272,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
README and sample code at: http://git.0pointer.net/rtkit.git
|
||||
*/
|
||||
if (rtkit_setpriority_nice((pid_t)threadID, priority)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -281,7 +281,7 @@ int SDL_SetLinuxThreadPriority(Sint64 threadID, int priority)
|
||||
}
|
||||
|
||||
// this is a public symbol, so it has to exist even if threads are disabled.
|
||||
int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
SDL_bool SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy)
|
||||
{
|
||||
#ifdef SDL_THREADS_DISABLED
|
||||
return SDL_Unsupported();
|
||||
@@ -310,7 +310,7 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
|
||||
}
|
||||
|
||||
if (setpriority(PRIO_PROCESS, (id_t)threadID, osPriority) == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,11 +329,11 @@ int SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
|
||||
*/
|
||||
if (schedPolicy == SCHED_RR || schedPolicy == SCHED_FIFO) {
|
||||
if (rtkit_setpriority_realtime((pid_t)threadID, osPriority)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (rtkit_setpriority_nice((pid_t)threadID, osPriority)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
|
||||
static SDL_UDEV_PrivateData *_this = NULL;
|
||||
|
||||
static bool SDL_UDEV_load_sym(const char *fn, void **addr);
|
||||
static int SDL_UDEV_load_syms(void);
|
||||
static bool SDL_UDEV_load_syms(void);
|
||||
static bool SDL_UDEV_hotplug_update_available(void);
|
||||
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len);
|
||||
static int guess_device_class(struct udev_device *dev);
|
||||
@@ -59,12 +59,12 @@ static bool SDL_UDEV_load_sym(const char *fn, void **addr)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_UDEV_load_syms(void)
|
||||
static bool SDL_UDEV_load_syms(void)
|
||||
{
|
||||
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
|
||||
#define SDL_UDEV_SYM(x) \
|
||||
if (!SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x)) \
|
||||
return -1
|
||||
return false
|
||||
|
||||
SDL_UDEV_SYM(udev_device_get_action);
|
||||
SDL_UDEV_SYM(udev_device_get_devnode);
|
||||
@@ -95,7 +95,7 @@ static int SDL_UDEV_load_syms(void)
|
||||
SDL_UDEV_SYM(udev_device_get_devnum);
|
||||
#undef SDL_UDEV_SYM
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SDL_UDEV_hotplug_update_available(void)
|
||||
@@ -109,20 +109,17 @@ static bool SDL_UDEV_hotplug_update_available(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
int SDL_UDEV_Init(void)
|
||||
bool SDL_UDEV_Init(void)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (!_this) {
|
||||
_this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
|
||||
if (!_this) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
retval = SDL_UDEV_LoadLibrary();
|
||||
if (retval < 0) {
|
||||
if (!SDL_UDEV_LoadLibrary()) {
|
||||
SDL_UDEV_Quit();
|
||||
return retval;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Set up udev monitoring
|
||||
@@ -152,7 +149,7 @@ int SDL_UDEV_Init(void)
|
||||
|
||||
_this->ref_count += 1;
|
||||
|
||||
return retval;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_UDEV_Quit(void)
|
||||
@@ -187,14 +184,14 @@ void SDL_UDEV_Quit(void)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_UDEV_Scan(void)
|
||||
bool SDL_UDEV_Scan(void)
|
||||
{
|
||||
struct udev_enumerate *enumerate = NULL;
|
||||
struct udev_list_entry *devs = NULL;
|
||||
struct udev_list_entry *item = NULL;
|
||||
|
||||
if (!_this) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
enumerate = _this->syms.udev_enumerate_new(_this->udev);
|
||||
@@ -219,7 +216,7 @@ int SDL_UDEV_Scan(void)
|
||||
}
|
||||
|
||||
_this->syms.udev_enumerate_unref(enumerate);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
|
||||
@@ -291,17 +288,17 @@ void SDL_UDEV_UnloadLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_UDEV_LoadLibrary(void)
|
||||
bool SDL_UDEV_LoadLibrary(void)
|
||||
{
|
||||
int retval = 0, i;
|
||||
bool result = true;
|
||||
|
||||
if (!_this) {
|
||||
return SDL_SetError("UDEV not initialized");
|
||||
}
|
||||
|
||||
// See if there is a udev library already loaded
|
||||
if (SDL_UDEV_load_syms() == 0) {
|
||||
return 0;
|
||||
if (SDL_UDEV_load_syms()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SDL_UDEV_DYNAMIC
|
||||
@@ -309,8 +306,8 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
if (!_this->udev_handle) {
|
||||
_this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
|
||||
if (_this->udev_handle) {
|
||||
retval = SDL_UDEV_load_syms();
|
||||
if (retval < 0) {
|
||||
result = SDL_UDEV_load_syms();
|
||||
if (!result) {
|
||||
SDL_UDEV_UnloadLibrary();
|
||||
}
|
||||
}
|
||||
@@ -318,11 +315,11 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
#endif
|
||||
|
||||
if (!_this->udev_handle) {
|
||||
for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
|
||||
for (int i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
|
||||
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
|
||||
if (_this->udev_handle) {
|
||||
retval = SDL_UDEV_load_syms();
|
||||
if (retval < 0) {
|
||||
result = SDL_UDEV_load_syms();
|
||||
if (!result) {
|
||||
SDL_UDEV_UnloadLibrary();
|
||||
} else {
|
||||
break;
|
||||
@@ -331,12 +328,12 @@ int SDL_UDEV_LoadLibrary(void)
|
||||
}
|
||||
|
||||
if (!_this->udev_handle) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
// Don't call SDL_SetError(): SDL_LoadObject already did.
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len)
|
||||
@@ -529,12 +526,12 @@ void SDL_UDEV_Poll(void)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
{
|
||||
SDL_UDEV_CallbackList *item;
|
||||
item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList));
|
||||
if (!item) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
item->callback = cb;
|
||||
@@ -546,7 +543,7 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
|
||||
_this->last = item;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
@@ -579,7 +576,7 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
|
||||
|
||||
const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void)
|
||||
{
|
||||
if (SDL_UDEV_Init() < 0) {
|
||||
if (!SDL_UDEV_Init()) {
|
||||
SDL_SetError("Could not initialize UDEV");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@ typedef struct SDL_UDEV_PrivateData
|
||||
SDL_UDEV_Symbols syms;
|
||||
} SDL_UDEV_PrivateData;
|
||||
|
||||
extern int SDL_UDEV_Init(void);
|
||||
extern bool SDL_UDEV_Init(void);
|
||||
extern void SDL_UDEV_Quit(void);
|
||||
extern void SDL_UDEV_UnloadLibrary(void);
|
||||
extern int SDL_UDEV_LoadLibrary(void);
|
||||
extern bool SDL_UDEV_LoadLibrary(void);
|
||||
extern void SDL_UDEV_Poll(void);
|
||||
extern int SDL_UDEV_Scan(void);
|
||||
extern bool SDL_UDEV_Scan(void);
|
||||
extern bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);
|
||||
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
|
||||
extern bool SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
|
||||
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
|
||||
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
|
||||
extern void SDL_UDEV_ReleaseUdevSyms(void);
|
||||
|
||||
@@ -36,17 +36,17 @@ static HMODULE s_pHIDDLL = 0;
|
||||
static int s_HIDDLLRefCount = 0;
|
||||
|
||||
|
||||
int WIN_LoadHIDDLL(void)
|
||||
bool WIN_LoadHIDDLL(void)
|
||||
{
|
||||
if (s_pHIDDLL) {
|
||||
SDL_assert(s_HIDDLLRefCount > 0);
|
||||
s_HIDDLLRefCount++;
|
||||
return 0; // already loaded
|
||||
return true; // already loaded
|
||||
}
|
||||
|
||||
s_pHIDDLL = LoadLibrary(TEXT("hid.dll"));
|
||||
if (!s_pHIDDLL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_assert(s_HIDDLLRefCount == 0);
|
||||
@@ -63,10 +63,10 @@ int WIN_LoadHIDDLL(void)
|
||||
!SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
|
||||
!SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) {
|
||||
WIN_UnloadHIDDLL();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WIN_UnloadHIDDLL(void)
|
||||
|
||||
@@ -190,7 +190,7 @@ typedef struct
|
||||
#define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES(0xC, 0x0010)
|
||||
#define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES(0xC, 0x0020)
|
||||
|
||||
extern int WIN_LoadHIDDLL(void);
|
||||
extern bool WIN_LoadHIDDLL(void);
|
||||
extern void WIN_UnloadHIDDLL(void);
|
||||
|
||||
typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);
|
||||
|
||||
@@ -207,12 +207,12 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationCl
|
||||
{
|
||||
// client is a static object; we don't ever free it.
|
||||
SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient;
|
||||
const ULONG retval = SDL_AtomicDecRef(&client->refcount);
|
||||
if (retval == 0) {
|
||||
const ULONG rc = SDL_AtomicDecRef(&client->refcount);
|
||||
if (rc == 0) {
|
||||
SDL_AtomicSet(&client->refcount, 0); // uhh...
|
||||
return 0;
|
||||
}
|
||||
return retval - 1;
|
||||
return rc - 1;
|
||||
}
|
||||
|
||||
// These are the entry points called when WASAPI device endpoints change.
|
||||
@@ -288,7 +288,7 @@ static const IMMNotificationClientVtbl notification_client_vtbl = {
|
||||
|
||||
static SDLMMNotificationClient notification_client = { ¬ification_client_vtbl, { 1 } };
|
||||
|
||||
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
|
||||
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
|
||||
{
|
||||
HRESULT ret;
|
||||
|
||||
@@ -320,7 +320,7 @@ int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks)
|
||||
immcallbacks.default_audio_device_changed = SDL_DefaultAudioDeviceChanged;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_IMMDevice_Quit(void)
|
||||
@@ -336,7 +336,7 @@ void SDL_IMMDevice_Quit(void)
|
||||
WIN_CoUninitialize();
|
||||
}
|
||||
|
||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording)
|
||||
bool SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording)
|
||||
{
|
||||
const Uint64 timeout = SDL_GetTicks() + 8000; // intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep.
|
||||
|
||||
@@ -357,8 +357,10 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recor
|
||||
break;
|
||||
}
|
||||
|
||||
return SUCCEEDED(ret) ? 0 : WIN_SetErrorFromHRESULT("WASAPI can't find requested audio endpoint", ret);
|
||||
|
||||
if (!SUCCEEDED(ret)) {
|
||||
return WIN_SetErrorFromHRESULT("WASAPI can't find requested audio endpoint", ret);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device)
|
||||
|
||||
@@ -34,9 +34,9 @@ typedef struct SDL_IMMDevice_callbacks
|
||||
void (*default_audio_device_changed)(SDL_AudioDevice *new_default_device);
|
||||
} SDL_IMMDevice_callbacks;
|
||||
|
||||
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
|
||||
bool SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
|
||||
void SDL_IMMDevice_Quit(void);
|
||||
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
|
||||
bool SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, bool recording);
|
||||
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording);
|
||||
LPGUID SDL_IMMDevice_GetDirectSoundGUID(SDL_AudioDevice *device);
|
||||
LPCWSTR SDL_IMMDevice_GetDevID(SDL_AudioDevice *device);
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef enum RO_INIT_TYPE
|
||||
#endif
|
||||
|
||||
// Sets an error message based on an HRESULT
|
||||
int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
char *message;
|
||||
@@ -73,11 +73,11 @@ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
||||
message = WIN_StringToUTF8(buffer);
|
||||
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
||||
SDL_free(message);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sets an error message based on GetLastError()
|
||||
int WIN_SetError(const char *prefix)
|
||||
bool WIN_SetError(const char *prefix)
|
||||
{
|
||||
return WIN_SetErrorFromHRESULT(prefix, GetLastError());
|
||||
}
|
||||
@@ -207,12 +207,12 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
||||
#else
|
||||
#define CHECKWINVER(notdesktop_platform_result, test) \
|
||||
static bool checked = false; \
|
||||
static BOOL retval = FALSE; \
|
||||
static BOOL result = FALSE; \
|
||||
if (!checked) { \
|
||||
retval = (test); \
|
||||
result = (test); \
|
||||
checked = true; \
|
||||
} \
|
||||
return retval;
|
||||
return result;
|
||||
#endif
|
||||
|
||||
// this is the oldest thing we run on (and we may lose support for this in SDL3 at any time!),
|
||||
@@ -275,7 +275,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
bool rc;
|
||||
HKEY hkey;
|
||||
DWORD len = 0;
|
||||
char *retval = NULL;
|
||||
char *result = NULL;
|
||||
|
||||
if (WIN_IsEqualGUID(guid, &nullguid)) {
|
||||
return WIN_StringToUTF8(name); // No GUID, go with what we've got.
|
||||
@@ -315,9 +315,9 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
||||
|
||||
strw[len / 2] = 0; // make sure it's null-terminated.
|
||||
|
||||
retval = WIN_StringToUTF8(strw);
|
||||
result = WIN_StringToUTF8(strw);
|
||||
SDL_free(strw);
|
||||
return retval ? retval : WIN_StringToUTF8(name);
|
||||
return result ? result : WIN_StringToUTF8(name);
|
||||
#endif // if SDL_PLATFORM_WINRT / else
|
||||
}
|
||||
|
||||
|
||||
@@ -117,10 +117,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Sets an error message based on a given HRESULT
|
||||
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
|
||||
extern bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
|
||||
|
||||
// Sets an error message based on GetLastError(). Always return -1.
|
||||
extern int WIN_SetError(const char *prefix);
|
||||
extern bool WIN_SetError(const char *prefix);
|
||||
|
||||
#ifndef SDL_PLATFORM_WINRT
|
||||
// Load a function from combase.dll
|
||||
|
||||
@@ -39,7 +39,7 @@ static int s_XInputDLLRefCount = 0;
|
||||
|
||||
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||
|
||||
int WIN_LoadXInputDLL(void)
|
||||
bool WIN_LoadXInputDLL(void)
|
||||
{
|
||||
/* Getting handles to system dlls (via LoadLibrary and its variants) is not
|
||||
* supported on WinRT, thus, pointers to XInput's functions can't be
|
||||
@@ -61,7 +61,7 @@ int WIN_LoadXInputDLL(void)
|
||||
// XInput 1.4 ships with Windows 8 and 8.1:
|
||||
SDL_XInputVersion = (1 << 16) | 4;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WIN_UnloadXInputDLL(void)
|
||||
@@ -70,14 +70,14 @@ void WIN_UnloadXInputDLL(void)
|
||||
|
||||
#else // !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
|
||||
|
||||
int WIN_LoadXInputDLL(void)
|
||||
bool WIN_LoadXInputDLL(void)
|
||||
{
|
||||
DWORD version = 0;
|
||||
|
||||
if (s_pXInputDLL) {
|
||||
SDL_assert(s_XInputDLLRefCount > 0);
|
||||
s_XInputDLLRefCount++;
|
||||
return 0; // already loaded
|
||||
return true; // already loaded
|
||||
}
|
||||
|
||||
/* NOTE: Don't load XinputUap.dll
|
||||
@@ -98,7 +98,7 @@ int WIN_LoadXInputDLL(void)
|
||||
s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll"));
|
||||
}
|
||||
if (!s_pXInputDLL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_assert(s_XInputDLLRefCount == 0);
|
||||
@@ -117,10 +117,10 @@ int WIN_LoadXInputDLL(void)
|
||||
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation");
|
||||
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
|
||||
WIN_UnloadXInputDLL();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WIN_UnloadXInputDLL(void)
|
||||
|
||||
@@ -252,7 +252,7 @@ typedef DWORD(WINAPI *XInputGetBatteryInformation_t)(
|
||||
BYTE devType,
|
||||
XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation);
|
||||
|
||||
extern int WIN_LoadXInputDLL(void);
|
||||
extern bool WIN_LoadXInputDLL(void);
|
||||
extern void WIN_UnloadXInputDLL(void);
|
||||
|
||||
extern XInputGetState_t SDL_XInputGetState;
|
||||
|
||||
@@ -94,12 +94,12 @@ IFrameworkView ^ SDLApplicationSource::CreateView()
|
||||
return app;
|
||||
}
|
||||
|
||||
int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
|
||||
bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
|
||||
{
|
||||
WINRT_SDLAppEntryPoint = mainFunction;
|
||||
auto direct3DApplicationSource = ref new SDLApplicationSource();
|
||||
CoreApplication::Run(direct3DApplicationSource);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange()
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include <Windows.h>
|
||||
|
||||
extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
|
||||
extern bool SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
|
||||
|
||||
ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform:
|
||||
* SDL + XAML Initialization
|
||||
*/
|
||||
|
||||
int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable)
|
||||
bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable)
|
||||
{
|
||||
#if SDL_WINAPI_FAMILY_PHONE
|
||||
return SDL_SetError("XAML support is not yet available in Windows Phone.");
|
||||
@@ -133,14 +133,14 @@ int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPane
|
||||
// Make sure video modes are detected now, while we still have access to the WinRT
|
||||
// CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the
|
||||
// SDL/WinRT thread.
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
||||
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
|
||||
// SDL_InitSubSystem will, on error, set the SDL error. Let that propagate to
|
||||
// the caller to here:
|
||||
WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// All done, for now.
|
||||
return 0;
|
||||
return true;
|
||||
#endif // SDL_WINAPI_FAMILY_PHONE
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern bool WINRT_XAMLWasEnabled;
|
||||
extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable);
|
||||
extern bool SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable);
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif // SDL_winrtapp_xaml_h_
|
||||
|
||||
Reference in New Issue
Block a user