Use C99 bool internally in SDL

This commit is contained in:
Sam Lantinga
2024-08-22 09:21:26 -07:00
parent 6501e90018
commit 8f546bb3c9
450 changed files with 6046 additions and 6033 deletions

View File

@@ -162,7 +162,7 @@ void *SDL_GetAndroidJNIEnv(void)
return NULL;
}
typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, SDL_bool granted);
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)
{
@@ -201,21 +201,21 @@ SDL_DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
SDL_bool SDL_IsAndroidTV(void)
{
SDL_Unsupported();
return SDL_FALSE;
return false;
}
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
SDL_bool SDL_IsChromebook(void)
{
SDL_Unsupported();
return SDL_FALSE;
return false;
}
SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
SDL_bool SDL_IsDeXMode(void)
{
SDL_Unsupported();
return SDL_FALSE;
return false;
}
SDL_DECLSPEC Sint32 SDLCALL JNI_OnLoad(void *vm, void *reserved);

View File

@@ -388,9 +388,9 @@ static jmethodID midHapticStop;
static SDL_DisplayOrientation displayNaturalOrientation;
static SDL_DisplayOrientation displayCurrentOrientation;
static float fLastAccelerometer[3];
static SDL_bool bHasNewData;
static bool bHasNewData;
static SDL_bool bHasEnvironmentVariables;
static bool bHasEnvironmentVariables;
// Android AssetManager
static void Internal_Android_Create_AssetManager(void);
@@ -557,7 +557,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
register_methods(env, "org/libsdl/app/SDLAudioManager", SDLAudioManager_tab, SDL_arraysize(SDLAudioManager_tab));
register_methods(env, "org/libsdl/app/SDLControllerManager", SDLControllerManager_tab, SDL_arraysize(SDLControllerManager_tab));
register_methods(env, "org/libsdl/app/HIDDeviceManager", HIDDeviceManager_tab, SDL_arraysize(HIDDeviceManager_tab));
SDL_AtomicSet(&bAllowRecreateActivity, SDL_FALSE);
SDL_AtomicSet(&bAllowRecreateActivity, false);
return JNI_VERSION_1_4;
}
@@ -759,10 +759,10 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeCheckSDLThreadCounter)(
static void SDLCALL SDL_AllowRecreateActivityChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
if (SDL_GetStringBoolean(hint, SDL_FALSE)) {
SDL_AtomicSet(&bAllowRecreateActivity, SDL_TRUE);
if (SDL_GetStringBoolean(hint, false)) {
SDL_AtomicSet(&bAllowRecreateActivity, true);
} else {
SDL_AtomicSet(&bAllowRecreateActivity, SDL_FALSE);
SDL_AtomicSet(&bAllowRecreateActivity, false);
}
}
@@ -824,7 +824,7 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls,
int argc;
int len;
char **argv;
SDL_bool isstack;
bool isstack;
// Prepare the arguments.
len = (*env)->GetArrayLength(env, array);
@@ -902,14 +902,14 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
SDL_LockMutex(Android_LifecycleMutex);
{
int index;
SDL_bool add_event = SDL_TRUE;
bool add_event = true;
switch (event) {
case SDL_ANDROID_LIFECYCLE_WAKE:
// We don't need more than one wake queued
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_WAKE);
if (index >= 0) {
add_event = SDL_FALSE;
add_event = false;
}
break;
case SDL_ANDROID_LIFECYCLE_PAUSE:
@@ -917,7 +917,7 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_RESUME);
if (index >= 0) {
RemoveLifecycleEvent(index);
add_event = SDL_FALSE;
add_event = false;
}
break;
case SDL_ANDROID_LIFECYCLE_RESUME:
@@ -925,14 +925,14 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_PAUSE);
if (index >= 0) {
RemoveLifecycleEvent(index);
add_event = SDL_FALSE;
add_event = false;
}
break;
case SDL_ANDROID_LIFECYCLE_LOWMEMORY:
// We don't need more than one low memory event queued
index = FindLifecycleEvent(SDL_ANDROID_LIFECYCLE_LOWMEMORY);
if (index >= 0) {
add_event = SDL_FALSE;
add_event = false;
}
break;
case SDL_ANDROID_LIFECYCLE_DESTROY:
@@ -943,7 +943,7 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
break;
default:
SDL_assert(!"Sending unexpected lifecycle event");
add_event = SDL_FALSE;
add_event = false;
break;
}
@@ -956,9 +956,9 @@ void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event)
SDL_UnlockMutex(Android_LifecycleMutex);
}
SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS)
bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS)
{
SDL_bool got_event = SDL_FALSE;
bool got_event = false;
while (!got_event && SDL_WaitSemaphoreTimeoutNS(Android_LifecycleEventSem, timeoutNS) == 0) {
SDL_LockMutex(Android_LifecycleMutex);
@@ -966,7 +966,7 @@ SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 tim
if (Android_NumLifecycleEvents > 0) {
*event = Android_LifecycleEvents[0];
RemoveLifecycleEvent(0);
got_event = SDL_TRUE;
got_event = true;
}
}
SDL_UnlockMutex(Android_LifecycleMutex);
@@ -1333,7 +1333,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
JNIEnv *env, jclass jcls)
{
if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) {
SDL_StopTextInput(Android_Window);
return JNI_TRUE;
}
@@ -1381,7 +1381,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
fLastAccelerometer[0] = x;
fLastAccelerometer[1] = y;
fLastAccelerometer[2] = z;
bHasNewData = SDL_TRUE;
bHasNewData = true;
}
// Clipboard
@@ -1563,16 +1563,16 @@ static struct LocalReferenceHolder LocalReferenceHolder_Setup(const char *func)
return refholder;
}
static SDL_bool LocalReferenceHolder_Init(struct LocalReferenceHolder *refholder, JNIEnv *env)
static bool LocalReferenceHolder_Init(struct LocalReferenceHolder *refholder, JNIEnv *env)
{
const int capacity = 16;
if ((*env)->PushLocalFrame(env, capacity) < 0) {
SDL_SetError("Failed to allocate enough JVM local references");
return SDL_FALSE;
return false;
}
SDL_AtomicIncRef(&s_active);
refholder->m_env = env;
return SDL_TRUE;
return true;
}
static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
@@ -1611,7 +1611,7 @@ void Android_JNI_SetActivityTitle(const char *title)
(*env)->DeleteLocalRef(env, jtitle);
}
void Android_JNI_SetWindowStyle(SDL_bool fullscreen)
void Android_JNI_SetWindowStyle(bool fullscreen)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
@@ -1642,23 +1642,23 @@ void Android_JNI_MinizeWindow(void)
(*env)->CallStaticVoidMethod(env, mActivityClass, midMinimizeWindow);
}
SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
bool Android_JNI_ShouldMinimizeOnFocusLoss(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midShouldMinimizeOnFocusLoss);
}
SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
bool Android_JNI_GetAccelerometerValues(float values[3])
{
SDL_bool retval = SDL_FALSE;
bool retval = false;
if (bHasNewData) {
int i;
for (i = 0; i < 3; ++i) {
values[i] = fLastAccelerometer[i];
}
bHasNewData = SDL_FALSE;
retval = SDL_TRUE;
bHasNewData = false;
retval = true;
}
return retval;
@@ -1694,7 +1694,7 @@ void Android_AudioThreadInit(SDL_AudioDevice *device)
// Test for an exception and call SDL_SetError with its detail if one occurs
// If the parameter silent is truthy then SDL_SetError() will not be called.
static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
static bool Android_JNI_ExceptionOccurred(bool silent)
{
JNIEnv *env = Android_JNI_GetEnv();
jthrowable exception;
@@ -1734,10 +1734,10 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
(*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
}
return SDL_TRUE;
return true;
}
return SDL_FALSE;
return false;
}
static void Internal_Android_Create_AssetManager(void)
@@ -1773,7 +1773,7 @@ static void Internal_Android_Create_AssetManager(void)
if (!asset_manager) {
(*env)->DeleteGlobalRef(env, javaAssetManagerRef);
Android_JNI_ExceptionOccurred(SDL_TRUE);
Android_JNI_ExceptionOccurred(true);
}
LocalReferenceHolder_Cleanup(&refs);
@@ -1872,7 +1872,7 @@ char *Android_JNI_GetClipboardText(void)
return (!text) ? SDL_strdup("") : text;
}
SDL_bool Android_JNI_HasClipboardText(void)
bool Android_JNI_HasClipboardText(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
@@ -2055,9 +2055,9 @@ int Android_JNI_SendMessage(int command, int param)
return success ? 0 : -1;
}
int Android_JNI_SuspendScreenSaver(SDL_bool suspend)
int Android_JNI_SuspendScreenSaver(bool suspend)
{
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
return Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == false) ? 0 : 1);
}
void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect)
@@ -2078,7 +2078,7 @@ void Android_JNI_HideScreenKeyboard(void)
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
}
SDL_bool Android_JNI_IsScreenKeyboardShown(void)
bool Android_JNI_IsScreenKeyboardShown(void)
{
JNIEnv *env = Android_JNI_GetEnv();
jboolean is_shown = 0;
@@ -2216,7 +2216,7 @@ int SDL_GetAndroidSDKVersion(void)
return sdk_version;
}
SDL_bool SDL_IsAndroidTablet(void)
bool SDL_IsAndroidTablet(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet);
@@ -2286,7 +2286,7 @@ const char *SDL_GetAndroidInternalStoragePath(void)
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
"getCanonicalPath", "()Ljava/lang/String;");
pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
if (Android_JNI_ExceptionOccurred(false)) {
LocalReferenceHolder_Cleanup(&refs);
return NULL;
}
@@ -2445,9 +2445,9 @@ void Android_JNI_GetManifestEnvironmentVariables(void)
if (!bHasEnvironmentVariables) {
JNIEnv *env = Android_JNI_GetEnv();
SDL_bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables);
bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables);
if (ret) {
bHasEnvironmentVariables = SDL_TRUE;
bHasEnvironmentVariables = true;
}
}
}
@@ -2474,25 +2474,25 @@ void Android_JNI_DestroyCustomCursor(int cursorID)
(*env)->CallStaticVoidMethod(env, mActivityClass, midDestroyCustomCursor, cursorID);
}
SDL_bool Android_JNI_SetCustomCursor(int cursorID)
bool Android_JNI_SetCustomCursor(int cursorID)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetCustomCursor, cursorID);
}
SDL_bool Android_JNI_SetSystemCursor(int cursorID)
bool Android_JNI_SetSystemCursor(int cursorID)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
}
SDL_bool Android_JNI_SupportsRelativeMouse(void)
bool Android_JNI_SupportsRelativeMouse(void)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
}
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
bool Android_JNI_SetRelativeMouseEnabled(bool enabled)
{
JNIEnv *env = Android_JNI_GetEnv();
return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
@@ -2519,7 +2519,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePermissionResult)(
if (info->request_code == (int) requestCode) {
prev->next = info->next;
SDL_UnlockMutex(Android_ActivityMutex);
info->callback(info->userdata, info->permission, result ? SDL_TRUE : SDL_FALSE);
info->callback(info->userdata, info->permission, result ? true : false);
SDL_free(info->permission);
SDL_free(info);
return;
@@ -2776,18 +2776,18 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
}
}
SDL_bool Android_JNI_OpenFileDialog(
bool Android_JNI_OpenFileDialog(
SDL_DialogFileCallback callback, void* userdata,
const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite,
SDL_bool multiple)
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
bool multiple)
{
if (mAndroidFileDialogData.callback != NULL) {
SDL_SetError("Only one file dialog can be run at a time.");
return SDL_FALSE;
return false;
}
if (forwrite) {
multiple = SDL_FALSE;
multiple = false;
}
JNIEnv *env = Android_JNI_GetEnv();
@@ -2821,10 +2821,10 @@ SDL_bool Android_JNI_OpenFileDialog(
SDL_AtomicAdd(&next_request_code, -1);
SDL_SetError("Unspecified error in JNI");
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
#endif // SDL_PLATFORM_ANDROID

View File

@@ -50,22 +50,22 @@ typedef enum
} SDL_AndroidLifecycleEvent;
void Android_SendLifecycleEvent(SDL_AndroidLifecycleEvent event);
SDL_bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS);
bool Android_WaitLifecycleEvent(SDL_AndroidLifecycleEvent *event, Sint64 timeoutNS);
void Android_LockActivityMutex(void);
void Android_UnlockActivityMutex(void);
// Interface from the SDL library into the Android Java activity
extern void Android_JNI_SetActivityTitle(const char *title);
extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen);
extern void Android_JNI_SetWindowStyle(bool fullscreen);
extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint);
extern void Android_JNI_MinizeWindow(void);
extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
extern bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
extern bool Android_JNI_GetAccelerometerValues(float values[3]);
extern void Android_JNI_ShowScreenKeyboard(int input_type, SDL_Rect *inputRect);
extern void Android_JNI_HideScreenKeyboard(void);
extern SDL_bool Android_JNI_IsScreenKeyboardShown(void);
extern bool Android_JNI_IsScreenKeyboardShown(void);
extern ANativeWindow *Android_JNI_GetNativeWindow(void);
extern SDL_DisplayOrientation Android_JNI_GetDisplayNaturalOrientation(void);
@@ -77,8 +77,8 @@ void Android_StopAudioHotplug(void);
extern void Android_AudioThreadInit(SDL_AudioDevice *device);
// Detecting device type
extern SDL_bool Android_IsDeXMode(void);
extern SDL_bool Android_IsChromebook(void);
extern bool Android_IsDeXMode(void);
extern bool Android_IsChromebook(void);
int Android_JNI_FileOpen(void **puserdata, const char *fileName, const char *mode);
Sint64 Android_JNI_FileSize(void *userdata);
@@ -94,7 +94,7 @@ int Android_JNI_OpenFileDescriptor(const char *uri, const char *mode);
// Clipboard support
int Android_JNI_SetClipboardText(const char *text);
char *Android_JNI_GetClipboardText(void);
SDL_bool Android_JNI_HasClipboardText(void);
bool Android_JNI_HasClipboardText(void);
// Power support
int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent);
@@ -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(SDL_bool suspend);
int Android_JNI_SuspendScreenSaver(bool suspend);
// Touch support
void Android_JNI_InitTouch(void);
@@ -131,12 +131,12 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
// Cursor support
int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y);
void Android_JNI_DestroyCustomCursor(int cursorID);
SDL_bool Android_JNI_SetCustomCursor(int cursorID);
SDL_bool Android_JNI_SetSystemCursor(int cursorID);
bool Android_JNI_SetCustomCursor(int cursorID);
bool Android_JNI_SetSystemCursor(int cursorID);
// Relative mouse support
SDL_bool Android_JNI_SupportsRelativeMouse(void);
SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled);
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);
@@ -145,15 +145,12 @@ int Android_JNI_OpenURL(const char *url);
int SDL_GetAndroidSDKVersion(void);
SDL_bool SDL_IsAndroidTablet(void);
SDL_bool SDL_IsAndroidTV(void);
SDL_bool SDL_IsChromebook(void);
SDL_bool SDL_IsDeXMode(void);
bool SDL_IsAndroidTablet(void);
// File Dialogs
SDL_bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
const SDL_DialogFileFilter *filters, int nfilters, SDL_bool forwrite,
SDL_bool multiple);
bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
bool multiple);
// Ends C function definitions when using C++
#ifdef __cplusplus

View File

@@ -53,11 +53,11 @@ struct SDL_EVDEV_keyboard_state
keymap_t *key_map;
keyboard_info_t *kbInfo;
unsigned char shift_down[4]; // shift state counters..
SDL_bool dead_key_next;
bool dead_key_next;
int npadch; // -1 or number assembled on pad
accentmap_t *accents;
unsigned int diacr;
SDL_bool rep; // flag telling character repeat
bool rep; // flag telling character repeat
unsigned char lockstate;
unsigned char ledflagstate;
char shift_state;
@@ -265,7 +265,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
kbd->key_map = &keymap_default_us_acc;
}
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
/* Take keyboard from console and open the actual keyboard device.
* Ensures that the keystrokes do not leak through to the console.
*/
@@ -281,7 +281,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
/* Make sure to restore keyboard if application fails to call
* SDL_Quit before exit or fatal signal is raised.
*/
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
kbd_register_emerg_cleanup(kbd);
}
SDL_free(devicePath);
@@ -320,7 +320,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
SDL_free(kbd);
}
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
{
}
@@ -434,7 +434,7 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_fl
}
if (kbd->dead_key_next) {
kbd->dead_key_next = SDL_FALSE;
kbd->dead_key_next = false;
kbd->diacr = value;
return;
}

View File

@@ -254,7 +254,7 @@ class SDL_BLooper : public BLooper
if (!be_app->IsCursorHidden())
be_app->HideCursor();
} else {
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, (float)x, (float)y);
SDL_SendMouseMotion(0, win, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y);
if (SDL_CursorVisible() && be_app->IsCursorHidden())
be_app->ShowCursor();
}

View File

@@ -128,7 +128,7 @@ static SDL_SpinLock spinlock_dbus_init = 0;
// you must hold spinlock_dbus_init before calling this!
static void SDL_DBus_Init_Spinlocked(void)
{
static SDL_bool is_dbus_available = SDL_TRUE;
static bool is_dbus_available = true;
if (!is_dbus_available) {
return; // don't keep trying if this fails.
}
@@ -137,12 +137,12 @@ static void SDL_DBus_Init_Spinlocked(void)
DBusError err;
if (LoadDBUSLibrary() == -1) {
is_dbus_available = SDL_FALSE; // can't load at all? Don't keep trying.
is_dbus_available = false; // can't load at all? Don't keep trying.
return;
}
if (!dbus.threads_init_default()) {
is_dbus_available = SDL_FALSE;
is_dbus_available = false;
return;
}
@@ -153,7 +153,7 @@ static void SDL_DBus_Init_Spinlocked(void)
if (dbus.error_is_set(&err)) {
dbus.error_free(&err);
SDL_DBus_Quit();
is_dbus_available = SDL_FALSE;
is_dbus_available = false;
return; // oh well
}
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
@@ -186,7 +186,7 @@ void SDL_DBus_Quit(void)
dbus.connection_unref(dbus.session_conn);
}
if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, SDL_FALSE)) {
if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, false)) {
if (dbus.shutdown) {
dbus.shutdown();
}
@@ -207,9 +207,9 @@ SDL_DBusContext *SDL_DBus_GetContext(void)
return (dbus_handle && dbus.session_conn) ? &dbus : NULL;
}
static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
static bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
{
SDL_bool retval = SDL_FALSE;
bool retval = false;
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
@@ -237,7 +237,7 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no
}
firstarg = va_arg(ap_reply, int);
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
retval = SDL_TRUE;
retval = true;
}
dbus.message_unref(reply);
}
@@ -250,9 +250,9 @@ static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *no
return retval;
}
SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
{
SDL_bool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap);
@@ -260,9 +260,9 @@ SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node,
return retval;
}
SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...)
{
SDL_bool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap);
@@ -270,9 +270,9 @@ SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *int
return retval;
}
static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
static bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap)
{
SDL_bool retval = SDL_FALSE;
bool retval = false;
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
@@ -281,7 +281,7 @@ static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char
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 = SDL_TRUE;
retval = true;
}
}
@@ -292,9 +292,9 @@ static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char
return retval;
}
static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
static bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *msg, const int expectedtype, void *result)
{
SDL_bool retval = SDL_FALSE;
bool retval = false;
DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL);
if (reply) {
@@ -308,7 +308,7 @@ static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *m
if (dbus.message_iter_get_arg_type(&actual_iter) == expectedtype) {
dbus.message_iter_get_basic(&actual_iter, result);
retval = SDL_TRUE;
retval = true;
}
dbus.message_unref(reply);
@@ -317,9 +317,9 @@ static SDL_bool SDL_DBus_CallWithBasicReply(DBusConnection *conn, DBusMessage *m
return retval;
}
SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...)
{
SDL_bool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap);
@@ -327,9 +327,9 @@ SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *n
return retval;
}
SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...)
{
SDL_bool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap);
@@ -337,9 +337,9 @@ SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char
return retval;
}
SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
{
SDL_bool retval = SDL_FALSE;
bool retval = false;
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, "org.freedesktop.DBus.Properties", "Get");
@@ -354,7 +354,7 @@ SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *no
return retval;
}
SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result)
{
return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result);
}
@@ -368,7 +368,7 @@ void SDL_DBus_ScreensaverTickle(void)
}
}
static SDL_bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit, const char **keys, const char **values, int count)
static bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit, const char **keys, const char **values, int count)
{
DBusMessageIter iterDict;
@@ -406,16 +406,16 @@ static SDL_bool SDL_DBus_AppendDictWithKeysAndValues(DBusMessageIter *iterInit,
goto failed;
}
return SDL_TRUE;
return true;
failed:
/* message_iter_abandon_container_if_open() and message_iter_abandon_container() might be
* missing if libdbus is too old. Instead, we just return without cleaning up any eventual
* open container */
return SDL_FALSE;
return false;
}
static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value)
static bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const char *key, const char *value)
{
const char *keys[1];
const char *values[1];
@@ -425,18 +425,18 @@ static SDL_bool SDL_DBus_AppendDictWithKeyValue(DBusMessageIter *iterInit, const
return SDL_DBus_AppendDictWithKeysAndValues(iterInit, keys, values, 1);
}
SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
bool SDL_DBus_ScreensaverInhibit(bool inhibit)
{
const char *default_inhibit_reason = "Playing a game";
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) {
return SDL_TRUE;
return true;
}
if (!dbus.session_conn) {
/* We either lost connection to the session bus or were not able to
* load the D-Bus library at all. */
return SDL_FALSE;
return false;
}
if (SDL_DetectSandbox() != SDL_SANDBOX_NONE) {
@@ -449,7 +449,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
if (inhibit) {
DBusMessage *msg;
SDL_bool retval = SDL_FALSE;
bool retval = false;
const char *key = "reason";
const char *reply = NULL;
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
@@ -459,12 +459,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit");
if (!msg) {
return SDL_FALSE;
return false;
}
if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &window, DBUS_TYPE_UINT32, &INHIBIT_IDLE, DBUS_TYPE_INVALID)) {
dbus.message_unref(msg);
return SDL_FALSE;
return false;
}
dbus.message_iter_init_append(msg, &iterInit);
@@ -472,19 +472,19 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
// a{sv}
if (!SDL_DBus_AppendDictWithKeyValue(&iterInit, key, reason)) {
dbus.message_unref(msg);
return SDL_FALSE;
return false;
}
if (SDL_DBus_CallWithBasicReply(dbus.session_conn, msg, DBUS_TYPE_OBJECT_PATH, &reply)) {
inhibit_handle = SDL_strdup(reply);
retval = SDL_TRUE;
retval = true;
}
dbus.message_unref(msg);
return retval;
} else {
if (!SDL_DBus_CallVoidMethod(bus_name, inhibit_handle, "org.freedesktop.portal.Request", "Close", DBUS_TYPE_INVALID)) {
return SDL_FALSE;
return false;
}
SDL_free(inhibit_handle);
inhibit_handle = NULL;
@@ -504,18 +504,18 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
if (!SDL_DBus_CallMethod(bus_name, path, interface, "Inhibit",
DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID,
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
return SDL_FALSE;
return false;
}
return (screensaver_cookie != 0);
} else {
if (!SDL_DBus_CallVoidMethod(bus_name, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
return SDL_FALSE;
return false;
}
screensaver_cookie = 0;
}
}
return SDL_TRUE;
return true;
}
void SDL_DBus_PumpEvents(void)

View File

@@ -92,17 +92,17 @@ extern void SDL_DBus_Quit(void);
extern SDL_DBusContext *SDL_DBus_GetContext(void);
// These use the built-in Session connection.
extern SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
extern SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
extern SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
extern bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...);
extern bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...);
extern bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
// These use whatever connection you like.
extern SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
extern SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
extern bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
extern bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
extern bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result);
extern void SDL_DBus_ScreensaverTickle(void);
extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit);
extern bool SDL_DBus_ScreensaverInhibit(bool inhibit);
extern void SDL_DBus_PumpEvents(void);
extern char *SDL_DBus_GetLocalMachineId(void);

View File

@@ -76,12 +76,12 @@ typedef struct SDL_evdevlist_item
int udev_class;
// TODO: use this for every device, not just touchscreen
SDL_bool out_of_sync;
bool out_of_sync;
/* TODO: expand on this to have data for every possible class (mouse,
keyboard, touchpad, etc.). Also there's probably some things in here we
can pull out to the SDL_evdevlist_item i.e. name */
SDL_bool is_touchscreen;
bool is_touchscreen;
struct
{
char *name;
@@ -108,9 +108,9 @@ typedef struct SDL_evdevlist_item
} *touchscreen_data;
// Mouse state
SDL_bool high_res_wheel;
SDL_bool high_res_hwheel;
SDL_bool relative_mouse;
bool high_res_wheel;
bool high_res_hwheel;
bool relative_mouse;
int mouse_x, mouse_y;
int mouse_wheel, mouse_hwheel;
int min_x, max_x, range_x;
@@ -150,7 +150,7 @@ static Uint8 EVDEV_MouseButtons[] = {
SDL_BUTTON_X2 + 3 // BTN_TASK 0x117
};
static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
static int SDL_EVDEV_SetRelativeMouseMode(bool enabled)
{
// Mice already send relative events through this interface
return 0;
@@ -159,9 +159,9 @@ static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
static void SDL_EVDEV_UpdateKeyboardMute(void)
{
if (SDL_EVDEV_GetDeviceCount(SDL_UDEV_DEVICE_KEYBOARD) > 0) {
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_TRUE);
SDL_EVDEV_kbd_set_muted(_this->kbd, true);
} else {
SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_FALSE);
SDL_EVDEV_kbd_set_muted(_this->kbd, false);
}
}
@@ -544,11 +544,11 @@ void SDL_EVDEV_Poll(void)
* be window-relative in that case. */
switch (item->touchscreen_data->slots[j].delta) {
case EVDEV_TOUCH_SLOTDELTA_DOWN:
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_TRUE, norm_x, norm_y, norm_pressure);
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, true, norm_x, norm_y, norm_pressure);
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
break;
case EVDEV_TOUCH_SLOTDELTA_UP:
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_FALSE, norm_x, norm_y, norm_pressure);
SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, false, norm_x, norm_y, norm_pressure);
item->touchscreen_data->slots[j].tracking_id = 0;
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
break;
@@ -562,12 +562,12 @@ void SDL_EVDEV_Poll(void)
}
if (item->out_of_sync) {
item->out_of_sync = SDL_FALSE;
item->out_of_sync = false;
}
break;
case SYN_DROPPED:
if (item->is_touchscreen) {
item->out_of_sync = SDL_TRUE;
item->out_of_sync = true;
}
SDL_EVDEV_sync_device(item);
break;
@@ -610,14 +610,14 @@ static int SDL_EVDEV_init_keyboard(SDL_evdevlist_item *item, int udev_class)
name[0] = '\0';
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, SDL_TRUE);
SDL_AddKeyboard((SDL_KeyboardID)item->fd, name, true);
return 0;
}
static void SDL_EVDEV_destroy_keyboard(SDL_evdevlist_item *item)
{
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, SDL_TRUE);
SDL_RemoveKeyboard((SDL_KeyboardID)item->fd, true);
}
static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
@@ -629,7 +629,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
name[0] = '\0';
ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
SDL_AddMouse((SDL_MouseID)item->fd, name, SDL_TRUE);
SDL_AddMouse((SDL_MouseID)item->fd, name, true);
ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info);
if (ret < 0) {
@@ -654,7 +654,7 @@ static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class)
static void SDL_EVDEV_destroy_mouse(SDL_evdevlist_item *item)
{
SDL_RemoveMouse((SDL_MouseID)item->fd, SDL_TRUE);
SDL_RemoveMouse((SDL_MouseID)item->fd, true);
}
static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
@@ -932,7 +932,7 @@ 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 = SDL_TRUE;
item->is_touchscreen = true;
ret = SDL_EVDEV_init_touchscreen(item, udev_class);
if (ret < 0) {
close(item->fd);

View File

@@ -84,15 +84,15 @@ static fn_handler_fn *fn_handler[] = {
struct SDL_EVDEV_keyboard_state
{
int console_fd;
SDL_bool muted;
bool muted;
int old_kbd_mode;
unsigned short **key_maps;
unsigned char shift_down[NR_SHIFT]; // shift state counters..
SDL_bool dead_key_next;
bool dead_key_next;
int npadch; // -1 or number assembled on pad
struct kbdiacrs *accents;
unsigned int diacr;
SDL_bool rep; // flag telling character repeat
bool rep; // flag telling character repeat
unsigned char lockstate;
unsigned char slockstate;
unsigned char ledflagstate;
@@ -321,7 +321,7 @@ static void kbd_vt_acquire_signal_action(int signum)
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
}
static SDL_bool setup_vt_signal(int signum, signal_handler handler)
static bool setup_vt_signal(int signum, signal_handler handler)
{
struct sigaction *old_action_p;
struct sigaction new_action;
@@ -330,14 +330,14 @@ static SDL_bool setup_vt_signal(int signum, signal_handler handler)
new_action.sa_handler = handler;
new_action.sa_flags = SA_RESTART;
if (sigaction(signum, &new_action, old_action_p) < 0) {
return SDL_FALSE;
return false;
}
if (old_action_p->sa_handler != SIG_DFL) {
// This signal is already in use
sigaction(signum, old_action_p, NULL);
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static int find_free_signal(signal_handler handler)
@@ -462,7 +462,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
return kbd;
}
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
{
if (!state) {
return;
@@ -473,7 +473,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
}
if (muted) {
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, SDL_TRUE)) {
if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
/* Mute the keyboard so keystrokes only generate evdev events
* and do not leak through to the console
*/
@@ -482,7 +482,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
/* Make sure to restore keyboard if application fails to call
* SDL_Quit before exit or fatal signal is raised.
*/
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
kbd_register_emerg_cleanup(state);
}
}
@@ -522,7 +522,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
return;
}
SDL_EVDEV_kbd_set_muted(state, SDL_FALSE);
SDL_EVDEV_kbd_set_muted(state, false);
kbd_vt_quit(state->console_fd);
@@ -690,7 +690,7 @@ static void fn_num(SDL_EVDEV_keyboard_state *kbd)
static void fn_compose(SDL_EVDEV_keyboard_state *kbd)
{
kbd->dead_key_next = SDL_TRUE;
kbd->dead_key_next = true;
}
/*
@@ -729,7 +729,7 @@ static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_f
}
if (kbd->dead_key_next) {
kbd->dead_key_next = SDL_FALSE;
kbd->dead_key_next = false;
kbd->diacr = value;
return;
}
@@ -974,7 +974,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
return NULL;
}
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
{
}

View File

@@ -26,7 +26,7 @@ struct SDL_EVDEV_keyboard_state;
typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted);
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted);
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data);
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);

View File

@@ -249,10 +249,10 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID);
}
static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname, char **ic_path)
{
const char *program = "program";
SDL_bool retval = SDL_FALSE;
bool retval = 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,7 +269,7 @@ static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appna
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 = SDL_TRUE;
retval = true;
}
dbus->message_unref(reply);
}
@@ -279,7 +279,7 @@ static SDL_bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appna
return retval;
}
static SDL_bool FcitxClientCreateIC(FcitxClient *client)
static bool FcitxClientCreateIC(FcitxClient *client)
{
char *appname = GetAppName();
char *ic_path = NULL;
@@ -305,10 +305,10 @@ static SDL_bool FcitxClientCreateIC(FcitxClient *client)
dbus->connection_flush(dbus->session_conn);
SDL_AddHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, Fcitx_SetCapabilities, client);
return SDL_TRUE;
return true;
}
return SDL_FALSE;
return false;
}
static Uint32 Fcitx_ModState(void)
@@ -344,7 +344,7 @@ static Uint32 Fcitx_ModState(void)
return fcitx_mods;
}
SDL_bool SDL_Fcitx_Init(void)
bool SDL_Fcitx_Init(void)
{
fcitx_client.dbus = SDL_DBus_GetContext();
@@ -365,7 +365,7 @@ void SDL_Fcitx_Quit(void)
}
}
void SDL_Fcitx_SetFocus(SDL_bool focused)
void SDL_Fcitx_SetFocus(bool focused)
{
if (focused) {
FcitxClientICCallMethod(&fcitx_client, "FocusIn");
@@ -379,15 +379,15 @@ void SDL_Fcitx_Reset(void)
FcitxClientICCallMethod(&fcitx_client, "Reset");
}
SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
Uint32 mod_state = Fcitx_ModState();
Uint32 handled = SDL_FALSE;
Uint32 handled = false;
Uint32 is_release = (state == SDL_RELEASED);
Uint32 event_time = 0;
if (!fcitx_client.ic_path) {
return SDL_FALSE;
return false;
}
if (SDL_DBus_CallMethod(FCITX_DBUS_SERVICE, fcitx_client.ic_path, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent",
@@ -395,11 +395,11 @@ SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID)) {
if (handled) {
SDL_Fcitx_UpdateTextInputArea(SDL_GetKeyboardFocus());
return SDL_TRUE;
return true;
}
}
return SDL_FALSE;
return false;
}
void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window)

View File

@@ -24,11 +24,11 @@
#include "SDL_internal.h"
extern SDL_bool SDL_Fcitx_Init(void);
extern bool SDL_Fcitx_Init(void);
extern void SDL_Fcitx_Quit(void);
extern void SDL_Fcitx_SetFocus(SDL_bool focused);
extern void SDL_Fcitx_SetFocus(bool focused);
extern void SDL_Fcitx_Reset(void);
extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window);
extern void SDL_Fcitx_PumpEvents(void);

View File

@@ -53,7 +53,7 @@ static const char *ibus_input_interface = NULL;
static char *input_ctx_path = NULL;
static SDL_Rect ibus_cursor_rect = { 0, 0, 0, 0 };
static DBusConnection *ibus_conn = NULL;
static SDL_bool ibus_is_portal_interface = SDL_FALSE;
static bool ibus_is_portal_interface = false;
static char *ibus_addr_file = NULL;
static int inotify_fd = -1, inotify_wd = -1;
@@ -91,40 +91,40 @@ static Uint32 IBus_ModState(void)
return ibus_mods;
}
static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
static bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
DBusMessageIter *inside, const char *struct_id, size_t id_size)
{
DBusMessageIter sub;
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) {
return SDL_FALSE;
return false;
}
dbus->message_iter_recurse(iter, &sub);
if (dbus->message_iter_get_arg_type(&sub) != DBUS_TYPE_STRUCT) {
return SDL_FALSE;
return false;
}
dbus->message_iter_recurse(&sub, inside);
if (dbus->message_iter_get_arg_type(inside) != DBUS_TYPE_STRING) {
return SDL_FALSE;
return false;
}
dbus->message_iter_get_basic(inside, &struct_id);
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
static bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
Uint32 *start_pos, Uint32 *end_pos)
{
DBusMessageIter sub1, sub2, array;
if (!IBus_EnterVariant(conn, iter, dbus, &sub1, "IBusText", sizeof("IBusText"))) {
return SDL_FALSE;
return false;
}
dbus->message_iter_next(&sub1);
@@ -132,14 +132,14 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
dbus->message_iter_next(&sub1);
if (!IBus_EnterVariant(conn, &sub1, dbus, &sub2, "IBusAttrList", sizeof("IBusAttrList"))) {
return SDL_FALSE;
return false;
}
dbus->message_iter_next(&sub2);
dbus->message_iter_next(&sub2);
if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_ARRAY) {
return SDL_FALSE;
return false;
}
dbus->message_iter_recurse(&sub2, &array);
@@ -172,14 +172,14 @@ static SDL_bool IBus_GetDecorationPosition(DBusConnection *conn, DBusMessageIter
if (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_UINT32) {
dbus->message_iter_get_basic(&sub, end_pos);
*start_pos = start;
return SDL_TRUE;
return true;
}
}
}
}
dbus->message_iter_next(&array);
}
return SDL_FALSE;
return false;
}
static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus)
@@ -203,18 +203,18 @@ static const char *IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *it
return text;
}
static SDL_bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
static bool IBus_GetVariantCursorPos(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus,
Uint32 *pos)
{
dbus->message_iter_next(iter);
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32) {
return SDL_FALSE;
return false;
}
dbus->message_iter_get_basic(iter, pos);
return SDL_TRUE;
return true;
}
static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
@@ -242,8 +242,8 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
if (text) {
Uint32 pos, start_pos, end_pos;
SDL_bool has_pos = SDL_FALSE;
SDL_bool has_dec_pos = SDL_FALSE;
bool has_pos = false;
bool has_dec_pos = false;
dbus->message_iter_init(msg, &iter);
has_dec_pos = IBus_GetDecorationPosition(conn, &iter, dbus, &start_pos, &end_pos);
@@ -277,7 +277,7 @@ static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *
static char *IBus_ReadAddressFromFile(const char *file_path)
{
char addr_buf[1024];
SDL_bool success = SDL_FALSE;
bool success = false;
FILE *addr_file;
addr_file = fopen(file_path, "r");
@@ -294,7 +294,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
if (addr_buf[sz - 2] == '\r') {
addr_buf[sz - 2] = 0;
}
success = SDL_TRUE;
success = true;
break;
}
}
@@ -401,7 +401,7 @@ static char *IBus_GetDBusAddressFilename(void)
return SDL_strdup(file_path);
}
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus);
static bool IBus_CheckConnection(SDL_DBusContext *dbus);
static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val,
const char *hint)
@@ -423,11 +423,11 @@ static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const cha
}
}
static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
static bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
{
const char *client_name = "SDL3_Application";
const char *path = NULL;
SDL_bool result = SDL_FALSE;
bool result = false;
DBusObjectPathVTable ibus_vtable;
SDL_zero(ibus_vtable);
@@ -436,7 +436,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
/* try the portal interface first. Modern systems have this in general,
and sandbox things like FlakPak and Snaps, etc, require it. */
ibus_is_portal_interface = SDL_TRUE;
ibus_is_portal_interface = true;
ibus_service = IBUS_PORTAL_SERVICE;
ibus_interface = IBUS_PORTAL_INTERFACE;
ibus_input_interface = IBUS_PORTAL_INPUT_INTERFACE;
@@ -446,21 +446,21 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID,
DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
if (!result) {
ibus_is_portal_interface = SDL_FALSE;
ibus_is_portal_interface = false;
ibus_service = IBUS_SERVICE;
ibus_interface = IBUS_INTERFACE;
ibus_input_interface = IBUS_INPUT_INTERFACE;
ibus_conn = dbus->connection_open_private(addr, NULL);
if (!ibus_conn) {
return SDL_FALSE; // oh well.
return false; // oh well.
}
dbus->connection_flush(ibus_conn);
if (!dbus->bus_register(ibus_conn, NULL)) {
ibus_conn = NULL;
return SDL_FALSE;
return false;
}
dbus->connection_flush(ibus_conn);
@@ -486,22 +486,22 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
SDL_Window *window = SDL_GetKeyboardFocus();
if (SDL_TextInputActive(window)) {
SDL_IBus_SetFocus(SDL_TRUE);
SDL_IBus_SetFocus(true);
SDL_IBus_UpdateTextInputArea(window);
} else {
SDL_IBus_SetFocus(SDL_FALSE);
SDL_IBus_SetFocus(false);
}
return result;
}
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
static bool IBus_CheckConnection(SDL_DBusContext *dbus)
{
if (!dbus) {
return SDL_FALSE;
return false;
}
if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) {
return SDL_TRUE;
return true;
}
if (inotify_fd > 0 && inotify_wd > 0) {
@@ -510,18 +510,18 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
if (readsize > 0) {
char *p;
SDL_bool file_updated = SDL_FALSE;
bool file_updated = false;
for (p = buf; p < buf + readsize; /**/) {
struct inotify_event *event = (struct inotify_event *)p;
if (event->len > 0) {
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
if (!addr_file_no_path) {
return SDL_FALSE;
return false;
}
if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) {
file_updated = SDL_TRUE;
file_updated = true;
break;
}
}
@@ -532,7 +532,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
if (file_updated) {
char *addr = IBus_ReadAddressFromFile(ibus_addr_file);
if (addr) {
SDL_bool result = IBus_SetupConnection(dbus, addr);
bool result = IBus_SetupConnection(dbus, addr);
SDL_free(addr);
return result;
}
@@ -540,12 +540,12 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
}
}
return SDL_FALSE;
return false;
}
SDL_bool SDL_IBus_Init(void)
bool SDL_IBus_Init(void)
{
SDL_bool result = SDL_FALSE;
bool result = false;
SDL_DBusContext *dbus = SDL_DBus_GetContext();
if (dbus) {
@@ -554,13 +554,13 @@ SDL_bool SDL_IBus_Init(void)
char *addr_file_dir;
if (!addr_file) {
return SDL_FALSE;
return false;
}
addr = IBus_ReadAddressFromFile(addr_file);
if (!addr) {
SDL_free(addr_file);
return SDL_FALSE;
return false;
}
if (ibus_addr_file) {
@@ -626,7 +626,7 @@ void SDL_IBus_Quit(void)
ibus_service = NULL;
ibus_interface = NULL;
ibus_input_interface = NULL;
ibus_is_portal_interface = SDL_FALSE;
ibus_is_portal_interface = false;
if (inotify_fd > 0 && inotify_wd > 0) {
inotify_rm_watch(inotify_fd, inotify_wd);
@@ -649,7 +649,7 @@ static void IBus_SimpleMessage(const char *method)
}
}
void SDL_IBus_SetFocus(SDL_bool focused)
void SDL_IBus_SetFocus(bool focused)
{
const char *method = focused ? "FocusIn" : "FocusOut";
IBus_SimpleMessage(method);
@@ -660,7 +660,7 @@ void SDL_IBus_Reset(void)
IBus_SimpleMessage("Reset");
}
SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
Uint32 result = 0;
SDL_DBusContext *dbus = SDL_DBus_GetContext();

View File

@@ -28,19 +28,19 @@
#define SDL_USE_IBUS 1
#include <ibus.h>
extern SDL_bool SDL_IBus_Init(void);
extern bool SDL_IBus_Init(void);
extern void SDL_IBus_Quit(void);
// Lets the IBus server know about changes in window focus
extern void SDL_IBus_SetFocus(SDL_bool focused);
extern void SDL_IBus_SetFocus(bool focused);
// Closes the candidate list and resets any text currently being edited
extern void SDL_IBus_Reset(void);
/* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to
/* Sends a keypress event to IBus, returns true if IBus used this event to
update its candidate list or change input methods. PumpEvents should be
called some time after this, to receive the TextInput / TextEditing event back. */
extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
/* Update the position of IBus' candidate list. If rect is NULL then this will
just reposition it relative to the focused window's new position. */

View File

@@ -24,11 +24,11 @@
#include "SDL_ibus.h"
#include "SDL_fcitx.h"
typedef SDL_bool (*SDL_IME_Init_t)(void);
typedef bool (*SDL_IME_Init_t)(void);
typedef void (*SDL_IME_Quit_t)(void);
typedef void (*SDL_IME_SetFocus_t)(SDL_bool);
typedef void (*SDL_IME_SetFocus_t)(bool);
typedef void (*SDL_IME_Reset_t)(void);
typedef SDL_bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
typedef bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
typedef void (*SDL_IME_UpdateTextInputArea_t)(SDL_Window *window);
typedef void (*SDL_IME_PumpEvents_t)(void);
@@ -42,17 +42,17 @@ static SDL_IME_PumpEvents_t SDL_IME_PumpEvents_Real = NULL;
static void InitIME(void)
{
static SDL_bool inited = SDL_FALSE;
static bool inited = false;
#ifdef HAVE_FCITX
const char *im_module = SDL_getenv("SDL_IM_MODULE");
const char *xmodifiers = SDL_getenv("XMODIFIERS");
#endif
if (inited == SDL_TRUE) {
if (inited == true) {
return;
}
inited = SDL_TRUE;
inited = true;
// See if fcitx IME support is being requested
#ifdef HAVE_FCITX
@@ -83,13 +83,13 @@ static void InitIME(void)
#endif // HAVE_IBUS_IBUS_H
}
SDL_bool SDL_IME_Init(void)
bool SDL_IME_Init(void)
{
InitIME();
if (SDL_IME_Init_Real) {
if (SDL_IME_Init_Real()) {
return SDL_TRUE;
return true;
}
// uhoh, the IME implementation's init failed! Disable IME support.
@@ -102,7 +102,7 @@ SDL_bool SDL_IME_Init(void)
SDL_IME_PumpEvents_Real = NULL;
}
return SDL_FALSE;
return false;
}
void SDL_IME_Quit(void)
@@ -112,7 +112,7 @@ void SDL_IME_Quit(void)
}
}
void SDL_IME_SetFocus(SDL_bool focused)
void SDL_IME_SetFocus(bool focused)
{
if (SDL_IME_SetFocus_Real) {
SDL_IME_SetFocus_Real(focused);
@@ -126,13 +126,13 @@ void SDL_IME_Reset(void)
}
}
SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
{
if (SDL_IME_ProcessKeyEvent_Real) {
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, state);
}
return SDL_FALSE;
return false;
}
void SDL_IME_UpdateTextInputArea(SDL_Window *window)

View File

@@ -24,11 +24,11 @@
#include "SDL_internal.h"
extern SDL_bool SDL_IME_Init(void);
extern bool SDL_IME_Init(void);
extern void SDL_IME_Quit(void);
extern void SDL_IME_SetFocus(SDL_bool focused);
extern void SDL_IME_SetFocus(bool focused);
extern void SDL_IME_Reset(void);
extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
extern void SDL_IME_UpdateTextInputArea(SDL_Window *window);
extern void SDL_IME_PumpEvents(void);

View File

@@ -44,16 +44,16 @@ typedef struct SystemThemeData
static SystemThemeData system_theme_data;
static SDL_bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme *theme) {
static bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme *theme) {
SDL_DBusContext *dbus = system_theme_data.dbus;
Uint32 color_scheme;
DBusMessageIter variant_iter;
if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
return SDL_FALSE;
return false;
dbus->message_iter_recurse(iter, &variant_iter);
if (dbus->message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_UINT32)
return SDL_FALSE;
return false;
dbus->message_iter_get_basic(&variant_iter, &color_scheme);
switch (color_scheme) {
case 0:
@@ -66,7 +66,7 @@ static SDL_bool DBus_ExtractThemeVariant(DBusMessageIter *iter, SDL_SystemTheme
*theme = SDL_SYSTEM_THEME_LIGHT;
break;
}
return SDL_TRUE;
return true;
}
static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) {
@@ -106,7 +106,7 @@ not_our_signal:
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
SDL_bool SDL_SystemTheme_Init(void)
bool SDL_SystemTheme_Init(void)
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
DBusMessage *msg;
@@ -116,7 +116,7 @@ SDL_bool SDL_SystemTheme_Init(void)
system_theme_data.theme = SDL_SYSTEM_THEME_UNKNOWN;
system_theme_data.dbus = dbus;
if (!dbus) {
return SDL_FALSE;
return false;
}
msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, PORTAL_METHOD);
@@ -147,7 +147,7 @@ incorrect_type:
dbus->connection_add_filter(dbus->session_conn,
&DBus_MessageFilter, dbus, NULL);
dbus->connection_flush(dbus->session_conn);
return SDL_TRUE;
return true;
}
SDL_SystemTheme SDL_SystemTheme_Get(void)

View File

@@ -24,7 +24,7 @@
#include "SDL_internal.h"
extern SDL_bool SDL_SystemTheme_Init(void);
extern bool SDL_SystemTheme_Init(void);
extern SDL_SystemTheme SDL_SystemTheme_Get(void);
#endif // SDL_system_theme_h_

View File

@@ -52,7 +52,7 @@
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
static SDL_bool rtkit_use_session_conn;
static bool rtkit_use_session_conn;
static const char *rtkit_dbus_node;
static const char *rtkit_dbus_path;
static const char *rtkit_dbus_interface;
@@ -67,7 +67,7 @@ static Sint64 rtkit_max_rttime_usec = 200000;
* - The desktop portal exists and supports the realtime interface.
* - The realtime interface is new enough to have the required bug fixes applied.
*/
static SDL_bool realtime_portal_supported(DBusConnection *conn)
static bool realtime_portal_supported(DBusConnection *conn)
{
Sint64 res;
return SDL_DBus_QueryPropertyOnConnection(conn, XDG_PORTAL_DBUS_NODE, XDG_PORTAL_DBUS_PATH, XDG_PORTAL_DBUS_INTERFACE,
@@ -80,12 +80,12 @@ static void set_rtkit_interface(void)
// xdg-desktop-portal works in all instances, so check for it first.
if (dbus && realtime_portal_supported(dbus->session_conn)) {
rtkit_use_session_conn = SDL_TRUE;
rtkit_use_session_conn = true;
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
} else { // Fall back to the standard rtkit interface in all other cases.
rtkit_use_session_conn = SDL_FALSE;
rtkit_use_session_conn = false;
rtkit_dbus_node = RTKIT_DBUS_NODE;
rtkit_dbus_path = RTKIT_DBUS_PATH;
rtkit_dbus_interface = RTKIT_DBUS_INTERFACE;
@@ -129,7 +129,7 @@ static void rtkit_initialize(void)
}
}
static SDL_bool rtkit_initialize_realtime_thread(void)
static bool rtkit_initialize_realtime_thread(void)
{
// Following is an excerpt from rtkit README that outlines the requirements
// a thread must meet before making rtkit requests:
@@ -163,7 +163,7 @@ static SDL_bool rtkit_initialize_realtime_thread(void)
// Requirement #1: Set RLIMIT_RTTIME
err = getrlimit(nLimit, &rlimit);
if (err) {
return SDL_FALSE;
return false;
}
// Current rtkit allows a max of 200ms right now
@@ -171,24 +171,24 @@ static SDL_bool rtkit_initialize_realtime_thread(void)
rlimit.rlim_cur = rlimit.rlim_max / 2;
err = setrlimit(nLimit, &rlimit);
if (err) {
return SDL_FALSE;
return false;
}
// Requirement #2: Add SCHED_RESET_ON_FORK to the scheduler policy
err = sched_getparam(nPid, &schedParam);
if (err) {
return SDL_FALSE;
return false;
}
err = sched_setscheduler(nPid, nSchedPolicy, &schedParam);
if (err) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
static bool rtkit_setpriority_nice(pid_t thread, int nice_level)
{
DBusConnection *dbus_conn;
Uint64 pid = (Uint64)getpid();
@@ -206,12 +206,12 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
static bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
{
DBusConnection *dbus_conn;
Uint64 pid = (Uint64)getpid();
@@ -237,9 +237,9 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
#else

View File

@@ -40,23 +40,23 @@ static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
static SDL_UDEV_PrivateData *_this = NULL;
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr);
static bool SDL_UDEV_load_sym(const char *fn, void **addr);
static int SDL_UDEV_load_syms(void);
static SDL_bool SDL_UDEV_hotplug_update_available(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);
static int device_class(struct udev_device *dev);
static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr)
static bool SDL_UDEV_load_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(_this->udev_handle, fn);
if (!*addr) {
// Don't call SDL_SetError(): SDL_LoadFunction already did.
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static int SDL_UDEV_load_syms(void)
@@ -98,15 +98,15 @@ static int SDL_UDEV_load_syms(void)
return 0;
}
static SDL_bool SDL_UDEV_hotplug_update_available(void)
static bool SDL_UDEV_hotplug_update_available(void)
{
if (_this->udev_mon) {
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
return SDL_TRUE;
return true;
}
}
return SDL_FALSE;
return false;
}
int SDL_UDEV_Init(void)
@@ -222,7 +222,7 @@ int SDL_UDEV_Scan(void)
return 0;
}
SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class)
{
struct stat statbuf;
char type;
@@ -231,11 +231,11 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
int class_temp;
if (!_this) {
return SDL_FALSE;
return false;
}
if (stat(device_path, &statbuf) == -1) {
return SDL_FALSE;
return false;
}
if (S_ISBLK(statbuf.st_mode)) {
@@ -245,13 +245,13 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
type = 'c';
}
else {
return SDL_FALSE;
return false;
}
dev = _this->syms.udev_device_new_from_devnum(_this->udev, type, statbuf.st_rdev);
if (!dev) {
return SDL_FALSE;
return false;
}
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
@@ -276,7 +276,7 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
_this->syms.udev_device_unref(dev);
return SDL_TRUE;
return true;
}
void SDL_UDEV_UnloadLibrary(void)

View File

@@ -102,7 +102,7 @@ extern void SDL_UDEV_UnloadLibrary(void);
extern int SDL_UDEV_LoadLibrary(void);
extern void SDL_UDEV_Poll(void);
extern int SDL_UDEV_Scan(void);
extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class);
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 void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);

View File

@@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
}
input->keyboardID = SDL_GetNextObjectID();
SDL_AddKeyboard(input->keyboardID, NULL, SDL_FALSE);
SDL_AddKeyboard(input->keyboardID, NULL, false);
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
if (!input->keymap.map) {

View File

@@ -52,7 +52,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse(void)
}
input->mouseID = SDL_GetNextObjectID();
SDL_AddMouse(input->mouseID, NULL, SDL_FALSE);
SDL_AddMouse(input->mouseID, NULL, false);
#ifdef WSMOUSEIO_SETMODE
ioctl(input->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT);

View File

@@ -56,16 +56,16 @@ static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x8
static const PROPERTYKEY SDL_PKEY_AudioEndpoint_GUID = { { 0x1da5d803, 0xd492, 0x4edd,{ 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, } }, 4 };
/* *INDENT-ON* */ // clang-format on
static SDL_bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata)
static bool FindByDevIDCallback(SDL_AudioDevice *device, void *userdata)
{
LPCWSTR devid = (LPCWSTR)userdata;
if (devid && device && device->handle) {
const SDL_IMMDevice_HandleData *handle = (const SDL_IMMDevice_HandleData *)device->handle;
if (handle->immdevice_id && SDL_wcscmp(handle->immdevice_id, devid) == 0) {
return SDL_TRUE;
return true;
}
}
return SDL_FALSE;
return false;
}
static SDL_AudioDevice *SDL_IMMDevice_FindByDevID(LPCWSTR devid)
@@ -120,7 +120,7 @@ void SDL_IMMDevice_FreeDeviceHandle(SDL_AudioDevice *device)
}
}
static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid)
static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid, GUID *dsoundguid)
{
/* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever).
In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for
@@ -248,7 +248,7 @@ static HRESULT STDMETHODCALLTYPE SDLMMNotificationClient_OnDeviceStateChanged(IM
if (SUCCEEDED(IMMDevice_QueryInterface(device, &SDL_IID_IMMEndpoint, (void **)&endpoint))) {
EDataFlow flow;
if (SUCCEEDED(IMMEndpoint_GetDataFlow(endpoint, &flow))) {
const SDL_bool recording = (flow == eCapture);
const bool recording = (flow == eCapture);
if (dwNewState == DEVICE_STATE_ACTIVE) {
char *utf8dev;
WAVEFORMATEXTENSIBLE fmt;
@@ -336,7 +336,7 @@ void SDL_IMMDevice_Quit(void)
WIN_CoUninitialize();
}
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording)
int 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.
@@ -361,7 +361,7 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool r
}
static void EnumerateEndpointsForFlow(const SDL_bool recording, SDL_AudioDevice **default_device)
static void EnumerateEndpointsForFlow(const bool recording, SDL_AudioDevice **default_device)
{
/* Note that WASAPI separates "adapter devices" from "audio endpoint devices"
...one adapter device ("SoundBlaster Pro") might have multiple endpoint devices ("Speakers", "Line-Out"). */
@@ -422,8 +422,8 @@ static void EnumerateEndpointsForFlow(const SDL_bool recording, SDL_AudioDevice
void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
{
EnumerateEndpointsForFlow(SDL_FALSE, default_playback);
EnumerateEndpointsForFlow(SDL_TRUE, default_recording);
EnumerateEndpointsForFlow(false, default_playback);
EnumerateEndpointsForFlow(true, default_recording);
// if this fails, we just won't get hotplug events. Carry on anyhow.
IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)&notification_client);

View File

@@ -36,7 +36,7 @@ typedef struct SDL_IMMDevice_callbacks
int SDL_IMMDevice_Init(const SDL_IMMDevice_callbacks *callbacks);
void SDL_IMMDevice_Quit(void);
int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool recording);
int 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);

View File

@@ -126,12 +126,12 @@ void WIN_CoUninitialize(void)
#ifndef SDL_PLATFORM_WINRT
FARPROC WIN_LoadComBaseFunction(const char *name)
{
static SDL_bool s_bLoaded;
static bool s_bLoaded;
static HMODULE s_hComBase;
if (!s_bLoaded) {
s_hComBase = LoadLibraryEx(TEXT("combase.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
s_bLoaded = SDL_TRUE;
s_bLoaded = true;
}
if (s_hComBase) {
return GetProcAddress(s_hComBase, name);
@@ -206,11 +206,11 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
#define CHECKWINVER(notdesktop_platform_result, test) return (notdesktop_platform_result);
#else
#define CHECKWINVER(notdesktop_platform_result, test) \
static SDL_bool checked = SDL_FALSE; \
static bool checked = false; \
static BOOL retval = FALSE; \
if (!checked) { \
retval = (test); \
checked = SDL_TRUE; \
checked = true; \
} \
return retval;
#endif
@@ -272,7 +272,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
const unsigned char *ptr;
char keystr[128];
WCHAR *strw = NULL;
SDL_bool rc;
bool rc;
HKEY hkey;
DWORD len = 0;
char *retval = NULL;

View File

@@ -135,16 +135,16 @@ extern void WIN_CoUninitialize(void);
extern HRESULT WIN_RoInitialize(void);
extern void WIN_RoUninitialize(void);
// Returns SDL_TRUE if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
extern BOOL WIN_IsWindowsXP(void);
// Returns SDL_TRUE if we're running on Windows Vista and newer
// Returns true if we're running on Windows Vista and newer
extern BOOL WIN_IsWindowsVistaOrGreater(void);
// Returns SDL_TRUE if we're running on Windows 7 and newer
// Returns true if we're running on Windows 7 and newer
extern BOOL WIN_IsWindows7OrGreater(void);
// Returns SDL_TRUE if we're running on Windows 8 and newer
// Returns true if we're running on Windows 8 and newer
extern BOOL WIN_IsWindows8OrGreater(void);
// You need to SDL_free() the result of this call.
@@ -158,7 +158,7 @@ extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
// Returns SDL_TRUE if the rect is empty
// Returns true if the rect is empty
extern BOOL WIN_IsRectEmpty(const RECT *rect);
extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);

View File

@@ -478,7 +478,7 @@ void SDL_WinRTApp::OnVisibilityChanged(CoreWindow ^ sender, VisibilityChangedEve
m_windowVisible = args->Visible;
if (WINRT_GlobalSDLWindow) {
SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
SDL_WindowFlags latestWindowFlags = WINRT_DetectWindowFlags(WINRT_GlobalSDLWindow);
if (args->Visible) {
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_SHOWN, 0, 0);
@@ -538,7 +538,7 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr
*/
#if !SDL_WINAPI_FAMILY_PHONE || NTDDI_VERSION >= NTDDI_WINBLUE
Point cursorPos = WINRT_TransformCursorPosition(window, sender->PointerPosition, TransformToSDLWindowSize);
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, cursorPos.X, cursorPos.Y);
SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, cursorPos.X, cursorPos.Y);
#endif
// TODO, WinRT: see if the Win32 bugfix from https://hg.libsdl.org/SDL/rev/d278747da408 needs to be applied (on window activation)
@@ -727,7 +727,7 @@ static void WINRT_OnBackButtonPressed(BackButtonEventArgs ^ args)
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_AC_BACK, SDL_PRESSED);
SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_AC_BACK, SDL_RELEASED);
if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, SDL_FALSE)) {
if (SDL_GetHintBoolean(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, false)) {
args->Handled = true;
}
}

View File

@@ -35,7 +35,7 @@
#include "SDL_winrtapp_xaml.h"
// SDL-internal globals:
SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
bool WINRT_XAMLWasEnabled = false;
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
extern "C" ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
@@ -127,8 +127,8 @@ int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPane
SDL_SetMainReady();
// Make sure video-init knows that we're initializing XAML:
SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
WINRT_XAMLWasEnabled = SDL_TRUE;
bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
WINRT_XAMLWasEnabled = true;
// 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

View File

@@ -24,7 +24,7 @@
#define SDL_winrtapp_xaml_h_
#ifdef __cplusplus
extern SDL_bool WINRT_XAMLWasEnabled;
extern bool WINRT_XAMLWasEnabled;
extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable);
#endif // ifdef __cplusplus