diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8ce5dba8..55dec2e138 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -972,6 +972,7 @@ if(SDL_LIBC) memory.h signal.h stdarg.h + stdbool.h stddef.h stdint.h stdio.h diff --git a/cmake/PreseedEmscriptenCache.cmake b/cmake/PreseedEmscriptenCache.cmake index ca68202b26..261e7ea677 100644 --- a/cmake/PreseedEmscriptenCache.cmake +++ b/cmake/PreseedEmscriptenCache.cmake @@ -82,6 +82,7 @@ if(EMSCRIPTEN) set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf") set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf") set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h") + set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h") set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h") set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h") set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h") diff --git a/cmake/PreseedMSVCCache.cmake b/cmake/PreseedMSVCCache.cmake index d0b5ebfe4b..76d3fa4b8b 100644 --- a/cmake/PreseedMSVCCache.cmake +++ b/cmake/PreseedMSVCCache.cmake @@ -96,6 +96,7 @@ if(MSVC) set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf") set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf") set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h") + set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h") set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h") set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h") set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h") diff --git a/include/build_config/SDL_build_config.h.cmake b/include/build_config/SDL_build_config.h.cmake index 74e4479ab9..dceb68cd43 100644 --- a/include/build_config/SDL_build_config.h.cmake +++ b/include/build_config/SDL_build_config.h.cmake @@ -59,6 +59,7 @@ #cmakedefine HAVE_MEMORY_H 1 #cmakedefine HAVE_SIGNAL_H 1 #cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDBOOL_H 1 #cmakedefine HAVE_STDDEF_H 1 #cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_android.h b/include/build_config/SDL_build_config_android.h index 926cff8df2..d6ae49abc5 100644 --- a/include/build_config/SDL_build_config_android.h +++ b/include/build_config/SDL_build_config_android.h @@ -42,6 +42,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_emscripten.h b/include/build_config/SDL_build_config_emscripten.h index c994d2540a..e4ac92abff 100644 --- a/include/build_config/SDL_build_config_emscripten.h +++ b/include/build_config/SDL_build_config_emscripten.h @@ -44,6 +44,7 @@ #define HAVE_MEMORY_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_ios.h b/include/build_config/SDL_build_config_ios.h index 430a984173..b283858e83 100644 --- a/include/build_config/SDL_build_config_ios.h +++ b/include/build_config/SDL_build_config_ios.h @@ -34,6 +34,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_macos.h b/include/build_config/SDL_build_config_macos.h index c5bbc199e9..874b4d3be8 100644 --- a/include/build_config/SDL_build_config_macos.h +++ b/include/build_config/SDL_build_config_macos.h @@ -39,6 +39,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_windows.h b/include/build_config/SDL_build_config_windows.h index 6834afc595..669d4e6810 100644 --- a/include/build_config/SDL_build_config_windows.h +++ b/include/build_config/SDL_build_config_windows.h @@ -124,6 +124,7 @@ typedef unsigned int uintptr_t; #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDIO_H 1 #define HAVE_STDLIB_H 1 diff --git a/include/build_config/SDL_build_config_wingdk.h b/include/build_config/SDL_build_config_wingdk.h index 859b606e8a..3fd847c9d1 100644 --- a/include/build_config/SDL_build_config_wingdk.h +++ b/include/build_config/SDL_build_config_wingdk.h @@ -63,6 +63,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_winrt.h b/include/build_config/SDL_build_config_winrt.h index 7de89bf803..57d1dea420 100644 --- a/include/build_config/SDL_build_config_winrt.h +++ b/include/build_config/SDL_build_config_winrt.h @@ -62,6 +62,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/include/build_config/SDL_build_config_xbox.h b/include/build_config/SDL_build_config_xbox.h index 0ff0ded83b..3ad30290dd 100644 --- a/include/build_config/SDL_build_config_xbox.h +++ b/include/build_config/SDL_build_config_xbox.h @@ -62,6 +62,7 @@ #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_STDARG_H 1 +#define HAVE_STDBOOL_H 1 #define HAVE_STDDEF_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDIO_H 1 diff --git a/src/SDL.c b/src/SDL.c index 2b3ae4e296..44d0da679d 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -117,10 +117,10 @@ int SDL_SetAppMetadata(const char *appname, const char *appversion, const char * return 0; } -static SDL_bool SDL_ValidMetadataProperty(const char *name) +static bool SDL_ValidMetadataProperty(const char *name) { if (!name || !*name) { - return SDL_FALSE; + return false; } if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0 || @@ -130,9 +130,9 @@ static SDL_bool SDL_ValidMetadataProperty(const char *name) SDL_strcmp(name, SDL_PROP_APP_METADATA_COPYRIGHT_STRING) == 0 || SDL_strcmp(name, SDL_PROP_APP_METADATA_URL_STRING) == 0 || SDL_strcmp(name, SDL_PROP_APP_METADATA_TYPE_STRING) == 0) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } int SDL_SetAppMetadataProperty(const char *name, const char *value) @@ -173,11 +173,11 @@ const char *SDL_GetAppMetadataProperty(const char *name) // The initialized subsystems #ifdef SDL_MAIN_NEEDED -static SDL_bool SDL_MainIsReady = SDL_FALSE; +static bool SDL_MainIsReady = false; #else -static SDL_bool SDL_MainIsReady = SDL_TRUE; +static bool SDL_MainIsReady = true; #endif -static SDL_bool SDL_bInMainQuit = SDL_FALSE; +static bool SDL_bInMainQuit = false; static Uint8 SDL_SubsystemRefCount[32]; // Private helper to increment a subsystem's ref counter. @@ -204,7 +204,7 @@ static void SDL_DecrementSubsystemRefCount(Uint32 subsystem) } // Private helper to check if a system needs init. -static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem) +static bool SDL_ShouldInitSubsystem(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); @@ -212,11 +212,11 @@ static SDL_bool SDL_ShouldInitSubsystem(Uint32 subsystem) } // Private helper to check if a system needs to be quit. -static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem) +static bool SDL_ShouldQuitSubsystem(Uint32 subsystem) { const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) { - return SDL_FALSE; + return false; } /* If we're in SDL_Quit, we shut down every subsystem, even if refcount @@ -227,23 +227,23 @@ static SDL_bool SDL_ShouldQuitSubsystem(Uint32 subsystem) /* Private helper to either increment's existing ref counter, * or fully init a new subsystem. */ -static SDL_bool SDL_InitOrIncrementSubsystem(Uint32 subsystem) +static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem) { int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); if (subsystem_index < 0) { - return SDL_FALSE; + return false; } if (SDL_SubsystemRefCount[subsystem_index] > 0) { ++SDL_SubsystemRefCount[subsystem_index]; - return SDL_TRUE; + return true; } return SDL_InitSubSystem(subsystem) == 0; } void SDL_SetMainReady(void) { - SDL_MainIsReady = SDL_TRUE; + SDL_MainIsReady = true; } // Initialize all the subsystems that require initialization before threads start @@ -612,7 +612,7 @@ Uint32 SDL_WasInit(SDL_InitFlags flags) void SDL_Quit(void) { - SDL_bInMainQuit = SDL_TRUE; + SDL_bInMainQuit = true; // Quit all subsystems #ifdef SDL_VIDEO_DRIVER_WINDOWS @@ -638,7 +638,7 @@ void SDL_Quit(void) SDL_QuitMainThread(); - SDL_bInMainQuit = SDL_FALSE; + SDL_bInMainQuit = false; } // Get the library version number @@ -726,13 +726,13 @@ const char *SDL_GetPlatform(void) SDL_bool SDL_IsTablet(void) { #ifdef SDL_PLATFORM_ANDROID - extern SDL_bool SDL_IsAndroidTablet(void); + extern bool SDL_IsAndroidTablet(void); return SDL_IsAndroidTablet(); #elif defined(SDL_PLATFORM_IOS) - extern SDL_bool SDL_IsIPad(void); + extern bool SDL_IsIPad(void); return SDL_IsIPad(); #else - return SDL_FALSE; + return false; #endif } diff --git a/src/SDL_assert.c b/src/SDL_assert.c index b3efe41735..c80f3fd1d5 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -248,7 +248,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v #ifdef SDL_PLATFORM_EMSCRIPTEN // This is nasty, but we can't block on a custom UI. for (;;) { - SDL_bool okay = SDL_TRUE; + bool okay = true; /* *INDENT-OFF* */ // clang-format off char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({ var str = @@ -275,7 +275,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v } else if (SDL_strcmp(buf, "A") == 0) { state = SDL_ASSERTION_ALWAYS_IGNORE; } else { - okay = SDL_FALSE; + okay = false; } free(buf); // This should NOT be SDL_free() @@ -373,7 +373,7 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons switch (state) { case SDL_ASSERTION_ALWAYS_IGNORE: state = SDL_ASSERTION_IGNORE; - data->always_ignore = SDL_TRUE; + data->always_ignore = true; break; case SDL_ASSERTION_IGNORE: @@ -430,7 +430,7 @@ void SDL_ResetAssertionReport(void) SDL_AssertData *item; for (item = triggered_assertions; item; item = next) { next = (SDL_AssertData *)item->next; - item->always_ignore = SDL_FALSE; + item->always_ignore = false; item->trigger_count = 0; item->next = NULL; } diff --git a/src/SDL_error.c b/src/SDL_error.c index 5b0d35d4e3..5dff9c8fdf 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -30,7 +30,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) if (fmt) { va_list ap; int result; - SDL_error *error = SDL_GetErrBuf(SDL_TRUE); + SDL_error *error = SDL_GetErrBuf(true); error->error = SDL_ErrorCodeGeneric; @@ -61,7 +61,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) const char *SDL_GetError(void) { - const SDL_error *error = SDL_GetErrBuf(SDL_FALSE); + const SDL_error *error = SDL_GetErrBuf(false); if (!error) { return ""; @@ -79,7 +79,7 @@ const char *SDL_GetError(void) int SDL_ClearError(void) { - SDL_error *error = SDL_GetErrBuf(SDL_FALSE); + SDL_error *error = SDL_GetErrBuf(false); if (error) { error->error = SDL_ErrorCodeNone; @@ -89,7 +89,7 @@ int SDL_ClearError(void) int SDL_OutOfMemory(void) { - SDL_error *error = SDL_GetErrBuf(SDL_TRUE); + SDL_error *error = SDL_GetErrBuf(true); if (error) { error->error = SDL_ErrorCodeOutOfMemory; diff --git a/src/SDL_error_c.h b/src/SDL_error_c.h index 55fa92d1e0..228f547205 100644 --- a/src/SDL_error_c.h +++ b/src/SDL_error_c.h @@ -44,6 +44,6 @@ typedef struct SDL_error } SDL_error; // Defined in SDL_thread.c -extern SDL_error *SDL_GetErrBuf(SDL_bool create); +extern SDL_error *SDL_GetErrBuf(bool create); #endif // SDL_error_c_h_ diff --git a/src/SDL_hashtable.c b/src/SDL_hashtable.c index 97b8e2a6d0..168fe1e30b 100644 --- a/src/SDL_hashtable.c +++ b/src/SDL_hashtable.c @@ -33,7 +33,7 @@ struct SDL_HashTable SDL_HashItem **table; Uint32 table_len; int hash_shift; - SDL_bool stackable; + bool stackable; void *data; SDL_HashTable_HashFn hash; SDL_HashTable_KeyMatchFn keymatch; @@ -43,7 +43,7 @@ struct SDL_HashTable SDL_HashTable *SDL_CreateHashTable(void *data, const Uint32 num_buckets, const SDL_HashTable_HashFn hashfn, const SDL_HashTable_KeyMatchFn keymatchfn, const SDL_HashTable_NukeFn nukefn, - const SDL_bool stackable) + const bool stackable) { SDL_HashTable *table; @@ -83,23 +83,23 @@ static SDL_INLINE Uint32 calc_hash(const SDL_HashTable *table, const void *key) } -SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value) +bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value) { SDL_HashItem *item; Uint32 hash; if (!table) { - return SDL_FALSE; + return false; } if ( (!table->stackable) && (SDL_FindInHashTable(table, key, NULL)) ) { - return SDL_FALSE; + return false; } // !!! FIXME: grow and rehash table if it gets too saturated. item = (SDL_HashItem *) SDL_malloc(sizeof (SDL_HashItem)); if (!item) { - return SDL_FALSE; + return false; } hash = calc_hash(table, key); @@ -109,17 +109,17 @@ SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const vo item->next = table->table[hash]; table->table[hash] = item; - return SDL_TRUE; + return true; } -SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value) +bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value) { Uint32 hash; void *data; SDL_HashItem *i; if (!table) { - return SDL_FALSE; + return false; } hash = calc_hash(table, key); @@ -130,14 +130,14 @@ SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const if (_value) { *_value = i->value; } - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key) +bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key) { Uint32 hash; SDL_HashItem *item = NULL; @@ -145,7 +145,7 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key) void *data; if (!table) { - return SDL_FALSE; + return false; } hash = calc_hash(table, key); @@ -163,21 +163,21 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key) table->nuke(item->key, item->value, data); } SDL_free(item); - return SDL_TRUE; + return true; } prev = item; } - return SDL_FALSE; + return false; } -SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter) +bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter) { SDL_HashItem *item; if (!table) { - return SDL_FALSE; + return false; } item = *iter ? ((SDL_HashItem *)*iter)->next : table->table[calc_hash(table, key)]; @@ -186,7 +186,7 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co if (table->keymatch(key, item->key, table->data)) { *_value = item->value; *iter = item; - return SDL_TRUE; + return true; } item = item->next; } @@ -194,16 +194,16 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co // no more matches. *_value = NULL; *iter = NULL; - return SDL_FALSE; + return false; } -SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter) +bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter) { SDL_HashItem *item = (SDL_HashItem *) *iter; Uint32 idx = 0; if (!table) { - return SDL_FALSE; + return false; } if (item) { @@ -221,17 +221,17 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con if (!item) { // no more matches? *_key = NULL; *iter = NULL; - return SDL_FALSE; + return false; } *_key = item->key; *_value = item->value; *iter = item; - return SDL_TRUE; + return true; } -SDL_bool SDL_HashTableEmpty(SDL_HashTable *table) +bool SDL_HashTableEmpty(SDL_HashTable *table) { if (table) { Uint32 i; @@ -239,11 +239,11 @@ SDL_bool SDL_HashTableEmpty(SDL_HashTable *table) for (i = 0; i < table->table_len; i++) { SDL_HashItem *item = table->table[i]; if (item) { - return SDL_FALSE; + return false; } } } - return SDL_TRUE; + return true; } void SDL_EmptyHashTable(SDL_HashTable *table) @@ -292,12 +292,12 @@ Uint32 SDL_HashString(const void *key, void *data) return hash_string_djbxor(str, SDL_strlen(str)); } -SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *data) +bool SDL_KeyMatchString(const void *a, const void *b, void *data) { if (a == b) { - return SDL_TRUE; // same pointer, must match. + return true; // same pointer, must match. } else if (!a || !b) { - return SDL_FALSE; // one pointer is NULL (and first test shows they aren't the same pointer), must not match. + return false; // one pointer is NULL (and first test shows they aren't the same pointer), must not match. } return (SDL_strcmp((const char *)a, (const char *)b) == 0); // Check against actual string contents. } @@ -310,12 +310,12 @@ Uint32 SDL_HashID(const void *key, void *unused) return (Uint32)(uintptr_t)key; } -SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused) +bool SDL_KeyMatchID(const void *a, const void *b, void *unused) { if (a == b) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } void SDL_NukeFreeValue(const void *key, const void *value, void *unused) diff --git a/src/SDL_hashtable.h b/src/SDL_hashtable.h index 160180ea62..c897e07c31 100644 --- a/src/SDL_hashtable.h +++ b/src/SDL_hashtable.h @@ -26,7 +26,7 @@ struct SDL_HashTable; typedef struct SDL_HashTable SDL_HashTable; typedef Uint32 (*SDL_HashTable_HashFn)(const void *key, void *data); -typedef SDL_bool (*SDL_HashTable_KeyMatchFn)(const void *a, const void *b, void *data); +typedef bool (*SDL_HashTable_KeyMatchFn)(const void *a, const void *b, void *data); typedef void (*SDL_HashTable_NukeFn)(const void *key, const void *value, void *data); extern SDL_HashTable *SDL_CreateHashTable(void *data, @@ -34,26 +34,26 @@ extern SDL_HashTable *SDL_CreateHashTable(void *data, const SDL_HashTable_HashFn hashfn, const SDL_HashTable_KeyMatchFn keymatchfn, const SDL_HashTable_NukeFn nukefn, - const SDL_bool stackable); + const bool stackable); extern void SDL_EmptyHashTable(SDL_HashTable *table); extern void SDL_DestroyHashTable(SDL_HashTable *table); -extern SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value); -extern SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key); -extern SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value); -extern SDL_bool SDL_HashTableEmpty(SDL_HashTable *table); +extern bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value); +extern bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key); +extern bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value); +extern bool SDL_HashTableEmpty(SDL_HashTable *table); // iterate all values for a specific key. This only makes sense if the hash is stackable. If not-stackable, just use SDL_FindInHashTable(). -extern SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter); +extern bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter); // iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values). -extern SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter); +extern bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter); extern Uint32 SDL_HashString(const void *key, void *unused); -extern SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *unused); +extern bool SDL_KeyMatchString(const void *a, const void *b, void *unused); extern Uint32 SDL_HashID(const void *key, void *unused); -extern SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused); +extern bool SDL_KeyMatchID(const void *a, const void *b, void *unused); extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused); diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 0b84d68de9..ba11022e79 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -38,7 +38,7 @@ typedef struct SDL_Hint static SDL_PropertiesID SDL_hint_props = 0; -static SDL_PropertiesID GetHintProperties(SDL_bool create) +static SDL_PropertiesID GetHintProperties(bool create) { if (!SDL_hint_props && create) { SDL_hint_props = SDL_CreateProperties(); @@ -49,7 +49,7 @@ static SDL_PropertiesID GetHintProperties(SDL_bool create) void SDL_InitHints(void) { // Just make sure the hint properties are created on the main thread - (void)GetHintProperties(SDL_TRUE); + (void)GetHintProperties(true); } static void SDLCALL CleanupHintProperty(void *userdata, void *value) @@ -77,7 +77,7 @@ int SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriorit return SDL_SetError("An environment variable is taking priority"); } - const SDL_PropertiesID hints = GetHintProperties(SDL_TRUE); + const SDL_PropertiesID hints = GetHintProperties(true); if (!hints) { return -1; } @@ -128,7 +128,7 @@ int SDL_ResetHint(const char *name) const char *env = SDL_getenv(name); - const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE); + const SDL_PropertiesID hints = GetHintProperties(false); if (!hints) { return -1; } @@ -182,7 +182,7 @@ static void SDLCALL ResetHintsCallback(void *userdata, SDL_PropertiesID hints, c void SDL_ResetHints(void) { - SDL_EnumerateProperties(GetHintProperties(SDL_FALSE), ResetHintsCallback, NULL); + SDL_EnumerateProperties(GetHintProperties(false), ResetHintsCallback, NULL); } int SDL_SetHint(const char *name, const char *value) @@ -198,7 +198,7 @@ const char *SDL_GetHint(const char *name) const char *retval = SDL_getenv(name); - const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE); + const SDL_PropertiesID hints = GetHintProperties(false); if (hints) { SDL_LockProperties(hints); @@ -232,15 +232,15 @@ int SDL_GetStringInteger(const char *value, int default_value) return default_value; } -SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value) +bool SDL_GetStringBoolean(const char *value, bool default_value) { if (!value || !*value) { return default_value; } if (*value == '0' || SDL_strcasecmp(value, "false") == 0) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } SDL_bool SDL_GetHintBoolean(const char *name, SDL_bool default_value) @@ -257,7 +257,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd return SDL_InvalidParamError("callback"); } - const SDL_PropertiesID hints = GetHintProperties(SDL_TRUE); + const SDL_PropertiesID hints = GetHintProperties(true); if (!hints) { return -1; } @@ -311,7 +311,7 @@ void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *user return; } - const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE); + const SDL_PropertiesID hints = GetHintProperties(false); if (!hints) { return; } diff --git a/src/SDL_hints_c.h b/src/SDL_hints_c.h index 10b674ba81..ab254e3645 100644 --- a/src/SDL_hints_c.h +++ b/src/SDL_hints_c.h @@ -26,7 +26,7 @@ #define SDL_hints_c_h_ extern void SDL_InitHints(void); -extern SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value); +extern bool SDL_GetStringBoolean(const char *value, bool default_value); extern int SDL_GetStringInteger(const char *value, int default_value); extern void SDL_QuitHints(void); diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 9be670d47a..5d3dc8a0f5 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -121,6 +121,16 @@ #include #endif +#ifndef __cplusplus +#ifdef HAVE_STDBOOL_H +#include +#else +typedef int bool; +#define true 1 +#define false 0 +#endif +#endif // !__cplusplus + // If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC #ifndef HAVE_O_CLOEXEC #define O_CLOEXEC 0 diff --git a/src/SDL_log.c b/src/SDL_log.c index 017dc5ac4c..342ed8521a 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -57,7 +57,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority static void SDL_ResetLogPrefixes(void); static SDL_LogLevel *SDL_loglevels; -static SDL_bool SDL_forced_priority = SDL_FALSE; +static bool SDL_forced_priority = false; static SDL_LogPriority SDL_forced_priority_level; static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; static void *SDL_log_userdata = NULL; @@ -139,7 +139,7 @@ void SDL_SetLogPriorities(SDL_LogPriority priority) entry->priority = priority; } - SDL_forced_priority = SDL_TRUE; + SDL_forced_priority = true; SDL_forced_priority_level = priority; } @@ -164,30 +164,30 @@ void SDL_SetLogPriority(int category, SDL_LogPriority priority) } } -static SDL_bool SDL_ParseLogCategory(const char *string, size_t length, int *category) +static bool SDL_ParseLogCategory(const char *string, size_t length, int *category) { int i; if (SDL_isdigit(*string)) { *category = SDL_atoi(string); - return SDL_TRUE; + return true; } if (*string == '*') { *category = DEFAULT_CATEGORY; - return SDL_TRUE; + return true; } for (i = 0; i < SDL_arraysize(SDL_category_names); ++i) { if (SDL_strncasecmp(string, SDL_category_names[i], length) == 0) { *category = i; - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority) +static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority) { int i; @@ -196,30 +196,30 @@ static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogP if (i == 0) { // 0 has a special meaning of "disable this category" *priority = SDL_NUM_LOG_PRIORITIES; - return SDL_TRUE; + return true; } if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_NUM_LOG_PRIORITIES) { *priority = (SDL_LogPriority)i; - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } if (SDL_strncasecmp(string, "quiet", length) == 0) { *priority = SDL_NUM_LOG_PRIORITIES; - return SDL_TRUE; + return true; } for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_NUM_LOG_PRIORITIES; ++i) { if (SDL_strncasecmp(string, SDL_priority_names[i], length) == 0) { *priority = (SDL_LogPriority)i; - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority) +static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority) { const char *name, *next; int current_category; @@ -251,7 +251,7 @@ static SDL_bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL } } } - return SDL_FALSE; + return false; } static SDL_LogPriority SDL_GetDefaultLogPriority(int category) @@ -306,7 +306,7 @@ void SDL_ResetLogPriorities(void) SDL_loglevels = entry->next; SDL_free(entry); } - SDL_forced_priority = SDL_FALSE; + SDL_forced_priority = false; } static void SDL_ResetLogPrefixes(void) @@ -533,7 +533,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority char *output; size_t length; LPTSTR tstr; - SDL_bool isstack; + bool isstack; #if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) BOOL attachResult; diff --git a/src/SDL_properties.c b/src/SDL_properties.c index 3fa3169593..bca4824709 100644 --- a/src/SDL_properties.c +++ b/src/SDL_properties.c @@ -33,7 +33,7 @@ typedef struct char *string_value; Sint64 number_value; float float_value; - SDL_bool boolean_value; + bool boolean_value; } value; char *string_storage; @@ -54,7 +54,7 @@ static SDL_PropertiesID SDL_last_properties_id; static SDL_PropertiesID SDL_global_properties; -static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void *data, SDL_bool cleanup) +static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void *data, bool cleanup) { SDL_Property *property = (SDL_Property *)value; if (property) { @@ -78,7 +78,7 @@ static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void static void SDL_FreeProperty(const void *key, const void *value, void *data) { - SDL_FreePropertyWithCleanup(key, value, data, SDL_TRUE); + SDL_FreePropertyWithCleanup(key, value, data, true); } static void SDL_FreeProperties(const void *key, const void *value, void *data) @@ -106,7 +106,7 @@ int SDL_InitProperties(void) } } if (!SDL_properties) { - SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, SDL_FALSE); + SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, SDL_FreeProperties, false); if (!SDL_properties) { return -1; } @@ -142,7 +142,7 @@ SDL_PropertiesID SDL_CreateProperties(void) { SDL_PropertiesID props = 0; SDL_Properties *properties = NULL; - SDL_bool inserted = SDL_FALSE; + bool inserted = false; if (!SDL_properties && SDL_InitProperties() < 0) { return 0; @@ -152,7 +152,7 @@ SDL_PropertiesID SDL_CreateProperties(void) if (!properties) { goto error; } - properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, SDL_FALSE); + properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, false); if (!properties->props) { goto error; } @@ -172,7 +172,7 @@ SDL_PropertiesID SDL_CreateProperties(void) } props = SDL_last_properties_id; if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) { - inserted = SDL_TRUE; + inserted = true; } SDL_UnlockMutex(SDL_properties_lock); @@ -247,7 +247,7 @@ int SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst) dst_property->value.string_value = SDL_strdup(src_property->value.string_value); } if (!SDL_InsertIntoHashTable(dst_properties->props, dst_name, dst_property)) { - SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, SDL_FALSE); + SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, false); result = -1; } } @@ -303,11 +303,11 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_ int result = 0; if (!props) { - SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE); + SDL_FreePropertyWithCleanup(NULL, property, NULL, true); return SDL_InvalidParamError("props"); } if (!name || !*name) { - SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE); + SDL_FreePropertyWithCleanup(NULL, property, NULL, true); return SDL_InvalidParamError("name"); } @@ -316,7 +316,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_ SDL_UnlockMutex(SDL_properties_lock); if (!properties) { - SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_TRUE); + SDL_FreePropertyWithCleanup(NULL, property, NULL, true); return SDL_InvalidParamError("props"); } @@ -326,7 +326,7 @@ static int SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_ if (property) { char *key = SDL_strdup(name); if (!SDL_InsertIntoHashTable(properties->props, key, property)) { - SDL_FreePropertyWithCleanup(key, property, NULL, SDL_TRUE); + SDL_FreePropertyWithCleanup(key, property, NULL, true); result = -1; } } @@ -352,7 +352,7 @@ int SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, if (cleanup) { cleanup(userdata, value); } - SDL_FreePropertyWithCleanup(NULL, property, NULL, SDL_FALSE); + SDL_FreePropertyWithCleanup(NULL, property, NULL, false); return -1; } property->type = SDL_PROPERTY_TYPE_POINTER; @@ -451,7 +451,7 @@ int SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool va return -1; } property->type = SDL_PROPERTY_TYPE_BOOLEAN; - property->value.boolean_value = value ? SDL_TRUE : SDL_FALSE; + property->value.boolean_value = value ? true : false; return SDL_PrivateSetProperty(props, name, property); } @@ -688,7 +688,7 @@ float SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float defau SDL_bool SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool default_value) { SDL_Properties *properties = NULL; - SDL_bool value = default_value; + bool value = default_value ? true : false; if (!props) { return value; @@ -790,7 +790,7 @@ static void SDLCALL SDL_DumpPropertiesCallback(void *userdata, SDL_PropertiesID SDL_Log("%s: %g\n", name, SDL_GetFloatProperty(props, name, 0.0f)); break; case SDL_PROPERTY_TYPE_BOOLEAN: - SDL_Log("%s: %s\n", name, SDL_GetBooleanProperty(props, name, SDL_FALSE) ? "true" : "false"); + SDL_Log("%s: %s\n", name, SDL_GetBooleanProperty(props, name, false) ? "true" : "false"); break; default: SDL_Log("%s UNKNOWN TYPE\n", name); diff --git a/src/SDL_utils.c b/src/SDL_utils.c index 290bc8ecfa..76d0e2da32 100644 --- a/src/SDL_utils.c +++ b/src/SDL_utils.c @@ -92,17 +92,17 @@ void SDL_CalculateFraction(float x, int *numerator, int *denominator) } } -SDL_bool SDL_endswith(const char *string, const char *suffix) +bool SDL_endswith(const char *string, const char *suffix) { size_t string_length = string ? SDL_strlen(string) : 0; size_t suffix_length = suffix ? SDL_strlen(suffix) : 0; if (suffix_length > 0 && suffix_length <= string_length) { if (SDL_memcmp(string + string_length - suffix_length, suffix, suffix_length) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } // Assume we can wrap SDL_AtomicInt values and cast to Uint32 @@ -126,18 +126,18 @@ static Uint32 SDL_HashObject(const void *key, void *unused) return (Uint32)(uintptr_t)key; } -static SDL_bool SDL_KeyMatchObject(const void *a, const void *b, void *unused) +static bool SDL_KeyMatchObject(const void *a, const void *b, void *unused) { return (a == b); } -void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid) +void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid) { SDL_assert(object != NULL); if (valid) { if (!SDL_objects) { - SDL_objects = SDL_CreateHashTable(NULL, 32, SDL_HashObject, SDL_KeyMatchObject, NULL, SDL_FALSE); + SDL_objects = SDL_CreateHashTable(NULL, 32, SDL_HashObject, SDL_KeyMatchObject, NULL, false); } SDL_InsertIntoHashTable(SDL_objects, object, (void *)(uintptr_t)type); @@ -148,15 +148,15 @@ void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid) } } -SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type) +bool SDL_ObjectValid(void *object, SDL_ObjectType type) { if (!object) { - return SDL_FALSE; + return false; } const void *object_type; if (!SDL_FindInHashTable(SDL_objects, object, &object_type)) { - return SDL_FALSE; + return false; } return (((SDL_ObjectType)(uintptr_t)object_type) == type); @@ -277,7 +277,7 @@ int SDL_URIToLocal(const char *src, char *dst) return -1; // wrong scheme } - SDL_bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/'); + bool local = src[0] != '/' || (src[0] != '\0' && src[1] == '/'); // Check the hostname, if present. RFC 3986 states that the hostname component of a URI is not case-sensitive. if (!local && src[0] == '/' && src[2] != '/') { @@ -293,7 +293,7 @@ int SDL_URIToLocal(const char *src, char *dst) hostname_len = SDL_strlen(hostname); if (hostname_len == src_len && SDL_strncasecmp(src + 1, hostname, src_len) == 0) { src = hostname_end + 1; - local = SDL_TRUE; + local = true; } } #endif @@ -303,7 +303,7 @@ int SDL_URIToLocal(const char *src, char *dst) hostname_len = SDL_strlen(localhost); if (hostname_len == src_len && SDL_strncasecmp(src + 1, localhost, src_len) == 0) { src = hostname_end + 1; - local = SDL_TRUE; + local = true; } } } @@ -344,7 +344,7 @@ const char *SDL_GetPersistentString(const char *string) SDL_HashTable *strings = (SDL_HashTable *)SDL_GetTLS(&SDL_string_storage); if (!strings) { - strings = SDL_CreateHashTable(NULL, 32, SDL_HashString, SDL_KeyMatchString, SDL_NukeFreeValue, SDL_FALSE); + strings = SDL_CreateHashTable(NULL, 32, SDL_HashString, SDL_KeyMatchString, SDL_NukeFreeValue, false); if (!strings) { return NULL; } diff --git a/src/SDL_utils_c.h b/src/SDL_utils_c.h index f093adb149..f864794dcf 100644 --- a/src/SDL_utils_c.h +++ b/src/SDL_utils_c.h @@ -30,7 +30,7 @@ extern int SDL_powerof2(int x); extern void SDL_CalculateFraction(float x, int *numerator, int *denominator); -extern SDL_bool SDL_endswith(const char *string, const char *suffix); +extern bool SDL_endswith(const char *string, const char *suffix); /** Convert URI to a local filename, stripping the "file://" * preamble and hostname if present, and writes the result @@ -61,8 +61,8 @@ typedef enum } SDL_ObjectType; extern Uint32 SDL_GetNextObjectID(void); -extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, SDL_bool valid); -extern SDL_bool SDL_ObjectValid(void *object, SDL_ObjectType type); +extern void SDL_SetObjectValid(void *object, SDL_ObjectType type, bool valid); +extern bool SDL_ObjectValid(void *object, SDL_ObjectType type); extern void SDL_SetObjectsInvalid(void); extern const char *SDL_GetPersistentString(const char *string); diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index fd368759c7..4afb963244 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -136,12 +136,12 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval) #elif defined(SDL_PLATFORM_SOLARIS) return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval); #elif defined(EMULATE_CAS) - SDL_bool retval = SDL_FALSE; + bool retval = false; enterLock(a); if (a->value == oldval) { a->value = newval; - retval = SDL_TRUE; + retval = true; } leaveLock(a); @@ -166,12 +166,12 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval) #elif defined(SDL_PLATFORM_SOLARIS) return (atomic_cas_ptr(a, oldval, newval) == oldval); #elif defined(EMULATE_CAS) - SDL_bool retval = SDL_FALSE; + bool retval = false; enterLock(a); if (*a == oldval) { *a = newval; - retval = SDL_TRUE; + retval = true; } leaveLock(a); diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index f119f05fc3..3ca84476b2 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -128,13 +128,13 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0); #elif defined(PS2) uint32_t oldintr; - SDL_bool res = SDL_FALSE; + bool res = false; // disable interuption oldintr = DIntr(); if (*lock == 0) { *lock = 1; - res = SDL_TRUE; + res = true; } // enable interuption if (oldintr) { @@ -153,10 +153,10 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) if (*lock == 0) { *lock = 1; SDL_UnlockMutex(_spinlock_mutex); - return SDL_TRUE; + return true; } else { SDL_UnlockMutex(_spinlock_mutex); - return SDL_FALSE; + return false; } #endif } diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index d2c190d1d4..d4a1dab545 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -112,10 +112,10 @@ int SDL_GetNumAudioDrivers(void) // Build a list of unique audio drivers. for (int i = 0; bootstrap[i] != NULL; ++i) { - SDL_bool duplicate = SDL_FALSE; + bool duplicate = false; for (int j = 0; j < i; ++j) { if (SDL_strcmp(bootstrap[i]->name, bootstrap[j]->name) == 0) { - duplicate = SDL_TRUE; + duplicate = true; break; } } @@ -216,7 +216,7 @@ void OnAudioStreamDestroy(SDL_AudioStream *stream) } // device should be locked when calling this. -static SDL_bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device) +static bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device) { SDL_assert(device != NULL); return ( @@ -240,7 +240,7 @@ static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device) } } } else { - const SDL_bool simple_copy = AudioDeviceCanUseSimpleCopy(device); + const bool simple_copy = AudioDeviceCanUseSimpleCopy(device); SDL_AudioSpec spec; device->simple_copy = simple_copy; @@ -263,14 +263,14 @@ static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device) } } -SDL_bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b) +bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b) { if ((a->format != b->format) || (a->channels != b->channels) || (a->freq != b->freq) || ((channel_map_a != NULL) != (channel_map_b != NULL))) { - return SDL_FALSE; + return false; } else if (channel_map_a && (SDL_memcmp(channel_map_a, channel_map_b, sizeof (*channel_map_a) * a->channels) != 0)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } @@ -330,7 +330,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device); SDL_COMPILE_TIME_ASSERT(check_lowest_audio_default_value, SDL_AUDIO_DEVICE_DEFAULT_RECORDING < SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK); static SDL_AtomicInt last_device_instance_id; // increments on each device add to provide unique instance IDs -static SDL_AudioDeviceID AssignAudioDeviceInstanceId(SDL_bool recording, SDL_bool islogical) +static SDL_AudioDeviceID AssignAudioDeviceInstanceId(bool recording, bool islogical) { /* Assign an instance id! Start at 2, in case there are things from the SDL2 era that still think 1 is a special value. Also, make sure we don't assign SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, etc. */ @@ -374,7 +374,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid, SDL_LogicalAudioDevice *logdev = NULL; // bit #1 of devid is set for physical devices and unset for logical. - const SDL_bool islogical = !(devid & (1<<1)); + const bool islogical = !(devid & (1<<1)); if (islogical) { // don't bother looking if it's not a logical device id value. SDL_LockRWLockForReading(current_audio.device_hash_lock); SDL_FindInHashTable(current_audio.device_hash, (const void *) (uintptr_t) devid, (const void **) &logdev); @@ -388,7 +388,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid, if (logdev) { // we have to release the device_hash_lock before we take the device lock, to avoid deadlocks, so do a loop // to make sure the correct physical device gets locked, in case we're in a race with the default changing. - while (SDL_TRUE) { + while (true) { SDL_LockMutex(device->lock); SDL_AudioDevice *recheck_device = (SDL_AudioDevice *) SDL_AtomicGetPtr((void **) &logdev->physical_device); if (device == recheck_device) { @@ -420,7 +420,7 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid) // ! SDL_AudioDevice *device = NULL; // bit #1 of devid is set for physical devices and unset for logical. - const SDL_bool islogical = !(devid & (1<<1)); + const bool islogical = !(devid & (1<<1)); if (islogical) { ObtainLogicalAudioDevice(devid, &device); } else if (!SDL_GetCurrentAudioDriver()) { // (the `islogical` path, above, checks this in ObtainLogicalAudioDevice.) @@ -442,14 +442,14 @@ static SDL_AudioDevice *ObtainPhysicalAudioDevice(SDL_AudioDeviceID devid) // ! static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceID devid) // !!! FIXME: SDL_ACQUIRE { - const SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING)); + const bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING)); if (!wants_default) { return ObtainPhysicalAudioDevice(devid); } const SDL_AudioDeviceID orig_devid = devid; - while (SDL_TRUE) { + while (true) { SDL_LockRWLockForReading(current_audio.device_hash_lock); if (orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) { devid = current_audio.default_playback_device_id; @@ -469,12 +469,12 @@ static SDL_AudioDevice *ObtainPhysicalAudioDeviceDefaultAllowed(SDL_AudioDeviceI } // make sure the default didn't change while we were waiting for the lock... - SDL_bool got_it = SDL_FALSE; + bool got_it = false; SDL_LockRWLockForReading(current_audio.device_hash_lock); if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) && (devid == current_audio.default_playback_device_id)) { - got_it = SDL_TRUE; + got_it = true; } else if ((orig_devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING) && (devid == current_audio.default_recording_device_id)) { - got_it = SDL_TRUE; + got_it = true; } SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -571,7 +571,7 @@ void RefPhysicalAudioDevice(SDL_AudioDevice *device) SDL_AtomicIncRef(&device->refcount); } -static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool recording, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count) +static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, bool recording, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count) { SDL_assert(name != NULL); @@ -617,7 +617,7 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool rec device->silence_value = SDL_GetSilenceValueForFormat(device->spec.format); device->handle = handle; - device->instance_id = AssignAudioDeviceInstanceId(recording, /*islogical=*/SDL_FALSE); + device->instance_id = AssignAudioDeviceInstanceId(recording, /*islogical=*/false); SDL_LockRWLockForWriting(current_audio.device_hash_lock); if (SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id, device)) { @@ -638,16 +638,16 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool rec static SDL_AudioDevice *CreateAudioRecordingDevice(const char *name, const SDL_AudioSpec *spec, void *handle) { SDL_assert(current_audio.impl.HasRecordingSupport); - return CreatePhysicalAudioDevice(name, SDL_TRUE, spec, handle, ¤t_audio.recording_device_count); + return CreatePhysicalAudioDevice(name, true, spec, handle, ¤t_audio.recording_device_count); } static SDL_AudioDevice *CreateAudioPlaybackDevice(const char *name, const SDL_AudioSpec *spec, void *handle) { - return CreatePhysicalAudioDevice(name, SDL_FALSE, spec, handle, ¤t_audio.playback_device_count); + return CreatePhysicalAudioDevice(name, false, spec, handle, ¤t_audio.playback_device_count); } // The audio backends call this when a new device is plugged in. -SDL_AudioDevice *SDL_AddAudioDevice(SDL_bool recording, const char *name, const SDL_AudioSpec *inspec, void *handle) +SDL_AudioDevice *SDL_AddAudioDevice(bool recording, const char *name, const SDL_AudioSpec *inspec, void *handle) { // device handles MUST be unique! If the target reuses the same handle for hardware with both recording and playback interfaces, wrap it in a pointer you SDL_malloc'd! SDL_assert(SDL_FindPhysicalAudioDeviceByHandle(handle) == NULL); @@ -708,10 +708,10 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device) SDL_LockRWLockForReading(current_audio.device_hash_lock); const SDL_AudioDeviceID devid = device->instance_id; - const SDL_bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id)); + const bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id)); SDL_UnlockRWLock(current_audio.device_hash_lock); - const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1); + const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1); if (first_disconnect) { // if already disconnected this device, don't do it twice. // Swap in "Zombie" versions of the usual platform interfaces, so the device will keep // making progress until the app closes it. Otherwise, streams might continue to @@ -790,9 +790,9 @@ static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_playback, S SDL_assert(current_audio.impl.OnlyHasDefaultPlaybackDevice); SDL_assert(current_audio.impl.OnlyHasDefaultRecordingDevice || !current_audio.impl.HasRecordingSupport); - *default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)((size_t)0x1)); + *default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)((size_t)0x1)); if (current_audio.impl.HasRecordingSupport) { - *default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)((size_t)0x2)); + *default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)((size_t)0x2)); } } @@ -833,7 +833,7 @@ static void CompleteAudioEntryPoints(void) #undef FILL_STUB } -static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool recording) +static SDL_AudioDevice *GetFirstAddedAudioDevice(const bool recording) { SDL_AudioDeviceID highest = (SDL_AudioDeviceID) SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK; // According to AssignAudioDeviceInstanceId, nothing can have a value this large. SDL_AudioDevice *retval = NULL; @@ -848,8 +848,8 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool recording) const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key; // bit #0 of devid is set for playback devices and unset for recording. // bit #1 of devid is set for physical devices and unset for logical. - const SDL_bool devid_recording = !(devid & (1 << 0)); - const SDL_bool isphysical = (devid & (1 << 1)); + const bool devid_recording = !(devid & (1 << 0)); + const bool isphysical = (devid & (1 << 1)); if (isphysical && (devid_recording == recording) && (devid < highest)) { highest = devid; retval = (SDL_AudioDevice *) value; @@ -867,7 +867,7 @@ static Uint32 HashAudioDeviceID(const void *key, void *data) return ((Uint32) ((uintptr_t) key)) >> 2; } -static SDL_bool MatchAudioDeviceID(const void *a, const void *b, void *data) +static bool MatchAudioDeviceID(const void *a, const void *b, void *data) { return (a == b); } @@ -895,7 +895,7 @@ int SDL_InitAudio(const char *driver_name) return -1; } - SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashAudioDeviceID, MatchAudioDeviceID, NukeAudioDeviceHashItem, SDL_FALSE); + SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashAudioDeviceID, MatchAudioDeviceID, NukeAudioDeviceHashItem, false); if (!device_hash) { SDL_DestroyRWLock(device_hash_lock); return -1; @@ -906,8 +906,8 @@ int SDL_InitAudio(const char *driver_name) driver_name = SDL_GetHint(SDL_HINT_AUDIO_DRIVER); } - SDL_bool initialized = SDL_FALSE; - SDL_bool tried_to_init = SDL_FALSE; + bool initialized = false; + bool tried_to_init = false; if (driver_name && *driver_name != 0) { char *driver_name_copy = SDL_strdup(driver_name); @@ -934,7 +934,7 @@ int SDL_InitAudio(const char *driver_name) for (int i = 0; bootstrap[i]; ++i) { if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) { - tried_to_init = SDL_TRUE; + tried_to_init = true; SDL_zero(current_audio); current_audio.pending_events_tail = ¤t_audio.pending_events; current_audio.device_hash_lock = device_hash_lock; @@ -942,7 +942,7 @@ int SDL_InitAudio(const char *driver_name) if (bootstrap[i]->init(¤t_audio.impl)) { current_audio.name = bootstrap[i]->name; current_audio.desc = bootstrap[i]->desc; - initialized = SDL_TRUE; + initialized = true; break; } } @@ -958,7 +958,7 @@ int SDL_InitAudio(const char *driver_name) continue; } - tried_to_init = SDL_TRUE; + tried_to_init = true; SDL_zero(current_audio); current_audio.pending_events_tail = ¤t_audio.pending_events; current_audio.device_hash_lock = device_hash_lock; @@ -966,7 +966,7 @@ int SDL_InitAudio(const char *driver_name) if (bootstrap[i]->init(¤t_audio.impl)) { current_audio.name = bootstrap[i]->name; current_audio.desc = bootstrap[i]->desc; - initialized = SDL_TRUE; + initialized = true; } } } @@ -996,11 +996,11 @@ int SDL_InitAudio(const char *driver_name) // If no default was _ever_ specified, just take the first device we see, if any. if (!default_playback) { - default_playback = GetFirstAddedAudioDevice(/*recording=*/SDL_FALSE); + default_playback = GetFirstAddedAudioDevice(/*recording=*/false); } if (!default_recording) { - default_recording = GetFirstAddedAudioDevice(/*recording=*/SDL_TRUE); + default_recording = GetFirstAddedAudioDevice(/*recording=*/true); } if (default_playback) { @@ -1051,7 +1051,7 @@ void SDL_QuitAudio(void) while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) { // bit #1 of devid is set for physical devices and unset for logical. const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key; - const SDL_bool isphysical = (devid & (1<<1)); + const bool isphysical = (devid & (1<<1)); if (isphysical) { DestroyPhysicalAudioDevice((SDL_AudioDevice *) value); } @@ -1087,7 +1087,7 @@ void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device) current_audio.impl.ThreadInit(device); } -SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) +bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) { SDL_assert(!device->recording); @@ -1095,16 +1095,16 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) if (SDL_AtomicGet(&device->shutdown)) { SDL_UnlockMutex(device->lock); - return SDL_FALSE; // we're done, shut it down. + return false; // we're done, shut it down. } - SDL_bool failed = SDL_FALSE; + bool failed = false; int buffer_size = device->buffer_size; Uint8 *device_buffer = device->GetDeviceBuf(device, &buffer_size); if (buffer_size == 0) { // WASAPI (maybe others, later) does this to say "just abandon this iteration and try again next time." } else if (!device_buffer) { - failed = SDL_TRUE; + failed = true; } else { SDL_assert(buffer_size <= device->buffer_size); // you can ask for less, but not more. SDL_assert(AudioDeviceCanUseSimpleCopy(device) == device->simple_copy); // make sure this hasn't gotten out of sync. @@ -1119,7 +1119,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) const int br = SDL_AtomicGet(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain); if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow. - failed = SDL_TRUE; + failed = true; SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die. } else if (br < buffer_size) { SDL_memset(device_buffer + br, device->silence_value, buffer_size - br); // silence whatever we didn't write to. @@ -1159,7 +1159,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) the same stream to different devices at the same time, though.) */ const int br = SDL_GetAudioStreamDataAdjustGain(stream, device->work_buffer, work_buffer_size, logdev->gain); if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow. - failed = SDL_TRUE; + failed = true; break; } else if (br > 0) { // it's okay if we get less than requested, we mix what we have. MixFloat32Audio(mix_buffer, (float *) device->work_buffer, br); @@ -1183,7 +1183,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) // PlayDevice SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitDevice instead! if (device->PlayDevice(device, device_buffer, buffer_size) < 0) { - failed = SDL_TRUE; + failed = true; } } @@ -1193,7 +1193,7 @@ SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device) SDL_AudioDeviceDisconnected(device); // doh. } - return SDL_TRUE; // always go on if not shutting down, even if device failed. + return true; // always go on if not shutting down, even if device failed. } void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device) @@ -1235,7 +1235,7 @@ void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device) current_audio.impl.ThreadInit(device); } -SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) +bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) { SDL_assert(device->recording); @@ -1243,10 +1243,10 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) if (SDL_AtomicGet(&device->shutdown)) { SDL_UnlockMutex(device->lock); - return SDL_FALSE; // we're done, shut it down. + return false; // we're done, shut it down. } - SDL_bool failed = SDL_FALSE; + bool failed = false; if (!device->logical_devices) { device->FlushRecording(device); // nothing wants data, dump anything pending. @@ -1254,7 +1254,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) // this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitRecordingDevice! int br = device->RecordDevice(device, device->work_buffer, device->buffer_size); if (br < 0) { // uhoh, device failed for some reason! - failed = SDL_TRUE; + failed = true; } else if (br > 0) { // queue the new data to each bound stream. for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { if (SDL_AtomicGet(&logdev->paused)) { @@ -1290,7 +1290,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) the same stream to different devices at the same time, though.) */ if (SDL_PutAudioStreamData(stream, output_buffer, br) < 0) { // oh crud, we probably ran out of memory. This is possibly an overreaction to kill the audio device, but it's likely the whole thing is going down in a moment anyhow. - failed = SDL_TRUE; + failed = true; break; } } @@ -1304,7 +1304,7 @@ SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device) SDL_AudioDeviceDisconnected(device); // doh. } - return SDL_TRUE; // always go on if not shutting down, even if device failed. + return true; // always go on if not shutting down, even if device failed. } void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device) @@ -1333,7 +1333,7 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point } -static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording) +static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording) { SDL_AudioDeviceID *retval = NULL; int num_devices = 0; @@ -1352,8 +1352,8 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording) const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key; // bit #0 of devid is set for playback devices and unset for recording. // bit #1 of devid is set for physical devices and unset for logical. - const SDL_bool devid_recording = !(devid & (1<<0)); - const SDL_bool isphysical = (devid & (1<<1)); + const bool devid_recording = !(devid & (1<<0)); + const bool isphysical = (devid & (1<<1)); if (isphysical && (devid_recording == recording)) { SDL_assert(devs_seen < num_devices); retval[devs_seen++] = devid; @@ -1381,16 +1381,16 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, SDL_bool recording) SDL_AudioDeviceID *SDL_GetAudioPlaybackDevices(int *count) { - return GetAudioDevices(count, SDL_FALSE); + return GetAudioDevices(count, false); } SDL_AudioDeviceID *SDL_GetAudioRecordingDevices(int *count) { - return GetAudioDevices(count, SDL_TRUE); + return GetAudioDevices(count, true); } -SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata) +SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata) { if (!SDL_GetCurrentAudioDriver()) { SDL_SetError("Audio subsystem is not initialized"); @@ -1405,7 +1405,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_ while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) { const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key; // bit #1 of devid is set for physical devices and unset for logical. - const SDL_bool isphysical = (devid & (1<<1)); + const bool isphysical = (devid & (1<<1)); if (isphysical) { SDL_AudioDevice *device = (SDL_AudioDevice *) value; if (callback(device, userdata)) { // found it? @@ -1420,7 +1420,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_ return NULL; } -static SDL_bool TestDeviceHandleCallback(SDL_AudioDevice *device, void *handle) +static bool TestDeviceHandleCallback(SDL_AudioDevice *device, void *handle) { return device->handle == handle; } @@ -1511,7 +1511,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device) if (device->currently_opened) { current_audio.impl.CloseDevice(device); // if ProvidesOwnCallbackThread, this must join on any existing device thread before returning! - device->currently_opened = SDL_FALSE; + device->currently_opened = false; device->hidden = NULL; // just in case. } @@ -1572,7 +1572,7 @@ static SDL_AudioFormat ParseAudioFormatString(const char *string) return 0; } -static void PrepareAudioFormat(SDL_bool recording, SDL_AudioSpec *spec) +static void PrepareAudioFormat(bool recording, SDL_AudioSpec *spec) { if (spec->freq == 0) { spec->freq = recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY; @@ -1655,7 +1655,7 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec device->sample_frames = GetDefaultSampleFramesFromFreq(device->spec.freq); SDL_UpdatedAudioDeviceFormat(device); // start this off sane. - device->currently_opened = SDL_TRUE; // mark this true even if impl.OpenDevice fails, so we know to clean up. + device->currently_opened = true; // mark this true even if impl.OpenDevice fails, so we know to clean up. if (current_audio.impl.OpenDevice(device) < 0) { ClosePhysicalAudioDevice(device); // clean up anything the backend left half-initialized. return -1; @@ -1700,11 +1700,11 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp return 0; } - SDL_bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING)); + bool wants_default = ((devid == SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK) || (devid == SDL_AUDIO_DEVICE_DEFAULT_RECORDING)); // this will let you use a logical device to make a new logical device on the parent physical device. Could be useful? SDL_AudioDevice *device = NULL; - const SDL_bool islogical = (!wants_default && !(devid & (1<<1))); + const bool islogical = (!wants_default && !(devid & (1<<1))); if (!islogical) { device = ObtainPhysicalAudioDeviceDefaultAllowed(devid); } else { @@ -1728,7 +1728,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp } else { RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice SDL_AtomicSet(&logdev->paused, 0); - retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/SDL_TRUE); + retval = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/true); logdev->physical_device = device; logdev->gain = 1.0f; logdev->opened_as_default = wants_default; @@ -1743,7 +1743,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp if (retval) { SDL_LockRWLockForWriting(current_audio.device_hash_lock); - const SDL_bool inserted = SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) retval, logdev); + const bool inserted = SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) retval, logdev); SDL_UnlockRWLock(current_audio.device_hash_lock); if (!inserted) { SDL_CloseAudioDevice(retval); @@ -1780,9 +1780,9 @@ SDL_bool SDL_AudioDevicePaused(SDL_AudioDeviceID devid) { SDL_AudioDevice *device = NULL; SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device); - SDL_bool retval = SDL_FALSE; + bool retval = false; if (logdev && SDL_AtomicGet(&logdev->paused)) { - retval = SDL_TRUE; + retval = true; } ReleaseAudioDevice(device); return retval; @@ -1809,7 +1809,7 @@ int SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain) if (logdev) { logdev->gain = gain; if (device->recording) { - const SDL_bool need_float32 = (logdev->postmix || logdev->gain != 1.0f); + const bool need_float32 = (logdev->postmix || logdev->gain != 1.0f); for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // set the proper end of the stream to the device's format. // SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec. @@ -1844,7 +1844,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac logdev->postmix_userdata = userdata; if (device->recording) { - const SDL_bool need_float32 = (callback || logdev->gain != 1.0f); + const bool need_float32 = (callback || logdev->gain != 1.0f); for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // set the proper end of the stream to the device's format. // SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec. @@ -1863,7 +1863,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams) { - const SDL_bool islogical = !(devid & (1<<1)); + const bool islogical = !(devid & (1<<1)); SDL_AudioDevice *device = NULL; SDL_LogicalAudioDevice *logdev = NULL; int retval = 0; @@ -1922,7 +1922,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int if (retval == 0) { // Now that everything is verified, chain everything together. - const SDL_bool recording = device->recording; + const bool recording = device->recording; for (int i = 0; i < num_streams; i++) { SDL_AudioStream *stream = streams[i]; if (stream) { // shouldn't be NULL, but just in case... @@ -1971,7 +1971,7 @@ void SDL_UnbindAudioStreams(SDL_AudioStream **streams, int num_streams) continue; // nothing to do, it's a NULL stream. } - while (SDL_TRUE) { + while (true) { SDL_LockMutex(stream->lock); // lock to check this and then release it, in case the device isn't locked yet. SDL_LogicalAudioDevice *bounddev = stream->bound_device; SDL_UnlockMutex(stream->lock); @@ -2059,17 +2059,17 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au return NULL; // error string should already be set. } - SDL_bool failed = SDL_FALSE; + bool failed = false; SDL_AudioStream *stream = NULL; SDL_AudioDevice *device = NULL; SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(logdevid, &device); if (!logdev) { // this shouldn't happen, but just in case. - failed = SDL_TRUE; + failed = true; } else { SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2. SDL_assert(device != NULL); - const SDL_bool recording = device->recording; + const bool recording = device->recording; // if the app didn't request a format _at all_, just make a stream that does no conversion; they can query for it later. SDL_AudioSpec tmpspec; @@ -2085,14 +2085,14 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au } if (!stream) { - failed = SDL_TRUE; + failed = true; } else { // don't do all the complicated validation and locking of SDL_BindAudioStream just to set a few fields here. logdev->bound_streams = stream; - logdev->simplified = SDL_TRUE; // forbid further binding changes on this logical device. + logdev->simplified = true; // forbid further binding changes on this logical device. stream->bound_device = logdev; - stream->simplified = SDL_TRUE; // so we know to close the audio device when this is destroyed. + stream->simplified = true; // so we know to close the audio device when this is destroyed. UpdateAudioStreamFormatsPhysical(device); @@ -2204,12 +2204,12 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) return; // uhoh. } - const SDL_bool recording = new_default_device->recording; + const bool recording = new_default_device->recording; // change the official default over right away, so new opens will go to the new device. SDL_LockRWLockForWriting(current_audio.device_hash_lock); const SDL_AudioDeviceID current_devid = recording ? current_audio.default_recording_device_id : current_audio.default_playback_device_id; - const SDL_bool is_already_default = (new_default_device->instance_id == current_devid); + const bool is_already_default = (new_default_device->instance_id == current_devid); if (!is_already_default) { if (recording) { current_audio.default_recording_device_id = new_default_device->instance_id; @@ -2244,12 +2244,12 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) // See if we have to open the new physical device, and if so, find the best audiospec for it. SDL_AudioSpec spec; - SDL_bool needs_migration = SDL_FALSE; + bool needs_migration = false; SDL_zero(spec); for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = logdev->next) { if (logdev->opened_as_default) { - needs_migration = SDL_TRUE; + needs_migration = true; for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { const SDL_AudioSpec *streamspec = recording ? &stream->dst_spec : &stream->src_spec; if (SDL_AUDIO_BITSIZE(streamspec->format) > SDL_AUDIO_BITSIZE(spec.format)) { @@ -2268,13 +2268,13 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) if (needs_migration) { // New default physical device not been opened yet? Open at the OS level... if (OpenPhysicalAudioDevice(new_default_device, &spec) < 0) { - needs_migration = SDL_FALSE; // uhoh, just leave everything on the old default, nothing to be done. + needs_migration = false; // uhoh, just leave everything on the old default, nothing to be done. } } if (needs_migration) { // we don't currently report channel map changes, so we'll leave them as NULL for now. - const SDL_bool spec_changed = !SDL_AudioSpecsEqual(¤t_default_device->spec, &new_default_device->spec, NULL, NULL); + const bool spec_changed = !SDL_AudioSpecsEqual(¤t_default_device->spec, &new_default_device->spec, NULL, NULL); SDL_LogicalAudioDevice *next = NULL; for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = next) { next = logdev->next; @@ -2362,7 +2362,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL SDL_copyp(&device->spec, newspec); UpdateAudioStreamFormatsPhysical(device); - SDL_bool kill_device = SDL_FALSE; + bool kill_device = false; device->sample_frames = new_sample_frames; SDL_UpdatedAudioDeviceFormat(device); @@ -2370,14 +2370,14 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL SDL_aligned_free(device->work_buffer); device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->work_buffer) { - kill_device = SDL_TRUE; + kill_device = true; } if (device->postmix_buffer) { SDL_aligned_free(device->postmix_buffer); device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->postmix_buffer) { - kill_device = SDL_TRUE; + kill_device = true; } } @@ -2386,7 +2386,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL if (device->spec.format != SDL_AUDIO_F32) { device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->mix_buffer) { - kill_device = SDL_TRUE; + kill_device = true; } } } diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 622d63149f..ecd9b2971f 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -99,7 +99,7 @@ static void SDL_TARGETING("sse") SDL_ConvertMonoToStereo_SSE(float *dst, const f // Include the autogenerated channel converters... #include "SDL_audio_channel_converters.h" -static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt) +static bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt) { switch (fmt) { case SDL_AUDIO_U8: @@ -110,43 +110,43 @@ static SDL_bool SDL_IsSupportedAudioFormat(const SDL_AudioFormat fmt) case SDL_AUDIO_S32BE: case SDL_AUDIO_F32LE: case SDL_AUDIO_F32BE: - return SDL_TRUE; // supported. + return true; // supported. default: break; } - return SDL_FALSE; // unsupported. + return false; // unsupported. } -static SDL_bool SDL_IsSupportedChannelCount(const int channels) +static bool SDL_IsSupportedChannelCount(const int channels) { return ((channels >= 1) && (channels <= 8)); } -SDL_bool SDL_ChannelMapIsBogus(const int *chmap, int channels) +bool SDL_ChannelMapIsBogus(const int *chmap, int channels) { if (chmap) { for (int i = 0; i < channels; i++) { const int mapping = chmap[i]; if ((mapping < 0) || (mapping >= channels)) { - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } -SDL_bool SDL_ChannelMapIsDefault(const int *chmap, int channels) +bool SDL_ChannelMapIsDefault(const int *chmap, int channels) { if (chmap) { for (int i = 0; i < channels; i++) { if (chmap[i] != i) { - return SDL_FALSE; + return false; } } } - return SDL_TRUE; + return true; } // Swizzle audio channels. src and dst can be the same pointer. It does not change the buffer size. @@ -162,7 +162,7 @@ static void SwizzleAudio(const int num_frames, void *dst, const void *src, int c } \ } \ } else { \ - SDL_bool isstack; \ + bool isstack; \ Uint##bits *tmp = (Uint##bits *) SDL_small_alloc(int, channels, &isstack); /* !!! FIXME: allocate this when setting the channel map instead. */ \ if (tmp) { \ for (int i = 0; i < num_frames; i++, tsrc += channels, tdst += channels) { \ @@ -276,9 +276,9 @@ void ConvertAudio(int num_frames, scratch = dst; } - const SDL_bool srcconvert = src_format != SDL_AUDIO_F32; - const SDL_bool channelconvert = src_channels != dst_channels; - const SDL_bool dstconvert = dst_format != SDL_AUDIO_F32; + const bool srcconvert = src_format != SDL_AUDIO_F32; + const bool channelconvert = src_channels != dst_channels; + const bool dstconvert = dst_format != SDL_AUDIO_F32; // get us to float format. if (srcconvert) { @@ -628,12 +628,12 @@ int SetAudioStreamChannelMap(SDL_AudioStream *stream, const SDL_AudioSpec *spec, int SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels) { - return SetAudioStreamChannelMap(stream, &stream->src_spec, &stream->src_chmap, chmap, channels, SDL_TRUE); + return SetAudioStreamChannelMap(stream, &stream->src_spec, &stream->src_chmap, chmap, channels, true); } int SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int channels) { - return SetAudioStreamChannelMap(stream, &stream->dst_spec, &stream->dst_chmap, chmap, channels, SDL_FALSE); + return SetAudioStreamChannelMap(stream, &stream->dst_spec, &stream->dst_chmap, chmap, channels, false); } int *SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count) @@ -876,10 +876,10 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne } static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter, - Sint64* inout_resample_offset, SDL_AudioSpec* out_spec, int **out_chmap, SDL_bool* out_flushed) + Sint64* inout_resample_offset, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed) { SDL_AudioSpec spec; - SDL_bool flushed; + bool flushed; int *chmap; size_t queued_bytes = SDL_NextAudioQueueIter(stream->queue, inout_iter, &spec, &chmap, &flushed); @@ -896,7 +896,7 @@ static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter, *inout_resample_offset = 0; if (out_flushed) { - *out_flushed = SDL_FALSE; + *out_flushed = false; } return SDL_MAX_SINT32; @@ -954,13 +954,13 @@ static Sint64 GetAudioStreamAvailableFrames(SDL_AudioStream* stream, Sint64* out return output_frames; } -static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spec, int **out_chmap, SDL_bool* out_flushed) +static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed) { void* iter = SDL_BeginAudioQueueIter(stream->queue); if (!iter) { SDL_zerop(out_spec); - *out_flushed = SDL_FALSE; + *out_flushed = false; return 0; } @@ -1161,7 +1161,7 @@ int SDL_GetAudioStreamDataAdjustGain(SDL_AudioStream *stream, void *voidbuf, int // Audio is processed a track at a time. SDL_AudioSpec input_spec; int *input_chmap; - SDL_bool flushed; + bool flushed; const Sint64 available_frames = GetAudioStreamHead(stream, &input_spec, &input_chmap, &flushed); if (available_frames == 0) { @@ -1278,7 +1278,7 @@ void SDL_DestroyAudioStream(SDL_AudioStream *stream) OnAudioStreamDestroy(stream); - const SDL_bool simplified = stream->simplified; + const bool simplified = stream->simplified; if (simplified) { if (stream->bound_device) { SDL_assert(stream->bound_device->simplified); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index d30f71c215..f48a5b25d0 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -45,13 +45,13 @@ #define SDL_PATH_DEV_AUDIO "/dev/audio" #endif -static void test_device(const SDL_bool recording, const char *fname, int flags, SDL_bool (*test)(int fd)) +static void test_device(const bool recording, const char *fname, int flags, bool (*test)(int fd)) { struct stat sb; const int audio_fd = open(fname, flags | O_CLOEXEC, 0); if (audio_fd >= 0) { if ((fstat(audio_fd, &sb) == 0) && (S_ISCHR(sb.st_mode))) { - const SDL_bool okay = test(audio_fd); + const bool okay = test(audio_fd); close(audio_fd); if (okay) { static size_t dummyhandle = 0; @@ -71,12 +71,12 @@ static void test_device(const SDL_bool recording, const char *fname, int flags, } } -static SDL_bool test_stub(int fd) +static bool test_stub(int fd) { - return SDL_TRUE; + return true; } -static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool recording, const SDL_bool classic, SDL_bool (*test)(int)) +static void SDL_EnumUnixAudioDevices_Internal(const bool recording, const bool classic, bool (*test)(int)) { const int flags = recording ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT; const char *audiodev; @@ -115,10 +115,10 @@ static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool recording, const SD } } -void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int)) +void SDL_EnumUnixAudioDevices(const bool classic, bool (*test)(int)) { - SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test); - SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test); + SDL_EnumUnixAudioDevices_Internal(true, classic, test); + SDL_EnumUnixAudioDevices_Internal(false, classic, test); } #endif // Audio device selection diff --git a/src/audio/SDL_audiodev_c.h b/src/audio/SDL_audiodev_c.h index 8ea867c25e..8f34448036 100644 --- a/src/audio/SDL_audiodev_c.h +++ b/src/audio/SDL_audiodev_c.h @@ -36,6 +36,6 @@ #define OPEN_FLAGS_INPUT (O_RDONLY | O_NONBLOCK) #endif -extern void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int)); +extern void SDL_EnumUnixAudioDevices(const bool classic, bool (*test)(int)); #endif // SDL_audiodev_c_h_ diff --git a/src/audio/SDL_audioqueue.c b/src/audio/SDL_audioqueue.c index 29b4077930..42fd74c983 100644 --- a/src/audio/SDL_audioqueue.c +++ b/src/audio/SDL_audioqueue.c @@ -37,7 +37,7 @@ struct SDL_AudioTrack { SDL_AudioSpec spec; int *chmap; - SDL_bool flushed; + bool flushed; SDL_AudioTrack *next; void *userdata; @@ -192,7 +192,7 @@ void SDL_ClearAudioQueue(SDL_AudioQueue *queue) static void FlushAudioTrack(SDL_AudioTrack *track) { - track->flushed = SDL_TRUE; + track->flushed = true; } void SDL_FlushAudioQueue(SDL_AudioQueue *queue) @@ -209,7 +209,7 @@ void SDL_PopAudioQueueHead(SDL_AudioQueue *queue) SDL_AudioTrack *track = queue->head; for (;;) { - SDL_bool flushed = track->flushed; + bool flushed = track->flushed; SDL_AudioTrack *next = track->next; DestroyAudioTrack(queue, track); @@ -370,7 +370,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue) return queue->head; } -size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, SDL_bool *out_flushed) +size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed) { SDL_AudioTrack *iter = (SDL_AudioTrack *)(*inout_iter); SDL_assert(iter != NULL); @@ -378,7 +378,7 @@ size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_Audi SDL_copyp(out_spec, &iter->spec); *out_chmap = iter->chmap; - SDL_bool flushed = SDL_FALSE; + bool flushed = false; size_t queued_bytes = 0; while (iter) { @@ -389,7 +389,7 @@ size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_Audi if (avail >= SDL_SIZE_MAX - queued_bytes) { queued_bytes = SDL_SIZE_MAX; - flushed = SDL_FALSE; + flushed = false; break; } @@ -548,7 +548,7 @@ const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue, size_t dst_present_bytes = present_frames * dst_frame_size; size_t dst_future_bytes = future_frames * dst_frame_size; - SDL_bool convert = (src_format != dst_format) || (src_channels != dst_channels); + bool convert = (src_format != dst_format) || (src_channels != dst_channels); if (convert && !dst) { // The user didn't ask for the data to be copied, but we need to convert it, so store it in the scratch buffer @@ -609,7 +609,7 @@ size_t SDL_GetAudioQueueQueued(SDL_AudioQueue *queue) while (iter) { SDL_AudioSpec src_spec; int *src_chmap; - SDL_bool flushed; + bool flushed; size_t avail = SDL_NextAudioQueueIter(queue, &iter, &src_spec, &src_chmap, &flushed); diff --git a/src/audio/SDL_audioqueue.h b/src/audio/SDL_audioqueue.h index 88d6972f1b..2880b22c7c 100644 --- a/src/audio/SDL_audioqueue.h +++ b/src/audio/SDL_audioqueue.h @@ -64,7 +64,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue); // Query and update the track iterator // REQUIRES: `*inout_iter != NULL` (a valid iterator) -size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, SDL_bool *out_flushed); +size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed); const Uint8 *SDL_ReadFromAudioQueue(SDL_AudioQueue *queue, Uint8 *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map, diff --git a/src/audio/SDL_audioresample.c b/src/audio/SDL_audioresample.c index 968ccd2e87..98cf399fb4 100644 --- a/src/audio/SDL_audioresample.c +++ b/src/audio/SDL_audioresample.c @@ -533,7 +533,7 @@ static void Transpose4x4(Cubic *data) static void SetupAudioResampler(void) { int i, j; - SDL_bool transpose = SDL_FALSE; + bool transpose = false; GenerateResamplerFilter(); @@ -542,7 +542,7 @@ static void SetupAudioResampler(void) for (i = 0; i < 8; ++i) { ResampleFrame[i] = ResampleFrame_Generic_SSE; } - transpose = SDL_TRUE; + transpose = true; } else #endif #ifdef SDL_NEON_INTRINSICS @@ -550,7 +550,7 @@ static void SetupAudioResampler(void) for (i = 0; i < 8; ++i) { ResampleFrame[i] = ResampleFrame_Generic_NEON; } - transpose = SDL_TRUE; + transpose = true; } else #endif { diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index 0478d86d7d..a2978ee1c6 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -870,7 +870,7 @@ void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bit void SDL_ChooseAudioConverters(void) { - static SDL_bool converters_chosen = SDL_FALSE; + static bool converters_chosen = false; if (converters_chosen) { return; } @@ -921,5 +921,5 @@ void SDL_ChooseAudioConverters(void) #undef SET_CONVERTER_FUNCS - converters_chosen = SDL_TRUE; + converters_chosen = true; } diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 4f6c189178..5a66440bf6 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -69,7 +69,7 @@ extern void SDL_SetupAudioResampler(void); /* Backends should call this as devices are added to the system (such as a USB headset being plugged in), and should also be called for for every device found during DetectDevices(). */ -extern SDL_AudioDevice *SDL_AddAudioDevice(SDL_bool recording, const char *name, const SDL_AudioSpec *spec, void *handle); +extern SDL_AudioDevice *SDL_AddAudioDevice(bool recording, const char *name, const SDL_AudioSpec *spec, void *handle); /* Backends should call this if an opened audio device is lost. This can happen due to i/o errors, or a device being unplugged, etc. */ @@ -88,7 +88,7 @@ extern int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, co extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByHandle(void *handle); // Find an SDL_AudioDevice, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE. -extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(SDL_bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata); +extern SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(bool (*callback)(SDL_AudioDevice *device, void *userdata), void *userdata); // Backends should call this if they change the device format, channels, freq, or sample_frames to keep other state correct. extern void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device); @@ -102,10 +102,10 @@ extern void UnrefPhysicalAudioDevice(SDL_AudioDevice *device); // These functions are the heart of the audio threads. Backends can call them directly if they aren't using the SDL-provided thread. extern void SDL_PlaybackAudioThreadSetup(SDL_AudioDevice *device); -extern SDL_bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device); +extern bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device); extern void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device); extern void SDL_RecordingAudioThreadSetup(SDL_AudioDevice *device); -extern SDL_bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device); +extern bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device); extern void SDL_RecordingAudioThreadShutdown(SDL_AudioDevice *device); extern void SDL_AudioThreadFinalize(SDL_AudioDevice *device); @@ -113,8 +113,8 @@ extern void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SD extern void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_AudioFormat dst_fmt); extern void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bitsize); -extern SDL_bool SDL_ChannelMapIsDefault(const int *map, int channels); -extern SDL_bool SDL_ChannelMapIsBogus(const int *map, int channels); +extern bool SDL_ChannelMapIsDefault(const int *map, int channels); +extern bool SDL_ChannelMapIsBogus(const int *map, int channels); // this gets used from the audio device threads. It has rules, don't use this if you don't know how to use it! extern void ConvertAudio(int num_frames, @@ -122,10 +122,10 @@ extern void ConvertAudio(int num_frames, void *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map, void* scratch, float gain); -// Compare two SDL_AudioSpecs, return SDL_TRUE if they match exactly. +// Compare two SDL_AudioSpecs, return true if they match exactly. // Using SDL_memcmp directly isn't safe, since potential padding might not be initialized. // either channel maps can be NULL for the default (and both should be if you don't care about them). -extern SDL_bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b); +extern bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const int *channel_map_a, const int *channel_map_b); // allocate+copy a channel map. extern int *SDL_ChannelMapDup(const int *origchmap, int channels); @@ -159,10 +159,10 @@ typedef struct SDL_AudioDriverImpl void (*Deinitialize)(void); // Some flags to push duplicate code into the core and reduce #ifdefs. - SDL_bool ProvidesOwnCallbackThread; // !!! FIXME: rename this, it's not a callback thread anymore. - SDL_bool HasRecordingSupport; - SDL_bool OnlyHasDefaultPlaybackDevice; - SDL_bool OnlyHasDefaultRecordingDevice; // !!! FIXME: is there ever a time where you'd have a default playback and not a default recording (or vice versa)? + bool ProvidesOwnCallbackThread; // !!! FIXME: rename this, it's not a callback thread anymore. + bool HasRecordingSupport; + bool OnlyHasDefaultPlaybackDevice; + bool OnlyHasDefaultRecordingDevice; // !!! FIXME: is there ever a time where you'd have a default playback and not a default recording (or vice versa)? } SDL_AudioDriverImpl; @@ -222,7 +222,7 @@ struct SDL_AudioStream Uint8 *work_buffer; // used for scratch space during data conversion/resampling. size_t work_buffer_allocation; - SDL_bool simplified; // SDL_TRUE if created via SDL_OpenAudioDeviceStream + bool simplified; // true if created via SDL_OpenAudioDeviceStream SDL_LogicalAudioDevice *bound_device; SDL_AudioStream *next_binding; @@ -253,11 +253,11 @@ struct SDL_LogicalAudioDevice // double-linked list of all audio streams currently bound to this opened device. SDL_AudioStream *bound_streams; - // SDL_TRUE if this was opened as a default device. - SDL_bool opened_as_default; + // true if this was opened as a default device. + bool opened_as_default; - // SDL_TRUE if device was opened with SDL_OpenAudioDeviceStream (so it forbids binding changes, etc). - SDL_bool simplified; + // true if device was opened with SDL_OpenAudioDeviceStream (so it forbids binding changes, etc). + bool simplified; // If non-NULL, callback into the app that lets them access the final postmix buffer. SDL_AudioPostmixCallback postmix; @@ -319,11 +319,11 @@ struct SDL_AudioDevice // non-zero if this was a disconnected device and we're waiting for it to be decommissioned. SDL_AtomicInt zombie; - // SDL_TRUE if this is a recording device instead of an playback device - SDL_bool recording; + // true if this is a recording device instead of an playback device + bool recording; - // SDL_TRUE if audio thread can skip silence/mix/convert stages and just do a basic memcpy. - SDL_bool simple_copy; + // true if audio thread can skip silence/mix/convert stages and just do a basic memcpy. + bool simple_copy; // Scratch buffers used for mixing. Uint8 *work_buffer; @@ -336,8 +336,8 @@ struct SDL_AudioDevice // A thread to feed the audio device SDL_Thread *thread; - // SDL_TRUE if this physical device is currently opened by the backend. - SDL_bool currently_opened; + // true if this physical device is currently opened by the backend. + bool currently_opened; // Data private to this driver struct SDL_PrivateAudioData *hidden; @@ -350,8 +350,8 @@ typedef struct AudioBootStrap { const char *name; const char *desc; - SDL_bool (*init)(SDL_AudioDriverImpl *impl); - SDL_bool demand_only; // if SDL_TRUE: request explicitly, or it won't be available. + bool (*init)(SDL_AudioDriverImpl *impl); + bool demand_only; // if true: request explicitly, or it won't be available. } AudioBootStrap; // Not all of these are available in a given build. Use #ifdefs, etc. diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 9484b09c68..f87837058b 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -1776,7 +1776,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint Uint32 chunkcountlimit = 10000; const char *hint; Sint64 RIFFstart, RIFFend, lastchunkpos; - SDL_bool RIFFlengthknown = SDL_FALSE; + bool RIFFlengthknown = false; WaveFormat *format = &file->format; WaveChunk *chunk = &file->chunk; WaveChunk RIFFchunk; @@ -1842,7 +1842,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint SDL_FALLTHROUGH; case RiffSizeForce: RIFFend = RIFFchunk.position + RIFFchunk.length; - RIFFlengthknown = SDL_TRUE; + RIFFlengthknown = true; break; case RiffSizeMaximum: RIFFend = SDL_MAX_SINT64; diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 91d51245a0..0207a2d118 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -282,7 +282,7 @@ static void AAUDIO_CloseDevice(SDL_AudioDevice *device) static int BuildAAudioStream(SDL_AudioDevice *device) { struct SDL_PrivateAudioData *hidden = device->hidden; - const SDL_bool recording = device->recording; + const bool recording = device->recording; aaudio_result_t res; SDL_AtomicSet(&hidden->error_callback_triggered, 0); @@ -322,7 +322,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device) ctx.AAudioStreamBuilder_setErrorCallback(builder, AAUDIO_errorCallback, device); ctx.AAudioStreamBuilder_setDataCallback(builder, AAUDIO_dataCallback, device); // Some devices have flat sounding audio when low latency mode is enabled, but this is a better experience for most people - if (SDL_GetHintBoolean("SDL_ANDROID_LOW_LATENCY_AUDIO", SDL_TRUE)) { + if (SDL_GetHintBoolean("SDL_ANDROID_LOW_LATENCY_AUDIO", true)) { ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY); } @@ -431,7 +431,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device) return BuildAAudioStream(device); } -static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata) +static bool PauseOneDevice(SDL_AudioDevice *device, void *userdata) { struct SDL_PrivateAudioData *hidden = (struct SDL_PrivateAudioData *)device->hidden; if (hidden) { @@ -451,7 +451,7 @@ static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata) } } } - return SDL_FALSE; // keep enumerating. + return false; // keep enumerating. } // Pause (block) all non already paused audio devices by taking their mixer lock @@ -463,7 +463,7 @@ void AAUDIO_PauseDevices(void) } // Resume (unblock) all non already paused audio devices by releasing their mixer lock -static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata) +static bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata) { struct SDL_PrivateAudioData *hidden = device->hidden; if (hidden) { @@ -475,7 +475,7 @@ static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata) } } } - return SDL_FALSE; // keep enumerating. + return false; // keep enumerating. } void AAUDIO_ResumeDevices(void) @@ -498,7 +498,7 @@ static void AAUDIO_Deinitialize(void) } -static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool AAUDIO_Init(SDL_AudioDriverImpl *impl) { LOGI(__func__); @@ -508,7 +508,7 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl) * See https://github.com/google/oboe/issues/40 for more information. */ if (SDL_GetAndroidSDKVersion() < 27) { - return SDL_FALSE; + return false; } SDL_zero(ctx); @@ -516,13 +516,13 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl) ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO); if (!ctx.handle) { LOGI("SDL couldn't find " LIB_AAUDIO_SO); - return SDL_FALSE; + return false; } if (AAUDIO_LoadFunctions(&ctx) < 0) { SDL_UnloadObject(ctx.handle); SDL_zero(ctx); - return SDL_FALSE; + return false; } impl->ThreadInit = Android_AudioThreadInit; @@ -535,21 +535,21 @@ static SDL_bool AAUDIO_Init(SDL_AudioDriverImpl *impl) impl->WaitRecordingDevice = AAUDIO_WaitDevice; impl->RecordDevice = AAUDIO_RecordDevice; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; #if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES impl->DetectDevices = Android_StartAudioHotplug; #else - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; #endif LOGI("SDL AAUDIO_Init OK"); - return SDL_TRUE; + return true; } AudioBootStrap AAUDIO_bootstrap = { - "AAudio", "AAudio audio driver", AAUDIO_Init, SDL_FALSE + "AAudio", "AAudio audio driver", AAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_AAUDIO diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 55a1ea706e..04ba46abdd 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -206,19 +206,19 @@ static int LoadALSALibrary(void) typedef struct ALSA_Device { char *name; - SDL_bool recording; + bool recording; struct ALSA_Device *next; } ALSA_Device; static const ALSA_Device default_playback_handle = { "default", - SDL_FALSE, + false, NULL }; static const ALSA_Device default_recording_handle = { "default", - SDL_TRUE, + true, NULL }; @@ -436,7 +436,7 @@ static int ALSA_set_buffer_size(SDL_AudioDevice *device, snd_pcm_hw_params_t *pa static int ALSA_OpenDevice(SDL_AudioDevice *device) { - const SDL_bool recording = device->recording; + const bool recording = device->recording; int status = 0; // Initialize all variables that we clean on shutdown @@ -622,7 +622,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device) return 0; // We're ready to rock and roll. :-) } -static void add_device(const SDL_bool recording, const char *name, void *hint, ALSA_Device **pSeen) +static void add_device(const bool recording, const char *name, void *hint, ALSA_Device **pSeen) { ALSA_Device *dev = SDL_malloc(sizeof(ALSA_Device)); char *desc; @@ -683,7 +683,7 @@ static void add_device(const SDL_bool recording, const char *name, void *hint, A static ALSA_Device *hotplug_devices = NULL; -static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_default_recording) +static void ALSA_HotplugIteration(bool *has_default_playback, bool *has_default_recording) { void **hints = NULL; ALSA_Device *unseen = NULL; @@ -741,13 +741,13 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_ } // only want physical hardware interfaces - const SDL_bool is_default = (has_default == i); + const bool is_default = (has_default == i); if (is_default || (match && SDL_strncmp(name, match, match_len) == 0)) { char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID"); - const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0); - const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0); - SDL_bool have_output = SDL_FALSE; - SDL_bool have_input = SDL_FALSE; + const bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0); + const bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0); + bool have_output = false; + bool have_input = false; free(ioid); // This should NOT be SDL_free() @@ -758,9 +758,9 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_ if (is_default) { if (has_default_playback && isoutput) { - *has_default_playback = SDL_TRUE; + *has_default_playback = true; } else if (has_default_recording && isinput) { - *has_default_recording = SDL_TRUE; + *has_default_recording = true; } free(name); // This should NOT be SDL_free() continue; @@ -779,10 +779,10 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_ dev->next = seen; seen = dev; if (isinput) { - have_input = SDL_TRUE; + have_input = true; } if (isoutput) { - have_output = SDL_TRUE; + have_output = true; } } else { prev = dev; @@ -790,10 +790,10 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_playback, SDL_bool *has_ } if (isinput && !have_input) { - add_device(SDL_TRUE, name, hints[i], &seen); + add_device(true, name, hints[i], &seen); } if (isoutput && !have_output) { - add_device(SDL_FALSE, name, hints[i], &seen); + add_device(false, name, hints[i], &seen); } } @@ -843,13 +843,13 @@ static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevi { // ALSA doesn't have a concept of a changeable default device, afaik, so we expose a generic default // device here. It's the best we can do at this level. - SDL_bool has_default_playback = SDL_FALSE, has_default_recording = SDL_FALSE; + bool has_default_playback = false, has_default_recording = false; ALSA_HotplugIteration(&has_default_playback, &has_default_recording); // run once now before a thread continues to check. if (has_default_playback) { - *default_playback = SDL_AddAudioDevice(/*recording=*/SDL_FALSE, "ALSA default playback device", NULL, (void*)&default_playback_handle); + *default_playback = SDL_AddAudioDevice(/*recording=*/false, "ALSA default playback device", NULL, (void*)&default_playback_handle); } if (has_default_recording) { - *default_recording = SDL_AddAudioDevice(/*recording=*/SDL_TRUE, "ALSA default recording device", NULL, (void*)&default_recording_handle); + *default_recording = SDL_AddAudioDevice(/*recording=*/true, "ALSA default recording device", NULL, (void*)&default_recording_handle); } #if SDL_ALSA_HOTPLUG_THREAD @@ -887,10 +887,10 @@ static void ALSA_Deinitialize(void) UnloadALSALibrary(); } -static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl) +static bool ALSA_Init(SDL_AudioDriverImpl *impl) { if (LoadALSALibrary() < 0) { - return SDL_FALSE; + return false; } impl->DetectDevices = ALSA_DetectDevices; @@ -905,13 +905,13 @@ static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl) impl->RecordDevice = ALSA_RecordDevice; impl->FlushRecording = ALSA_FlushRecording; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap ALSA_bootstrap = { - "alsa", "ALSA PCM audio", ALSA_Init, SDL_FALSE + "alsa", "ALSA PCM audio", ALSA_Init, false }; #endif // SDL_AUDIO_DRIVER_ALSA diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index cd64e30383..e00d835b0b 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -60,7 +60,7 @@ struct SDL_PrivateAudioData #ifdef MACOSX_COREAUDIO AudioDeviceID deviceID; #else - SDL_bool interrupted; + bool interrupted; CFTypeRef interruption_listener; #endif }; diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index e500af6de6..1da1156b41 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -48,17 +48,17 @@ typedef struct SDLCoreAudioHandle { AudioDeviceID devid; - SDL_bool recording; + bool recording; } SDLCoreAudioHandle; -static SDL_bool TestCoreAudioDeviceHandleCallback(SDL_AudioDevice *device, void *handle) +static bool TestCoreAudioDeviceHandleCallback(SDL_AudioDevice *device, void *handle) { const SDLCoreAudioHandle *a = (const SDLCoreAudioHandle *) device->handle; const SDLCoreAudioHandle *b = (const SDLCoreAudioHandle *) handle; return (a->devid == b->devid) && (!!a->recording == !!b->recording); } -static SDL_AudioDevice *FindCoreAudioDeviceByHandle(const AudioDeviceID devid, const SDL_bool recording) +static SDL_AudioDevice *FindCoreAudioDeviceByHandle(const AudioDeviceID devid, const bool recording) { SDLCoreAudioHandle handle = { devid, recording }; return SDL_FindPhysicalAudioDeviceByCallback(TestCoreAudioDeviceHandleCallback, &handle); @@ -98,11 +98,11 @@ static OSStatus DeviceAliveNotification(AudioObjectID devid, UInt32 num_addr, co UInt32 size = sizeof(alive); const OSStatus error = AudioObjectGetPropertyData(devid, addrs, 0, NULL, &size, &alive); - SDL_bool dead = SDL_FALSE; + bool dead = false; if (error == kAudioHardwareBadDeviceError) { - dead = SDL_TRUE; // device was unplugged. + dead = true; // device was unplugged. } else if ((error == kAudioHardwareNoError) && (!alive)) { - dead = SDL_TRUE; // device died in some other way. + dead = true; // device died in some other way. } if (dead) { @@ -127,7 +127,7 @@ static void RefreshPhysicalDevices(void) { UInt32 size = 0; AudioDeviceID *devs = NULL; - SDL_bool isstack; + bool isstack; if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &devlist_address, 0, NULL, &size) != kAudioHardwareNoError) { return; @@ -140,7 +140,7 @@ static void RefreshPhysicalDevices(void) const UInt32 total_devices = (UInt32) (size / sizeof(AudioDeviceID)); for (UInt32 i = 0; i < total_devices; i++) { - if (FindCoreAudioDeviceByHandle(devs[i], SDL_TRUE) || FindCoreAudioDeviceByHandle(devs[i], SDL_FALSE)) { + if (FindCoreAudioDeviceByHandle(devs[i], true) || FindCoreAudioDeviceByHandle(devs[i], false)) { devs[i] = 0; // The system and SDL both agree it's already here, don't check it again. } } @@ -207,7 +207,7 @@ static void RefreshPhysicalDevices(void) CFIndex len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr), kCFStringEncodingUTF8); char *name = (char *)SDL_malloc(len + 1); - SDL_bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8))); + bool usable = ((name != NULL) && (CFStringGetCString(cfstr, name, len + 1, kCFStringEncodingUTF8))); CFRelease(cfstr); @@ -229,7 +229,7 @@ static void RefreshPhysicalDevices(void) SDLCoreAudioHandle *newhandle = (SDLCoreAudioHandle *) SDL_calloc(1, sizeof (*newhandle)); if (newhandle) { newhandle->devid = dev; - newhandle->recording = recording ? SDL_TRUE : SDL_FALSE; + newhandle->recording = recording ? true : false; SDL_AudioDevice *device = SDL_AddAudioDevice(newhandle->recording, name, &spec, newhandle); if (device) { AudioObjectAddPropertyListener(dev, &alive_address, DeviceAliveNotification, device); @@ -252,7 +252,7 @@ static OSStatus DeviceListChangedNotification(AudioObjectID systemObj, UInt32 nu return noErr; } -static OSStatus DefaultAudioDeviceChangedNotification(const SDL_bool recording, AudioObjectID inObjectID, const AudioObjectPropertyAddress *addr) +static OSStatus DefaultAudioDeviceChangedNotification(const bool recording, AudioObjectID inObjectID, const AudioObjectPropertyAddress *addr) { AudioDeviceID devid; UInt32 size = sizeof(devid); @@ -268,7 +268,7 @@ static OSStatus DefaultPlaybackDeviceChangedNotification(AudioObjectID inObjectI SDL_Log("COREAUDIO: default playback device changed!"); #endif SDL_assert(inNumberAddresses == 1); - return DefaultAudioDeviceChangedNotification(SDL_FALSE, inObjectID, inAddresses); + return DefaultAudioDeviceChangedNotification(false, inObjectID, inAddresses); } static OSStatus DefaultRecordingDeviceChangedNotification(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inUserData) @@ -277,7 +277,7 @@ static OSStatus DefaultRecordingDeviceChangedNotification(AudioObjectID inObject SDL_Log("COREAUDIO: default recording device changed!"); #endif SDL_assert(inNumberAddresses == 1); - return DefaultAudioDeviceChangedNotification(SDL_TRUE, inObjectID, inAddresses); + return DefaultAudioDeviceChangedNotification(true, inObjectID, inAddresses); } static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) @@ -292,7 +292,7 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi size = sizeof(AudioDeviceID); if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_playback_device_address, 0, NULL, &size, &devid) == noErr) { - SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, SDL_FALSE); + SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, false); if (device) { *default_playback = device; } @@ -301,7 +301,7 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi size = sizeof(AudioDeviceID); if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &default_recording_device_address, 0, NULL, &size, &devid) == noErr) { - SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, SDL_TRUE); + SDL_AudioDevice *device = FindCoreAudioDeviceByHandle(devid, true); if (device) { *default_recording = device; } @@ -311,14 +311,14 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audi #else // iOS-specific section follows. -static SDL_bool session_active = SDL_FALSE; +static bool session_active = false; -static SDL_bool PauseOneAudioDevice(SDL_AudioDevice *device, void *userdata) +static bool PauseOneAudioDevice(SDL_AudioDevice *device, void *userdata) { if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) { AudioQueuePause(device->hidden->audioQueue); } - return SDL_FALSE; // keep enumerating devices until we've paused them all. + return false; // keep enumerating devices until we've paused them all. } static void PauseAudioDevices(void) @@ -326,12 +326,12 @@ static void PauseAudioDevices(void) (void) SDL_FindPhysicalAudioDeviceByCallback(PauseOneAudioDevice, NULL); } -static SDL_bool ResumeOneAudioDevice(SDL_AudioDevice *device, void *userdata) +static bool ResumeOneAudioDevice(SDL_AudioDevice *device, void *userdata) { if (device->hidden && device->hidden->audioQueue && !device->hidden->interrupted) { AudioQueueStart(device->hidden->audioQueue, NULL); } - return SDL_FALSE; // keep enumerating devices until we've resumed them all. + return false; // keep enumerating devices until we've resumed them all. } static void ResumeAudioDevices(void) @@ -342,7 +342,7 @@ static void ResumeAudioDevices(void) static void InterruptionBegin(SDL_AudioDevice *device) { if (device != NULL && device->hidden->audioQueue != NULL) { - device->hidden->interrupted = SDL_TRUE; + device->hidden->interrupted = true; AudioQueuePause(device->hidden->audioQueue); } } @@ -350,7 +350,7 @@ static void InterruptionBegin(SDL_AudioDevice *device) static void InterruptionEnd(SDL_AudioDevice *device) { if (device != NULL && device->hidden != NULL && device->hidden->audioQueue != NULL && device->hidden->interrupted && AudioQueueStart(device->hidden->audioQueue, NULL) == AVAudioSessionErrorCodeNone) { - device->hidden->interrupted = SDL_FALSE; + device->hidden->interrupted = false; } } @@ -389,7 +389,7 @@ typedef struct int recording; } CountOpenAudioDevicesData; -static SDL_bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata) +static bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata) { CountOpenAudioDevicesData *data = (CountOpenAudioDevicesData *) userdata; if (device->hidden != NULL) { // assume it's open if hidden != NULL @@ -399,10 +399,10 @@ static SDL_bool CountOpenAudioDevices(SDL_AudioDevice *device, void *userdata) data->playback++; } } - return SDL_FALSE; // keep enumerating until all devices have been checked. + return false; // keep enumerating until all devices have been checked. } -static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_bool allow_playandrecord) +static bool UpdateAudioSession(SDL_AudioDevice *device, bool open, bool allow_playandrecord) { @autoreleasepool { AVAudioSession *session = [AVAudioSession sharedInstance]; @@ -467,12 +467,12 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b // Stop the current session so we don't interrupt other application audio PauseAudioDevices(); [session setActive:NO error:nil]; - session_active = SDL_FALSE; + session_active = false; if (![session setCategory:category mode:mode options:options error:&err]) { NSString *desc = err.description; SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String); - return SDL_FALSE; + return false; } } } else { @@ -480,12 +480,12 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b // Stop the current session so we don't interrupt other application audio PauseAudioDevices(); [session setActive:NO error:nil]; - session_active = SDL_FALSE; + session_active = false; if (![session setCategory:category error:&err]) { NSString *desc = err.description; SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String); - return SDL_FALSE; + return false; } } } @@ -494,19 +494,19 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b if (![session setActive:YES error:&err]) { if ([err code] == AVAudioSessionErrorCodeResourceNotAvailable && category == AVAudioSessionCategoryPlayAndRecord) { - return UpdateAudioSession(device, open, SDL_FALSE); + return UpdateAudioSession(device, open, false); } NSString *desc = err.description; SDL_SetError("Could not activate Audio Session: %s", desc.UTF8String); - return SDL_FALSE; + return false; } - session_active = SDL_TRUE; + session_active = true; ResumeAudioDevices(); } else if (!data.playback && !data.recording && session_active) { PauseAudioDevices(); [session setActive:NO error:nil]; - session_active = SDL_FALSE; + session_active = false; } if (open) { @@ -543,7 +543,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b } } - return SDL_TRUE; + return true; } #endif @@ -574,7 +574,7 @@ static void PlaybackBufferReadyCallback(void *inUserData, AudioQueueRef inAQ, Au SDL_assert(inBuffer != NULL); // ...right? SDL_assert(device->hidden->current_buffer == NULL); // shouldn't have anything pending device->hidden->current_buffer = inBuffer; - const SDL_bool okay = SDL_PlaybackAudioThreadIterate(device); + const bool okay = SDL_PlaybackAudioThreadIterate(device); SDL_assert((device->hidden->current_buffer == NULL) || !okay); // PlayDevice should have enqueued and cleaned it out, unless we failed or shutdown. // buffer is unexpectedly here? We're probably dying, but try to requeue this buffer with silence. @@ -646,7 +646,7 @@ static void COREAUDIO_CloseDevice(SDL_AudioDevice *device) } #ifndef MACOSX_COREAUDIO - UpdateAudioSession(device, SDL_FALSE, SDL_TRUE); + UpdateAudioSession(device, false, true); #endif if (device->hidden->ready_semaphore) { @@ -722,7 +722,7 @@ static int AssignDeviceToAudioQueue(SDL_AudioDevice *device) static int PrepareAudioQueue(SDL_AudioDevice *device) { const AudioStreamBasicDescription *strdesc = &device->hidden->strdesc; - const SDL_bool recording = device->recording; + const bool recording = device->recording; OSStatus result; SDL_assert(CFRunLoopGetCurrent() != NULL); @@ -864,7 +864,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) } #ifndef MACOSX_COREAUDIO - if (!UpdateAudioSession(device, SDL_TRUE, SDL_TRUE)) { + if (!UpdateAudioSession(device, true, true)) { return -1; } @@ -975,7 +975,7 @@ static void COREAUDIO_DeinitializeStart(void) #endif } -static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = COREAUDIO_OpenDevice; impl->PlayDevice = COREAUDIO_PlayDevice; @@ -989,18 +989,18 @@ static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) impl->DetectDevices = COREAUDIO_DetectDevices; impl->FreeDeviceHandle = COREAUDIO_FreeDeviceHandle; #else - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; #endif - impl->ProvidesOwnCallbackThread = SDL_TRUE; - impl->HasRecordingSupport = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap COREAUDIO_bootstrap = { - "coreaudio", "CoreAudio", COREAUDIO_Init, SDL_FALSE + "coreaudio", "CoreAudio", COREAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_COREAUDIO diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 59e57e04cf..729d2e5be8 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -35,7 +35,7 @@ // For Vista+, we can enumerate DSound devices with IMMDevice #ifdef HAVE_MMDEVICEAPI_H -static SDL_bool SupportsIMMDevice = SDL_FALSE; +static bool SupportsIMMDevice = false; #endif // DirectX function pointers for audio @@ -170,7 +170,7 @@ static void DSOUND_FreeDeviceHandle(SDL_AudioDevice *device) // FindAllDevs is presumably only used on WinXP; Vista and later can use IMMDevice for better results. typedef struct FindAllDevsData { - SDL_bool recording; + bool recording; SDL_AudioDevice **default_device; LPCGUID default_device_guid; } FindAllDevsData; @@ -216,12 +216,12 @@ static void DSOUND_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDe FindAllDevsData data; GUID guid; - data.recording = SDL_TRUE; + data.recording = true; data.default_device = default_recording; data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultCapture, &guid) == DS_OK) ? &guid : NULL; pDirectSoundCaptureEnumerateW(FindAllDevs, &data); - data.recording = SDL_FALSE; + data.recording = false; data.default_device = default_playback; data.default_device_guid = (pGetDeviceID(&SDL_DSDEVID_DefaultPlayback, &guid) == DS_OK) ? &guid : NULL; pDirectSoundEnumerateW(FindAllDevs, &data); @@ -533,7 +533,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device) const DWORD numchunks = 8; DWORD bufsize; - SDL_bool tried_format = SDL_FALSE; + bool tried_format = false; SDL_AudioFormat test_format; const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format); while ((test_format = *(closefmts++)) != 0) { @@ -542,7 +542,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device) case SDL_AUDIO_S16: case SDL_AUDIO_S32: case SDL_AUDIO_F32: - tried_format = SDL_TRUE; + tried_format = true; device->spec.format = test_format; @@ -641,14 +641,14 @@ static void DSOUND_Deinitialize(void) { DSOUND_Unload(); #ifdef HAVE_MMDEVICEAPI_H - SupportsIMMDevice = SDL_FALSE; + SupportsIMMDevice = false; #endif } -static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl) +static bool DSOUND_Init(SDL_AudioDriverImpl *impl) { if (!DSOUND_Load()) { - return SDL_FALSE; + return false; } #ifdef HAVE_MMDEVICEAPI_H @@ -668,13 +668,13 @@ static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl) impl->DeinitializeStart = DSOUND_DeinitializeStart; impl->Deinitialize = DSOUND_Deinitialize; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap DSOUND_bootstrap = { - "directsound", "DirectSound", DSOUND_Init, SDL_FALSE + "directsound", "DirectSound", DSOUND_Init, false }; #endif // SDL_AUDIO_DRIVER_DSOUND diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 1e8a485a99..9c1e61338b 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -91,7 +91,7 @@ static void DISKAUDIO_CloseDevice(SDL_AudioDevice *device) } } -static const char *get_filename(const SDL_bool recording) +static const char *get_filename(const bool recording) { const char *devname = SDL_GetHint(recording ? SDL_HINT_AUDIO_DISK_INPUT_FILE : SDL_HINT_AUDIO_DISK_OUTPUT_FILE); if (!devname) { @@ -102,7 +102,7 @@ static const char *get_filename(const SDL_bool recording) static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device) { - SDL_bool recording = device->recording; + bool recording = device->recording; const char *fname = get_filename(recording); device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); @@ -143,11 +143,11 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device) static void DISKAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) { - *default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1); - *default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2); + *default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1); + *default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2); } -static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = DISKAUDIO_OpenDevice; impl->WaitDevice = DISKAUDIO_WaitDevice; @@ -159,13 +159,13 @@ static SDL_bool DISKAUDIO_Init(SDL_AudioDriverImpl *impl) impl->CloseDevice = DISKAUDIO_CloseDevice; impl->DetectDevices = DISKAUDIO_DetectDevices; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap DISKAUDIO_bootstrap = { - "disk", "direct-to-disk audio", DISKAUDIO_Init, SDL_TRUE + "disk", "direct-to-disk audio", DISKAUDIO_Init, true }; #endif // SDL_AUDIO_DRIVER_DISK diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index a55b273cd5..8bff53924b 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -41,7 +41,7 @@ static void DSP_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) { - SDL_EnumUnixAudioDevices(SDL_FALSE, NULL); + SDL_EnumUnixAudioDevices(false, NULL); } static void DSP_CloseDevice(SDL_AudioDevice *device) @@ -264,21 +264,21 @@ static void DSP_FlushRecording(SDL_AudioDevice *device) } } -static SDL_bool InitTimeDevicesExist = SDL_FALSE; -static SDL_bool look_for_devices_test(int fd) +static bool InitTimeDevicesExist = false; +static bool look_for_devices_test(int fd) { - InitTimeDevicesExist = SDL_TRUE; // note that _something_ exists. + InitTimeDevicesExist = true; // note that _something_ exists. // Don't add to the device list, we're just seeing if any devices exist. - return SDL_FALSE; + return false; } -static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl) +static bool DSP_Init(SDL_AudioDriverImpl *impl) { - InitTimeDevicesExist = SDL_FALSE; - SDL_EnumUnixAudioDevices(SDL_FALSE, look_for_devices_test); + InitTimeDevicesExist = false; + SDL_EnumUnixAudioDevices(false, look_for_devices_test); if (!InitTimeDevicesExist) { SDL_SetError("dsp: No such audio device"); - return SDL_FALSE; // maybe try a different backend. + return false; // maybe try a different backend. } impl->DetectDevices = DSP_DetectDevices; @@ -291,13 +291,13 @@ static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl) impl->RecordDevice = DSP_RecordDevice; impl->FlushRecording = DSP_FlushRecording; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap DSP_bootstrap = { - "dsp", "Open Sound System (/dev/dsp)", DSP_Init, SDL_FALSE + "dsp", "Open Sound System (/dev/dsp)", DSP_Init, false }; #endif // SDL_AUDIO_DRIVER_OSS diff --git a/src/audio/dummy/SDL_dummyaudio.c b/src/audio/dummy/SDL_dummyaudio.c index a1b8523798..807004d3d1 100644 --- a/src/audio/dummy/SDL_dummyaudio.c +++ b/src/audio/dummy/SDL_dummyaudio.c @@ -78,7 +78,7 @@ static int DUMMYAUDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int bu return buflen; } -static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = DUMMYAUDIO_OpenDevice; impl->CloseDevice = DUMMYAUDIO_CloseDevice; @@ -87,13 +87,13 @@ static SDL_bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl) impl->WaitRecordingDevice = DUMMYAUDIO_WaitDevice; impl->RecordDevice = DUMMYAUDIO_RecordDevice; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; - impl->HasRecordingSupport = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap DUMMYAUDIO_bootstrap = { - "dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, SDL_TRUE + "dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, true }; diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index ab0b2390c7..7e0bbfea69 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -297,9 +297,9 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device) return 0; } -static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl) { - SDL_bool available, recording_available; + bool available, recording_available; impl->OpenDevice = EMSCRIPTENAUDIO_OpenDevice; impl->CloseDevice = EMSCRIPTENAUDIO_CloseDevice; @@ -308,10 +308,10 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl) impl->FlushRecording = EMSCRIPTENAUDIO_FlushRecording; impl->RecordDevice = EMSCRIPTENAUDIO_RecordDevice; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; // technically, this is just runs in idle time in the main thread, but it's close enough to a "thread" for our purposes. - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; // check availability available = MAIN_THREAD_EM_ASM_INT({ @@ -343,7 +343,7 @@ static SDL_bool EMSCRIPTENAUDIO_Init(SDL_AudioDriverImpl *impl) } AudioBootStrap EMSCRIPTENAUDIO_bootstrap = { - "emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, SDL_FALSE + "emscripten", "SDL emscripten audio driver", EMSCRIPTENAUDIO_Init, false }; /* *INDENT-ON* */ // clang-format on diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index 073a3901ac..5de7b81199 100644 --- a/src/audio/haiku/SDL_haikuaudio.cc +++ b/src/audio/haiku/SDL_haikuaudio.cc @@ -194,10 +194,10 @@ static void HAIKUAUDIO_Deinitialize(void) SDL_QuitBeApp(); } -static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl) { if (SDL_InitBeApp() < 0) { - return SDL_FALSE; + return false; } // Set the function pointers @@ -206,17 +206,17 @@ static SDL_bool HAIKUAUDIO_Init(SDL_AudioDriverImpl *impl) impl->PlayDevice = HAIKUAUDIO_PlayDevice; impl->CloseDevice = HAIKUAUDIO_CloseDevice; impl->Deinitialize = HAIKUAUDIO_Deinitialize; - impl->ProvidesOwnCallbackThread = SDL_TRUE; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; + impl->OnlyHasDefaultPlaybackDevice = true; - return SDL_TRUE; + return true; } extern "C" { extern AudioBootStrap HAIKUAUDIO_bootstrap; } AudioBootStrap HAIKUAUDIO_bootstrap = { - "haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, SDL_FALSE + "haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_HAIKU diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index d334fb3fc1..91f7d0338a 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -273,7 +273,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) data to us) and "input" for playback (we input audio data to them). Likewise, SDL's playback port will be "output" (we write data out) and recording will be "input" (we read data in). */ - const SDL_bool recording = device->recording; + const bool recording = device->recording; const unsigned long sysportflags = recording ? JackPortIsOutput : JackPortIsInput; const unsigned long sdlportflags = recording ? JackPortIsInput : JackPortIsOutput; const JackProcessCallback callback = recording ? jackProcessRecordingCallback : jackProcessPlaybackCallback; @@ -398,10 +398,10 @@ static void JACK_Deinitialize(void) UnloadJackLibrary(); } -static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) +static bool JACK_Init(SDL_AudioDriverImpl *impl) { if (LoadJackLibrary() < 0) { - return SDL_FALSE; + return false; } else { // Make sure a JACK server is running and available. jack_status_t status; @@ -409,7 +409,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) if (!client) { UnloadJackLibrary(); SDL_SetError("Can't open JACK client"); - return SDL_FALSE; + return false; } JACK_jack_client_close(client); } @@ -421,16 +421,16 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) impl->Deinitialize = JACK_Deinitialize; impl->RecordDevice = JACK_RecordDevice; impl->FlushRecording = JACK_FlushRecording; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; - impl->HasRecordingSupport = SDL_TRUE; - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; + impl->HasRecordingSupport = true; + impl->ProvidesOwnCallbackThread = true; - return SDL_TRUE; + return true; } AudioBootStrap JACK_bootstrap = { - "jack", "JACK Audio Connection Kit", JACK_Init, SDL_FALSE + "jack", "JACK Audio Connection Kit", JACK_Init, false }; #endif // SDL_AUDIO_DRIVER_JACK diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c index 75cafde023..8ef6579d76 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.c +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -47,7 +47,7 @@ static void N3DSAUD_DspHook(DSP_HookType hook) { if (hook == DSPHOOK_ONCANCEL) { contextLock(audio_device); - audio_device->hidden->isCancelled = SDL_TRUE; + audio_device->hidden->isCancelled = true; SDL_AudioDeviceDisconnected(audio_device); CondVar_Broadcast(&audio_device->hidden->cv); contextUnlock(audio_device); @@ -65,7 +65,7 @@ static void AudioFrameFinished(void *vdevice) for (i = 0; i < NUM_BUFFERS; i++) { if (device->hidden->waveBuf[i].status == NDSP_WBUF_DONE) { device->hidden->waveBuf[i].status = NDSP_WBUF_FREE; - shouldBroadcast = SDL_TRUE; + shouldBroadcast = true; } } @@ -261,7 +261,7 @@ static void N3DSAUDIO_ThreadInit(SDL_AudioDevice *device) svcSetThreadPriority(CUR_THREAD_HANDLE, current_priority); } -static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = N3DSAUDIO_OpenDevice; impl->PlayDevice = N3DSAUDIO_PlayDevice; @@ -269,12 +269,12 @@ static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) impl->GetDeviceBuf = N3DSAUDIO_GetDeviceBuf; impl->CloseDevice = N3DSAUDIO_CloseDevice; impl->ThreadInit = N3DSAUDIO_ThreadInit; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; // Should be possible, but micInit would fail - impl->HasRecordingSupport = SDL_FALSE; + impl->HasRecordingSupport = false; - return SDL_TRUE; + return true; } AudioBootStrap N3DSAUDIO_bootstrap = { diff --git a/src/audio/n3ds/SDL_n3dsaudio.h b/src/audio/n3ds/SDL_n3dsaudio.h index 932944d374..115ccc9329 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.h +++ b/src/audio/n3ds/SDL_n3dsaudio.h @@ -34,7 +34,7 @@ struct SDL_PrivateAudioData ndspWaveBuf waveBuf[NUM_BUFFERS]; LightLock lock; CondVar cv; - SDL_bool isCancelled; + bool isCancelled; }; #endif // SDL_n3dsaudio_h diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index 3846be075b..3d3680001c 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -41,7 +41,7 @@ static void NETBSDAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) { - SDL_EnumUnixAudioDevices(SDL_FALSE, NULL); + SDL_EnumUnixAudioDevices(false, NULL); } static void NETBSDAUDIO_Status(SDL_AudioDevice *device) @@ -116,7 +116,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device) static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device) { - const SDL_bool recording = device->recording; + const bool recording = device->recording; while (!SDL_AtomicGet(&device->shutdown)) { audio_info_t info; const int rc = ioctl(device->hidden->audio_fd, AUDIO_GETINFO, &info); @@ -208,7 +208,7 @@ static void NETBSDAUDIO_CloseDevice(SDL_AudioDevice *device) static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device) { - const SDL_bool recording = device->recording; + const bool recording = device->recording; int encoding = AUDIO_ENCODING_NONE; audio_info_t info, hwinfo; struct audio_prinfo *prinfo = recording ? &info.record : &info.play; @@ -304,7 +304,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device) return 0; // We're ready to rock and roll. :-) } -static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->DetectDevices = NETBSDAUDIO_DetectDevices; impl->OpenDevice = NETBSDAUDIO_OpenDevice; @@ -316,13 +316,13 @@ static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl) impl->RecordDevice = NETBSDAUDIO_RecordDevice; impl->FlushRecording = NETBSDAUDIO_FlushRecording; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap NETBSDAUDIO_bootstrap = { - "netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE + "netbsd", "NetBSD audio", NETBSDAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_NETBSD diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index f2a8caec2c..d4f9132b2f 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -750,12 +750,12 @@ static void OPENSLES_CloseDevice(SDL_AudioDevice *device) } } -static SDL_bool OPENSLES_Init(SDL_AudioDriverImpl *impl) +static bool OPENSLES_Init(SDL_AudioDriverImpl *impl) { LOGI("OPENSLES_Init() called"); if (!OPENSLES_CreateEngine()) { - return SDL_FALSE; + return false; } LOGI("OPENSLES_Init() - set pointers"); @@ -773,18 +773,18 @@ static SDL_bool OPENSLES_Init(SDL_AudioDriverImpl *impl) impl->Deinitialize = OPENSLES_DestroyEngine; // and the capabilities - impl->HasRecordingSupport = SDL_TRUE; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; + impl->HasRecordingSupport = true; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; LOGI("OPENSLES_Init() - success"); // this audio target is available. - return SDL_TRUE; + return true; } AudioBootStrap OPENSLES_bootstrap = { - "openslES", "OpenSL ES audio driver", OPENSLES_Init, SDL_FALSE + "openslES", "OpenSL ES audio driver", OPENSLES_Init, false }; void OPENSLES_ResumeDevices(void) diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index f51c5567b6..09f02ed441 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -50,7 +50,7 @@ enum PW_READY_FLAGS #define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x) #define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x) -static SDL_bool pipewire_initialized = SDL_FALSE; +static bool pipewire_initialized = false; // Pipewire entry points static const char *(*PIPEWIRE_pw_get_library_version)(void); @@ -204,7 +204,7 @@ struct node_object Uint32 id; int seq; - SDL_bool persist; + bool persist; /* * NOTE: If used, this is *must* be allocated with SDL_malloc() or similar @@ -226,7 +226,7 @@ struct io_node struct spa_list link; Uint32 id; - SDL_bool recording; + bool recording; SDL_AudioSpec spec; const char *name; // Friendly name @@ -245,8 +245,8 @@ static struct spa_hook hotplug_core_listener; static struct spa_list hotplug_pending_list; static struct spa_list hotplug_io_list; static int hotplug_init_seq_val; -static SDL_bool hotplug_init_complete; -static SDL_bool hotplug_events_enabled; +static bool hotplug_init_complete; +static bool hotplug_events_enabled; static int pipewire_version_major; static int pipewire_version_minor; @@ -254,7 +254,7 @@ static int pipewire_version_patch; static char *pipewire_default_sink_id = NULL; static char *pipewire_default_source_id = NULL; -static SDL_bool pipewire_core_version_at_least(int major, int minor, int patch) +static bool pipewire_core_version_at_least(int major, int minor, int patch) { return (pipewire_version_major >= major) && (pipewire_version_major > major || pipewire_version_minor >= minor) && @@ -262,15 +262,15 @@ static SDL_bool pipewire_core_version_at_least(int major, int minor, int patch) } // The active node list -static SDL_bool io_list_check_add(struct io_node *node) +static bool io_list_check_add(struct io_node *node) { struct io_node *n; - SDL_bool ret = SDL_TRUE; + bool ret = true; // See if the node is already in the list spa_list_for_each (n, &hotplug_io_list, link) { if (n->id == node->id) { - ret = SDL_FALSE; + ret = false; goto dup_found; } } @@ -402,7 +402,7 @@ static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq spa_hook_remove(&hotplug_core_listener); // Signal that the initial I/O list is populated - hotplug_init_complete = SDL_TRUE; + hotplug_init_complete = true; PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false); } } @@ -463,7 +463,7 @@ static void hotplug_core_sync(struct node_object *node) } // Helpers for retrieving values from params -static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) +static bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) { const struct spa_pod_prop *prop; struct spa_pod *value; @@ -488,15 +488,15 @@ static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *de *max = (int)v[2]; } - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } -static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val) +static bool get_int_param(const struct spa_pod *param, Uint32 key, int *val) { const struct spa_pod_prop *prop; Sint32 v; @@ -508,10 +508,10 @@ static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val) *val = (int)v; } - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } // Interface node callbacks @@ -607,14 +607,14 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons SDL_free(pipewire_default_sink_id); } pipewire_default_sink_id = get_name_from_json(value); - node->persist = SDL_TRUE; + node->persist = true; change_default_device(pipewire_default_sink_id); } else if (!SDL_strcmp(key, "default.audio.source")) { if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); } pipewire_default_source_id = get_name_from_json(value); - node->persist = SDL_TRUE; + node->persist = true; change_default_device(pipewire_default_source_id); } } @@ -638,15 +638,15 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p const char *node_desc; const char *node_path; struct io_node *io; - SDL_bool recording; + bool recording; int desc_buffer_len; int path_buffer_len; // Just want sink and source if (!SDL_strcasecmp(media_class, "Audio/Sink")) { - recording = SDL_FALSE; + recording = false; } else if (!SDL_strcasecmp(media_class, "Audio/Source")) { - recording = SDL_TRUE; + recording = true; } else { return; } @@ -757,8 +757,8 @@ static void hotplug_loop_destroy(void) pending_list_clear(); io_list_clear(); - hotplug_init_complete = SDL_FALSE; - hotplug_events_enabled = SDL_FALSE; + hotplug_init_complete = false; + hotplug_events_enabled = false; if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); @@ -814,7 +814,7 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_playback, SDL_Audio } } - hotplug_events_enabled = SDL_TRUE; + hotplug_events_enabled = true; PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); } @@ -901,7 +901,7 @@ static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info static Uint8 *PIPEWIRE_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) { - // See if a buffer is available. If this returns NULL, SDL_PlaybackAudioThreadIterate will return SDL_FALSE, but since we own the thread, it won't kill playback. + // See if a buffer is available. If this returns NULL, SDL_PlaybackAudioThreadIterate will return false, but since we own the thread, it won't kill playback. // !!! FIXME: It's not clear to me if this ever returns NULL or if this was just defensive coding. struct pw_stream *stream = device->hidden->stream; @@ -985,7 +985,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer) { SDL_AudioDevice *device = (SDL_AudioDevice *) data; - if (device->recording == SDL_FALSE) { + if (device->recording == false) { /* Clamp the output spec samples and size to the max size of the Pipewire buffer. If they exceed the maximum size of the Pipewire buffer, double buffering will be used. */ if (device->buffer_size > buffer->buffer->datas[0].maxsize) { @@ -1042,7 +1042,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) struct pw_properties *props; const char *app_name, *icon_name, *app_id, *stream_name, *stream_role, *error; Uint32 node_id = !device->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(device->handle); - const SDL_bool recording = device->recording; + const bool recording = device->recording; int res; // Clamp the period size to sane values @@ -1214,23 +1214,23 @@ static void PIPEWIRE_Deinitialize(void) { if (pipewire_initialized) { deinit_pipewire_library(); - pipewire_initialized = SDL_FALSE; + pipewire_initialized = false; } } -static SDL_bool PipewireInitialize(SDL_AudioDriverImpl *impl) +static bool PipewireInitialize(SDL_AudioDriverImpl *impl) { if (!pipewire_initialized) { if (init_pipewire_library() < 0) { - return SDL_FALSE; + return false; } - pipewire_initialized = SDL_TRUE; + pipewire_initialized = true; if (hotplug_loop_init() < 0) { PIPEWIRE_Deinitialize(); - return SDL_FALSE; + return false; } } @@ -1244,16 +1244,16 @@ static SDL_bool PipewireInitialize(SDL_AudioDriverImpl *impl) impl->FlushRecording = PIPEWIRE_FlushRecording; impl->CloseDevice = PIPEWIRE_CloseDevice; - impl->HasRecordingSupport = SDL_TRUE; - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->HasRecordingSupport = true; + impl->ProvidesOwnCallbackThread = true; - return SDL_TRUE; + return true; } -static SDL_bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl) +static bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl) { if (!PipewireInitialize(impl)) { - return SDL_FALSE; + return false; } // run device detection but don't add any devices to SDL; we're just waiting to see if PipeWire sees any devices. If not, fall back to the next backend. @@ -1271,22 +1271,22 @@ static SDL_bool PIPEWIRE_PREFERRED_Init(SDL_AudioDriverImpl *impl) if (no_devices || !pipewire_core_version_at_least(1, 0, 0)) { hotplug_loop_destroy(); PIPEWIRE_Deinitialize(); - return SDL_FALSE; + return false; } - return SDL_TRUE; // this will move on to PIPEWIRE_DetectDevices and reuse hotplug_io_list. + return true; // this will move on to PIPEWIRE_DetectDevices and reuse hotplug_io_list. } -static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl) +static bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl) { return PipewireInitialize(impl); } AudioBootStrap PIPEWIRE_PREFERRED_bootstrap = { - "pipewire", "Pipewire", PIPEWIRE_PREFERRED_Init, SDL_FALSE + "pipewire", "Pipewire", PIPEWIRE_PREFERRED_Init, false }; AudioBootStrap PIPEWIRE_bootstrap = { - "pipewire", "Pipewire", PIPEWIRE_Init, SDL_FALSE + "pipewire", "Pipewire", PIPEWIRE_Init, false }; #endif // SDL_AUDIO_DRIVER_PIPEWIRE diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index 579e8ecb50..11f703263f 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -137,10 +137,10 @@ static void PS2AUDIO_Deinitialize(void) deinit_audio_driver(); } -static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl) +static bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl) { if (init_audio_driver() < 0) { - return SDL_FALSE; + return false; } impl->OpenDevice = PS2AUDIO_OpenDevice; @@ -150,10 +150,10 @@ static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl *impl) impl->CloseDevice = PS2AUDIO_CloseDevice; impl->ThreadInit = PS2AUDIO_ThreadInit; impl->Deinitialize = PS2AUDIO_Deinitialize; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - return SDL_TRUE; // this audio target is available. + impl->OnlyHasDefaultPlaybackDevice = true; + return true; // this audio target is available. } AudioBootStrap PS2AUDIO_bootstrap = { - "ps2", "PS2 audio driver", PS2AUDIO_Init, SDL_FALSE + "ps2", "PS2 audio driver", PS2AUDIO_Init, false }; diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 3fe2caf627..f5a3bd6a21 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -33,7 +33,7 @@ #include #include -static inline SDL_bool isBasicAudioConfig(const SDL_AudioSpec *spec) +static bool isBasicAudioConfig(const SDL_AudioSpec *spec) { return spec->freq == 44100; } @@ -162,7 +162,7 @@ static void PSPAUDIO_ThreadInit(SDL_AudioDevice *device) } } -static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = PSPAUDIO_OpenDevice; impl->PlayDevice = PSPAUDIO_PlayDevice; @@ -170,14 +170,14 @@ static SDL_bool PSPAUDIO_Init(SDL_AudioDriverImpl *impl) impl->GetDeviceBuf = PSPAUDIO_GetDeviceBuf; impl->CloseDevice = PSPAUDIO_CloseDevice; impl->ThreadInit = PSPAUDIO_ThreadInit; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - //impl->HasRecordingSupport = SDL_TRUE; - //impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; - return SDL_TRUE; + impl->OnlyHasDefaultPlaybackDevice = true; + //impl->HasRecordingSupport = true; + //impl->OnlyHasDefaultRecordingDevice = true; + return true; } AudioBootStrap PSPAUDIO_bootstrap = { - "psp", "PSP audio driver", PSPAUDIO_Init, SDL_FALSE + "psp", "PSP audio driver", PSPAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_PSP diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 1ba721ec46..6b03eac260 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -46,7 +46,7 @@ typedef struct PulseDeviceHandle } PulseDeviceHandle; // should we include monitors in the device list? Set at SDL_Init time -static SDL_bool include_monitors = SDL_FALSE; +static bool include_monitors = false; static pa_threaded_mainloop *pulseaudio_threaded_mainloop = NULL; static pa_context *pulseaudio_context = NULL; @@ -58,8 +58,8 @@ static SDL_AtomicInt pulseaudio_hotplug_thread_active; // to the change. static char *default_sink_path = NULL; static char *default_source_path = NULL; -static SDL_bool default_sink_changed = SDL_FALSE; -static SDL_bool default_source_changed = SDL_FALSE; +static bool default_sink_changed = false; +static bool default_source_changed = false; static const char *(*PULSEAUDIO_pa_get_library_version)(void); @@ -593,7 +593,7 @@ static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata) static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) { - const SDL_bool recording = device->recording; + const bool recording = device->recording; struct SDL_PrivateAudioData *h = NULL; SDL_AudioFormat test_format; const SDL_AudioFormat *closefmts; @@ -761,7 +761,7 @@ static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format) } } -static void AddPulseAudioDevice(const SDL_bool recording, const char *description, const char *name, const uint32_t index, const pa_sample_spec *sample_spec) +static void AddPulseAudioDevice(const bool recording, const char *description, const char *name, const uint32_t index, const pa_sample_spec *sample_spec) { SDL_AudioSpec spec; SDL_zero(spec); @@ -784,7 +784,7 @@ static void AddPulseAudioDevice(const SDL_bool recording, const char *descriptio static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) { if (i) { - AddPulseAudioDevice(SDL_FALSE, i->description, i->name, i->index, &i->sample_spec); + AddPulseAudioDevice(false, i->description, i->name, i->index, &i->sample_spec); } PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } @@ -794,7 +794,7 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la { // Maybe skip "monitor" sources. These are just output from other sinks. if (i && (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX))) { - AddPulseAudioDevice(SDL_TRUE, i->description, i->name, i->index, &i->sample_spec); + AddPulseAudioDevice(true, i->description, i->name, i->index, &i->sample_spec); } PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } @@ -808,7 +808,7 @@ static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *dat if (str) { SDL_free(default_sink_path); default_sink_path = str; - default_sink_changed = SDL_TRUE; + default_sink_changed = true; } } @@ -817,21 +817,21 @@ static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *dat if (str) { SDL_free(default_source_path); default_source_path = str; - default_source_changed = SDL_TRUE; + default_source_changed = true; } } PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } -static SDL_bool FindAudioDeviceByIndex(SDL_AudioDevice *device, void *userdata) +static bool FindAudioDeviceByIndex(SDL_AudioDevice *device, void *userdata) { const uint32_t idx = (uint32_t) (uintptr_t) userdata; const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle; return (handle->device_index == idx); } -static SDL_bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata) +static bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata) { const char *path = (const char *) userdata; const PulseDeviceHandle *handle = (const PulseDeviceHandle *) device->handle; @@ -841,13 +841,13 @@ static SDL_bool FindAudioDeviceByPath(SDL_AudioDevice *device, void *userdata) // This is called when PulseAudio has a device connected/removed/changed. static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data) { - const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW); - const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE); - const SDL_bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE); + const bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW); + const bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE); + const bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE); if (added || removed || changed) { // we only care about add/remove events. - const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK); - const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE); + const bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK); + const bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE); if (changed) { PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL)); @@ -868,20 +868,20 @@ static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint3 PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } -static SDL_bool CheckDefaultDevice(const SDL_bool changed, char *device_path) +static bool CheckDefaultDevice(const bool changed, char *device_path) { if (!changed) { - return SDL_FALSE; // nothing's happening, leave the flag marked as unchanged. + return false; // nothing's happening, leave the flag marked as unchanged. } else if (!device_path) { - return SDL_TRUE; // check again later, we don't have a device name... + return true; // check again later, we don't have a device name... } SDL_AudioDevice *device = SDL_FindPhysicalAudioDeviceByCallback(FindAudioDeviceByPath, device_path); if (device) { // if NULL, we might still be waiting for a SinkInfoCallback or something, we'll try later. SDL_DefaultAudioDeviceChanged(device); - return SDL_FALSE; // changing complete, set flag to unchanged for future tests. + return false; // changing complete, set flag to unchanged for future tests. } - return SDL_TRUE; // couldn't find the changed device, leave it marked as changed to try again later. + return true; // couldn't find the changed device, leave it marked as changed to try again later. } // this runs as a thread while the Pulse target is initialized to catch hotplug events. @@ -906,11 +906,11 @@ static int SDLCALL HotplugThread(void *data) } // Update default devices; don't hold the pulse lock during this, since it could deadlock vs a playing device that we're about to lock here. - SDL_bool check_default_sink = default_sink_changed; - SDL_bool check_default_source = default_source_changed; + bool check_default_sink = default_sink_changed; + bool check_default_source = default_source_changed; char *current_default_sink = check_default_sink ? SDL_strdup(default_sink_path) : NULL; char *current_default_source = check_default_source ? SDL_strdup(default_source_path) : NULL; - default_sink_changed = default_source_changed = SDL_FALSE; + default_sink_changed = default_source_changed = false; PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); check_default_sink = CheckDefaultDevice(check_default_sink, current_default_sink); check_default_source = CheckDefaultDevice(check_default_source, current_default_source); @@ -984,24 +984,24 @@ static void PULSEAUDIO_Deinitialize(void) SDL_free(default_sink_path); default_sink_path = NULL; - default_sink_changed = SDL_FALSE; + default_sink_changed = false; SDL_free(default_source_path); default_source_path = NULL; - default_source_changed = SDL_FALSE; + default_source_changed = false; UnloadPulseAudioLibrary(); } -static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) +static bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) { if (LoadPulseAudioLibrary() < 0) { - return SDL_FALSE; + return false; } else if (ConnectToPulseServer() < 0) { UnloadPulseAudioLibrary(); - return SDL_FALSE; + return false; } - include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, SDL_FALSE); + include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, false); impl->DetectDevices = PULSEAUDIO_DetectDevices; impl->OpenDevice = PULSEAUDIO_OpenDevice; @@ -1016,13 +1016,13 @@ static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) impl->FlushRecording = PULSEAUDIO_FlushRecording; impl->FreeDeviceHandle = PULSEAUDIO_FreeDeviceHandle; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap PULSEAUDIO_bootstrap = { - "pulseaudio", "PulseAudio", PULSEAUDIO_Init, SDL_FALSE + "pulseaudio", "PulseAudio", PULSEAUDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_PULSEAUDIO diff --git a/src/audio/qnx/SDL_qsa_audio.c b/src/audio/qnx/SDL_qsa_audio.c index 42e9c0e13d..d8736b8805 100644 --- a/src/audio/qnx/SDL_qsa_audio.c +++ b/src/audio/qnx/SDL_qsa_audio.c @@ -100,10 +100,10 @@ static int QSA_WaitDevice(SDL_AudioDevice *device) SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "QSA: SDL_IOReady() failed: %s", strerror(errno)); return -1; case 0: - device->hidden->timeout_on_wait = SDL_TRUE; // !!! FIXME: Should we just disconnect the device in this case? + device->hidden->timeout_on_wait = true; // !!! FIXME: Should we just disconnect the device in this case? break; default: - device->hidden->timeout_on_wait = SDL_FALSE; + device->hidden->timeout_on_wait = false; break; } @@ -200,7 +200,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device) const Uint32 sdlhandle = (Uint32) ((size_t) device->handle); const uint32_t cardno = (uint32_t) (sdlhandle & 0xFFFF); const uint32_t deviceno = (uint32_t) ((sdlhandle >> 16) & 0xFFFF); - const SDL_bool recording = device->recording; + const bool recording = device->recording; int status = 0; // Initialize all variables that we clean on shutdown @@ -318,7 +318,7 @@ static void QSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevic // this value can be changed in the runtime int num_cards = 0; (void) snd_cards_list(NULL, 0, &alloc_num_cards); - SDL_bool isstack = SDL_FALSE; + bool isstack = false; int *cards = SDL_small_alloc(int, num_cards, &isstack); if (!cards) { return; // we're in trouble. @@ -350,13 +350,13 @@ static void QSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevic SDL_snprintf(fullname, sizeof (fullname), "%s d%d", name, (int) deviceno); // Check if this device id could play anything - SDL_bool recording = SDL_FALSE; + bool recording = false; status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_PLAYBACK); if (status != EOK) { // no? See if it's a recording device instead. #if 0 // !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in! status = snd_pcm_open(&handle, card, deviceno, SND_PCM_OPEN_CAPTURE); if (status == EOK) { - recording = SDL_TRUE; + recording = true; } #endif } @@ -426,7 +426,7 @@ static void QSA_Deinitialize(void) // nothing to do here atm. } -static SDL_bool QSA_Init(SDL_AudioDriverImpl * impl) +static bool QSA_Init(SDL_AudioDriverImpl * impl) { impl->DetectDevices = QSA_DetectDevices; impl->OpenDevice = QSA_OpenDevice; @@ -438,9 +438,9 @@ static SDL_bool QSA_Init(SDL_AudioDriverImpl * impl) impl->Deinitialize = QSA_Deinitialize; // !!! FIXME: most of this code has support for recording devices, but there's no RecordDevice, etc functions. Fill them in! - //impl->HasRecordingSupport = SDL_TRUE; + //impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap QSAAUDIO_bootstrap = { diff --git a/src/audio/qnx/SDL_qsa_audio.h b/src/audio/qnx/SDL_qsa_audio.h index ea53752092..3bb0b6f780 100644 --- a/src/audio/qnx/SDL_qsa_audio.h +++ b/src/audio/qnx/SDL_qsa_audio.h @@ -32,7 +32,7 @@ struct SDL_PrivateAudioData { snd_pcm_t *audio_handle; // The audio device handle int audio_fd; // The audio file descriptor, for selecting on - SDL_bool timeout_on_wait; // Select timeout status + bool timeout_on_wait; // Select timeout status Uint8 *pcm_buf; // Raw mixing buffer }; diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index e8f59a64e2..8a2d08fd7f 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -149,7 +149,7 @@ static int LoadSNDIOLibrary(void) static int SNDIO_WaitDevice(SDL_AudioDevice *device) { - const SDL_bool recording = device->recording; + const bool recording = device->recording; while (!SDL_AtomicGet(&device->shutdown)) { if (SNDIO_sio_eof(device->hidden->dev)) { @@ -323,14 +323,14 @@ static void SNDIO_Deinitialize(void) static void SNDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording) { - *default_playback = SDL_AddAudioDevice(SDL_FALSE, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1); - *default_recording = SDL_AddAudioDevice(SDL_TRUE, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2); + *default_playback = SDL_AddAudioDevice(false, DEFAULT_PLAYBACK_DEVNAME, NULL, (void *)0x1); + *default_recording = SDL_AddAudioDevice(true, DEFAULT_RECORDING_DEVNAME, NULL, (void *)0x2); } -static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl) +static bool SNDIO_Init(SDL_AudioDriverImpl *impl) { if (LoadSNDIOLibrary() < 0) { - return SDL_FALSE; + return false; } impl->OpenDevice = SNDIO_OpenDevice; @@ -344,13 +344,13 @@ static SDL_bool SNDIO_Init(SDL_AudioDriverImpl *impl) impl->Deinitialize = SNDIO_Deinitialize; impl->DetectDevices = SNDIO_DetectDevices; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap SNDIO_bootstrap = { - "sndio", "OpenBSD sndio", SNDIO_Init, SDL_FALSE + "sndio", "OpenBSD sndio", SNDIO_Init, false }; #endif // SDL_AUDIO_DRIVER_SNDIO diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 09d23753c6..5b577bec8e 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -211,7 +211,7 @@ static void VITAAUD_ThreadInit(SDL_AudioDevice *device) } } -static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl) +static bool VITAAUD_Init(SDL_AudioDriverImpl *impl) { impl->OpenDevice = VITAAUD_OpenDevice; impl->PlayDevice = VITAAUD_PlayDevice; @@ -223,15 +223,15 @@ static SDL_bool VITAAUD_Init(SDL_AudioDriverImpl *impl) impl->FlushRecording = VITAAUD_FlushRecording; impl->RecordDevice = VITAAUD_RecordDevice; - impl->HasRecordingSupport = SDL_TRUE; - impl->OnlyHasDefaultPlaybackDevice = SDL_TRUE; - impl->OnlyHasDefaultRecordingDevice = SDL_TRUE; + impl->HasRecordingSupport = true; + impl->OnlyHasDefaultPlaybackDevice = true; + impl->OnlyHasDefaultRecordingDevice = true; - return SDL_TRUE; + return true; } AudioBootStrap VITAAUD_bootstrap = { - "vita", "VITA audio driver", VITAAUD_Init, SDL_FALSE + "vita", "VITA audio driver", VITAAUD_Init, false }; #endif // SDL_AUDIO_DRIVER_VITA diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index e38a1a4650..732b10659c 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -286,17 +286,17 @@ void WASAPI_DisconnectDevice(SDL_AudioDevice *device) WASAPI_ProxyToManagementThread(mgmtthrtask_DisconnectDevice, device, &rc); } -static SDL_bool WasapiFailed(SDL_AudioDevice *device, const HRESULT err) +static bool WasapiFailed(SDL_AudioDevice *device, const HRESULT err) { if (err == S_OK) { - return SDL_FALSE; + return false; } else if (err == AUDCLNT_E_DEVICE_INVALIDATED) { - device->hidden->device_lost = SDL_TRUE; + device->hidden->device_lost = true; } else { - device->hidden->device_dead = SDL_TRUE; + device->hidden->device_dead = true; } - return SDL_TRUE; + return true; } static int mgmtthrtask_StopAndReleaseClient(void *userdata) @@ -397,38 +397,38 @@ static int ActivateWasapiDevice(SDL_AudioDevice *device) } // do not call when holding the device lock! -static SDL_bool RecoverWasapiDevice(SDL_AudioDevice *device) +static bool RecoverWasapiDevice(SDL_AudioDevice *device) { ResetWasapiDevice(device); // dump the lost device's handles. // This handles a non-default device that simply had its format changed in the Windows Control Panel. if (ActivateWasapiDevice(device) < 0) { WASAPI_DisconnectDevice(device); - return SDL_FALSE; + return false; } - device->hidden->device_lost = SDL_FALSE; + device->hidden->device_lost = false; - return SDL_TRUE; // okay, carry on with new device details! + return true; // okay, carry on with new device details! } // do not call when holding the device lock! -static SDL_bool RecoverWasapiIfLost(SDL_AudioDevice *device) +static bool RecoverWasapiIfLost(SDL_AudioDevice *device) { if (SDL_AtomicGet(&device->shutdown)) { - return SDL_FALSE; // already failed. + return false; // already failed. } else if (device->hidden->device_dead) { // had a fatal error elsewhere, clean up and quit IAudioClient_Stop(device->hidden->client); WASAPI_DisconnectDevice(device); SDL_assert(SDL_AtomicGet(&device->shutdown)); // so we don't come back through here. - return SDL_FALSE; // already failed. + return false; // already failed. } else if (SDL_AtomicGet(&device->zombie)) { - return SDL_FALSE; // we're already dead, so just leave and let the Zombie implementations take over. + return false; // we're already dead, so just leave and let the Zombie implementations take over. } else if (!device->hidden->client) { - return SDL_TRUE; // still waiting for activation. + return true; // still waiting for activation. } - return device->hidden->device_lost ? RecoverWasapiDevice(device) : SDL_TRUE; + return device->hidden->device_lost ? RecoverWasapiDevice(device) : true; } static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) @@ -524,7 +524,7 @@ static int WASAPI_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen const int total = ((int)frames) * device->hidden->framesize; const int cpy = SDL_min(buflen, total); const int leftover = total - cpy; - const SDL_bool silent = (flags & AUDCLNT_BUFFERFLAGS_SILENT) ? SDL_TRUE : SDL_FALSE; + const bool silent = (flags & AUDCLNT_BUFFERFLAGS_SILENT) ? true : false; SDL_assert(leftover == 0); // according to MSDN, this isn't everything available, just one "packet" of data per-GetBuffer call. @@ -656,7 +656,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) streamflags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK; int new_sample_frames = 0; - SDL_bool iaudioclient3_initialized = SDL_FALSE; + bool iaudioclient3_initialized = false; #ifdef __IAudioClient3_INTERFACE_DEFINED__ // Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED @@ -678,7 +678,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) ret = IAudioClient3_InitializeSharedAudioStream(client3, streamflags, period_in_frames, waveformat, NULL); if (SUCCEEDED(ret)) { new_sample_frames = (int)period_in_frames; - iaudioclient3_initialized = SDL_TRUE; + iaudioclient3_initialized = true; } } @@ -822,10 +822,10 @@ static void WASAPI_Deinitialize(void) DeinitManagementThread(); } -static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl) +static bool WASAPI_Init(SDL_AudioDriverImpl *impl) { if (InitManagementThread() < 0) { - return SDL_FALSE; + return false; } impl->DetectDevices = WASAPI_DetectDevices; @@ -843,13 +843,13 @@ static SDL_bool WASAPI_Init(SDL_AudioDriverImpl *impl) impl->Deinitialize = WASAPI_Deinitialize; impl->FreeDeviceHandle = WASAPI_FreeDeviceHandle; - impl->HasRecordingSupport = SDL_TRUE; + impl->HasRecordingSupport = true; - return SDL_TRUE; + return true; } AudioBootStrap WASAPI_bootstrap = { - "wasapi", "WASAPI", WASAPI_Init, SDL_FALSE + "wasapi", "WASAPI", WASAPI_Init, false }; #endif // SDL_AUDIO_DRIVER_WASAPI diff --git a/src/audio/wasapi/SDL_wasapi.h b/src/audio/wasapi/SDL_wasapi.h index fb5aa22a99..0ad9d8ae3b 100644 --- a/src/audio/wasapi/SDL_wasapi.h +++ b/src/audio/wasapi/SDL_wasapi.h @@ -38,10 +38,10 @@ struct SDL_PrivateAudioData IAudioCaptureClient *capture; HANDLE event; HANDLE task; - SDL_bool coinitialized; + bool coinitialized; int framesize; - SDL_bool device_lost; - SDL_bool device_dead; + bool device_lost; + bool device_dead; void *activation_handler; }; diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index 95bf839d8b..905a66894a 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -43,7 +43,7 @@ typedef BOOL(WINAPI *pfnAvRevertMmThreadCharacteristics)(HANDLE); static pfnAvSetMmThreadCharacteristicsW pAvSetMmThreadCharacteristicsW = NULL; static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL; -static SDL_bool immdevice_initialized = SDL_FALSE; +static bool immdevice_initialized = false; // Some GUIDs we need to know without linking to libraries that aren't available before Vista. static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; @@ -91,7 +91,7 @@ int WASAPI_PlatformInit(void) return -1; // Error string is set by SDL_IMMDevice_Init } - immdevice_initialized = SDL_TRUE; + immdevice_initialized = true; libavrt = LoadLibrary(TEXT("avrt.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! if (libavrt) { @@ -106,7 +106,7 @@ static void StopWasapiHotplug(void) { if (immdevice_initialized) { SDL_IMMDevice_Quit(); - immdevice_initialized = SDL_FALSE; + immdevice_initialized = false; } } @@ -134,7 +134,7 @@ void WASAPI_PlatformThreadInit(SDL_AudioDevice *device) { // this thread uses COM. if (SUCCEEDED(WIN_CoInitialize())) { // can't report errors, hope it worked! - device->hidden->coinitialized = SDL_TRUE; + device->hidden->coinitialized = true; } // Set this thread to very high "Pro Audio" priority. @@ -157,7 +157,7 @@ void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device) if (device->hidden->coinitialized) { WIN_CoUninitialize(); - device->hidden->coinitialized = SDL_FALSE; + device->hidden->coinitialized = false; } } diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 4300cc1b69..a5d0f3cef8 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -53,7 +53,7 @@ using namespace Microsoft::WRL; static Platform::String ^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0"; -static SDL_bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata) +static bool FindWinRTAudioDeviceCallback(SDL_AudioDevice *device, void *userdata) { return (SDL_wcscmp((LPCWSTR) device->handle, (LPCWSTR) userdata) == 0); } @@ -66,7 +66,7 @@ static SDL_AudioDevice *FindWinRTAudioDevice(LPCWSTR devid) class SDL_WasapiDeviceEventHandler { public: - SDL_WasapiDeviceEventHandler(const SDL_bool _recording); + SDL_WasapiDeviceEventHandler(const bool _recording); ~SDL_WasapiDeviceEventHandler(); void OnDeviceAdded(DeviceWatcher ^ sender, DeviceInformation ^ args); void OnDeviceRemoved(DeviceWatcher ^ sender, DeviceInformationUpdate ^ args); @@ -78,7 +78,7 @@ class SDL_WasapiDeviceEventHandler private: SDL_Semaphore *completed_semaphore; - const SDL_bool recording; + const bool recording; DeviceWatcher ^ watcher; Windows::Foundation::EventRegistrationToken added_handler; Windows::Foundation::EventRegistrationToken removed_handler; @@ -87,7 +87,7 @@ class SDL_WasapiDeviceEventHandler Windows::Foundation::EventRegistrationToken default_changed_handler; }; -SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _recording) +SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const bool _recording) : recording(_recording), completed_semaphore(SDL_CreateSemaphore(0)) { if (!completed_semaphore) { @@ -245,14 +245,14 @@ void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_playback, SDL_AudioDevi // DeviceWatchers will fire an Added event for each existing device at // startup, so we don't need to enumerate them separately before // listening for updates. - playback_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_FALSE); + playback_device_event_handler = new SDL_WasapiDeviceEventHandler(false); playback_device_event_handler->WaitForCompletion(); defdevid = MediaDevice::GetDefaultAudioRenderId(AudioDeviceRole::Default); if (defdevid) { *default_playback = FindWinRTAudioDevice(defdevid->Data()); } - recording_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_TRUE); + recording_device_event_handler = new SDL_WasapiDeviceEventHandler(true); recording_device_event_handler->WaitForCompletion(); defdevid = MediaDevice::GetDefaultAudioCaptureId(AudioDeviceRole::Default); if (defdevid) { diff --git a/src/camera/SDL_camera.c b/src/camera/SDL_camera.c index b87089e954..6e40b7763f 100644 --- a/src/camera/SDL_camera.c +++ b/src/camera/SDL_camera.c @@ -542,7 +542,7 @@ void SDL_CameraDisconnected(SDL_Camera *device) ObtainPhysicalCameraObj(device); - const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1); + const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1); if (first_disconnect) { // if already disconnected this device, don't do it twice. // Swap in "Zombie" versions of the usual platform interfaces, so the device will keep // making progress until the app closes it. Otherwise, streams might continue to @@ -580,7 +580,7 @@ void SDL_CameraDisconnected(SDL_Camera *device) } } -void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved) +void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved) { if (!device) { return; @@ -618,7 +618,7 @@ void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved) } -SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata) +SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata) { if (!SDL_GetCurrentCameraDriver()) { SDL_SetError("Camera subsystem is not initialized"); @@ -784,22 +784,22 @@ void SDL_CameraThreadSetup(SDL_Camera *device) #endif } -SDL_bool SDL_CameraThreadIterate(SDL_Camera *device) +bool SDL_CameraThreadIterate(SDL_Camera *device) { SDL_LockMutex(device->lock); if (SDL_AtomicGet(&device->shutdown)) { SDL_UnlockMutex(device->lock); - return SDL_FALSE; // we're done, shut it down. + return false; // we're done, shut it down. } const int permission = device->permission; if (permission <= 0) { SDL_UnlockMutex(device->lock); - return (permission < 0) ? SDL_FALSE : SDL_TRUE; // if permission was denied, shut it down. if undecided, we're done for now. + return (permission < 0) ? false : true; // if permission was denied, shut it down. if undecided, we're done for now. } - SDL_bool failed = SDL_FALSE; // set to true if disaster worthy of treating the device as lost has happened. + bool failed = false; // set to true if disaster worthy of treating the device as lost has happened. SDL_Surface *acquired = NULL; SDL_Surface *output_surface = NULL; SurfaceList *slist = NULL; @@ -851,7 +851,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device) #if DEBUG_CAMERA SDL_Log("CAMERA: dev[%p] error AcquireFrame: %s", device, SDL_GetError()); #endif - failed = SDL_TRUE; + failed = true; } // we can let go of the lock once we've tried to grab a frame of video and maybe moved the output frame off the empty list. @@ -908,7 +908,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device) SDL_UnlockMutex(device->lock); } - return SDL_TRUE; // always go on if not shutting down, even if device failed. + return true; // always go on if not shutting down, even if device failed. } void SDL_CameraThreadShutdown(SDL_Camera *device) @@ -1140,7 +1140,7 @@ SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec) // if we have to scale _and_ convert, we need a middleman surface, since we can't do both changes at once. if (device->needs_scaling && device->needs_conversion) { - const SDL_bool downsampling_first = (device->needs_scaling < 0); + const bool downsampling_first = (device->needs_scaling < 0); const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest; const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format; device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt); @@ -1229,7 +1229,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS) slist = slist->next; } - const SDL_bool list_is_empty = (slist == slistprev); + const bool list_is_empty = (slist == slistprev); if (!list_is_empty) { // report the oldest frame. if (timestampNS) { *timestampNS = slist->timestampNS; @@ -1398,7 +1398,7 @@ static Uint32 HashCameraID(const void *key, void *data) return ((Uint32) ((uintptr_t) key)) - 1; } -static SDL_bool MatchCameraID(const void *a, const void *b, void *data) +static bool MatchCameraID(const void *a, const void *b, void *data) { return (a == b); // simple integers, just compare them as pointer values. } @@ -1419,7 +1419,7 @@ int SDL_CameraInit(const char *driver_name) return -1; } - SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, SDL_FALSE); + SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, false); if (!device_hash) { SDL_DestroyRWLock(device_hash_lock); return -1; @@ -1430,8 +1430,8 @@ int SDL_CameraInit(const char *driver_name) driver_name = SDL_GetHint(SDL_HINT_CAMERA_DRIVER); } - SDL_bool initialized = SDL_FALSE; - SDL_bool tried_to_init = SDL_FALSE; + bool initialized = false; + bool tried_to_init = false; if (driver_name && (*driver_name != 0)) { char *driver_name_copy = SDL_strdup(driver_name); @@ -1451,7 +1451,7 @@ int SDL_CameraInit(const char *driver_name) for (int i = 0; bootstrap[i]; i++) { if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) { - tried_to_init = SDL_TRUE; + tried_to_init = true; SDL_zero(camera_driver); camera_driver.pending_events_tail = &camera_driver.pending_events; camera_driver.device_hash_lock = device_hash_lock; @@ -1459,7 +1459,7 @@ int SDL_CameraInit(const char *driver_name) if (bootstrap[i]->init(&camera_driver.impl)) { camera_driver.name = bootstrap[i]->name; camera_driver.desc = bootstrap[i]->desc; - initialized = SDL_TRUE; + initialized = true; } break; } @@ -1475,7 +1475,7 @@ int SDL_CameraInit(const char *driver_name) continue; } - tried_to_init = SDL_TRUE; + tried_to_init = true; SDL_zero(camera_driver); camera_driver.pending_events_tail = &camera_driver.pending_events; camera_driver.device_hash_lock = device_hash_lock; @@ -1483,7 +1483,7 @@ int SDL_CameraInit(const char *driver_name) if (bootstrap[i]->init(&camera_driver.impl)) { camera_driver.name = bootstrap[i]->name; camera_driver.desc = bootstrap[i]->desc; - initialized = SDL_TRUE; + initialized = true; } } } diff --git a/src/camera/SDL_syscamera.h b/src/camera/SDL_syscamera.h index 2e6e95ca26..a48779824e 100644 --- a/src/camera/SDL_syscamera.h +++ b/src/camera/SDL_syscamera.h @@ -39,10 +39,10 @@ extern SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position, extern void SDL_CameraDisconnected(SDL_Camera *device); // Find an SDL_Camera, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE. -extern SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata); +extern SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata); // Backends should call this when the user has approved/denied access to a camera. -extern void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved); +extern void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved); // Backends can call this to get a standardized name for a thread to power a specific camera device. extern char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen); @@ -53,7 +53,7 @@ extern void UnrefPhysicalCamera(SDL_Camera *device); // These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread. extern void SDL_CameraThreadSetup(SDL_Camera *device); -extern SDL_bool SDL_CameraThreadIterate(SDL_Camera *device); +extern bool SDL_CameraThreadIterate(SDL_Camera *device); extern void SDL_CameraThreadShutdown(SDL_Camera *device); // common utility functionality to gather up camera specs. Not required! @@ -138,8 +138,8 @@ struct SDL_Camera // non-zero if acquire_surface needs to be scaled for final output. int needs_scaling; // -1: downscale, 0: no scaling, 1: upscale - // SDL_TRUE if acquire_surface needs to be converted for final output. - SDL_bool needs_conversion; + // true if acquire_surface needs to be converted for final output. + bool needs_conversion; // Current state flags SDL_AtomicInt shutdown; @@ -169,7 +169,7 @@ typedef struct SDL_CameraDriverImpl void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera() void (*Deinitialize)(void); - SDL_bool ProvidesOwnCallbackThread; + bool ProvidesOwnCallbackThread; } SDL_CameraDriverImpl; typedef struct SDL_PendingCameraEvent @@ -198,8 +198,8 @@ typedef struct CameraBootStrap { const char *name; const char *desc; - SDL_bool (*init)(SDL_CameraDriverImpl *impl); - SDL_bool demand_only; // if SDL_TRUE: request explicitly, or it won't be available. + bool (*init)(SDL_CameraDriverImpl *impl); + bool demand_only; // if true: request explicitly, or it won't be available. } CameraBootStrap; // Not all of these are available in a given build. Use #ifdefs, etc. diff --git a/src/camera/android/SDL_camera_android.c b/src/camera/android/SDL_camera_android.c index 75c6be439a..9fb8deec46 100644 --- a/src/camera/android/SDL_camera_android.c +++ b/src/camera/android/SDL_camera_android.c @@ -520,13 +520,13 @@ static void SDLCALL CameraPermissionCallback(void *userdata, const char *permiss SDL_Camera *device = (SDL_Camera *) userdata; if (device->hidden != NULL) { // if device was already closed, don't send an event. if (!granted) { - SDL_CameraPermissionOutcome(device, SDL_FALSE); // sorry, permission denied. + SDL_CameraPermissionOutcome(device, false); // sorry, permission denied. } else if (PrepareCamera(device) < 0) { // permission given? Actually open the camera now. // uhoh, setup failed; since the app thinks we already "opened" the device, mark it as disconnected and don't report the permission. SDL_CameraDisconnected(device); } else { // okay! We have permission to use the camera _and_ opening the hardware worked out, report that the camera is usable! - SDL_CameraPermissionOutcome(device, SDL_TRUE); // go go go! + SDL_CameraPermissionOutcome(device, true); // go go go! } } @@ -666,7 +666,7 @@ static void GatherCameraSpecs(const char *devid, CameraFormatAddData *add_data, pACameraMetadata_free(metadata); } -static SDL_bool FindAndroidCameraByID(SDL_Camera *device, void *userdata) +static bool FindAndroidCameraByID(SDL_Camera *device, void *userdata) { const char *devid = (const char *) userdata; return (SDL_strcmp(devid, (const char *) device->handle) == 0); @@ -800,25 +800,25 @@ static void ANDROIDCAMERA_Deinitialize(void) pAImageReader_new = NULL; } -static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl) +static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl) { // !!! FIXME: slide this off into a subroutine // system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime. void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL); if (!libcamera2) { SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror()); - return SDL_FALSE; + return false; } void *libmedia = dlopen("libmediandk.so", RTLD_NOW | RTLD_LOCAL); if (!libmedia) { SDL_Log("CAMERA: libmediandk.so can't be loaded: %s", dlerror()); dlclose(libcamera2); - return SDL_FALSE; + return false; } - SDL_bool okay = SDL_TRUE; - #define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = SDL_FALSE; } } + bool okay = true; + #define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = false; } } //#define LOADSYM(lib, fn) p##fn = (pfn##fn) fn LOADSYM(libcamera2, ACameraManager_create); LOADSYM(libcamera2, ACameraManager_registerAvailabilityCallback); @@ -867,7 +867,7 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl) if (CreateCameraManager() < 0) { dlclose(libmedia); dlclose(libcamera2); - return SDL_FALSE; + return false; } libcamera2ndk = libcamera2; @@ -882,13 +882,13 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = ANDROIDCAMERA_FreeDeviceHandle; impl->Deinitialize = ANDROIDCAMERA_Deinitialize; - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; - return SDL_TRUE; + return true; } CameraBootStrap ANDROIDCAMERA_bootstrap = { - "android", "SDL Android camera driver", ANDROIDCAMERA_Init, SDL_FALSE + "android", "SDL Android camera driver", ANDROIDCAMERA_Init, false }; #endif diff --git a/src/camera/coremedia/SDL_camera_coremedia.m b/src/camera/coremedia/SDL_camera_coremedia.m index f6462e7091..f865fcd5eb 100644 --- a/src/camera/coremedia/SDL_camera_coremedia.m +++ b/src/camera/coremedia/SDL_camera_coremedia.m @@ -83,16 +83,16 @@ static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormat *pixel_format @end -static SDL_bool CheckCameraPermissions(SDL_Camera *device) +static bool CheckCameraPermissions(SDL_Camera *device) { if (device->permission == 0) { // still expecting a permission result. if (@available(macOS 14, *)) { const AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (status != AVAuthorizationStatusNotDetermined) { // NotDetermined == still waiting for an answer from the user. - SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? SDL_TRUE : SDL_FALSE); + SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? true : false); } } else { - SDL_CameraPermissionOutcome(device, SDL_TRUE); // always allowed (or just unqueryable...?) on older macOS. + SDL_CameraPermissionOutcome(device, true); // always allowed (or just unqueryable...?) on older macOS. } } @@ -408,11 +408,11 @@ static void GatherCameraSpecs(AVCaptureDevice *device, CameraFormatAddData *add_ } } -static SDL_bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata) +static bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata) { NSString *uniqueid = (__bridge NSString *) userdata; AVCaptureDevice *avdev = (__bridge AVCaptureDevice *) device->handle; - return ([uniqueid isEqualToString:avdev.uniqueID]) ? SDL_TRUE : SDL_FALSE; + return ([uniqueid isEqualToString:avdev.uniqueID]) ? true : false; } static void MaybeAddDevice(AVCaptureDevice *avdevice) @@ -484,7 +484,7 @@ static void COREMEDIA_Deinitialize(void) // !!! FIXME: disable hotplug. } -static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl) +static bool COREMEDIA_Init(SDL_CameraDriverImpl *impl) { impl->DetectDevices = COREMEDIA_DetectDevices; impl->OpenDevice = COREMEDIA_OpenDevice; @@ -495,13 +495,13 @@ static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = COREMEDIA_FreeDeviceHandle; impl->Deinitialize = COREMEDIA_Deinitialize; - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; - return SDL_TRUE; + return true; } CameraBootStrap COREMEDIA_bootstrap = { - "coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, SDL_FALSE + "coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, false }; #endif // SDL_CAMERA_DRIVER_COREMEDIA diff --git a/src/camera/dummy/SDL_camera_dummy.c b/src/camera/dummy/SDL_camera_dummy.c index 1c846b1e89..a46d7da8a8 100644 --- a/src/camera/dummy/SDL_camera_dummy.c +++ b/src/camera/dummy/SDL_camera_dummy.c @@ -59,7 +59,7 @@ static void DUMMYCAMERA_Deinitialize(void) { } -static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl) +static bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl) { impl->DetectDevices = DUMMYCAMERA_DetectDevices; impl->OpenDevice = DUMMYCAMERA_OpenDevice; @@ -70,11 +70,11 @@ static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = DUMMYCAMERA_FreeDeviceHandle; impl->Deinitialize = DUMMYCAMERA_Deinitialize; - return SDL_TRUE; + return true; } CameraBootStrap DUMMYCAMERA_bootstrap = { - "dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, SDL_TRUE + "dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, true }; #endif // SDL_CAMERA_DRIVER_DUMMY diff --git a/src/camera/emscripten/SDL_camera_emscripten.c b/src/camera/emscripten/SDL_camera_emscripten.c index b22e8d8f55..69cb921105 100644 --- a/src/camera/emscripten/SDL_camera_emscripten.c +++ b/src/camera/emscripten/SDL_camera_emscripten.c @@ -107,7 +107,7 @@ static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approve device->acquire_surface->w = w; device->acquire_surface->h = h; } - SDL_CameraPermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE); + SDL_CameraPermissionOutcome(device, approved ? true : false); } static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec) @@ -234,7 +234,7 @@ static void EMSCRIPTENCAMERA_DetectDevices(void) } } -static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl) +static bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl) { MAIN_THREAD_EM_ASM({ if (typeof(Module['SDL3']) === 'undefined') { @@ -252,13 +252,13 @@ static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = EMSCRIPTENCAMERA_FreeDeviceHandle; impl->Deinitialize = EMSCRIPTENCAMERA_Deinitialize; - impl->ProvidesOwnCallbackThread = SDL_TRUE; + impl->ProvidesOwnCallbackThread = true; - return SDL_TRUE; + return true; } CameraBootStrap EMSCRIPTENCAMERA_bootstrap = { - "emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, SDL_FALSE + "emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, false }; /* *INDENT-ON* */ // clang-format on diff --git a/src/camera/mediafoundation/SDL_camera_mediafoundation.c b/src/camera/mediafoundation/SDL_camera_mediafoundation.c index f080ab94ae..192c26bf4c 100644 --- a/src/camera/mediafoundation/SDL_camera_mediafoundation.c +++ b/src/camera/mediafoundation/SDL_camera_mediafoundation.c @@ -821,7 +821,7 @@ static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec * IMFMediaSource_Release(source); // srcreader is holding a reference to this. // There is no user permission prompt for camera access (I think?) - SDL_CameraPermissionOutcome(device, SDL_TRUE); + SDL_CameraPermissionOutcome(device, true); #undef CHECK_HRESULT @@ -962,7 +962,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d IMFPresentationDescriptor_Release(presentdesc); } -static SDL_bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata) +static bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata) { return (SDL_strcmp((const char *) device->handle, (const char *) userdata) == 0); } @@ -1051,29 +1051,29 @@ static void MEDIAFOUNDATION_Deinitialize(void) pMFGetStrideForBitmapInfoHeader = NULL; } -static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl) +static bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl) { // !!! FIXME: slide this off into a subroutine HMODULE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows if (!mf) { - return SDL_FALSE; + return false; } HMODULE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! if (!mfplat) { FreeLibrary(mf); - return SDL_FALSE; + return false; } HMODULE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! if (!mfreadwrite) { FreeLibrary(mfplat); FreeLibrary(mf); - return SDL_FALSE; + return false; } - SDL_bool okay = SDL_TRUE; - #define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = SDL_FALSE; } } + bool okay = true; + #define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = false; } } LOADSYM(mf, MFEnumDeviceSources); LOADSYM(mf, MFCreateDeviceSource); LOADSYM(mfplat, MFStartup); @@ -1087,7 +1087,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl) if (okay) { const HRESULT ret = pMFStartup(MF_VERSION, MFSTARTUP_LITE); if (FAILED(ret)) { - okay = SDL_FALSE; + okay = false; } } @@ -1095,7 +1095,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl) FreeLibrary(mfreadwrite); FreeLibrary(mfplat); FreeLibrary(mf); - return SDL_FALSE; + return false; } libmf = mf; @@ -1111,11 +1111,11 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = MEDIAFOUNDATION_FreeDeviceHandle; impl->Deinitialize = MEDIAFOUNDATION_Deinitialize; - return SDL_TRUE; + return true; } CameraBootStrap MEDIAFOUNDATION_bootstrap = { - "mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, SDL_FALSE + "mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, false }; #endif // SDL_CAMERA_DRIVER_MEDIAFOUNDATION diff --git a/src/camera/pipewire/SDL_camera_pipewire.c b/src/camera/pipewire/SDL_camera_pipewire.c index 555f8c6ac4..e91804e29c 100644 --- a/src/camera/pipewire/SDL_camera_pipewire.c +++ b/src/camera/pipewire/SDL_camera_pipewire.c @@ -54,7 +54,7 @@ enum PW_READY_FLAGS #define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x) #define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x) -static SDL_bool pipewire_initialized = SDL_FALSE; +static bool pipewire_initialized = false; // Pipewire entry points static const char *(*PIPEWIRE_pw_get_library_version)(void); @@ -232,9 +232,9 @@ static struct struct spa_list global_list; - SDL_bool have_1_0_5; - SDL_bool init_complete; - SDL_bool events_enabled; + bool have_1_0_5; + bool init_complete; + bool events_enabled; } hotplug; struct global @@ -258,7 +258,7 @@ struct global struct spa_list pending_list; struct spa_list param_list; - SDL_bool added; + bool added; }; struct global_class @@ -434,7 +434,7 @@ static void on_stream_state_changed(void *data, enum pw_stream_state old, case PW_STREAM_STATE_UNCONNECTED: break; case PW_STREAM_STATE_STREAMING: - SDL_CameraPermissionOutcome(device, SDL_TRUE); + SDL_CameraPermissionOutcome(device, true); break; default: break; @@ -722,7 +722,7 @@ static void add_device(struct global *g) } SDL_free(data.specs); - g->added = SDL_TRUE; + g->added = true; } static void PIPEWIRECAMERA_DetectDevices(void) @@ -742,7 +742,7 @@ static void PIPEWIRECAMERA_DetectDevices(void) } } - hotplug.events_enabled = SDL_TRUE; + hotplug.events_enabled = true; PIPEWIRE_pw_thread_loop_unlock(hotplug.loop); } @@ -954,7 +954,7 @@ static void hotplug_core_done_callback(void *object, uint32_t id, int seq) add_device(g); } } - hotplug.init_complete = SDL_TRUE; + hotplug.init_complete = true; PIPEWIRE_pw_thread_loop_signal(hotplug.loop, false); } } @@ -968,7 +968,7 @@ static const struct pw_core_events hotplug_core_events = /* When in a container, the library version can differ from the underlying core version, * so make sure the underlying Pipewire implementation meets the version requirement. */ -static SDL_bool pipewire_server_version_at_least(int major, int minor, int patch) +static bool pipewire_server_version_at_least(int major, int minor, int patch) { return (hotplug.server_major >= major) && (hotplug.server_major > major || hotplug.server_minor >= minor) && @@ -1055,23 +1055,23 @@ static void PIPEWIRECAMERA_Deinitialize(void) } deinit_pipewire_library(); spa_zero(hotplug); - pipewire_initialized = SDL_FALSE; + pipewire_initialized = false; } } -static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl) +static bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl) { if (!pipewire_initialized) { if (init_pipewire_library() < 0) { - return SDL_FALSE; + return false; } - pipewire_initialized = SDL_TRUE; + pipewire_initialized = true; if (hotplug_loop_init() < 0) { PIPEWIRECAMERA_Deinitialize(); - return SDL_FALSE; + return false; } } @@ -1084,11 +1084,11 @@ static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = PIPEWIRECAMERA_FreeDeviceHandle; impl->Deinitialize = PIPEWIRECAMERA_Deinitialize; - return SDL_TRUE; + return true; } CameraBootStrap PIPEWIRECAMERA_bootstrap = { - "pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, SDL_FALSE + "pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, false }; #endif // SDL_CAMERA_DRIVER_PIPEWIRE diff --git a/src/camera/v4l2/SDL_camera_v4l2.c b/src/camera/v4l2/SDL_camera_v4l2.c index de904737ba..4488c4bc32 100644 --- a/src/camera/v4l2/SDL_camera_v4l2.c +++ b/src/camera/v4l2/SDL_camera_v4l2.c @@ -601,7 +601,7 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec) } size_t size, pitch; - SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, SDL_FALSE); + SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, false); int rc = 0; switch (io) { @@ -634,12 +634,12 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec) } // Currently there is no user permission prompt for camera access, but maybe there will be a D-Bus portal interface at some point. - SDL_CameraPermissionOutcome(device, SDL_TRUE); + SDL_CameraPermissionOutcome(device, true); return 0; } -static SDL_bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata) +static bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata) { const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle; return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0); @@ -820,7 +820,7 @@ static void V4L2_FreeDeviceHandle(SDL_Camera *device) } #ifdef SDL_USE_LIBUDEV -static SDL_bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata) +static bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata) { const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle; return (SDL_strcmp(handle->path, (const char *) userdata) == 0); @@ -878,7 +878,7 @@ static void V4L2_DetectDevices(void) #endif // SDL_USE_LIBUDEV } -static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl) +static bool V4L2_Init(SDL_CameraDriverImpl *impl) { impl->DetectDevices = V4L2_DetectDevices; impl->OpenDevice = V4L2_OpenDevice; @@ -889,11 +889,11 @@ static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl) impl->FreeDeviceHandle = V4L2_FreeDeviceHandle; impl->Deinitialize = V4L2_Deinitialize; - return SDL_TRUE; + return true; } CameraBootStrap V4L2_bootstrap = { - "v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, SDL_FALSE + "v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, false }; #endif // SDL_CAMERA_DRIVER_V4L2 diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c index 96e62dd186..677243c3eb 100644 --- a/src/core/SDL_core_unsupported.c +++ b/src/core/SDL_core_unsupported.c @@ -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); diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 1a9bcc81f0..3b200e9b81 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -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 diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index b91e576f0d..8eef801cbf 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -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 diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c index cc96a4d109..faa7f70c1b 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -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; } diff --git a/src/core/haiku/SDL_BApp.h b/src/core/haiku/SDL_BApp.h index 3e55bebb41..8b9275598e 100644 --- a/src/core/haiku/SDL_BApp.h +++ b/src/core/haiku/SDL_BApp.h @@ -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(); } diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index d0ff169e1d..3969471b00 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -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) diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index 11c6d95395..45da4e160e 100644 --- a/src/core/linux/SDL_dbus.h +++ b/src/core/linux/SDL_dbus.h @@ -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); diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index e998c1b303..b9808bed5f 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -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); diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index cf3cecb9f1..f6629f8cff 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -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) { } diff --git a/src/core/linux/SDL_evdev_kbd.h b/src/core/linux/SDL_evdev_kbd.h index e08d641109..39f1d7223b 100644 --- a/src/core/linux/SDL_evdev_kbd.h +++ b/src/core/linux/SDL_evdev_kbd.h @@ -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); diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index ed36bd1120..91f46353c5 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -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) diff --git a/src/core/linux/SDL_fcitx.h b/src/core/linux/SDL_fcitx.h index abc763399e..5788baaca6 100644 --- a/src/core/linux/SDL_fcitx.h +++ b/src/core/linux/SDL_fcitx.h @@ -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); diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index f7438d347b..ab14c1704a 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -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(); diff --git a/src/core/linux/SDL_ibus.h b/src/core/linux/SDL_ibus.h index 97f924b60e..26349f9769 100644 --- a/src/core/linux/SDL_ibus.h +++ b/src/core/linux/SDL_ibus.h @@ -28,19 +28,19 @@ #define SDL_USE_IBUS 1 #include -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. */ diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c index c248c019a1..2904f020f9 100644 --- a/src/core/linux/SDL_ime.c +++ b/src/core/linux/SDL_ime.c @@ -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) diff --git a/src/core/linux/SDL_ime.h b/src/core/linux/SDL_ime.h index ef16cdbe5b..907676325c 100644 --- a/src/core/linux/SDL_ime.h +++ b/src/core/linux/SDL_ime.h @@ -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); diff --git a/src/core/linux/SDL_system_theme.c b/src/core/linux/SDL_system_theme.c index 0d4846b9d0..570d932519 100644 --- a/src/core/linux/SDL_system_theme.c +++ b/src/core/linux/SDL_system_theme.c @@ -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) diff --git a/src/core/linux/SDL_system_theme.h b/src/core/linux/SDL_system_theme.h index 85e1fffbb7..2693e5d071 100644 --- a/src/core/linux/SDL_system_theme.h +++ b/src/core/linux/SDL_system_theme.h @@ -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_ diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index bd1daac081..03a928877f 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -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 diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 3faf2194cc..62f49a4e09 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -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) diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index fccdd22a49..c58e57bb2d 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -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); diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index 2d02135702..b6d924302a 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -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) { diff --git a/src/core/openbsd/SDL_wscons_mouse.c b/src/core/openbsd/SDL_wscons_mouse.c index 9eadd36c24..03b0f7de24 100644 --- a/src/core/openbsd/SDL_wscons_mouse.c +++ b/src/core/openbsd/SDL_wscons_mouse.c @@ -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); diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index 07f86ccc2e..554355438d 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -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 *)¬ification_client); diff --git a/src/core/windows/SDL_immdevice.h b/src/core/windows/SDL_immdevice.h index b119ed05df..e196763377 100644 --- a/src/core/windows/SDL_immdevice.h +++ b/src/core/windows/SDL_immdevice.h @@ -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); diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index c7913cb025..f8d59dd406 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -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; diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 3d7f5c043f..95f5aee34f 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -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); diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 9cde09902c..2591eb7188 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -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; } } diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp index ad259a2ddb..5fa2ffa9d3 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -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 diff --git a/src/core/winrt/SDL_winrtapp_xaml.h b/src/core/winrt/SDL_winrtapp_xaml.h index b321cc8320..c4797fa705 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.h +++ b/src/core/winrt/SDL_winrtapp_xaml.h @@ -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 diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 9872f7e815..4704bdc6ea 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -276,14 +276,14 @@ done: static int CPU_CPUIDFeatures[4]; static int CPU_CPUIDMaxFunction = 0; -static SDL_bool CPU_OSSavesYMM = SDL_FALSE; -static SDL_bool CPU_OSSavesZMM = SDL_FALSE; +static bool CPU_OSSavesYMM = false; +static bool CPU_OSSavesZMM = false; static void CPU_calcCPUIDFeatures(void) { - static SDL_bool checked = SDL_FALSE; + static bool checked = false; if (!checked) { - checked = SDL_TRUE; + checked = true; if (CPU_haveCPUID()) { int a, b, c, d; cpuid(0, a, b, c, d); @@ -313,8 +313,8 @@ static void CPU_calcCPUIDFeatures(void) mov a, eax } #endif - CPU_OSSavesYMM = ((a & 6) == 6) ? SDL_TRUE : SDL_FALSE; - CPU_OSSavesZMM = (CPU_OSSavesYMM && ((a & 0xe0) == 0xe0)) ? SDL_TRUE : SDL_FALSE; + CPU_OSSavesYMM = ((a & 6) == 6) ? true : false; + CPU_OSSavesZMM = (CPU_OSSavesYMM && ((a & 0xe0) == 0xe0)) ? true : false; } } } @@ -888,7 +888,7 @@ int SDL_GetCPUCacheLineSize(void) static Uint32 SDL_CPUFeatures = SDL_CPUFEATURES_RESET_VALUE; static Uint32 SDL_SIMDAlignment = 0xFFFFFFFF; -static SDL_bool ref_string_equals(const char *ref, const char *test, const char *end_test) { +static bool ref_string_equals(const char *ref, const char *test, const char *end_test) { size_t len_test = end_test - test; return SDL_strncmp(ref, test, len_test) == 0 && ref[len_test] == '\0' && (test[len_test] == '\0' || test[len_test] == ','); } @@ -903,7 +903,7 @@ static Uint32 SDLCALL SDL_CPUFeatureMaskFromHint(void) for (const char *spot = hint, *next; *spot; spot = next) { const char *end = SDL_strchr(spot, ','); Uint32 spot_mask; - SDL_bool add_spot_mask = SDL_TRUE; + bool add_spot_mask = true; if (end) { next = end + 1; } else { @@ -912,10 +912,10 @@ static Uint32 SDLCALL SDL_CPUFeatureMaskFromHint(void) next = end; } if (spot[0] == '+') { - add_spot_mask = SDL_TRUE; + add_spot_mask = true; spot += 1; } else if (spot[0] == '-') { - add_spot_mask = SDL_FALSE; + add_spot_mask = false; spot += 1; } if (ref_string_equals("all", spot, end)) { @@ -1033,7 +1033,7 @@ void SDL_QuitCPUInfo(void) { SDL_CPUFeatures = SDL_CPUFEATURES_RESET_VALUE; } -#define CPU_FEATURE_AVAILABLE(f) ((SDL_GetCPUFeatures() & (f)) ? SDL_TRUE : SDL_FALSE) +#define CPU_FEATURE_AVAILABLE(f) ((SDL_GetCPUFeatures() & (f)) ? true : false) SDL_bool SDL_HasAltiVec(void) { diff --git a/src/dialog/android/SDL_androiddialog.c b/src/dialog/android/SDL_androiddialog.c index be09792956..80de9bfd75 100644 --- a/src/dialog/android/SDL_androiddialog.c +++ b/src/dialog/android/SDL_androiddialog.c @@ -24,7 +24,7 @@ void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, SDL_bool allow_many) { - if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_FALSE, allow_many)) { + if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, false, allow_many)) { // SDL_SetError is already called when it fails callback(userdata, NULL, -1); } @@ -32,7 +32,7 @@ void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userd void SDLCALL SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location) { - if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, SDL_TRUE, SDL_FALSE)) { + if (!Android_JNI_OpenFileDialog(callback, userdata, filters, nfilters, true, false)) { // SDL_SetError is already called when it fails callback(userdata, NULL, -1); } diff --git a/src/dialog/cocoa/SDL_cocoadialog.m b/src/dialog/cocoa/SDL_cocoadialog.m index f65025b050..72f2df6e8b 100644 --- a/src/dialog/cocoa/SDL_cocoadialog.m +++ b/src/dialog/cocoa/SDL_cocoadialog.m @@ -31,7 +31,7 @@ typedef enum FDT_OPENFOLDER } cocoa_FileDialogType; -void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) +void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many) { #if defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_IOS) SDL_SetError("tvOS and iOS don't support path-based file dialogs"); @@ -63,14 +63,14 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback break; case FDT_OPEN: dialog_as_open = [NSOpenPanel openPanel]; - [dialog_as_open setAllowsMultipleSelection:((allow_many == SDL_TRUE) ? YES : NO)]; + [dialog_as_open setAllowsMultipleSelection:((allow_many == true) ? YES : NO)]; dialog = dialog_as_open; break; case FDT_OPENFOLDER: dialog_as_open = [NSOpenPanel openPanel]; [dialog_as_open setCanChooseFiles:NO]; [dialog_as_open setCanChooseDirectories:YES]; - [dialog_as_open setAllowsMultipleSelection:((allow_many == SDL_TRUE) ? YES : NO)]; + [dialog_as_open setAllowsMultipleSelection:((allow_many == true) ? YES : NO)]; dialog = dialog_as_open; break; }; diff --git a/src/dialog/haiku/SDL_haikudialog.cc b/src/dialog/haiku/SDL_haikudialog.cc index 9c03958610..5dd4f0c9cf 100644 --- a/src/dialog/haiku/SDL_haikudialog.cc +++ b/src/dialog/haiku/SDL_haikudialog.cc @@ -245,7 +245,7 @@ void ShowDialog(bool save, SDL_DialogFileCallback callback, void *userdata, bool void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, SDL_bool allow_many) { - ShowDialog(false, callback, userdata, allow_many == SDL_TRUE, !!window, filters, nfilters, false, default_location); + ShowDialog(false, callback, userdata, allow_many == true, !!window, filters, nfilters, false, default_location); } void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location) @@ -255,5 +255,5 @@ void SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char* default_location, SDL_bool allow_many) { - ShowDialog(false, callback, userdata, allow_many == SDL_TRUE, !!window, NULL, 0, true, default_location); + ShowDialog(false, callback, userdata, allow_many == true, !!window, NULL, 0, true, default_location); } diff --git a/src/dialog/unix/SDL_portaldialog.c b/src/dialog/unix/SDL_portaldialog.c index 642f4f342d..66dbcd1d9d 100644 --- a/src/dialog/unix/SDL_portaldialog.c +++ b/src/dialog/unix/SDL_portaldialog.c @@ -275,7 +275,7 @@ not_our_signal: return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static void DBus_OpenDialog(const char *method, const char *method_title, SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many, int open_folders) +static void DBus_OpenDialog(const char *method, const char *method_title, SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many, int open_folders) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); DBusMessage *msg; @@ -357,7 +357,7 @@ static void DBus_OpenDialog(const char *method, const char *method_title, SDL_Di SDL_free(handle_str); DBus_AppendBoolOption(dbus, &options, "modal", !!window); - if (allow_many == SDL_TRUE) { + if (allow_many == true) { DBus_AppendBoolOption(dbus, &options, "multiple", 1); } if (open_folders) { @@ -425,7 +425,7 @@ incorrect_type: dbus->message_unref(reply); } -void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) +void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many) { DBus_OpenDialog("OpenFile", "Open File", callback, userdata, window, filters, nfilters, default_location, allow_many, 0); } @@ -435,7 +435,7 @@ void SDL_Portal_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userda DBus_OpenDialog("SaveFile", "Save File", callback, userdata, window, filters, nfilters, default_location, 0, 0); } -void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many) +void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many) { DBus_OpenDialog("OpenFile", "Open Folder", callback, userdata, window, NULL, 0, default_location, allow_many, 1); } @@ -500,7 +500,7 @@ done: // Dummy implementation to avoid compilation problems -void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) +void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many) { SDL_Unsupported(); callback(userdata, NULL, -1); @@ -512,7 +512,7 @@ void SDL_Portal_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userda callback(userdata, NULL, -1); } -void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many) +void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many) { SDL_Unsupported(); callback(userdata, NULL, -1); diff --git a/src/dialog/unix/SDL_portaldialog.h b/src/dialog/unix/SDL_portaldialog.h index f0051d3033..f6275d8343 100644 --- a/src/dialog/unix/SDL_portaldialog.h +++ b/src/dialog/unix/SDL_portaldialog.h @@ -21,9 +21,9 @@ #include "SDL_internal.h" -void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many); +void SDL_Portal_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many); void SDL_Portal_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location); -void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many); +void SDL_Portal_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many); /** @returns non-zero if available, zero if unavailable */ int SDL_Portal_detect(void); diff --git a/src/dialog/unix/SDL_unixdialog.c b/src/dialog/unix/SDL_unixdialog.c index 6928d24d57..91603e7d68 100644 --- a/src/dialog/unix/SDL_unixdialog.c +++ b/src/dialog/unix/SDL_unixdialog.c @@ -23,9 +23,9 @@ #include "./SDL_portaldialog.h" #include "./SDL_zenitydialog.h" -static void (*detected_open)(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) = NULL; +static void (*detected_open)(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many) = NULL; static void (*detected_save)(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location) = NULL; -static void (*detected_folder)(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many) = NULL; +static void (*detected_folder)(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many) = NULL; static int detect_available_methods(const char *value); @@ -36,10 +36,10 @@ void SDLCALL hint_callback(void *userdata, const char *name, const char *oldValu static void set_callback(void) { - static SDL_bool is_set = SDL_FALSE; + static bool is_set = false; - if (is_set == SDL_FALSE) { - is_set = SDL_TRUE; + if (is_set == false) { + is_set = true; SDL_AddHintCallback(SDL_HINT_FILE_DIALOG_DRIVER, hint_callback, NULL); } } diff --git a/src/dialog/unix/SDL_zenitydialog.c b/src/dialog/unix/SDL_zenitydialog.c index a6e07b8376..f6f037f285 100644 --- a/src/dialog/unix/SDL_zenitydialog.c +++ b/src/dialog/unix/SDL_zenitydialog.c @@ -323,7 +323,7 @@ static int run_zenity_thread(void* ptr) return 0; } -void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many) +void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many) { zenityArgs *args; SDL_Thread *thread; @@ -339,7 +339,7 @@ void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userda args->filename = default_location; args->filters = filters; args->nfilters = nfilters; - args->flags = (allow_many == SDL_TRUE) ? ZENITY_MULTIPLE : 0; + args->flags = (allow_many == true) ? ZENITY_MULTIPLE : 0; thread = SDL_CreateThread(run_zenity_thread, "SDL_ShowOpenFileDialog", (void *) args); @@ -379,7 +379,7 @@ void SDL_Zenity_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userda SDL_DetachThread(thread); } -void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many) +void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many) { zenityArgs *args; SDL_Thread *thread; @@ -395,7 +395,7 @@ void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* user args->filename = default_location; args->filters = NULL; args->nfilters = 0; - args->flags = ((allow_many == SDL_TRUE) ? ZENITY_MULTIPLE : 0) | ZENITY_DIRECTORY; + args->flags = ((allow_many == true) ? ZENITY_MULTIPLE : 0) | ZENITY_DIRECTORY; thread = SDL_CreateThread(run_zenity_thread, "SDL_ShowOpenFolderDialog", (void *) args); diff --git a/src/dialog/unix/SDL_zenitydialog.h b/src/dialog/unix/SDL_zenitydialog.h index 3c200639a2..507f801e92 100644 --- a/src/dialog/unix/SDL_zenitydialog.h +++ b/src/dialog/unix/SDL_zenitydialog.h @@ -21,9 +21,9 @@ #include "SDL_internal.h" -void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, SDL_bool allow_many); +void SDL_Zenity_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location, bool allow_many); void SDL_Zenity_ShowSaveFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const SDL_DialogFileFilter *filters, int nfilters, const char* default_location); -void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, SDL_bool allow_many); +void SDL_Zenity_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void* userdata, SDL_Window* window, const char* default_location, bool allow_many); /** @returns non-zero if available, zero if unavailable */ int SDL_Zenity_detect(void); diff --git a/src/dialog/windows/SDL_windowsdialog.c b/src/dialog/windows/SDL_windowsdialog.c index b6f7508267..405b2a9c17 100644 --- a/src/dialog/windows/SDL_windowsdialog.c +++ b/src/dialog/windows/SDL_windowsdialog.c @@ -450,7 +450,7 @@ void SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void* userdata, SDL args->nfilters = nfilters; args->default_file = default_location; args->parent = window; - args->flags = (allow_many == SDL_TRUE) ? OFN_ALLOWMULTISELECT : 0; + args->flags = (allow_many == true) ? OFN_ALLOWMULTISELECT : 0; args->callback = callback; args->userdata = userdata; diff --git a/src/events/SDL_dropevents.c b/src/events/SDL_dropevents.c index d7ad1f3e2f..de6491ab4a 100644 --- a/src/events/SDL_dropevents.c +++ b/src/events/SDL_dropevents.c @@ -29,14 +29,14 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *source, const char *data, float x, float y) { - static SDL_bool app_is_dropping = SDL_FALSE; + static bool app_is_dropping = false; static float last_drop_x = 0; static float last_drop_y = 0; int posted = 0; // Post the event, if desired if (SDL_EventEnabled(evtype)) { - const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping; + const bool need_begin = window ? !window->is_dropping : !app_is_dropping; SDL_Event event; if (need_begin) { @@ -49,9 +49,9 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch return 0; } if (window) { - window->is_dropping = SDL_TRUE; + window->is_dropping = true; } else { - app_is_dropping = SDL_TRUE; + app_is_dropping = true; } } @@ -82,9 +82,9 @@ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const ch if (posted && (evtype == SDL_EVENT_DROP_COMPLETE)) { if (window) { - window->is_dropping = SDL_FALSE; + window->is_dropping = false; } else { - app_is_dropping = SDL_FALSE; + app_is_dropping = false; } last_drop_x = 0; diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index f21c9ce1e1..2279adcf75 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -56,15 +56,15 @@ typedef struct SDL_EventWatcher { SDL_EventFilter callback; void *userdata; - SDL_bool removed; + bool removed; } SDL_EventWatcher; static SDL_Mutex *SDL_event_watchers_lock; static SDL_EventWatcher SDL_EventOK; static SDL_EventWatcher *SDL_event_watchers = NULL; static int SDL_event_watchers_count = 0; -static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE; -static SDL_bool SDL_event_watchers_removed = SDL_FALSE; +static bool SDL_event_watchers_dispatching = false; +static bool SDL_event_watchers_removed = false; static SDL_AtomicInt SDL_sentinel_pending; static Uint32 SDL_last_event_id = 0; @@ -102,13 +102,13 @@ typedef struct SDL_EventEntry static struct { SDL_Mutex *lock; - SDL_bool active; + bool active; SDL_AtomicInt count; int max_events_seen; SDL_EventEntry *head; SDL_EventEntry *tail; SDL_EventEntry *free; -} SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL }; +} SDL_EventQ = { NULL, false, { 0 }, 0, NULL, NULL, NULL }; static void SDL_CleanupTemporaryMemory(void *data) @@ -119,7 +119,7 @@ static void SDL_CleanupTemporaryMemory(void *data) SDL_free(state); } -static SDL_TemporaryMemoryState *SDL_GetTemporaryMemoryState(SDL_bool create) +static SDL_TemporaryMemoryState *SDL_GetTemporaryMemoryState(bool create) { SDL_TemporaryMemoryState *state; @@ -188,7 +188,7 @@ static void SDL_UnlinkTemporaryMemoryEntry(SDL_TemporaryMemoryState *state, SDL_ entry->next = NULL; } -static void SDL_FreeTemporaryMemoryEntry(SDL_TemporaryMemoryState *state, SDL_TemporaryMemory *entry, SDL_bool free_data) +static void SDL_FreeTemporaryMemoryEntry(SDL_TemporaryMemoryState *state, SDL_TemporaryMemory *entry, bool free_data) { if (free_data) { SDL_free(entry->memory); @@ -201,7 +201,7 @@ static void SDL_LinkTemporaryMemoryToEvent(SDL_EventEntry *event, const void *me SDL_TemporaryMemoryState *state; SDL_TemporaryMemory *entry; - state = SDL_GetTemporaryMemoryState(SDL_FALSE); + state = SDL_GetTemporaryMemoryState(false); if (!state) { return; } @@ -250,7 +250,7 @@ static void SDL_TransferTemporaryMemoryFromEvent(SDL_EventEntry *event) return; } - state = SDL_GetTemporaryMemoryState(SDL_TRUE); + state = SDL_GetTemporaryMemoryState(true); if (!state) { return; // this is now a leak, but you probably have bigger problems if malloc failed. } @@ -273,7 +273,7 @@ static void *SDL_FreeLater(void *memory) // Make sure we're not adding this to the list twice //SDL_assert(!SDL_ClaimTemporaryMemory(memory)); - state = SDL_GetTemporaryMemoryState(SDL_TRUE); + state = SDL_GetTemporaryMemoryState(true); if (!state) { return memory; // this is now a leak, but you probably have bigger problems if malloc failed. } @@ -307,12 +307,12 @@ void *SDL_ClaimTemporaryMemory(const void *mem) { SDL_TemporaryMemoryState *state; - state = SDL_GetTemporaryMemoryState(SDL_FALSE); + state = SDL_GetTemporaryMemoryState(false); if (state && mem) { SDL_TemporaryMemory *entry = SDL_GetTemporaryMemoryEntry(state, mem); if (entry) { SDL_UnlinkTemporaryMemoryEntry(state, entry); - SDL_FreeTemporaryMemoryEntry(state, entry, SDL_FALSE); + SDL_FreeTemporaryMemoryEntry(state, entry, false); return (void *)mem; } } @@ -323,7 +323,7 @@ void SDL_FreeTemporaryMemory(void) { SDL_TemporaryMemoryState *state; - state = SDL_GetTemporaryMemoryState(SDL_FALSE); + state = SDL_GetTemporaryMemoryState(false); if (!state) { return; } @@ -332,35 +332,35 @@ void SDL_FreeTemporaryMemory(void) SDL_TemporaryMemory *entry = state->head; SDL_UnlinkTemporaryMemoryEntry(state, entry); - SDL_FreeTemporaryMemoryEntry(state, entry, SDL_TRUE); + SDL_FreeTemporaryMemoryEntry(state, entry, true); } } #ifndef SDL_JOYSTICK_DISABLED -static SDL_bool SDL_update_joysticks = SDL_TRUE; +static bool SDL_update_joysticks = true; static void SDLCALL SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - SDL_update_joysticks = SDL_GetStringBoolean(hint, SDL_TRUE); + SDL_update_joysticks = SDL_GetStringBoolean(hint, true); } #endif // !SDL_JOYSTICK_DISABLED #ifndef SDL_SENSOR_DISABLED -static SDL_bool SDL_update_sensors = SDL_TRUE; +static bool SDL_update_sensors = true; static void SDLCALL SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - SDL_update_sensors = SDL_GetStringBoolean(hint, SDL_TRUE); + SDL_update_sensors = SDL_GetStringBoolean(hint, true); } #endif // !SDL_SENSOR_DISABLED static void SDLCALL SDL_PollSentinelChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - SDL_SetEventEnabled(SDL_EVENT_POLL_SENTINEL, SDL_GetStringBoolean(hint, SDL_TRUE)); + SDL_SetEventEnabled(SDL_EVENT_POLL_SENTINEL, SDL_GetStringBoolean(hint, true)); } /** @@ -832,7 +832,7 @@ void SDL_StopEventLoop(void) SDL_LockMutex(SDL_EventQ.lock); - SDL_EventQ.active = SDL_FALSE; + SDL_EventQ.active = false; if (report && SDL_atoi(report)) { SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n", @@ -912,7 +912,7 @@ int SDL_StartEventLoop(void) } #endif // !SDL_THREADS_DISABLED - SDL_EventQ.active = SDL_TRUE; + SDL_EventQ.active = true; SDL_UnlockMutex(SDL_EventQ.lock); return 0; } @@ -1031,7 +1031,7 @@ static int SDL_SendWakeupEvent(void) // Lock the event queue, take a peep at it, and unlock it static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAction action, - Uint32 minType, Uint32 maxType, SDL_bool include_sentinel) + Uint32 minType, Uint32 maxType, bool include_sentinel) { int i, used, sentinels_expected = 0; @@ -1102,7 +1102,7 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAct int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType) { - return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, SDL_FALSE); + return SDL_PeepEventsInternal(events, numevents, action, minType, maxType, false); } SDL_bool SDL_HasEvent(Uint32 type) @@ -1153,7 +1153,7 @@ void SDL_FlushEvents(Uint32 minType, Uint32 maxType) } // Run the system dependent event loops -static void SDL_PumpEventsInternal(SDL_bool push_sentinel) +static void SDL_PumpEventsInternal(bool push_sentinel) { // Free any temporary memory from old events SDL_FreeTemporaryMemory(); @@ -1201,7 +1201,7 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) // Make sure we don't already have a sentinel in the queue, and add one to the end if (SDL_AtomicGet(&SDL_sentinel_pending) > 0) { - SDL_PeepEventsInternal(&sentinel, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE); + SDL_PeepEventsInternal(&sentinel, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, true); } sentinel.type = SDL_EVENT_POLL_SENTINEL; @@ -1212,7 +1212,7 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) void SDL_PumpEvents(void) { - SDL_PumpEventsInternal(SDL_FALSE); + SDL_PumpEventsInternal(false); } // Public functions @@ -1263,7 +1263,7 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu c) Periodic processing that takes place in some platform PumpEvents() functions happens d) Signals received in WaitEventTimeout() are turned into SDL events */ - SDL_PumpEventsInternal(SDL_TRUE); + SDL_PumpEventsInternal(true); SDL_LockMutex(_this->wakeup_lock); { @@ -1352,7 +1352,7 @@ SDL_bool SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS) SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) { Uint64 start, expiration; - SDL_bool include_sentinel = (timeoutNS == 0); + bool include_sentinel = (timeoutNS == 0); int result; if (timeoutNS > 0) { @@ -1365,40 +1365,40 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) // If there isn't a poll sentinel event pending, pump events and add one if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) { - SDL_PumpEventsInternal(SDL_TRUE); + SDL_PumpEventsInternal(true); } // First check for existing events result = SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, include_sentinel); if (result < 0) { - return SDL_FALSE; + return false; } if (include_sentinel) { if (event) { if (event->type == SDL_EVENT_POLL_SENTINEL) { // Reached the end of a poll cycle, and not willing to wait - return SDL_FALSE; + return false; } } else { // Need to peek the next event to check for sentinel SDL_Event dummy; - if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, SDL_TRUE) && + if (SDL_PeepEventsInternal(&dummy, 1, SDL_PEEKEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST, true) && dummy.type == SDL_EVENT_POLL_SENTINEL) { - SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE); + SDL_PeepEventsInternal(&dummy, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, true); // Reached the end of a poll cycle, and not willing to wait - return SDL_FALSE; + return false; } } } if (result == 0) { if (timeoutNS == 0) { // No events available, and not willing to wait - return SDL_FALSE; + return false; } } else { // Has existing events - return SDL_TRUE; + return true; } // We should have completely handled timeoutNS == 0 above SDL_assert(timeoutNS != 0); @@ -1406,7 +1406,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) #ifdef SDL_PLATFORM_ANDROID for (;;) { if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) > 0) { - return SDL_TRUE; + return true; } Uint64 delay = -1; @@ -1414,7 +1414,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) Uint64 now = SDL_GetTicksNS(); if (now >= expiration) { // Timeout expired and no events - return SDL_FALSE; + return false; } delay = (expiration - now); } @@ -1428,9 +1428,9 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) if (wakeup_window) { result = SDL_WaitEventTimeout_Device(_this, wakeup_window, event, start, timeoutNS); if (result > 0) { - return SDL_TRUE; + return true; } else if (result == 0) { - return SDL_FALSE; + return false; } else { /* There may be implementation-defined conditions where the backend cannot * reliably wait for the next event. If that happens, fall back to polling. @@ -1440,10 +1440,10 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) } for (;;) { - SDL_PumpEventsInternal(SDL_TRUE); + SDL_PumpEventsInternal(true); if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) > 0) { - return SDL_TRUE; + return true; } Uint64 delay = EVENT_POLL_INTERVAL_NS; @@ -1451,7 +1451,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) Uint64 now = SDL_GetTicksNS(); if (now >= expiration) { // Timeout expired and no events - return SDL_FALSE; + return false; } delay = SDL_min((expiration - now), delay); } @@ -1460,7 +1460,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS) #endif // SDL_PLATFORM_ANDROID } -static SDL_bool SDL_CallEventWatchers(SDL_Event *event) +static bool SDL_CallEventWatchers(SDL_Event *event) { if ((SDL_EventOK.callback || SDL_event_watchers_count > 0) && (event->common.type != SDL_EVENT_POLL_SENTINEL)) { @@ -1468,20 +1468,20 @@ static SDL_bool SDL_CallEventWatchers(SDL_Event *event) { if (SDL_EventOK.callback && !SDL_EventOK.callback(SDL_EventOK.userdata, event)) { SDL_UnlockMutex(SDL_event_watchers_lock); - return SDL_FALSE; + return false; } if (SDL_event_watchers_count > 0) { // Make sure we only dispatch the current watcher list int i, event_watchers_count = SDL_event_watchers_count; - SDL_event_watchers_dispatching = SDL_TRUE; + SDL_event_watchers_dispatching = true; for (i = 0; i < event_watchers_count; ++i) { if (!SDL_event_watchers[i].removed) { SDL_event_watchers[i].callback(SDL_event_watchers[i].userdata, event); } } - SDL_event_watchers_dispatching = SDL_FALSE; + SDL_event_watchers_dispatching = false; if (SDL_event_watchers_removed) { for (i = SDL_event_watchers_count; i--;) { @@ -1492,14 +1492,14 @@ static SDL_bool SDL_CallEventWatchers(SDL_Event *event) } } } - SDL_event_watchers_removed = SDL_FALSE; + SDL_event_watchers_removed = false; } } } SDL_UnlockMutex(SDL_event_watchers_lock); } - return SDL_TRUE; + return true; } int SDL_PushEvent(SDL_Event *event) @@ -1560,7 +1560,7 @@ SDL_bool SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata) if (userdata) { *userdata = event_ok.userdata; } - return event_ok.callback ? SDL_TRUE : SDL_FALSE; + return event_ok.callback ? true : false; } int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) @@ -1579,7 +1579,7 @@ int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) watcher = &SDL_event_watchers[SDL_event_watchers_count]; watcher->callback = filter; watcher->userdata = userdata; - watcher->removed = SDL_FALSE; + watcher->removed = false; ++SDL_event_watchers_count; } else { result = -1; @@ -1599,8 +1599,8 @@ void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) for (i = 0; i < SDL_event_watchers_count; ++i) { if (SDL_event_watchers[i].callback == filter && SDL_event_watchers[i].userdata == userdata) { if (SDL_event_watchers_dispatching) { - SDL_event_watchers[i].removed = SDL_TRUE; - SDL_event_watchers_removed = SDL_TRUE; + SDL_event_watchers[i].removed = true; + SDL_event_watchers_removed = true; } else { --SDL_event_watchers_count; if (i < SDL_event_watchers_count) { @@ -1631,17 +1631,17 @@ void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled) { - SDL_bool current_state; + bool current_state; Uint8 hi = ((type >> 8) & 0xff); Uint8 lo = (type & 0xff); - enabled = !!enabled; // make sure this is definitely either SDL_TRUE or SDL_FALSE. + enabled = !!enabled; // make sure this is definitely either true or false. if (SDL_disabled_events[hi] && (SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) { - current_state = SDL_FALSE; + current_state = false; } else { - current_state = SDL_TRUE; + current_state = true; } if (enabled != current_state) { @@ -1652,21 +1652,21 @@ void SDL_SetEventEnabled(Uint32 type, SDL_bool enabled) // Gamepad events depend on joystick events switch (type) { case SDL_EVENT_GAMEPAD_ADDED: - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_ADDED, SDL_TRUE); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_ADDED, true); break; case SDL_EVENT_GAMEPAD_REMOVED: - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_REMOVED, SDL_TRUE); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_REMOVED, true); break; case SDL_EVENT_GAMEPAD_AXIS_MOTION: case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_UP: - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_AXIS_MOTION, SDL_TRUE); - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_HAT_MOTION, SDL_TRUE); - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_BUTTON_DOWN, SDL_TRUE); - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_BUTTON_UP, SDL_TRUE); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_AXIS_MOTION, true); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_HAT_MOTION, true); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_BUTTON_DOWN, true); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_BUTTON_UP, true); break; case SDL_EVENT_GAMEPAD_UPDATE_COMPLETE: - SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, SDL_TRUE); + SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, true); break; default: break; @@ -1698,9 +1698,9 @@ SDL_bool SDL_EventEnabled(Uint32 type) if (SDL_disabled_events[hi] && (SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) { - return SDL_FALSE; + return false; } else { - return SDL_TRUE; + return true; } } diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 7a5d57701c..d966222494 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -56,11 +56,11 @@ typedef struct SDL_Keyboard Uint8 keysource[SDL_NUM_SCANCODES]; Uint8 keystate[SDL_NUM_SCANCODES]; SDL_Keymap *keymap; - SDL_bool french_numbers; - SDL_bool latin_letters; - SDL_bool thai_keyboard; + bool french_numbers; + bool latin_letters; + bool thai_keyboard; Uint32 keycode_options; - SDL_bool autorelease_pending; + bool autorelease_pending; Uint64 hardware_timestamp; int next_reserved_scancode; } SDL_Keyboard; @@ -99,15 +99,15 @@ int SDL_InitKeyboard(void) return 0; } -SDL_bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys) +bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys) { const int REAL_KEYBOARD_KEY_COUNT = 50; if (num_keys > 0 && num_keys < REAL_KEYBOARD_KEY_COUNT) { - return SDL_FALSE; + return false; } // Eventually we'll have a blacklist of devices that enumerate as keyboards but aren't really - return SDL_TRUE; + return true; } static int SDL_GetKeyboardIndex(SDL_KeyboardID keyboardID) @@ -120,7 +120,7 @@ static int SDL_GetKeyboardIndex(SDL_KeyboardID keyboardID) return -1; } -void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, SDL_bool send_event) +void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool send_event) { int keyboard_index = SDL_GetKeyboardIndex(keyboardID); if (keyboard_index >= 0) { @@ -149,7 +149,7 @@ void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, SDL_bool send_ } } -void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, SDL_bool send_event) +void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event) { int keyboard_index = SDL_GetKeyboardIndex(keyboardID); if (keyboard_index < 0) { @@ -244,7 +244,7 @@ SDL_Keymap *SDL_GetCurrentKeymap(void) return keyboard->keymap; } -void SDL_SetKeymap(SDL_Keymap *keymap, SDL_bool send_event) +void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event) { SDL_Keyboard *keyboard = &SDL_keyboard; @@ -255,27 +255,27 @@ void SDL_SetKeymap(SDL_Keymap *keymap, SDL_bool send_event) keyboard->keymap = keymap; // Detect French number row (all symbols) - keyboard->french_numbers = SDL_TRUE; + keyboard->french_numbers = true; for (int i = SDL_SCANCODE_1; i <= SDL_SCANCODE_0; ++i) { if (SDL_isdigit(SDL_GetKeymapKeycode(keymap, (SDL_Scancode)i, SDL_KMOD_NONE)) || !SDL_isdigit(SDL_GetKeymapKeycode(keymap, (SDL_Scancode)i, SDL_KMOD_SHIFT))) { - keyboard->french_numbers = SDL_FALSE; + keyboard->french_numbers = false; break; } } // Detect non-Latin keymap - keyboard->thai_keyboard = SDL_FALSE; - keyboard->latin_letters = SDL_FALSE; + keyboard->thai_keyboard = false; + keyboard->latin_letters = false; for (int i = SDL_SCANCODE_A; i <= SDL_SCANCODE_D; ++i) { SDL_Keycode key = SDL_GetKeymapKeycode(keymap, (SDL_Scancode)i, SDL_KMOD_NONE); if (key <= 0xFF) { - keyboard->latin_letters = SDL_TRUE; + keyboard->latin_letters = true; break; } if (key >= 0x0E00 && key <= 0x0E7F) { - keyboard->thai_keyboard = SDL_TRUE; + keyboard->thai_keyboard = true; break; } } @@ -363,7 +363,7 @@ int SDL_SetKeyboardFocus(SDL_Window *window) return 0; } -static SDL_Keycode SDL_ConvertNumpadKeycode(SDL_Keycode keycode, SDL_bool numlock) +static SDL_Keycode SDL_ConvertNumpadKeycode(SDL_Keycode keycode, bool numlock) { switch (keycode) { case SDLK_KP_DIVIDE: @@ -459,7 +459,7 @@ SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, S if (key_event) { SDL_Keymap *keymap = SDL_GetCurrentKeymap(); - SDL_bool numlock = (modstate & SDL_KMOD_NUM) != 0; + bool numlock = (modstate & SDL_KMOD_NUM) != 0; SDL_Keycode keycode; // We won't be applying any modifiers by default @@ -496,7 +496,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo int posted; SDL_Keycode keycode = SDLK_UNKNOWN; Uint32 type; - Uint8 repeat = SDL_FALSE; + Uint8 repeat = false; const Uint8 source = flags & KEYBOARD_SOURCE_MASK; #ifdef DEBUG_KEYBOARD @@ -525,7 +525,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo keyboard->keysource[scancode] |= source; return 0; } - repeat = SDL_TRUE; + repeat = true; } keyboard->keysource[scancode] |= source; } else { @@ -538,7 +538,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo // Update internal keyboard state keyboard->keystate[scancode] = state; - keycode = SDL_GetKeyFromScancode(scancode, keyboard->modstate, SDL_TRUE); + keycode = SDL_GetKeyFromScancode(scancode, keyboard->modstate, true); } else if (rawcode == 0) { // Nothing to do! @@ -548,7 +548,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo if (source == KEYBOARD_HARDWARE) { keyboard->hardware_timestamp = SDL_GetTicks(); } else if (source == KEYBOARD_AUTORELEASE) { - keyboard->autorelease_pending = SDL_TRUE; + keyboard->autorelease_pending = true; } // Update modifiers state if applicable @@ -633,7 +633,7 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keybo keyboard->focus && (keyboard->focus->flags & SDL_WINDOW_KEYBOARD_GRABBED) && (keyboard->focus->flags & SDL_WINDOW_FULLSCREEN) && - SDL_GetHintBoolean(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, SDL_TRUE)) { + SDL_GetHintBoolean(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, true)) { /* We will temporarily forfeit our grab by minimizing our window, allowing the user to escape the application */ SDL_MinimizeWindow(keyboard->focus); @@ -706,7 +706,7 @@ void SDL_ReleaseAutoReleaseKeys(void) SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, SDL_RELEASED); } } - keyboard->autorelease_pending = SDL_FALSE; + keyboard->autorelease_pending = false; } if (keyboard->hardware_timestamp) { @@ -717,18 +717,18 @@ void SDL_ReleaseAutoReleaseKeys(void) } } -SDL_bool SDL_HardwareKeyboardKeyPressed(void) +bool SDL_HardwareKeyboardKeyPressed(void) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keysource[scancode] & KEYBOARD_HARDWARE) { - return SDL_TRUE; + return true; } } - return keyboard->hardware_timestamp ? SDL_TRUE : SDL_FALSE; + return keyboard->hardware_timestamp ? true : false; } int SDL_SendKeyboardText(const char *text) @@ -828,7 +828,7 @@ static const char * const *CreateCandidatesForEvent(char **candidates, int num_c return event_candidates; } -int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, SDL_bool horizontal) +int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, bool horizontal) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; @@ -858,7 +858,7 @@ int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int sel event.edit_candidates.candidates = NULL; event.edit_candidates.num_candidates = 0; event.edit_candidates.selected_candidate = -1; - event.edit_candidates.horizontal = SDL_FALSE; + event.edit_candidates.horizontal = false; } posted = (SDL_PushEvent(&event) > 0); } @@ -868,7 +868,7 @@ int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int sel void SDL_QuitKeyboard(void) { for (int i = SDL_keyboard_count; i--;) { - SDL_RemoveKeyboard(SDL_keyboards[i].instance_id, SDL_FALSE); + SDL_RemoveKeyboard(SDL_keyboards[i].instance_id, false); } SDL_free(SDL_keyboards); SDL_keyboards = NULL; @@ -907,7 +907,7 @@ void SDL_SetModState(SDL_Keymod modstate) } // Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. -void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) +void SDL_ToggleModState(const SDL_Keymod modstate, const bool toggle) { SDL_Keyboard *keyboard = &SDL_keyboard; if (toggle) { diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h index 17f9596cd6..a810c92031 100644 --- a/src/events/SDL_keyboard_c.h +++ b/src/events/SDL_keyboard_c.h @@ -35,16 +35,16 @@ extern int SDL_InitKeyboard(void); // Return whether a device is actually a keyboard -extern SDL_bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys); +extern bool SDL_IsKeyboard(Uint16 vendor, Uint16 product, int num_keys); // A keyboard has been added to the system -extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, SDL_bool send_event); +extern void SDL_AddKeyboard(SDL_KeyboardID keyboardID, const char *name, bool send_event); // A keyboard has been removed from the system -extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, SDL_bool send_event); +extern void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event); // Set the mapping of scancode to key codes -extern void SDL_SetKeymap(SDL_Keymap *keymap, SDL_bool send_event); +extern void SDL_SetKeymap(SDL_Keymap *keymap, bool send_event); // Set the keyboard focus window extern int SDL_SetKeyboardFocus(SDL_Window *window); @@ -67,7 +67,7 @@ extern int SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboa extern void SDL_ReleaseAutoReleaseKeys(void); // Return true if any hardware key is pressed -extern SDL_bool SDL_HardwareKeyboardKeyPressed(void); +extern bool SDL_HardwareKeyboardKeyPressed(void); // Send keyboard text input extern int SDL_SendKeyboardText(const char *text); @@ -76,12 +76,12 @@ extern int SDL_SendKeyboardText(const char *text); extern int SDL_SendEditingText(const char *text, int start, int length); // Send editing text candidates, which will be copied into the event -int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, SDL_bool horizontal); +int SDL_SendEditingTextCandidates(char **candidates, int num_candidates, int selected_candidate, bool horizontal); // Shutdown the keyboard subsystem extern void SDL_QuitKeyboard(void); // Toggle on or off pieces of the keyboard mod state. -extern void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle); +extern void SDL_ToggleModState(const SDL_Keymod modstate, const bool toggle); #endif // SDL_keyboard_c_h_ diff --git a/src/events/SDL_keymap.c b/src/events/SDL_keymap.c index ca158551e8..acc4946fb1 100644 --- a/src/events/SDL_keymap.c +++ b/src/events/SDL_keymap.c @@ -40,8 +40,8 @@ SDL_Keymap *SDL_CreateKeymap(void) return NULL; } - keymap->scancode_to_keycode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE); - keymap->keycode_to_scancode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE); + keymap->scancode_to_keycode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, false); + keymap->keycode_to_scancode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, false); if (!keymap->scancode_to_keycode || !keymap->keycode_to_scancode) { SDL_DestroyKeymap(keymap); return NULL; @@ -202,11 +202,11 @@ static SDL_Keycode SDL_GetDefaultKeyFromScancode(SDL_Scancode scancode, SDL_Keym } if (scancode < SDL_SCANCODE_1) { - SDL_bool shifted = (modstate & SDL_KMOD_SHIFT) ? SDL_TRUE : SDL_FALSE; + bool shifted = (modstate & SDL_KMOD_SHIFT) ? true : false; #ifdef SDL_PLATFORM_APPLE // Apple maps to upper case for either shift or capslock inclusive if (modstate & SDL_KMOD_CAPS) { - shifted = SDL_TRUE; + shifted = true; } #else if (modstate & SDL_KMOD_CAPS) { @@ -224,7 +224,7 @@ static SDL_Keycode SDL_GetDefaultKeyFromScancode(SDL_Scancode scancode, SDL_Keym } if (scancode < SDL_SCANCODE_CAPSLOCK) { - SDL_bool shifted = (modstate & SDL_KMOD_SHIFT) ? SDL_TRUE : SDL_FALSE; + bool shifted = (modstate & SDL_KMOD_SHIFT) ? true : false; if (modstate & SDL_KMOD_MODE) { return SDLK_UNKNOWN; @@ -983,7 +983,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name) const char *SDL_GetKeyName(SDL_Keycode key) { - const SDL_bool uppercase = SDL_TRUE; + const bool uppercase = true; char name[8]; char *end; @@ -1030,7 +1030,7 @@ const char *SDL_GetKeyName(SDL_Keycode key) SDL_Keycode SDL_GetKeyFromName(const char *name) { - const SDL_bool uppercase = SDL_TRUE; + const bool uppercase = true; SDL_Keycode key; // Check input @@ -1088,5 +1088,5 @@ SDL_Keycode SDL_GetKeyFromName(const char *name) return key; } - return SDL_GetKeyFromScancode(SDL_GetScancodeFromName(name), SDL_KMOD_NONE, SDL_FALSE); + return SDL_GetKeyFromScancode(SDL_GetScancodeFromName(name), SDL_KMOD_NONE, false); } diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index a3024f22db..fa7c09be79 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -46,9 +46,9 @@ static int SDL_mouse_count; static SDL_MouseInstance *SDL_mice; // for mapping mouse events to touch -static SDL_bool track_mouse_down = SDL_FALSE; +static bool track_mouse_down = false; -static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y); +static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y); static void SDLCALL SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { @@ -92,10 +92,10 @@ static void SDLCALL SDL_MouseNormalSpeedScaleChanged(void *userdata, const char SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { - mouse->enable_normal_speed_scale = SDL_TRUE; + mouse->enable_normal_speed_scale = true; mouse->normal_speed_scale = (float)SDL_atof(hint); } else { - mouse->enable_normal_speed_scale = SDL_FALSE; + mouse->enable_normal_speed_scale = false; mouse->normal_speed_scale = 1.0f; } } @@ -105,10 +105,10 @@ static void SDLCALL SDL_MouseRelativeSpeedScaleChanged(void *userdata, const cha SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { - mouse->enable_relative_speed_scale = SDL_TRUE; + mouse->enable_relative_speed_scale = true; mouse->relative_speed_scale = (float)SDL_atof(hint); } else { - mouse->enable_relative_speed_scale = SDL_FALSE; + mouse->enable_relative_speed_scale = false; mouse->relative_speed_scale = 1.0f; } } @@ -117,18 +117,18 @@ static void SDLCALL SDL_MouseRelativeSystemScaleChanged(void *userdata, const ch { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - mouse->enable_relative_system_scale = SDL_GetStringBoolean(hint, SDL_FALSE); + mouse->enable_relative_system_scale = SDL_GetStringBoolean(hint, false); } static void SDLCALL SDL_MouseWarpEmulationChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - mouse->warp_emulation_hint = SDL_GetStringBoolean(hint, SDL_TRUE); + mouse->warp_emulation_hint = SDL_GetStringBoolean(hint, true); if (!mouse->warp_emulation_hint && mouse->warp_emulation_active) { - SDL_SetRelativeMouseMode(SDL_FALSE); - mouse->warp_emulation_active = SDL_FALSE; + SDL_SetRelativeMouseMode(false); + mouse->warp_emulation_active = false; } } @@ -136,7 +136,7 @@ static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE); + mouse->touch_mouse_events = SDL_GetStringBoolean(hint, true); } #ifdef SDL_PLATFORM_VITA @@ -163,12 +163,12 @@ static void SDLCALL SDL_VitaTouchMouseDeviceChanged(void *userdata, const char * static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - SDL_bool default_value; + bool default_value; #if defined(SDL_PLATFORM_ANDROID) || (defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_TVOS)) - default_value = SDL_TRUE; + default_value = true; #else - default_value = SDL_FALSE; + default_value = false; #endif mouse->mouse_touch_events = SDL_GetStringBoolean(hint, default_value); @@ -180,11 +180,11 @@ static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name static void SDLCALL SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE); + bool auto_capture = SDL_GetStringBoolean(hint, true); if (auto_capture != mouse->auto_capture) { mouse->auto_capture = auto_capture; - SDL_UpdateMouseCapture(SDL_FALSE); + SDL_UpdateMouseCapture(false); } } @@ -192,14 +192,14 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - mouse->relative_mode_warp_motion = SDL_GetStringBoolean(hint, SDL_FALSE); + mouse->relative_mode_warp_motion = SDL_GetStringBoolean(hint, false); } static void SDLCALL SDL_MouseRelativeCursorVisibleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; - mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, SDL_FALSE); + mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, false); } // Public functions @@ -250,9 +250,9 @@ int SDL_PreInitMouse(void) SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_CLIP_INTERVAL, SDL_MouseRelativeClipIntervalChanged, mouse); - mouse->was_touch_mouse_events = SDL_FALSE; // no touch to mouse movement event pending + mouse->was_touch_mouse_events = false; // no touch to mouse movement event pending - mouse->cursor_shown = SDL_TRUE; + mouse->cursor_shown = true; return 0; } @@ -274,10 +274,10 @@ void SDL_PostInitMouse(void) } } -SDL_bool SDL_IsMouse(Uint16 vendor, Uint16 product) +bool SDL_IsMouse(Uint16 vendor, Uint16 product) { // Eventually we'll have a blacklist of devices that enumerate as mice but aren't really - return SDL_TRUE; + return true; } static int SDL_GetMouseIndex(SDL_MouseID mouseID) @@ -290,7 +290,7 @@ static int SDL_GetMouseIndex(SDL_MouseID mouseID) return -1; } -void SDL_AddMouse(SDL_MouseID mouseID, const char *name, SDL_bool send_event) +void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event) { int mouse_index = SDL_GetMouseIndex(mouseID); if (mouse_index >= 0) { @@ -319,7 +319,7 @@ void SDL_AddMouse(SDL_MouseID mouseID, const char *name, SDL_bool send_event) } } -void SDL_RemoveMouse(SDL_MouseID mouseID, SDL_bool send_event) +void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event) { int mouse_index = SDL_GetMouseIndex(mouseID); if (mouse_index < 0) { @@ -443,7 +443,7 @@ SDL_Mouse *SDL_GetMouse(void) return &SDL_mouse; } -static SDL_MouseButtonFlags SDL_GetMouseButtonState(SDL_Mouse *mouse, SDL_MouseID mouseID, SDL_bool include_touch) +static SDL_MouseButtonFlags SDL_GetMouseButtonState(SDL_Mouse *mouse, SDL_MouseID mouseID, bool include_touch) { int i; SDL_MouseButtonFlags buttonstate = 0; @@ -481,7 +481,7 @@ SDL_Window *SDL_GetMouseFocus(void) void SDL_ResetMouse(void) { SDL_Mouse *mouse = SDL_GetMouse(); - Uint32 buttonState = SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_FALSE); + Uint32 buttonState = SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, false); int i; for (i = 1; i <= sizeof(buttonState)*8; ++i) { @@ -489,7 +489,7 @@ void SDL_ResetMouse(void) SDL_SendMouseButton(0, mouse->focus, mouse->mouseID, SDL_RELEASED, i); } } - SDL_assert(SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_FALSE) == 0); + SDL_assert(SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, false) == 0); } #endif // 0 @@ -519,7 +519,7 @@ void SDL_SetMouseFocus(SDL_Window *window) } mouse->focus = window; - mouse->has_position = SDL_FALSE; + mouse->has_position = false; if (mouse->focus) { SDL_SendWindowEvent(mouse->focus, SDL_EVENT_WINDOW_MOUSE_ENTER, 0, 0); @@ -529,25 +529,25 @@ void SDL_SetMouseFocus(SDL_Window *window) SDL_SetCursor(NULL); } -SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y) +bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y) { if (!window) { - return SDL_FALSE; + return false; } if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { if (x < 0.0f || y < 0.0f || x >= (float)window->w || y >= (float)window->h) { - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } // Check to see if we need to synthesize focus events -static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint32 buttonstate, SDL_bool send_mouse_motion) +static bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint32 buttonstate, bool send_mouse_motion) { SDL_Mouse *mouse = SDL_GetMouse(); - SDL_bool inWindow = SDL_MousePositionInWindow(window, x, y); + bool inWindow = SDL_MousePositionInWindow(window, x, y); if (!inWindow) { if (window == mouse->focus) { @@ -555,11 +555,11 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3 SDL_Log("Mouse left window, synthesizing move & focus lost event\n"); #endif if (send_mouse_motion) { - SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); } SDL_SetMouseFocus(NULL); } - return SDL_FALSE; + return false; } if (window != mouse->focus) { @@ -568,17 +568,17 @@ static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, float x, float y, Uint3 #endif SDL_SetMouseFocus(window); if (send_mouse_motion) { - SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); } } - return SDL_TRUE; + return true; } -int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y) +int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y) { if (window && !relative) { SDL_Mouse *mouse = SDL_GetMouse(); - if (!SDL_UpdateMouseFocus(window, x, y, SDL_GetMouseButtonState(mouse, mouseID, SDL_TRUE), (mouseID != SDL_TOUCH_MOUSEID))) { + if (!SDL_UpdateMouseFocus(window, x, y, SDL_GetMouseButtonState(mouse, mouseID, true), (mouseID != SDL_TOUCH_MOUSEID))) { return 0; } } @@ -732,7 +732,7 @@ static void ConstrainMousePosition(SDL_Mouse *mouse, SDL_Window *window, float * } } -static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y) +static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -778,7 +778,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ if (mouse->WarpMouse) { mouse->WarpMouse(window, center_x, center_y); } else { - SDL_PrivateSendMouseMotion(timestamp, window, mouseID, SDL_FALSE, center_x, center_y); + SDL_PrivateSendMouseMotion(timestamp, window, mouseID, false, center_x, center_y); } } } @@ -808,7 +808,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ } // Ignore relative motion positioning the first touch - if (mouseID == SDL_TOUCH_MOUSEID && !SDL_GetMouseButtonState(mouse, mouseID, SDL_TRUE)) { + if (mouseID == SDL_TOUCH_MOUSEID && !SDL_GetMouseButtonState(mouse, mouseID, true)) { xrel = 0.0f; yrel = 0.0f; } @@ -826,7 +826,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ } else { mouse->x = x; mouse->y = y; - mouse->has_position = SDL_TRUE; + mouse->has_position = true; } mouse->xdelta += xrel; @@ -848,7 +848,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_ event.motion.which = mouseID; // Set us pending (or clear during a normal mouse movement event) as having triggered mouse->was_touch_mouse_events = (mouseID == SDL_TOUCH_MOUSEID); - event.motion.state = SDL_GetMouseButtonState(mouse, mouseID, SDL_TRUE); + event.motion.state = SDL_GetMouseButtonState(mouse, mouseID, true); event.motion.x = mouse->x; event.motion.y = mouse->y; event.motion.xrel = xrel; @@ -948,9 +948,9 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ if (mouse->mouse_touch_events) { if (mouseID != SDL_TOUCH_MOUSEID && button == SDL_BUTTON_LEFT) { if (state == SDL_PRESSED) { - track_mouse_down = SDL_TRUE; + track_mouse_down = true; } else { - track_mouse_down = SDL_FALSE; + track_mouse_down = false; } if (window) { float normalized_x = mouse->x / (float)window->w; @@ -984,7 +984,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ // We do this after calculating buttonstate so button presses gain focus if (window && state == SDL_PRESSED) { - SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, SDL_TRUE); + SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, true); } if (buttonstate == source->buttonstate) { @@ -1035,12 +1035,12 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ // We do this after dispatching event so button releases can lose focus if (window && state == SDL_RELEASED) { - SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, SDL_TRUE); + SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate, true); } // Automatically capture the mouse while buttons are pressed if (mouse->auto_capture) { - SDL_UpdateMouseCapture(SDL_FALSE); + SDL_UpdateMouseCapture(false); } return posted; @@ -1094,10 +1094,10 @@ void SDL_QuitMouse(void) SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->CaptureMouse) { - SDL_CaptureMouse(SDL_FALSE); - SDL_UpdateMouseCapture(SDL_TRUE); + SDL_CaptureMouse(false); + SDL_UpdateMouseCapture(true); } - SDL_SetRelativeMouseMode(SDL_FALSE); + SDL_SetRelativeMouseMode(false); SDL_ShowCursor(); if (mouse->def_cursor) { @@ -1168,7 +1168,7 @@ void SDL_QuitMouse(void) SDL_MouseRelativeClipIntervalChanged, mouse); for (int i = SDL_mouse_count; i--; ) { - SDL_RemoveMouse(SDL_mice[i].instance_id, SDL_FALSE); + SDL_RemoveMouse(SDL_mice[i].instance_id, false); } SDL_free(SDL_mice); SDL_mice = NULL; @@ -1184,7 +1184,7 @@ SDL_MouseButtonFlags SDL_GetMouseState(float *x, float *y) if (y) { *y = mouse->y; } - return SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_TRUE); + return SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, true); } SDL_MouseButtonFlags SDL_GetRelativeMouseState(float *x, float *y) @@ -1199,7 +1199,7 @@ SDL_MouseButtonFlags SDL_GetRelativeMouseState(float *x, float *y) } mouse->xdelta = 0.0f; mouse->ydelta = 0.0f; - return SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_TRUE); + return SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, true); } SDL_MouseButtonFlags SDL_GetGlobalMouseState(float *x, float *y) @@ -1225,7 +1225,7 @@ SDL_MouseButtonFlags SDL_GetGlobalMouseState(float *x, float *y) } } -void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool ignore_relative_mode) +void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1244,7 +1244,7 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool // Ignore the previous position when we warp mouse->last_x = x; mouse->last_y = y; - mouse->has_position = SDL_FALSE; + mouse->has_position = false; if (mouse->relative_mode && !ignore_relative_mode) { /* 2.0.22 made warping in relative mode actually functional, which @@ -1257,7 +1257,7 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool if (!mouse->relative_mode_warp_motion) { mouse->x = x; mouse->y = y; - mouse->has_position = SDL_TRUE; + mouse->has_position = true; return; } } @@ -1266,7 +1266,7 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool (!mouse->relative_mode || mouse->relative_mode_warp)) { mouse->WarpMouse(window, x, y); } else { - SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_PrivateSendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); } } @@ -1275,10 +1275,10 @@ void SDL_DisableMouseWarpEmulation() SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->warp_emulation_active) { - SDL_SetRelativeMouseMode(SDL_FALSE); + SDL_SetRelativeMouseMode(false); } - mouse->warp_emulation_prohibited = SDL_TRUE; + mouse->warp_emulation_prohibited = true; } static void SDL_MaybeEnableWarpEmulation(SDL_Window *window, float x, float y) @@ -1299,8 +1299,8 @@ static void SDL_MaybeEnableWarpEmulation(SDL_Window *window, float x, float y) // Require two consecutive warps to the center within a certain timespan to enter warp emulation mode. const Uint64 now = SDL_GetTicksNS(); if (now - mouse->last_center_warp_time_ns < WARP_EMULATION_THRESHOLD_NS) { - if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) { - mouse->warp_emulation_active = SDL_TRUE; + if (SDL_SetRelativeMouseMode(true) == 0) { + mouse->warp_emulation_active = true; } } @@ -1332,24 +1332,24 @@ int SDL_WarpMouseGlobal(float x, float y) return SDL_Unsupported(); } -static SDL_bool SDL_ShouldUseRelativeModeWarp(SDL_Mouse *mouse) +static bool SDL_ShouldUseRelativeModeWarp(SDL_Mouse *mouse) { if (!mouse->WarpMouse) { // Need this functionality for relative mode warp implementation - return SDL_FALSE; + return false; } - return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, false); } -int SDL_SetRelativeMouseMode(SDL_bool enabled) +int SDL_SetRelativeMouseMode(bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *focusWindow = SDL_GetKeyboardFocus(); if (!enabled) { // If warps were being emulated, reset the flag. - mouse->warp_emulation_active = SDL_FALSE; + mouse->warp_emulation_active = false; } if (enabled == mouse->relative_mode) { @@ -1358,16 +1358,16 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) // Set the relative mode if (!enabled && mouse->relative_mode_warp) { - mouse->relative_mode_warp = SDL_FALSE; + mouse->relative_mode_warp = false; } else if (enabled && SDL_ShouldUseRelativeModeWarp(mouse)) { - mouse->relative_mode_warp = SDL_TRUE; + mouse->relative_mode_warp = true; } else if (!mouse->SetRelativeMouseMode || mouse->SetRelativeMouseMode(enabled) < 0) { if (enabled) { // Fall back to warp mode if native relative mode failed if (!mouse->WarpMouse) { return SDL_SetError("No relative mode implementation available"); } - mouse->relative_mode_warp = SDL_TRUE; + mouse->relative_mode_warp = true; } } mouse->relative_mode = enabled; @@ -1383,7 +1383,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) if (mouse->relative_mode_warp) { float center_x = (float)focusWindow->w / 2.0f; float center_y = (float)focusWindow->h / 2.0f; - SDL_PerformWarpMouseInWindow(focusWindow, center_x, center_y, SDL_TRUE); + SDL_PerformWarpMouseInWindow(focusWindow, center_x, center_y, true); } } @@ -1392,10 +1392,10 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) // Put the cursor back to where the application expects it if (!enabled) { - SDL_PerformWarpMouseInWindow(focusWindow, mouse->x, mouse->y, SDL_TRUE); + SDL_PerformWarpMouseInWindow(focusWindow, mouse->x, mouse->y, true); } - SDL_UpdateMouseCapture(SDL_FALSE); + SDL_UpdateMouseCapture(false); } if (!enabled) { @@ -1409,7 +1409,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) return 0; } -SDL_bool SDL_GetRelativeMouseMode(void) +bool SDL_GetRelativeMouseMode(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1420,14 +1420,14 @@ void SDL_UpdateRelativeMouseMode(void) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *focus = SDL_GetKeyboardFocus(); - SDL_bool relative_mode = (focus && (focus->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE)); + bool relative_mode = (focus && (focus->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE)); if (relative_mode != mouse->relative_mode) { SDL_SetRelativeMouseMode(relative_mode); } } -int SDL_UpdateMouseCapture(SDL_bool force_release) +int SDL_UpdateMouseCapture(bool force_release) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *capture_window = NULL; @@ -1438,7 +1438,7 @@ int SDL_UpdateMouseCapture(SDL_bool force_release) if (!force_release) { if (SDL_GetMessageBoxCount() == 0 && - (mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, SDL_FALSE) != 0))) { + (mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseButtonState(mouse, SDL_GLOBAL_MOUSE_ID, false) != 0))) { if (!mouse->relative_mode) { capture_window = mouse->focus; } @@ -1502,7 +1502,7 @@ int SDL_CaptureMouse(SDL_bool enabled) } mouse->capture_desired = enabled; - return SDL_UpdateMouseCapture(SDL_FALSE); + return SDL_UpdateMouseCapture(false); } SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y) @@ -1722,12 +1722,12 @@ int SDL_ShowCursor(void) SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->warp_emulation_active) { - SDL_SetRelativeMouseMode(SDL_FALSE); - mouse->warp_emulation_active = SDL_FALSE; + SDL_SetRelativeMouseMode(false); + mouse->warp_emulation_active = false; } if (!mouse->cursor_shown) { - mouse->cursor_shown = SDL_TRUE; + mouse->cursor_shown = true; SDL_SetCursor(NULL); } return 0; @@ -1738,7 +1738,7 @@ int SDL_HideCursor(void) SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->cursor_shown) { - mouse->cursor_shown = SDL_FALSE; + mouse->cursor_shown = false; SDL_SetCursor(NULL); } return 0; diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 064f6ea2b5..5085b4ca7e 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -74,7 +74,7 @@ typedef struct int (*WarpMouseGlobal)(float x, float y); // Set relative mode - int (*SetRelativeMouseMode)(SDL_bool enabled); + int (*SetRelativeMouseMode)(bool enabled); // Set mouse capture int (*CaptureMouse)(SDL_Window *window); @@ -89,33 +89,33 @@ typedef struct float xdelta; float ydelta; float last_x, last_y; // the last reported x and y coordinates - SDL_bool has_position; - SDL_bool relative_mode; - SDL_bool relative_mode_warp; - SDL_bool relative_mode_warp_motion; - SDL_bool relative_mode_cursor_visible; - SDL_bool warp_emulation_hint; - SDL_bool warp_emulation_active; - SDL_bool warp_emulation_prohibited; + bool has_position; + bool relative_mode; + bool relative_mode_warp; + bool relative_mode_warp_motion; + bool relative_mode_cursor_visible; + bool warp_emulation_hint; + bool warp_emulation_active; + bool warp_emulation_prohibited; Uint64 last_center_warp_time_ns; int relative_mode_clip_interval; - SDL_bool enable_normal_speed_scale; + bool enable_normal_speed_scale; float normal_speed_scale; - SDL_bool enable_relative_speed_scale; + bool enable_relative_speed_scale; float relative_speed_scale; - SDL_bool enable_relative_system_scale; + bool enable_relative_system_scale; int num_system_scale_values; float *system_scale_values; Uint32 double_click_time; int double_click_radius; - SDL_bool touch_mouse_events; - SDL_bool mouse_touch_events; - SDL_bool was_touch_mouse_events; // Was a touch-mouse event pending? + bool touch_mouse_events; + bool mouse_touch_events; + bool was_touch_mouse_events; // Was a touch-mouse event pending? #ifdef SDL_PLATFORM_VITA Uint8 vita_touch_mouse_device; #endif - SDL_bool auto_capture; - SDL_bool capture_desired; + bool auto_capture; + bool capture_desired; SDL_Window *capture_window; // Data for input source state @@ -129,7 +129,7 @@ typedef struct SDL_Cursor *cursors; SDL_Cursor *def_cursor; SDL_Cursor *cur_cursor; - SDL_bool cursor_shown; + bool cursor_shown; // Driver-dependent data. void *internal; @@ -142,13 +142,13 @@ extern int SDL_PreInitMouse(void); extern void SDL_PostInitMouse(void); // Return whether a device is actually a mouse -extern SDL_bool SDL_IsMouse(Uint16 vendor, Uint16 product); +extern bool SDL_IsMouse(Uint16 vendor, Uint16 product); // A mouse has been added to the system -extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, SDL_bool send_event); +extern void SDL_AddMouse(SDL_MouseID mouseID, const char *name, bool send_event); // A mouse has been removed from the system -extern void SDL_RemoveMouse(SDL_MouseID mouseID, SDL_bool send_event); +extern void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event); // Get the mouse state structure extern SDL_Mouse *SDL_GetMouse(void); @@ -160,13 +160,13 @@ extern void SDL_SetDefaultCursor(SDL_Cursor *cursor); extern void SDL_SetMouseFocus(SDL_Window *window); // Update the mouse capture window -extern int SDL_UpdateMouseCapture(SDL_bool force_release); +extern int SDL_UpdateMouseCapture(bool force_release); // You can set either a single scale, or a set of {speed, scale} values in sorted order extern int SDL_SetMouseSystemScale(int num_values, const float *values); // Send a mouse motion event -extern int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, SDL_bool relative, float x, float y); +extern int SDL_SendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, bool relative, float x, float y); // Send a mouse button event extern int SDL_SendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button); @@ -178,11 +178,11 @@ extern int SDL_SendMouseButtonClicks(Uint64 timestamp, SDL_Window *window, SDL_M extern int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); // Warp the mouse within the window, potentially overriding relative mode -extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool ignore_relative_mode); +extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, bool ignore_relative_mode); // Relative mouse mode -extern int SDL_SetRelativeMouseMode(SDL_bool enabled); -extern SDL_bool SDL_GetRelativeMouseMode(void); +extern int SDL_SetRelativeMouseMode(bool enabled); +extern bool SDL_GetRelativeMouseMode(void); extern void SDL_UpdateRelativeMouseMode(void); extern void SDL_DisableMouseWarpEmulation(void); @@ -192,7 +192,7 @@ extern void SDL_ResetMouse(void); #endif // 0 // Check if mouse position is within window or captured by window -extern SDL_bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y); +extern bool SDL_MousePositionInWindow(SDL_Window *window, float x, float y); // Shutdown the mouse subsystem extern void SDL_QuitMouse(void); diff --git a/src/events/SDL_pen.c b/src/events/SDL_pen.c index 15d7b41622..b7ef12b286 100644 --- a/src/events/SDL_pen.c +++ b/src/events/SDL_pen.c @@ -74,7 +74,7 @@ SDL_PenID SDL_FindPenByHandle(void *handle) return retval; } -SDL_PenID SDL_FindPenByCallback(SDL_bool (*callback)(void *handle, void *userdata), void *userdata) +SDL_PenID SDL_FindPenByCallback(bool (*callback)(void *handle, void *userdata), void *userdata) { SDL_PenID retval = 0; SDL_LockRWLockForReading(pen_device_rwlock); @@ -181,11 +181,11 @@ SDL_PenInputFlags SDL_GetPenStatus(SDL_PenID instance_id, float *axes, int num_a return retval; } -SDL_bool SDL_PenConnected(SDL_PenID instance_id) +bool SDL_PenConnected(SDL_PenID instance_id) { SDL_LockRWLockForReading(pen_device_rwlock); const SDL_Pen *pen = FindPenByInstanceId(instance_id); - const SDL_bool retval = (pen != NULL); + const bool retval = (pen != NULL); SDL_UnlockRWLock(pen_device_rwlock); return retval; } @@ -311,7 +311,7 @@ void SDL_RemoveAllPenDevices(void (*callback)(SDL_PenID instance_id, void *handl int SDL_SendPenTouch(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *window, Uint8 state, Uint8 eraser) { - SDL_bool push_event = SDL_FALSE; + bool push_event = false; SDL_PenInputFlags input_state = 0; float x = 0.0f; float y = 0.0f; @@ -329,18 +329,18 @@ int SDL_SendPenTouch(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window * if (state && ((input_state & SDL_PEN_INPUT_DOWN) == 0)) { input_state |= SDL_PEN_INPUT_DOWN; - push_event = SDL_TRUE; + push_event = true; } else if (!state && (input_state & SDL_PEN_INPUT_DOWN)) { input_state &= ~SDL_PEN_INPUT_DOWN; - push_event = SDL_TRUE; + push_event = true; } if (eraser && ((input_state & SDL_PEN_INPUT_ERASER_TIP) == 0)) { input_state |= SDL_PEN_INPUT_ERASER_TIP; - push_event = SDL_TRUE; + push_event = true; } else if (!state && (input_state & SDL_PEN_INPUT_ERASER_TIP)) { input_state &= ~SDL_PEN_INPUT_ERASER_TIP; - push_event = SDL_TRUE; + push_event = true; } pen->input_state = input_state; // we could do an SDL_AtomicSet here if we run into trouble... @@ -373,7 +373,7 @@ int SDL_SendPenAxis(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *w { SDL_assert((axis >= 0) && (axis < SDL_PEN_NUM_AXES)); // fix the backend if this triggers. - SDL_bool push_event = SDL_FALSE; + bool push_event = false; SDL_PenInputFlags input_state = 0; float x = 0.0f; float y = 0.0f; @@ -390,7 +390,7 @@ int SDL_SendPenAxis(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *w input_state = pen->input_state; x = pen->x; y = pen->y; - push_event = SDL_TRUE; + push_event = true; } } SDL_UnlockRWLock(pen_device_rwlock); @@ -416,7 +416,7 @@ int SDL_SendPenAxis(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *w int SDL_SendPenMotion(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *window, float x, float y) { - SDL_bool push_event = SDL_FALSE; + bool push_event = false; SDL_PenInputFlags input_state = 0; // note that this locks for _reading_ because the lock protects the @@ -430,7 +430,7 @@ int SDL_SendPenMotion(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window pen->x = x; // we could do an SDL_AtomicSet here if we run into trouble... pen->y = y; // we could do an SDL_AtomicSet here if we run into trouble... input_state = pen->input_state; - push_event = SDL_TRUE; + push_event = true; } } SDL_UnlockRWLock(pen_device_rwlock); @@ -457,7 +457,7 @@ int SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window if ((button < 1) || (button > 5)) { return 0; // clamp for now. } - SDL_bool push_event = SDL_FALSE; + bool push_event = false; SDL_PenInputFlags input_state = 0; float x = 0.0f; float y = 0.0f; @@ -476,10 +476,10 @@ int SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window y = pen->y; if (state && !current) { input_state |= flag; - push_event = SDL_TRUE; + push_event = true; } else if (!state && current) { input_state &= ~flag; - push_event = SDL_TRUE; + push_event = true; } pen->input_state = input_state; // we could do an SDL_AtomicSet here if we run into trouble... } diff --git a/src/events/SDL_pen_c.h b/src/events/SDL_pen_c.h index d405d13f68..df3d944cbe 100644 --- a/src/events/SDL_pen_c.h +++ b/src/events/SDL_pen_c.h @@ -83,7 +83,7 @@ extern int SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, const SDL_ extern SDL_PenID SDL_FindPenByHandle(void *handle); // Backend can optionally use this to find a SDL_PenID, selected by a callback examining all devices. Zero if not found. -extern SDL_PenID SDL_FindPenByCallback(SDL_bool (*callback)(void *handle, void *userdata), void *userdata); +extern SDL_PenID SDL_FindPenByCallback(bool (*callback)(void *handle, void *userdata), void *userdata); // Backend can use this to map an axis to a capability bit. SDL_PenCapabilityFlags SDL_GetPenCapabilityFromAxis(SDL_PenAxis axis); diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c index 30f73243c8..dc3b6c84d7 100644 --- a/src/events/SDL_quit.c +++ b/src/events/SDL_quit.c @@ -33,15 +33,15 @@ #endif #ifdef HAVE_SIGNAL_SUPPORT -static SDL_bool disable_signals = SDL_FALSE; -static SDL_bool send_quit_pending = SDL_FALSE; +static bool disable_signals = false; +static bool send_quit_pending = false; #ifdef SDL_BACKGROUNDING_SIGNAL -static SDL_bool send_backgrounding_pending = SDL_FALSE; +static bool send_backgrounding_pending = false; #endif #ifdef SDL_FOREGROUNDING_SIGNAL -static SDL_bool send_foregrounding_pending = SDL_FALSE; +static bool send_foregrounding_pending = false; #endif static void SDL_HandleSIG(int sig) @@ -52,18 +52,18 @@ static void SDL_HandleSIG(int sig) // Send a quit event next time the event loop pumps. // We can't send it in signal handler; SDL_malloc() might be interrupted! if ((sig == SIGINT) || (sig == SIGTERM)) { - send_quit_pending = SDL_TRUE; + send_quit_pending = true; } #ifdef SDL_BACKGROUNDING_SIGNAL else if (sig == SDL_BACKGROUNDING_SIGNAL) { - send_backgrounding_pending = SDL_TRUE; + send_backgrounding_pending = true; } #endif #ifdef SDL_FOREGROUNDING_SIGNAL else if (sig == SDL_FOREGROUNDING_SIGNAL) { - send_foregrounding_pending = SDL_TRUE; + send_foregrounding_pending = true; } #endif } @@ -145,7 +145,7 @@ static void SDL_QuitQuit_Internal(void) int SDL_InitQuit(void) { #ifdef HAVE_SIGNAL_SUPPORT - if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) { return SDL_QuitInit_Internal(); } #endif @@ -171,14 +171,14 @@ void SDL_SendPendingSignalEvents(void) #ifdef SDL_BACKGROUNDING_SIGNAL if (send_backgrounding_pending) { - send_backgrounding_pending = SDL_FALSE; + send_backgrounding_pending = false; SDL_OnApplicationWillEnterBackground(); } #endif #ifdef SDL_FOREGROUNDING_SIGNAL if (send_foregrounding_pending) { - send_foregrounding_pending = SDL_FALSE; + send_foregrounding_pending = false; SDL_OnApplicationDidEnterForeground(); } #endif @@ -189,7 +189,7 @@ void SDL_SendPendingSignalEvents(void) int SDL_SendQuit(void) { #ifdef HAVE_SIGNAL_SUPPORT - send_quit_pending = SDL_FALSE; + send_quit_pending = false; #endif return SDL_SendAppEvent(SDL_EVENT_QUIT); } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 87c1670b14..d560e65665 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -33,7 +33,7 @@ static SDL_Touch **SDL_touchDevices = NULL; #define SYNTHESIZE_TOUCH_TO_MOUSE 1 #if SYNTHESIZE_TOUCH_TO_MOUSE -static SDL_bool finger_touching = SDL_FALSE; +static bool finger_touching = false; static SDL_FingerID track_fingerid; static SDL_TouchID track_touchid; #endif @@ -44,7 +44,7 @@ int SDL_InitTouch(void) return 0; } -SDL_bool SDL_TouchDevicesAvailable(void) +bool SDL_TouchDevicesAvailable(void) { return SDL_num_touch > 0; } @@ -255,7 +255,7 @@ static int SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid) return 0; } -int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_bool down, float x, float y, float pressure) +int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, bool down, float x, float y, float pressure) { int posted; SDL_Finger *finger; @@ -281,7 +281,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W if (id != SDL_MOUSE_TOUCHID) { if (window) { if (down) { - if (finger_touching == SDL_FALSE) { + if (finger_touching == false) { float pos_x = (x * (float)window->w); float pos_y = (y * (float)window->h); if (pos_x < 0) { @@ -296,24 +296,24 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W if (pos_y > (float)(window->h - 1)) { pos_y = (float)(window->h - 1); } - SDL_SendMouseMotion(timestamp, window, SDL_TOUCH_MOUSEID, SDL_FALSE, pos_x, pos_y); + SDL_SendMouseMotion(timestamp, window, SDL_TOUCH_MOUSEID, false, pos_x, pos_y); SDL_SendMouseButton(timestamp, window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); } } else { - if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) { + if (finger_touching == true && track_touchid == id && track_fingerid == fingerid) { SDL_SendMouseButton(timestamp, window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); } } } if (down) { - if (finger_touching == SDL_FALSE) { - finger_touching = SDL_TRUE; + if (finger_touching == false) { + finger_touching = true; track_touchid = id; track_fingerid = fingerid; } } else { - if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) { - finger_touching = SDL_FALSE; + if (finger_touching == true && track_touchid == id && track_fingerid == fingerid) { + finger_touching = false; } } } @@ -333,7 +333,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W if (finger) { /* This finger is already down. Assume the finger-up for the previous touch was lost, and send it. */ - SDL_SendTouch(timestamp, id, fingerid, window, SDL_FALSE, x, y, pressure); + SDL_SendTouch(timestamp, id, fingerid, window, false, x, y, pressure); } if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) { @@ -405,7 +405,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, if (mouse->touch_mouse_events) { if (id != SDL_MOUSE_TOUCHID) { if (window) { - if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) { + if (finger_touching == true && track_touchid == id && track_fingerid == fingerid) { float pos_x = (x * (float)window->w); float pos_y = (y * (float)window->h); if (pos_x < 0.0f) { @@ -420,7 +420,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, if (pos_y > (float)(window->h - 1)) { pos_y = (float)(window->h - 1); } - SDL_SendMouseMotion(timestamp, window, SDL_TOUCH_MOUSEID, SDL_FALSE, pos_x, pos_y); + SDL_SendMouseMotion(timestamp, window, SDL_TOUCH_MOUSEID, false, pos_x, pos_y); } } } @@ -437,7 +437,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, finger = SDL_GetFinger(touch, fingerid); if (!finger) { - return SDL_SendTouch(timestamp, id, fingerid, window, SDL_TRUE, x, y, pressure); + return SDL_SendTouch(timestamp, id, fingerid, window, true, x, y, pressure); } xrel = x - finger->x; diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h index 87748f18c2..7da34f6432 100644 --- a/src/events/SDL_touch_c.h +++ b/src/events/SDL_touch_c.h @@ -36,8 +36,8 @@ typedef struct SDL_Touch // Initialize the touch subsystem extern int SDL_InitTouch(void); -// Returns SDL_TRUE if _any_ connected touch devices are known to SDL -extern SDL_bool SDL_TouchDevicesAvailable(void); +// Returns true if _any_ connected touch devices are known to SDL +extern bool SDL_TouchDevicesAvailable(void); // Add a touch, returning the index of the touch, or -1 if there was an error. extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *name); @@ -46,7 +46,7 @@ extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *na extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); // Send a touch down/up event for a touch -extern int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_bool down, float x, float y, float pressure); +extern int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, bool down, float x, float y, float pressure); // Send a touch motion event for a touch extern int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure); diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 58b96ea356..bcb7927acc 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -33,9 +33,9 @@ static SDL_bool SDLCALL RemoveSupercededWindowEvents(void *userdata, SDL_Event * if (event->type == new_event->type && event->window.windowID == new_event->window.windowID) { // We're about to post a new move event, drop the old one - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, @@ -68,8 +68,8 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, window->flags &= ~SDL_WINDOW_OCCLUDED; break; case SDL_EVENT_WINDOW_MOVED: - window->undefined_x = SDL_FALSE; - window->undefined_y = SDL_FALSE; + window->undefined_x = false; + window->undefined_y = false; if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { window->windowed.x = data1; window->windowed.y = data2; @@ -257,7 +257,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, } if (toplevel_count <= 1) { - if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, true)) { SDL_SendQuit(); // This is the last toplevel window in the list so send the SDL_EVENT_QUIT event } } diff --git a/src/file/SDL_iostream.c b/src/file/SDL_iostream.c index 42c7727e46..1fe2bbd690 100644 --- a/src/file/SDL_iostream.c +++ b/src/file/SDL_iostream.c @@ -58,7 +58,7 @@ struct SDL_IOStream typedef struct IOStreamWindowsData { - SDL_bool append; + bool append; HANDLE h; void *data; size_t size; @@ -150,7 +150,7 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi return -2; // failed (CreateFile) } iodata->h = h; - iodata->append = a_mode ? SDL_TRUE : SDL_FALSE; + iodata->append = a_mode ? true : false; return 0; // ok } @@ -296,7 +296,7 @@ static int SDLCALL windows_file_close(void *userdata) typedef struct IOStreamStdioData { FILE *fp; - SDL_bool autoclose; + bool autoclose; } IOStreamStdioData; #ifdef HAVE_FOPEN64 @@ -361,7 +361,7 @@ static Sint64 SDLCALL stdio_seek(void *userdata, Sint64 offset, SDL_IOWhence whe #endif // don't make a possibly-costly API call for the noop seek from SDL_TellIO - const SDL_bool is_noop = (whence == SDL_IO_SEEK_CUR) && (offset == 0); + const bool is_noop = (whence == SDL_IO_SEEK_CUR) && (offset == 0); if (is_noop || fseek(iodata->fp, (fseek_off_t)offset, stdiowhence) == 0) { const Sint64 pos = ftell(iodata->fp); @@ -406,7 +406,7 @@ static int SDLCALL stdio_close(void *userdata) return status; } -static SDL_IOStream *SDL_IOFromFP(FILE *fp, SDL_bool autoclose) +static SDL_IOStream *SDL_IOFromFP(FILE *fp, bool autoclose) { IOStreamStdioData *iodata = (IOStreamStdioData *) SDL_malloc(sizeof (*iodata)); if (!iodata) { @@ -514,21 +514,21 @@ static int SDLCALL mem_close(void *userdata) // Functions to create SDL_IOStream structures from various data sources #if defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINDOWS) -static SDL_bool IsRegularFileOrPipe(FILE *f) +static bool IsRegularFileOrPipe(FILE *f) { #ifdef SDL_PLATFORM_WINRT struct __stat64 st; if (_fstat64(_fileno(f), &st) < 0 || !((st.st_mode & _S_IFMT) == _S_IFREG || (st.st_mode & _S_IFMT) == _S_IFIFO)) { - return SDL_FALSE; + return false; } #else struct stat st; if (fstat(fileno(f), &st) < 0 || !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) { - return SDL_FALSE; + return false; } #endif - return SDL_TRUE; + return true; } #endif @@ -573,7 +573,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) return NULL; } - return SDL_IOFromFP(fp, SDL_TRUE); + return SDL_IOFromFP(fp, true); } else { // Try opening it from internal storage if it's a relative path char *path = NULL; @@ -665,7 +665,7 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode) fp = NULL; SDL_SetError("%s is not a regular file or pipe", file); } else { - iostr = SDL_IOFromFP(fp, SDL_TRUE); + iostr = SDL_IOFromFP(fp, true); } } @@ -891,7 +891,7 @@ void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio) Sint64 size, size_total = 0; size_t size_read; char *data = NULL, *newdata; - SDL_bool loading_chunks = SDL_FALSE; + bool loading_chunks = false; if (!src) { SDL_InvalidParamError("src"); @@ -901,7 +901,7 @@ void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio) size = SDL_GetIOSize(src); if (size < 0) { size = FILE_CHUNK_SIZE; - loading_chunks = SDL_TRUE; + loading_chunks = true; } if (size >= SDL_SIZE_MAX) { goto done; @@ -954,7 +954,7 @@ done: void *SDL_LoadFile(const char *file, size_t *datasize) { - return SDL_LoadFile_IO(SDL_IOFromFile(file, "rb"), datasize, SDL_TRUE); + return SDL_LoadFile_IO(SDL_IOFromFile(file, "rb"), datasize, true); } SDL_PropertiesID SDL_GetIOProperties(SDL_IOStream *context) @@ -1103,10 +1103,10 @@ size_t SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char SDL_bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value) { Uint8 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = data; @@ -1117,10 +1117,10 @@ SDL_bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value) SDL_bool SDL_ReadS8(SDL_IOStream *src, Sint8 *value) { Sint8 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = data; @@ -1131,10 +1131,10 @@ SDL_bool SDL_ReadS8(SDL_IOStream *src, Sint8 *value) SDL_bool SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value) { Uint16 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap16LE(data); @@ -1150,10 +1150,10 @@ SDL_bool SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value) SDL_bool SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value) { Uint16 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap16BE(data); @@ -1169,10 +1169,10 @@ SDL_bool SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value) SDL_bool SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value) { Uint32 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap32LE(data); @@ -1188,10 +1188,10 @@ SDL_bool SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value) SDL_bool SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value) { Uint32 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap32BE(data); @@ -1207,10 +1207,10 @@ SDL_bool SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value) SDL_bool SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value) { Uint64 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap64LE(data); @@ -1226,10 +1226,10 @@ SDL_bool SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value) SDL_bool SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value) { Uint64 data = 0; - SDL_bool result = SDL_FALSE; + bool result = false; if (SDL_ReadIO(src, &data, sizeof(data)) == sizeof(data)) { - result = SDL_TRUE; + result = true; } if (value) { *value = SDL_Swap64BE(data); diff --git a/src/file/n3ds/SDL_iostreamromfs.c b/src/file/n3ds/SDL_iostreamromfs.c index 7829639136..984b093e01 100644 --- a/src/file/n3ds/SDL_iostreamromfs.c +++ b/src/file/n3ds/SDL_iostreamromfs.c @@ -22,10 +22,10 @@ #include "SDL_iostreamromfs.h" // Checks if the mode is a kind of reading -static SDL_bool IsReadMode(const char *mode); +static bool IsReadMode(const char *mode); // Checks if the file starts with the given prefix -static SDL_bool HasPrefix(const char *file, const char *prefix); +static bool HasPrefix(const char *file, const char *prefix); static FILE *TryOpenFile(const char *file, const char *mode); static FILE *TryOpenInRomfs(const char *file, const char *mode); @@ -50,12 +50,12 @@ FILE *N3DS_FileOpen(const char *file, const char *mode) return TryOpenFile(file, mode); } -static SDL_bool IsReadMode(const char *mode) +static bool IsReadMode(const char *mode) { return SDL_strchr(mode, 'r') != NULL; } -static SDL_bool HasPrefix(const char *file, const char *prefix) +static bool HasPrefix(const char *file, const char *prefix) { return SDL_strncmp(prefix, file, SDL_strlen(prefix)) == 0; } diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c index ebe9c2db92..d6d51265c5 100644 --- a/src/filesystem/SDL_filesystem.c +++ b/src/filesystem/SDL_filesystem.c @@ -88,18 +88,18 @@ int SDL_GetPathInfo(const char *path, SDL_PathInfo *info) return SDL_SYS_GetPathInfo(path, info); } -static SDL_bool EverythingMatch(const char *pattern, const char *str, SDL_bool *matched_to_dir) +static bool EverythingMatch(const char *pattern, const char *str, bool *matched_to_dir) { SDL_assert(pattern == NULL); SDL_assert(str != NULL); SDL_assert(matched_to_dir != NULL); - *matched_to_dir = SDL_TRUE; - return SDL_TRUE; // everything matches! + *matched_to_dir = true; + return true; // everything matches! } // this is just '*' and '?', with '/' matching nothing. -static SDL_bool WildcardMatch(const char *pattern, const char *str, SDL_bool *matched_to_dir) +static bool WildcardMatch(const char *pattern, const char *str, bool *matched_to_dir) { SDL_assert(pattern != NULL); SDL_assert(str != NULL); @@ -127,8 +127,8 @@ static SDL_bool WildcardMatch(const char *pattern, const char *str, SDL_bool *ma sch = *(++str); pch = *(++pattern); } else if (!pattern_backtrack || (sch_backtrack == '/')) { // we didn't have a match. Are we in a '*' and NOT on a path separator? Keep going. Otherwise, fail. - *matched_to_dir = SDL_FALSE; - return SDL_FALSE; + *matched_to_dir = false; + return false; } else { // still here? Wasn't a match, but we're definitely in a '*' pattern. str = ++str_backtrack; pattern = pattern_backtrack; @@ -230,7 +230,7 @@ static char *CaseFoldUtf8String(const char *fname) typedef struct GlobDirCallbackData { - SDL_bool (*matcher)(const char *pattern, const char *str, SDL_bool *matched_to_dir); + bool (*matcher)(const char *pattern, const char *str, bool *matched_to_dir); const char *pattern; int num_entries; SDL_GlobFlags flags; @@ -267,8 +267,8 @@ static int SDLCALL GlobDirectoryCallback(void *userdata, const char *dirname, co } } - SDL_bool matched_to_dir = SDL_FALSE; - const SDL_bool matched = data->matcher(data->pattern, (folded ? folded : fullpath) + data->basedirlen, &matched_to_dir); + bool matched_to_dir = false; + const bool matched = data->matcher(data->pattern, (folded ? folded : fullpath) + data->basedirlen, &matched_to_dir); //SDL_Log("GlobDirectoryCallback: Considered %spath='%s' vs pattern='%s': %smatched (matched_to_dir=%s)", folded ? "(folded) " : "", (folded ? folded : fullpath) + data->basedirlen, data->pattern, matched ? "" : "NOT ", matched_to_dir ? "TRUE" : "FALSE"); SDL_free(folded); diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index 58913bd10e..7d140d6dcd 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -89,9 +89,9 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) * actually stick around, you'll need to use iCloud storage. */ { - static SDL_bool shown = SDL_FALSE; + static bool shown = false; if (!shown) { - shown = SDL_TRUE; + shown = true; SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "tvOS does not have persistent local storage! Use iCloud storage if you want your data to persist between sessions.\n"); } } diff --git a/src/filesystem/gdk/SDL_sysfilesystem.cpp b/src/filesystem/gdk/SDL_sysfilesystem.cpp index c035bdd88a..fa8d21549c 100644 --- a/src/filesystem/gdk/SDL_sysfilesystem.cpp +++ b/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -44,7 +44,7 @@ SDL_SYS_GetBasePath(void) DWORD len = 0; int i; - while (SDL_TRUE) { + while (true) { void *ptr = SDL_realloc(path, buflen * sizeof(CHAR)); if (!ptr) { SDL_free(path); diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index e3e9c62cd2..401a0b0fb6 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -51,7 +51,7 @@ char *SDL_SYS_GetBasePath(void) DWORD len = 0; int i; - while (SDL_TRUE) { + while (true) { void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR)); if (!ptr) { SDL_free(path); diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 7945b50598..c7962aad32 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -44,7 +44,7 @@ int SDL_InitHaptics(void) return status; } -static SDL_bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index) +static bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index) { int num_haptics, device_index; @@ -54,13 +54,13 @@ static SDL_bool SDL_GetHapticIndex(SDL_HapticID instance_id, int *driver_index) SDL_HapticID haptic_id = SDL_SYS_HapticInstanceID(device_index); if (haptic_id == instance_id) { *driver_index = device_index; - return SDL_TRUE; + return true; } } } SDL_SetError("Haptic device %" SDL_PRIu32 " not found", instance_id); - return SDL_FALSE; + return false; } SDL_HapticID *SDL_GetHaptics(int *count) @@ -134,7 +134,7 @@ SDL_Haptic *SDL_OpenHaptic(SDL_HapticID instance_id) } // Initialize the haptic device - SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_TRUE); + SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, true); haptic->instance_id = instance_id; haptic->rumble_id = -1; if (SDL_SYS_HapticOpen(haptic) < 0) { @@ -195,9 +195,9 @@ const char *SDL_GetHapticName(SDL_Haptic *haptic) SDL_bool SDL_IsMouseHaptic(void) { if (SDL_SYS_HapticMouse() < 0) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } SDL_Haptic *SDL_OpenHapticFromMouse(void) @@ -216,7 +216,7 @@ SDL_Haptic *SDL_OpenHapticFromMouse(void) SDL_bool SDL_IsJoystickHaptic(SDL_Joystick *joystick) { - SDL_bool result = SDL_FALSE; + bool result = false; SDL_LockJoysticks(); { @@ -315,7 +315,7 @@ void SDL_CloseHaptic(SDL_Haptic *haptic) } } SDL_SYS_HapticClose(haptic); - SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, SDL_FALSE); + SDL_SetObjectValid(haptic, SDL_OBJECT_TYPE_HAPTIC, false); // Remove from the list hapticlist = SDL_haptics; @@ -379,16 +379,16 @@ int SDL_GetNumHapticAxes(SDL_Haptic *haptic) SDL_bool SDL_HapticEffectSupported(SDL_Haptic *haptic, const SDL_HapticEffect *effect) { - CHECK_HAPTIC_MAGIC(haptic, SDL_FALSE); + CHECK_HAPTIC_MAGIC(haptic, false); if (!effect) { - return SDL_FALSE; + return false; } if ((haptic->supported & effect->type) != 0) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect) @@ -402,7 +402,7 @@ int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect) } // Check to see if effect is supported - if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) { + if (SDL_HapticEffectSupported(haptic, effect) == false) { return SDL_SetError("Haptic: Effect not supported by haptic device."); } @@ -614,7 +614,7 @@ int SDL_StopHapticEffects(SDL_Haptic *haptic) SDL_bool SDL_HapticRumbleSupported(SDL_Haptic *haptic) { - CHECK_HAPTIC_MAGIC(haptic, SDL_FALSE); + CHECK_HAPTIC_MAGIC(haptic, false); // Most things can use SINE, but XInput only has LEFTRIGHT. return (haptic->supported & (SDL_HAPTIC_SINE | SDL_HAPTIC_LEFTRIGHT)) != 0; diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index a14a55e3c5..ec8856f1ff 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -93,7 +93,7 @@ int SDL_SYS_HapticMouse(void); /* * Checks to see if the joystick has haptic capabilities. */ -extern SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick); +extern bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick); /* * Opens the haptic device for usage using the same device as @@ -106,9 +106,9 @@ extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, /* * Checks to see if haptic device and joystick device are the same. * - * Returns SDL_TRUE if they are the same, SDL_FALSE if they aren't. + * Returns true if they are the same, false if they aren't. */ -extern SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, +extern bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick); /* diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index 7dc901554b..e9bfc6834c 100644 --- a/src/haptic/android/SDL_syshaptic.c +++ b/src/haptic/android/SDL_syshaptic.c @@ -138,9 +138,9 @@ int SDL_SYS_HapticMouse(void) return -1; } -SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { - return SDL_FALSE; + return false; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) @@ -148,9 +148,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) return SDL_Unsupported(); } -SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) +bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { - return SDL_FALSE; + return false; } void SDL_SYS_HapticClose(SDL_Haptic *haptic) diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 3f770781ec..38fb9e3473 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -587,34 +587,34 @@ int SDL_SYS_HapticMouse(void) /* * Checks to see if a joystick has haptic features. */ -SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_IOKIT if (joystick->driver != &SDL_DARWIN_JoystickDriver) { - return SDL_FALSE; + return false; } if (joystick->hwdata->ffservice != 0) { - return SDL_TRUE; + return true; } #endif - return SDL_FALSE; + return false; } /* * Checks to see if the haptic device and joystick are in reality the same. */ -SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) +bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_IOKIT if (joystick->driver != &SDL_DARWIN_JoystickDriver) { - return SDL_FALSE; + return false; } if (IOObjectIsEqualTo((io_object_t)((size_t)haptic->hwdata->device), joystick->hwdata->ffservice)) { - return SDL_TRUE; + return true; } #endif - return SDL_FALSE; + return false; } /* @@ -1277,9 +1277,9 @@ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic *haptic, } if (status == 0) { - return SDL_FALSE; + return false; } - return SDL_TRUE; // Assume it's playing or emulated. + return true; // Assume it's playing or emulated. } /* diff --git a/src/haptic/dummy/SDL_syshaptic.c b/src/haptic/dummy/SDL_syshaptic.c index 3c1115da75..c003354684 100644 --- a/src/haptic/dummy/SDL_syshaptic.c +++ b/src/haptic/dummy/SDL_syshaptic.c @@ -61,9 +61,9 @@ int SDL_SYS_HapticMouse(void) return -1; } -SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { - return SDL_FALSE; + return false; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) @@ -71,9 +71,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) return SDL_SYS_LogicError(); } -SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) +bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { - return SDL_FALSE; + return false; } void SDL_SYS_HapticClose(SDL_Haptic *haptic) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index b9afe56b6d..6a91e70372 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -503,39 +503,39 @@ int SDL_SYS_HapticMouse(void) /* * Checks to see if a joystick has haptic features. */ -SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_LINUX SDL_AssertJoysticksLocked(); if (joystick->driver != &SDL_LINUX_JoystickDriver) { - return SDL_FALSE; + return false; } if (EV_IsHaptic(joystick->hwdata->fd)) { - return SDL_TRUE; + return true; } #endif - return SDL_FALSE; + return false; } /* * Checks to see if the haptic device and joystick are in reality the same. */ -SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) +bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_LINUX SDL_AssertJoysticksLocked(); if (joystick->driver != &SDL_LINUX_JoystickDriver) { - return SDL_FALSE; + return false; } /* We are assuming Linux is using evdev which should trump the old * joystick methods. */ if (SDL_strcmp(joystick->hwdata->fname, haptic->hwdata->fname) == 0) { - return SDL_TRUE; + return true; } #endif - return SDL_FALSE; + return false; } /* diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index d9ed3b0698..0a5c3c69a3 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -40,7 +40,7 @@ static const HWND SDL_HelperWindow = NULL; /* * Internal stuff. */ -static SDL_bool coinitialized = SDL_FALSE; +static bool coinitialized = false; static LPDIRECTINPUT8 dinput = NULL; /* @@ -71,7 +71,7 @@ int SDL_DINPUT_HapticInit(void) return SDL_SetError("Haptic: SubSystem already open."); } - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, true)) { // In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. return 0; } @@ -81,7 +81,7 @@ int SDL_DINPUT_HapticInit(void) return DI_SetError("Coinitialize", ret); } - coinitialized = SDL_TRUE; + coinitialized = true; ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8, (LPVOID *)&dinput); @@ -280,7 +280,7 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) * - Reset actuators. * - Get supported features. */ -static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick) +static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVICE8 device8, bool is_joystick) { HRESULT ret; DIPROPDWORD dipdw; @@ -428,7 +428,7 @@ int SDL_DINPUT_HapticOpen(SDL_Haptic *haptic, SDL_hapticlist_item *item) return -1; } - if (SDL_DINPUT_HapticOpenFromDevice(haptic, device, SDL_FALSE) < 0) { + if (SDL_DINPUT_HapticOpenFromDevice(haptic, device, false) < 0) { IDirectInputDevice8_Release(device); return -1; } @@ -475,7 +475,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick if (WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) { haptic->instance_id = item->instance_id; haptic->name = SDL_strdup(item->name); - return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE); + return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, true); } } @@ -501,7 +501,7 @@ void SDL_DINPUT_HapticQuit(void) if (coinitialized) { WIN_CoUninitialize(); - coinitialized = SDL_FALSE; + coinitialized = false; } } @@ -1056,9 +1056,9 @@ int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic *haptic, struct haptic_effect *e } if (status == 0) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } int SDL_DINPUT_HapticSetGain(SDL_Haptic *haptic, int gain) diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 868676452e..9423161e31 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -180,24 +180,24 @@ int SDL_SYS_HapticMouse(void) /* * Checks to see if a joystick has haptic features. */ -SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) +bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { - return SDL_FALSE; + return false; } if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } /* * Checks to see if the haptic device and joystick are in reality the same. */ -SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) +bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { - return SDL_FALSE; + return false; } return SDL_DINPUT_JoystickSameHaptic(haptic, joystick); } diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h index d1167ca964..cd1d1eb716 100644 --- a/src/haptic/windows/SDL_windowshaptic_c.h +++ b/src/haptic/windows/SDL_windowshaptic_c.h @@ -41,7 +41,7 @@ struct haptic_hwdata LPDIRECTINPUTDEVICE8 device; #endif DWORD axes[3]; // Axes to use. - SDL_bool is_joystick; // Device is loaded as joystick. + bool is_joystick; // Device is loaded as joystick. SDL_Thread *thread; SDL_Mutex *mutex; Uint64 stopTicks; diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index 07cd281673..19843fa14e 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -96,9 +96,9 @@ static const SDL_UDEV_Symbols *usyms = NULL; static struct { - SDL_bool m_bInitialized; + bool m_bInitialized; Uint32 m_unDeviceChangeCounter; - SDL_bool m_bCanGetNotifications; + bool m_bCanGetNotifications; Uint64 m_unLastDetect; #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) @@ -225,9 +225,9 @@ static int StrIsInteger(const char *string) static void HIDAPI_InitializeDiscovery(void) { - SDL_HIDAPI_discovery.m_bInitialized = SDL_TRUE; + SDL_HIDAPI_discovery.m_bInitialized = true; SDL_HIDAPI_discovery.m_unDeviceChangeCounter = 1; - SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_FALSE; + SDL_HIDAPI_discovery.m_bCanGetNotifications = false; SDL_HIDAPI_discovery.m_unLastDetect = 0; #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) @@ -325,7 +325,7 @@ static void HIDAPI_InitializeDiscovery(void) if (SDL_HIDAPI_discovery.m_pUdevMonitor != NULL) { usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor); SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor); - SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; + SDL_HIDAPI_discovery.m_bCanGetNotifications = true; } } } @@ -357,7 +357,7 @@ static void HIDAPI_InitializeDiscovery(void) return; } - SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; + SDL_HIDAPI_discovery.m_bCanGetNotifications = true; #endif // HAVE_INOTIFY } } @@ -526,7 +526,7 @@ static void HIDAPI_ShutdownDiscovery(void) #endif } - SDL_HIDAPI_discovery.m_bInitialized = SDL_FALSE; + SDL_HIDAPI_discovery.m_bInitialized = false; } // Platform HIDAPI Implementation @@ -891,16 +891,16 @@ static const struct { { 0x057e, 0x0337 } // Nintendo WUP-028, Wii U/Switch GameCube Adapter }; -static SDL_bool IsInWhitelist(Uint16 vendor, Uint16 product) +static bool IsInWhitelist(Uint16 vendor, Uint16 product) { int i; for (i = 0; i < SDL_arraysize(SDL_libusb_whitelist); i += 1) { if (vendor == SDL_libusb_whitelist[i].vendor && product == SDL_libusb_whitelist[i].product) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } #endif // HAVE_LIBUSB @@ -909,13 +909,13 @@ static SDL_bool IsInWhitelist(Uint16 vendor, Uint16 product) #if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) // We have another way to get HID devices, so use the whitelist to get devices where libusb is preferred -#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT SDL_TRUE +#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT true #else // libusb is the only way to get HID devices, so don't use the whitelist, get them all -#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT SDL_FALSE +#define SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT false #endif // HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND -static SDL_bool use_libusb_whitelist = SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT; +static bool use_libusb_whitelist = SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT; // Shared HIDAPI Implementation @@ -1010,7 +1010,7 @@ struct SDL_hid_device static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend) { SDL_hid_device *wrapper = (SDL_hid_device *)SDL_malloc(sizeof(*wrapper)); - SDL_SetObjectValid(wrapper, SDL_OBJECT_TYPE_HIDAPI_DEVICE, SDL_TRUE); + SDL_SetObjectValid(wrapper, SDL_OBJECT_TYPE_HIDAPI_DEVICE, true); wrapper->device = device; wrapper->backend = backend; SDL_zero(wrapper->info); @@ -1021,7 +1021,7 @@ static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_ static void DeleteHIDDeviceWrapper(SDL_hid_device *wrapper) { - SDL_SetObjectValid(wrapper, SDL_OBJECT_TYPE_HIDAPI_DEVICE, SDL_FALSE); + SDL_SetObjectValid(wrapper, SDL_OBJECT_TYPE_HIDAPI_DEVICE, false); SDL_free(wrapper->info.path); SDL_free(wrapper->info.serial_number); SDL_free(wrapper->info.manufacturer_string); @@ -1071,12 +1071,12 @@ static void CopyHIDDeviceInfo(struct hid_device_info *pSrc, struct SDL_hid_devic #undef WCOPY_IF_EXISTS static int SDL_hidapi_refcount = 0; -static SDL_bool SDL_hidapi_only_controllers; +static bool SDL_hidapi_only_controllers; static char *SDL_hidapi_ignored_devices = NULL; static void SDLCALL OnlyControllersChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - SDL_hidapi_only_controllers = SDL_GetStringBoolean(hint, SDL_TRUE); + SDL_hidapi_only_controllers = SDL_GetStringBoolean(hint, true); } static void SDLCALL IgnoredDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint) @@ -1091,7 +1091,7 @@ static void SDLCALL IgnoredDevicesChanged(void *userdata, const char *name, cons } } -SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage) +bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage) { // See if there are any devices we should skip in enumeration if (SDL_hidapi_only_controllers && usage_page) { @@ -1106,13 +1106,13 @@ SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product #endif usage_page == USB_USAGEPAGE_GENERIC_DESKTOP && (usage == USB_USAGE_GENERIC_KEYBOARD || usage == USB_USAGE_GENERIC_MOUSE)) { - return SDL_TRUE; + return true; } } else if (usage_page == USB_USAGEPAGE_GENERIC_DESKTOP && (usage == USB_USAGE_GENERIC_JOYSTICK || usage == USB_USAGE_GENERIC_GAMEPAD || usage == USB_USAGE_GENERIC_MULTIAXISCONTROLLER)) { // This is a controller } else { - return SDL_TRUE; + return true; } } if (SDL_hidapi_ignored_devices) { @@ -1121,10 +1121,10 @@ SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product SDL_snprintf(product_match, sizeof(product_match), "0x%.4x/0x%.4x", vendor_id, product_id); if (SDL_strcasestr(SDL_hidapi_ignored_devices, vendor_match) || SDL_strcasestr(SDL_hidapi_ignored_devices, product_match)) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } int SDL_hid_init(void) @@ -1140,7 +1140,7 @@ int SDL_hid_init(void) SDL_AddHintCallback(SDL_HINT_HIDAPI_IGNORE_DEVICES, IgnoredDevicesChanged, NULL); #ifdef SDL_USE_LIBUDEV - if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_UDEV, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_UDEV, true)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "udev disabled by SDL_HINT_HIDAPI_UDEV"); linux_enumeration_method = ENUMERATION_FALLBACK; @@ -1158,7 +1158,7 @@ int SDL_hid_init(void) use_libusb_whitelist = SDL_GetHintBoolean(SDL_HINT_HIDAPI_LIBUSB_WHITELIST, SDL_HINT_HIDAPI_LIBUSB_WHITELIST_DEFAULT); #ifdef HAVE_LIBUSB - if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_LIBUSB, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_LIBUSB, true)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "libusb disabled with SDL_HINT_HIDAPI_LIBUSB"); libusb_ctx.libhandle = NULL; @@ -1170,11 +1170,11 @@ int SDL_hid_init(void) libusb_ctx.libhandle = (void *)1; #endif if (libusb_ctx.libhandle != NULL) { - SDL_bool loaded = SDL_TRUE; + bool loaded = true; #ifdef SDL_LIBUSB_DYNAMIC #define LOAD_LIBUSB_SYMBOL(type, func) \ if (!(libusb_ctx.func = (type)SDL_LoadFunction(libusb_ctx.libhandle, "libusb_" #func))) { \ - loaded = SDL_FALSE; \ + loaded = false; \ } #else #define LOAD_LIBUSB_SYMBOL(type, func) \ diff --git a/src/hidapi/SDL_hidapi_c.h b/src/hidapi/SDL_hidapi_c.h index 62148cdc36..ab5183ad00 100644 --- a/src/hidapi/SDL_hidapi_c.h +++ b/src/hidapi/SDL_hidapi_c.h @@ -22,7 +22,7 @@ /* Return true if the HIDAPI should ignore a device during enumeration */ -extern SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus_type, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage); +extern bool SDL_HIDAPI_ShouldIgnoreDevice(int bus_type, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage); #ifdef SDL_JOYSTICK_HIDAPI #ifdef HAVE_LIBUSB diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp index c1c2288310..68ebd272a3 100644 --- a/src/hidapi/android/hid.cpp +++ b/src/hidapi/android/hid.cpp @@ -1035,13 +1035,13 @@ static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, con SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1); } -static SDL_bool RequestBluetoothPermissions(const char *permission) +static bool RequestBluetoothPermissions(const char *permission) { // !!! FIXME: make this non-blocking! SDL_AtomicInt permission_response; SDL_AtomicSet(&permission_response, 0); if (SDL_RequestAndroidPermission(permission, RequestAndroidPermissionBlockingCallback, &permission_response) == -1) { - return SDL_FALSE; + return false; } while (SDL_AtomicGet(&permission_response) == 0) { @@ -1067,7 +1067,7 @@ int hid_init(void) // before initializing Bluetooth, which will prompt the user for permission. bool init_usb = true; bool init_bluetooth = false; - if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, false)) { if (SDL_GetAndroidSDKVersion() < 31 || RequestBluetoothPermissions("android.permission.BLUETOOTH_CONNECT")) { init_bluetooth = true; diff --git a/src/hidapi/ios/hid.m b/src/hidapi/ios/hid.m index 8f9e5fe841..bfa375c18b 100644 --- a/src/hidapi/ios/hid.m +++ b/src/hidapi/ios/hid.m @@ -241,7 +241,7 @@ typedef enum // Bluetooth is currently only used for Steam Controllers, so check that hint // before initializing Bluetooth, which will prompt the user for permission. - if ( SDL_GetHintBoolean( SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_FALSE ) ) + if ( SDL_GetHintBoolean( SDL_HINT_JOYSTICK_HIDAPI_STEAM, false ) ) { [[NSNotificationCenter defaultCenter] addObserver:sharedInstance selector:@selector(appWillResignActiveNotification:) name: UIApplicationWillResignActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:sharedInstance selector:@selector(appDidBecomeActiveNotification:) name:UIApplicationDidBecomeActiveNotification object:nil]; diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index e7e2481920..888ed7a0dd 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -55,7 +55,7 @@ #define SDL_GAMEPAD_SDKLE_FIELD "sdk<=:" #define SDL_GAMEPAD_SDKLE_FIELD_SIZE SDL_strlen(SDL_GAMEPAD_SDKLE_FIELD) -static SDL_bool SDL_gamepads_initialized; +static bool SDL_gamepads_initialized; static SDL_Gamepad *SDL_gamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL; // The face button style of a gamepad @@ -141,25 +141,25 @@ static SDL_vidpid_list SDL_allowed_gamepads = { SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, 0, 0, NULL, NULL, 0, 0, NULL, 0, NULL, - SDL_FALSE + false }; static SDL_vidpid_list SDL_ignored_gamepads = { SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, 0, 0, NULL, NULL, 0, 0, NULL, 0, NULL, - SDL_FALSE + false }; -static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority); +static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, bool *existing, SDL_GamepadMappingPriority priority); static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t *pGamepadMapping); -static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping); +static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, bool create_mapping); static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value); static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadButton button, Uint8 state); -static SDL_bool HasSameOutput(SDL_GamepadBinding *a, SDL_GamepadBinding *b) +static bool HasSameOutput(SDL_GamepadBinding *a, SDL_GamepadBinding *b) { if (a->output_type != b->output_type) { - return SDL_FALSE; + return false; } if (a->output_type == SDL_GAMEPAD_BINDTYPE_AXIS) { @@ -422,7 +422,7 @@ static SDL_bool SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event break; } - return SDL_TRUE; + return true; } /* SDL defines sensor orientation relative to the device natural @@ -501,7 +501,7 @@ static void PushMappingChangeTracking(void) return; } for (i = 0; i < num_joysticks; ++i) { - tracker->joystick_mappings[i] = SDL_PrivateGetGamepadMapping(tracker->joysticks[i], SDL_FALSE); + tracker->joystick_mappings[i] = SDL_PrivateGetGamepadMapping(tracker->joysticks[i], false); } } @@ -524,7 +524,7 @@ static void AddMappingChangeTracking(GamepadMapping_t *mapping) } } -static SDL_bool HasMappingChangeTracking(MappingChangeTracker *tracker, GamepadMapping_t *mapping) +static bool HasMappingChangeTracking(MappingChangeTracker *tracker, GamepadMapping_t *mapping) { int i; @@ -532,10 +532,10 @@ static SDL_bool HasMappingChangeTracking(MappingChangeTracker *tracker, GamepadM for (i = 0; i < tracker->num_changed_mappings; ++i) { if (tracker->changed_mappings[i] == mapping) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void PopMappingChangeTracking(void) @@ -559,16 +559,16 @@ static void PopMappingChangeTracking(void) // Looking up the new mapping might create one and associate it with the gamepad (and generate events) SDL_JoystickID joystick = tracker->joysticks[i]; SDL_Gamepad *gamepad = SDL_GetGamepadFromID(joystick); - GamepadMapping_t *new_mapping = SDL_PrivateGetGamepadMapping(joystick, SDL_FALSE); + GamepadMapping_t *new_mapping = SDL_PrivateGetGamepadMapping(joystick, false); GamepadMapping_t *old_mapping = gamepad ? gamepad->mapping : tracker->joystick_mappings[i]; if (new_mapping && !old_mapping) { SDL_RemoveFromHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick); - SDL_InsertIntoHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick, (const void *)SDL_TRUE); + SDL_InsertIntoHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick, (const void *)true); SDL_PrivateGamepadAdded(joystick); } else if (old_mapping && !new_mapping) { SDL_RemoveFromHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick); - SDL_InsertIntoHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick, (const void *)SDL_FALSE); + SDL_InsertIntoHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)joystick, (const void *)false); SDL_PrivateGamepadRemoved(joystick); } else if (old_mapping != new_mapping || HasMappingChangeTracking(tracker, new_mapping)) { if (gamepad) { @@ -595,7 +595,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) (1 << SDL_GAMEPAD_BUTTON_EAST) | (1 << SDL_GAMEPAD_BUTTON_WEST) | (1 << SDL_GAMEPAD_BUTTON_NORTH)); - SDL_bool existing; + bool existing; char mapping_string[1024]; int button_mask; int axis_mask; @@ -693,7 +693,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) */ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) { - SDL_bool existing; + bool existing; char mapping_string[1024]; Uint16 vendor; Uint16 product; @@ -746,7 +746,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) case k_eWiiExtensionControllerType_Nunchuk: { // FIXME: Should we map this to the left or right side? - const SDL_bool map_nunchuck_left_side = SDL_TRUE; + const bool map_nunchuck_left_side = true; if (map_nunchuck_left_side) { SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,start:b6,x:b2,y:b3,", sizeof(mapping_string)); @@ -755,7 +755,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) } } break; default: - if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, false)) { // Vertical mode if (guid.data[15] == k_eSwitchDeviceInfoControllerType_JoyConLeft) { SDL_strlcat(mapping_string, "back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,misc1:b11,paddle2:b13,paddle4:b15,", sizeof(mapping_string)); @@ -838,7 +838,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) */ static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_GUID guid) { - SDL_bool existing; + bool existing; char mapping_string[1024]; SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string)); @@ -852,7 +852,7 @@ static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_GUID guid) */ static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_GUID guid) { - SDL_bool existing; + bool existing; char mapping_string[1024]; if (guid.data[15] != SDL_JOYSTICK_TYPE_GAMEPAD) { @@ -868,7 +868,7 @@ static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_GUID guid) /* * Helper function to scan the mappings database for a gamepad with the specified GUID */ -static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, SDL_bool match_version) +static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, bool match_version) { GamepadMapping_t *mapping, *best_match = NULL; Uint16 crc = 0; @@ -920,11 +920,11 @@ static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, SD /* * Helper function to scan the mappings database for a gamepad with the specified GUID */ -static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_bool adding_mapping) +static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, bool adding_mapping) { GamepadMapping_t *mapping; - mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_TRUE); + mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, true); if (mapping) { return mapping; } @@ -938,7 +938,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_ if (SDL_JoystickGUIDUsesVersion(guid)) { // Try again, ignoring the version - mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, SDL_FALSE); + mapping = SDL_PrivateMatchGamepadMappingForGUID(guid, false); if (mapping) { return mapping; } @@ -1092,7 +1092,7 @@ SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForG /* * convert a string to its enum equivalent */ -static SDL_GamepadButton SDL_PrivateGetGamepadButtonFromString(const char *str, SDL_bool baxy) +static SDL_GamepadButton SDL_PrivateGetGamepadButtonFromString(const char *str, bool baxy) { int i; @@ -1124,7 +1124,7 @@ static SDL_GamepadButton SDL_PrivateGetGamepadButtonFromString(const char *str, } SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str) { - return SDL_PrivateGetGamepadButtonFromString(str, SDL_FALSE); + return SDL_PrivateGetGamepadButtonFromString(str, false); } /* @@ -1141,17 +1141,17 @@ const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button) /* * given a gamepad button name and a joystick name update our mapping structure with it */ -static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton) +static bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char *szGameButton, const char *szJoystickButton) { SDL_GamepadBinding bind; SDL_GamepadButton button; SDL_GamepadAxis axis; - SDL_bool invert_input = SDL_FALSE; + bool invert_input = false; char half_axis_input = 0; char half_axis_output = 0; int i; SDL_GamepadBinding *new_bindings; - SDL_bool baxy_mapping = SDL_FALSE; + bool baxy_mapping = false; SDL_AssertJoysticksLocked(); @@ -1162,7 +1162,7 @@ static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char } if (SDL_strstr(gamepad->mapping->mapping, ",hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") != NULL) { - baxy_mapping = SDL_TRUE; + baxy_mapping = true; } axis = SDL_GetGamepadAxisFromString(szGameButton); @@ -1189,14 +1189,14 @@ static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char bind.output_type = SDL_GAMEPAD_BINDTYPE_BUTTON; bind.output.button = button; } else { - return SDL_FALSE; + return false; } if (*szJoystickButton == '+' || *szJoystickButton == '-') { half_axis_input = *szJoystickButton++; } if (szJoystickButton[SDL_strlen(szJoystickButton) - 1] == '~') { - invert_input = SDL_TRUE; + invert_input = true; } if (szJoystickButton[0] == 'a' && SDL_isdigit((unsigned char)szJoystickButton[1])) { @@ -1228,13 +1228,13 @@ static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char bind.input.hat.hat = hat; bind.input.hat.hat_mask = mask; } else { - return SDL_FALSE; + return false; } for (i = 0; i < gamepad->num_bindings; ++i) { if (SDL_memcmp(&gamepad->bindings[i], &bind, sizeof(bind)) == 0) { // We already have this binding, could be different face button names? - return SDL_TRUE; + return true; } } @@ -1244,11 +1244,11 @@ static SDL_bool SDL_PrivateParseGamepadElement(SDL_Gamepad *gamepad, const char SDL_free(gamepad->bindings); gamepad->num_bindings = 0; gamepad->bindings = NULL; - return SDL_FALSE; + return false; } gamepad->bindings = new_bindings; gamepad->bindings[gamepad->num_bindings - 1] = bind; - return SDL_TRUE; + return true; } /* @@ -1258,7 +1258,7 @@ static int SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char { char szGameButton[20]; char szJoystickButton[20]; - SDL_bool bGameButton = SDL_TRUE; + bool bGameButton = true; int i = 0; const char *pchPos = pchString; @@ -1268,12 +1268,12 @@ static int SDL_PrivateParseGamepadConfigString(SDL_Gamepad *gamepad, const char while (pchPos && *pchPos) { if (*pchPos == ':') { i = 0; - bGameButton = SDL_FALSE; + bGameButton = false; } else if (*pchPos == ' ') { } else if (*pchPos == ',') { i = 0; - bGameButton = SDL_TRUE; + bGameButton = true; SDL_PrivateParseGamepadElement(gamepad, szGameButton, szJoystickButton); SDL_zeroa(szGameButton); SDL_zeroa(szJoystickButton); @@ -1529,7 +1529,7 @@ static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping) /* * Helper function to add a mapping for a guid */ -static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority) +static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, bool *existing, SDL_GamepadMappingPriority priority) { char *pchName; char *pchMapping; @@ -1595,7 +1595,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char PushMappingChangeTracking(); - pGamepadMapping = SDL_PrivateGetGamepadMappingForGUID(jGUID, SDL_TRUE); + pGamepadMapping = SDL_PrivateGetGamepadMappingForGUID(jGUID, true); if (pGamepadMapping) { // Only overwrite the mapping if the priority is the same or higher. if (pGamepadMapping->priority <= priority) { @@ -1610,7 +1610,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char SDL_free(pchMapping); } if (existing) { - *existing = SDL_TRUE; + *existing = true; } AddMappingChangeTracking(pGamepadMapping); } else { @@ -1645,7 +1645,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char s_pSupportedGamepads = pGamepadMapping; } if (existing) { - *existing = SDL_FALSE; + *existing = false; } } @@ -1663,12 +1663,12 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * SDL_AssertJoysticksLocked(); - mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_FALSE); + mapping = SDL_PrivateGetGamepadMappingForGUID(guid, false); #ifdef SDL_PLATFORM_LINUX if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { // The Linux driver xpad.c maps the wireless dpad to buttons - SDL_bool existing; + bool existing; mapping = SDL_PrivateAddMappingForGUID(guid, "none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT); @@ -1706,7 +1706,7 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string, (void)SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F); break; default: - SDL_assert(SDL_FALSE); + SDL_assert(false); } SDL_strlcat(mapping_string, buffer, mapping_string_len); @@ -1717,7 +1717,7 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char * SDL_GUID guid, SDL_GamepadMapping *raw_map) { - SDL_bool existing; + bool existing; char name_string[128]; char mapping[1024]; @@ -1770,7 +1770,7 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char * return SDL_PrivateAddMappingForGUID(guid, mapping, &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT); } -static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping) +static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, bool create_mapping) { const char *name; SDL_GUID guid; @@ -1855,7 +1855,7 @@ int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool closeio) int SDL_AddGamepadMappingsFromFile(const char *file) { - return SDL_AddGamepadMappingsFromIO(SDL_IOFromFile(file, "rb"), 1); + return SDL_AddGamepadMappingsFromIO(SDL_IOFromFile(file, "rb"), true); } int SDL_ReloadGamepadMappings(void) @@ -1928,9 +1928,9 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa char *remapped = NULL; char *pchGUID; SDL_GUID jGUID; - SDL_bool is_default_mapping = SDL_FALSE; - SDL_bool is_xinput_mapping = SDL_FALSE; - SDL_bool existing = SDL_FALSE; + bool is_default_mapping = false; + bool is_xinput_mapping = false; + bool existing = false; GamepadMapping_t *pGamepadMapping; int retval = -1; @@ -1945,17 +1945,17 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa tmp = SDL_strstr(mappingString, SDL_GAMEPAD_HINT_FIELD); if (tmp) { - SDL_bool default_value, value, negate; + bool default_value, value, negate; int len; char hint[128]; tmp += SDL_GAMEPAD_HINT_FIELD_SIZE; if (*tmp == '!') { - negate = SDL_TRUE; + negate = true; ++tmp; } else { - negate = SDL_FALSE; + negate = false; } len = 0; @@ -1968,7 +1968,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa tmp += 2; default_value = SDL_atoi(tmp); } else { - default_value = SDL_FALSE; + default_value = false; } if (SDL_strcmp(hint, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS") == 0) { @@ -2025,9 +2025,9 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa goto done; } if (!SDL_strcasecmp(pchGUID, "default")) { - is_default_mapping = SDL_TRUE; + is_default_mapping = true; } else if (!SDL_strcasecmp(pchGUID, "xinput")) { - is_xinput_mapping = SDL_TRUE; + is_xinput_mapping = true; } jGUID = SDL_StringToGUID(pchGUID); SDL_free(pchGUID); @@ -2078,7 +2078,7 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_GUID guid) char *pMappingString, *pPlatformString; char pchGUID[33]; size_t needed; - SDL_bool need_platform = SDL_FALSE; + bool need_platform = false; const char *platform = NULL; SDL_AssertJoysticksLocked(); @@ -2090,7 +2090,7 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_GUID guid) if (!SDL_strstr(mapping->mapping, SDL_GAMEPAD_PLATFORM_FIELD)) { // add memory for ',' + platform:PLATFORM - need_platform = SDL_TRUE; + need_platform = true; if (mapping->mapping[SDL_strlen(mapping->mapping) - 1] != ',') { needed += 1; } @@ -2145,10 +2145,10 @@ char **SDL_GetGamepadMappings(int *count) } size_t final_allocation = sizeof (char *); // for the NULL terminator element. - SDL_bool failed = SDL_FALSE; + bool failed = false; mappings = (char **) SDL_calloc(num_mappings + 1, sizeof (char *)); if (!mappings) { - failed = SDL_TRUE; + failed = true; } else { int i = 0; for (GamepadMapping_t *mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) { @@ -2158,7 +2158,7 @@ char **SDL_GetGamepadMappings(int *count) char *mappingstr = CreateMappingString(mapping, mapping->guid); if (!mappingstr) { - failed = SDL_TRUE; + failed = true; break; // error string is already set. } @@ -2210,7 +2210,7 @@ char *SDL_GetGamepadMappingForGUID(SDL_GUID guid) SDL_LockJoysticks(); { - GamepadMapping_t *mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_FALSE); + GamepadMapping_t *mapping = SDL_PrivateGetGamepadMappingForGUID(guid, false); if (mapping) { retval = CreateMappingString(mapping, guid); } else { @@ -2305,7 +2305,7 @@ static void SDL_LoadGamepadHints(void) * Usually this will just be SDL_HINT_GAMECONTROLLERCONFIG_FILE, but for * Android, we want to get the internal storage path. */ -static SDL_bool SDL_GetGamepadMappingFilePath(char *path, size_t size) +static bool SDL_GetGamepadMappingFilePath(char *path, size_t size) { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE); if (hint && *hint) { @@ -2315,7 +2315,7 @@ static SDL_bool SDL_GetGamepadMappingFilePath(char *path, size_t size) #ifdef SDL_PLATFORM_ANDROID return SDL_snprintf(path, size, "%s/gamepad_map.txt", SDL_GetAndroidInternalStoragePath()) < size; #else - return SDL_FALSE; + return false; #endif } @@ -2360,7 +2360,7 @@ int SDL_InitGamepads(void) int i; SDL_JoystickID *joysticks; - SDL_gamepads_initialized = SDL_TRUE; + SDL_gamepads_initialized = true; // Watch for joystick events and fire gamepad ones if needed SDL_AddEventWatch(SDL_GamepadEventWatcher, NULL); @@ -2394,9 +2394,9 @@ SDL_bool SDL_HasGamepad(void) SDL_free(joysticks); } if (num_gamepads > 0) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } SDL_JoystickID *SDL_GetGamepads(int *count) @@ -2426,7 +2426,7 @@ const char *SDL_GetGamepadNameForID(SDL_JoystickID instance_id) SDL_LockJoysticks(); { - GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); + GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, true); if (mapping) { if (SDL_strcmp(mapping->name, "*") == 0) { retval = SDL_GetJoystickNameForID(instance_id); @@ -2476,7 +2476,7 @@ SDL_GamepadType SDL_GetGamepadTypeForID(SDL_JoystickID instance_id) SDL_LockJoysticks(); { - GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); + GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, true); if (mapping) { char *type_string, *comma; @@ -2525,7 +2525,7 @@ char *SDL_GetGamepadMappingForID(SDL_JoystickID instance_id) SDL_LockJoysticks(); { - GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); + GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, true); if (mapping) { char pchGUID[33]; SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id); @@ -2541,16 +2541,16 @@ char *SDL_GetGamepadMappingForID(SDL_JoystickID instance_id) /* * Return 1 if the joystick with this name and GUID is a supported gamepad */ -SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid) +bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid) { - SDL_bool retval; + bool retval; SDL_LockJoysticks(); { if (s_pDefaultMapping || SDL_PrivateGetGamepadMappingForNameAndGUID(name, guid) != NULL) { - retval = SDL_TRUE; + retval = true; } else { - retval = SDL_FALSE; + retval = false; } } SDL_UnlockJoysticks(); @@ -2563,22 +2563,22 @@ SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid) */ SDL_bool SDL_IsGamepad(SDL_JoystickID instance_id) { - SDL_bool retval; + bool retval; SDL_LockJoysticks(); { const void *value; if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) { - retval = (SDL_bool)(uintptr_t)value; + retval = (bool)(uintptr_t)value; } else { - if (SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE) != NULL) { - retval = SDL_TRUE; + if (SDL_PrivateGetGamepadMapping(instance_id, true) != NULL) { + retval = true; } else { - retval = SDL_FALSE; + retval = false; } if (!s_gamepadInstanceIDs) { - s_gamepadInstanceIDs = SDL_CreateHashTable(NULL, 4, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE); + s_gamepadInstanceIDs = SDL_CreateHashTable(NULL, 4, SDL_HashID, SDL_KeyMatchID, NULL, false); } SDL_InsertIntoHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, (void *)(uintptr_t)retval); } @@ -2591,7 +2591,7 @@ SDL_bool SDL_IsGamepad(SDL_JoystickID instance_id) /* * Return 1 if the gamepad should be ignored by SDL */ -SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid) +bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid) { Uint16 vendor; Uint16 product; @@ -2600,60 +2600,60 @@ SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid) #ifdef SDL_PLATFORM_LINUX if (SDL_endswith(name, " Motion Sensors")) { // Don't treat the PS3 and PS4 motion controls as a separate gamepad - return SDL_TRUE; + return true; } if (SDL_strncmp(name, "Nintendo ", 9) == 0 && SDL_strstr(name, " IMU") != NULL) { // Don't treat the Nintendo IMU as a separate gamepad - return SDL_TRUE; + return true; } if (SDL_endswith(name, " Accelerometer") || SDL_endswith(name, " IR") || SDL_endswith(name, " Motion Plus") || SDL_endswith(name, " Nunchuk")) { // Don't treat the Wii extension controls as a separate gamepad - return SDL_TRUE; + return true; } #endif if (name && SDL_strcmp(name, "uinput-fpc") == 0) { // The Google Pixel fingerprint sensor reports itself as a joystick - return SDL_TRUE; + return true; } if (SDL_allowed_gamepads.num_included_entries == 0 && SDL_ignored_gamepads.num_included_entries == 0) { - return SDL_FALSE; + return false; } SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL); - if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false)) { // We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real gamepads so it can remap input for the virtual gamepad // https://partner.steamgames.com/doc/features/steam_gamepad/steam_input_gamepad_emulation_bestpractices - SDL_bool bSteamVirtualGamepad = SDL_FALSE; + bool bSteamVirtualGamepad = false; #ifdef SDL_PLATFORM_LINUX bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD); #elif defined(SDL_PLATFORM_MACOS) bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0); #elif defined(SDL_PLATFORM_WIN32) // We can't tell on Windows, but Steam will block others in input hooks - bSteamVirtualGamepad = SDL_TRUE; + bSteamVirtualGamepad = true; #endif if (bSteamVirtualGamepad) { - return SDL_FALSE; + return false; } } if (SDL_allowed_gamepads.num_included_entries > 0) { if (SDL_VIDPIDInList(vendor, product, &SDL_allowed_gamepads)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } else { if (SDL_VIDPIDInList(vendor, product, &SDL_ignored_gamepads)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } } @@ -2683,7 +2683,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) } // Find a gamepad mapping - pSupportedGamepad = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); + pSupportedGamepad = SDL_PrivateGetGamepadMapping(instance_id, true); if (!pSupportedGamepad) { SDL_SetError("Couldn't find mapping for device (%" SDL_PRIu32 ")", instance_id); SDL_UnlockJoysticks(); @@ -2696,7 +2696,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) SDL_UnlockJoysticks(); return NULL; } - SDL_SetObjectValid(gamepad, SDL_OBJECT_TYPE_GAMEPAD, SDL_TRUE); + SDL_SetObjectValid(gamepad, SDL_OBJECT_TYPE_GAMEPAD, true); gamepad->joystick = SDL_OpenJoystick(instance_id); if (!gamepad->joystick) { @@ -2752,18 +2752,18 @@ void SDL_UpdateGamepads(void) */ SDL_bool SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis) { - SDL_bool retval = SDL_FALSE; + bool retval = false; SDL_LockJoysticks(); { int i; - CHECK_GAMEPAD_MAGIC(gamepad, SDL_FALSE); + CHECK_GAMEPAD_MAGIC(gamepad, false); for (i = 0; i < gamepad->num_bindings; ++i) { SDL_GamepadBinding *binding = &gamepad->bindings[i]; if (binding->output_type == SDL_GAMEPAD_BINDTYPE_AXIS && binding->output.axis.axis == axis) { - retval = SDL_TRUE; + retval = true; break; } } @@ -2790,8 +2790,8 @@ Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis) SDL_GamepadBinding *binding = &gamepad->bindings[i]; if (binding->output_type == SDL_GAMEPAD_BINDTYPE_AXIS && binding->output.axis.axis == axis) { int value = 0; - SDL_bool valid_input_range; - SDL_bool valid_output_range; + bool valid_input_range; + bool valid_output_range; if (binding->input_type == SDL_GAMEPAD_BINDTYPE_AXIS) { value = SDL_GetJoystickAxis(gamepad->joystick, binding->input.axis.axis); @@ -2843,18 +2843,18 @@ Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis) */ SDL_bool SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button) { - SDL_bool retval = SDL_FALSE; + bool retval = false; SDL_LockJoysticks(); { int i; - CHECK_GAMEPAD_MAGIC(gamepad, SDL_FALSE); + CHECK_GAMEPAD_MAGIC(gamepad, false); for (i = 0; i < gamepad->num_bindings; ++i) { SDL_GamepadBinding *binding = &gamepad->bindings[i]; if (binding->output_type == SDL_GAMEPAD_BINDTYPE_BUTTON && binding->output.button == button) { - retval = SDL_TRUE; + retval = true; break; } } @@ -2881,7 +2881,7 @@ Uint8 SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button) SDL_GamepadBinding *binding = &gamepad->bindings[i]; if (binding->output_type == SDL_GAMEPAD_BINDTYPE_BUTTON && binding->output.button == button) { if (binding->input_type == SDL_GAMEPAD_BINDTYPE_AXIS) { - SDL_bool valid_input_range; + bool valid_input_range; int value = SDL_GetJoystickAxis(gamepad->joystick, binding->input.axis.axis); int threshold = binding->input.axis.axis_min + (binding->input.axis.axis_max - binding->input.axis.axis_min) / 2; @@ -3097,7 +3097,7 @@ int SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, */ SDL_bool SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type) { - SDL_bool retval = SDL_FALSE; + bool retval = false; SDL_LockJoysticks(); { @@ -3106,7 +3106,7 @@ SDL_bool SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type) int i; for (i = 0; i < joystick->nsensors; ++i) { if (joystick->sensors[i].type == type) { - retval = SDL_TRUE; + retval = true; break; } } @@ -3165,7 +3165,7 @@ int SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_b } else { if (enabled) { if (joystick->nsensors_enabled == 0) { - if (joystick->driver->SetSensorsEnabled(joystick, SDL_TRUE) < 0) { + if (joystick->driver->SetSensorsEnabled(joystick, true) < 0) { SDL_UnlockJoysticks(); return -1; } @@ -3173,7 +3173,7 @@ int SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_b ++joystick->nsensors_enabled; } else { if (joystick->nsensors_enabled == 1) { - if (joystick->driver->SetSensorsEnabled(joystick, SDL_FALSE) < 0) { + if (joystick->driver->SetSensorsEnabled(joystick, false) < 0) { SDL_UnlockJoysticks(); return -1; } @@ -3199,7 +3199,7 @@ int SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_b */ SDL_bool SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type) { - SDL_bool retval = SDL_FALSE; + bool retval = false; SDL_LockJoysticks(); { @@ -3481,7 +3481,7 @@ SDL_bool SDL_GamepadConnected(SDL_Gamepad *gamepad) SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); if (!joystick) { - return SDL_FALSE; + return false; } return SDL_JoystickConnected(joystick); } @@ -3655,7 +3655,7 @@ void SDL_CloseGamepad(SDL_Gamepad *gamepad) gamepadlist = gamepadlist->next; } - SDL_SetObjectValid(gamepad, SDL_OBJECT_TYPE_GAMEPAD, SDL_FALSE); + SDL_SetObjectValid(gamepad, SDL_OBJECT_TYPE_GAMEPAD, false); SDL_free(gamepad->bindings); SDL_free(gamepad->last_match_axis); SDL_free(gamepad->last_hat_mask); @@ -3677,7 +3677,7 @@ void SDL_QuitGamepads(void) SDL_PrivateGamepadRemoved(gamepad->joystick->instance_id); } - SDL_gamepads_initialized = SDL_FALSE; + SDL_gamepads_initialized = false; SDL_DelEventWatch(SDL_GamepadEventWatcher, NULL); @@ -3772,10 +3772,10 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam } } else { if (now < (gamepad->guide_button_down + SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) { - gamepad->joystick->delayed_guide_button = SDL_TRUE; + gamepad->joystick->delayed_guide_button = true; return 0; } - gamepad->joystick->delayed_guide_button = SDL_FALSE; + gamepad->joystick->delayed_guide_button = false; } } @@ -3815,7 +3815,7 @@ void SDL_SetGamepadEventsEnabled(SDL_bool enabled) SDL_bool SDL_GamepadEventsEnabled(void) { - SDL_bool enabled = SDL_FALSE; + bool enabled = false; unsigned int i; for (i = 0; i < SDL_arraysize(SDL_gamepad_event_list); ++i) { diff --git a/src/joystick/SDL_gamepad_c.h b/src/joystick/SDL_gamepad_c.h index 918ccd6981..23005261fc 100644 --- a/src/joystick/SDL_gamepad_c.h +++ b/src/joystick/SDL_gamepad_c.h @@ -36,10 +36,10 @@ extern void SDL_PrivateGamepadAdded(SDL_JoystickID instance_id); extern void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id); // Function to return whether a joystick name and GUID is a gamepad -extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid); +extern bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid); // Function to return whether a gamepad should be ignored -extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid); +extern bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid); // Handle delayed guide button on a gamepad extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick); diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 8bf211270f..1956367b78 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -114,13 +114,13 @@ static SDL_Mutex *SDL_joystick_lock = NULL; // This needs to support recursive locks static SDL_AtomicInt SDL_joystick_lock_pending; static int SDL_joysticks_locked; -static SDL_bool SDL_joysticks_initialized; -static SDL_bool SDL_joysticks_quitting; -static SDL_bool SDL_joystick_being_added; +static bool SDL_joysticks_initialized; +static bool SDL_joysticks_quitting; +static bool SDL_joystick_being_added; static SDL_Joystick *SDL_joysticks SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static int SDL_joystick_player_count SDL_GUARDED_BY(SDL_joystick_lock) = 0; static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = NULL; -static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; +static bool SDL_joystick_allows_background_events = false; static Uint32 initial_arcadestick_devices[] = { MAKE_VIDPID(0x0079, 0x181a), // Venom Arcade Stick @@ -160,7 +160,7 @@ static SDL_vidpid_list arcadestick_devices = { SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_arcadestick_devices), initial_arcadestick_devices, - SDL_FALSE + false }; /* This list is taken from: @@ -279,7 +279,7 @@ static SDL_vidpid_list blacklist_devices = { SDL_HINT_JOYSTICK_BLACKLIST_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_blacklist_devices), initial_blacklist_devices, - SDL_FALSE + false }; static Uint32 initial_flightstick_devices[] = { @@ -295,7 +295,7 @@ static SDL_vidpid_list flightstick_devices = { SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_flightstick_devices), initial_flightstick_devices, - SDL_FALSE + false }; static Uint32 initial_gamecube_devices[] = { @@ -306,7 +306,7 @@ static SDL_vidpid_list gamecube_devices = { SDL_HINT_JOYSTICK_GAMECUBE_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_gamecube_devices), initial_gamecube_devices, - SDL_FALSE + false }; static Uint32 initial_rog_gamepad_mice[] = { @@ -322,7 +322,7 @@ static SDL_vidpid_list rog_gamepad_mice = { SDL_HINT_ROG_GAMEPAD_MICE, 0, 0, NULL, SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_rog_gamepad_mice), initial_rog_gamepad_mice, - SDL_FALSE + false }; static Uint32 initial_throttle_devices[] = { @@ -333,7 +333,7 @@ static SDL_vidpid_list throttle_devices = { SDL_HINT_JOYSTICK_THROTTLE_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_throttle_devices), initial_throttle_devices, - SDL_FALSE + false }; static Uint32 initial_wheel_devices[] = { @@ -402,7 +402,7 @@ static SDL_vidpid_list wheel_devices = { SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL, SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED, 0, 0, NULL, SDL_arraysize(initial_wheel_devices), initial_wheel_devices, - SDL_FALSE + false }; static Uint32 initial_zero_centered_devices[] = { @@ -413,7 +413,7 @@ static SDL_vidpid_list zero_centered_devices = { SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES, 0, 0, NULL, NULL, 0, 0, NULL, SDL_arraysize(initial_zero_centered_devices), initial_zero_centered_devices, - SDL_FALSE + false }; #define CHECK_JOYSTICK_MAGIC(joystick, retval) \ @@ -423,12 +423,12 @@ static SDL_vidpid_list zero_centered_devices = { return retval; \ } -SDL_bool SDL_JoysticksInitialized(void) +bool SDL_JoysticksInitialized(void) { return SDL_joysticks_initialized; } -SDL_bool SDL_JoysticksQuitting(void) +bool SDL_JoysticksQuitting(void) { return SDL_joysticks_quitting; } @@ -444,14 +444,14 @@ void SDL_LockJoysticks(void) void SDL_UnlockJoysticks(void) { - SDL_bool last_unlock = SDL_FALSE; + bool last_unlock = false; --SDL_joysticks_locked; if (!SDL_joysticks_initialized) { // NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks if (!SDL_joysticks_locked && SDL_AtomicGet(&SDL_joystick_lock_pending) == 0) { - last_unlock = SDL_TRUE; + last_unlock = true; } } @@ -474,7 +474,7 @@ void SDL_UnlockJoysticks(void) } } -SDL_bool SDL_JoysticksLocked(void) +bool SDL_JoysticksLocked(void) { return (SDL_joysticks_locked > 0); } @@ -488,7 +488,7 @@ void SDL_AssertJoysticksLocked(void) * Get the driver and device index for a joystick instance ID * This should be called while the joystick lock is held, to prevent another thread from updating the list */ -static SDL_bool SDL_GetDriverAndJoystickIndex(SDL_JoystickID instance_id, SDL_JoystickDriver **driver, int *driver_index) +static bool SDL_GetDriverAndJoystickIndex(SDL_JoystickID instance_id, SDL_JoystickDriver **driver, int *driver_index) { int i, num_joysticks, device_index; @@ -502,14 +502,14 @@ static SDL_bool SDL_GetDriverAndJoystickIndex(SDL_JoystickID instance_id, SDL_Jo if (joystick_id == instance_id) { *driver = SDL_joystick_drivers[i]; *driver_index = device_index; - return SDL_TRUE; + return true; } } } } SDL_SetError("Joystick %" SDL_PRIu32 " not found", instance_id); - return SDL_FALSE; + return false; } static int SDL_FindFreePlayerIndex(void) @@ -553,7 +553,7 @@ static SDL_JoystickID SDL_GetJoystickIDForPlayerIndex(int player_index) return SDL_joystick_players[player_index]; } -static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) +static bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) { SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index); SDL_JoystickDriver *driver; @@ -565,7 +565,7 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID if (player_index >= SDL_joystick_player_count) { SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players)); if (!new_players) { - return SDL_FALSE; + return false; } SDL_joystick_players = new_players; @@ -573,7 +573,7 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID SDL_joystick_player_count = player_index + 1; } else if (player_index >= 0 && SDL_joystick_players[player_index] == instance_id) { // Joystick is already assigned the requested player index - return SDL_TRUE; + return true; } // Clear the old player index @@ -595,15 +595,15 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID if (existing_instance > 0) { SDL_SetJoystickIDForPlayerIndex(SDL_FindFreePlayerIndex(), existing_instance); } - return SDL_TRUE; + return true; } static void SDLCALL SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - if (SDL_GetStringBoolean(hint, SDL_FALSE)) { - SDL_joystick_allows_background_events = SDL_TRUE; + if (SDL_GetStringBoolean(hint, false)) { + SDL_joystick_allows_background_events = true; } else { - SDL_joystick_allows_background_events = SDL_FALSE; + SDL_joystick_allows_background_events = false; } } @@ -622,7 +622,7 @@ int SDL_InitJoysticks(void) SDL_LockJoysticks(); - SDL_joysticks_initialized = SDL_TRUE; + SDL_joysticks_initialized = true; SDL_InitGamepadMappings(); @@ -656,16 +656,16 @@ int SDL_InitJoysticks(void) return status; } -SDL_bool SDL_JoysticksOpened(void) +bool SDL_JoysticksOpened(void) { - SDL_bool opened; + bool opened; SDL_LockJoysticks(); { if (SDL_joysticks != NULL) { - opened = SDL_TRUE; + opened = true; } else { - opened = SDL_FALSE; + opened = false; } } SDL_UnlockJoysticks(); @@ -673,10 +673,10 @@ SDL_bool SDL_JoysticksOpened(void) return opened; } -SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { int i; - SDL_bool result = SDL_FALSE; + bool result = false; SDL_LockJoysticks(); { @@ -686,7 +686,7 @@ SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, U break; } if (SDL_joystick_drivers[i]->IsDevicePresent(vendor_id, product_id, version, name)) { - result = SDL_TRUE; + result = true; break; } } @@ -710,9 +710,9 @@ SDL_bool SDL_HasJoystick(void) SDL_UnlockJoysticks(); if (total_joysticks > 0) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } SDL_JoystickID *SDL_GetJoysticks(int *count) @@ -830,23 +830,23 @@ int SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id) * This isn't generally needed unless the joystick never generates an initial axis value near zero, * e.g. it's emulating axes with digital buttons */ -static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) +static bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) { #ifdef SDL_PLATFORM_WINRT - return SDL_TRUE; + return true; #else // printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes); if (joystick->naxes == 2) { // Assume D-pad or thumbstick style axes are centered at 0 - return SDL_TRUE; + return true; } return SDL_VIDPIDInList(SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick), &zero_centered_devices); #endif // SDL_PLATFORM_WINRT } -static SDL_bool IsROGAlly(SDL_Joystick *joystick) +static bool IsROGAlly(SDL_Joystick *joystick) { Uint16 vendor, product; SDL_GUID guid = SDL_GetJoystickGUID(joystick); @@ -855,8 +855,8 @@ static SDL_bool IsROGAlly(SDL_Joystick *joystick) SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER) { // Check to see if this system has the expected sensors - SDL_bool has_ally_accel = SDL_FALSE; - SDL_bool has_ally_gyro = SDL_FALSE; + bool has_ally_accel = false; + bool has_ally_gyro = false; if (SDL_InitSubSystem(SDL_INIT_SENSOR) == 0) { SDL_SensorID *sensors = SDL_GetSensors(NULL); @@ -868,13 +868,13 @@ static SDL_bool IsROGAlly(SDL_Joystick *joystick) if (!has_ally_accel && SDL_GetSensorTypeForID(sensor) == SDL_SENSOR_ACCEL) { const char *sensor_name = SDL_GetSensorNameForID(sensor); if (sensor_name && SDL_strcmp(sensor_name, "Sensor BMI320 Acc") == 0) { - has_ally_accel = SDL_TRUE; + has_ally_accel = true; } } if (!has_ally_gyro && SDL_GetSensorTypeForID(sensor) == SDL_SENSOR_GYRO) { const char *sensor_name = SDL_GetSensorNameForID(sensor); if (sensor_name && SDL_strcmp(sensor_name, "Sensor BMI320 Gyr") == 0) { - has_ally_gyro = SDL_TRUE; + has_ally_gyro = true; } } } @@ -883,45 +883,45 @@ static SDL_bool IsROGAlly(SDL_Joystick *joystick) SDL_QuitSubSystem(SDL_INIT_SENSOR); } if (has_ally_accel && has_ally_gyro) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *invert_sensors) +static bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, bool *invert_sensors) { const char *hint; int hint_value; SDL_AssertJoysticksLocked(); - *invert_sensors = SDL_FALSE; + *invert_sensors = false; // The SDL controller sensor API is only available for gamepads (at the moment) if (!SDL_IsGamepad(joystick->instance_id)) { - return SDL_FALSE; + return false; } // If the controller already has sensors, use those if (joystick->nsensors > 0) { - return SDL_FALSE; + return false; } hint = SDL_GetHint(SDL_HINT_GAMECONTROLLER_SENSOR_FUSION); hint_value = SDL_GetStringInteger(hint, -1); if (hint_value > 0) { - return SDL_TRUE; + return true; } if (hint_value == 0) { - return SDL_FALSE; + return false; } if (hint) { SDL_vidpid_list gamepads; SDL_GUID guid; Uint16 vendor, product; - SDL_bool enabled; + bool enabled; SDL_zero(gamepads); // See if the gamepad is in our list of devices to enable @@ -931,7 +931,7 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve enabled = SDL_VIDPIDInList(vendor, product, &gamepads); SDL_FreeVIDPIDList(&gamepads); if (enabled) { - return SDL_TRUE; + return true; } } @@ -939,19 +939,19 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve if (joystick->name && (SDL_strstr(joystick->name, "Backbone One") || SDL_strstr(joystick->name, "Kishi"))) { - return SDL_TRUE; + return true; } if (IsROGAlly(joystick)) { /* I'm not sure if this is a Windows thing, or a quirk for ROG Ally, * but we need to invert the sensor data on all axes. */ - *invert_sensors = SDL_TRUE; - return SDL_TRUE; + *invert_sensors = true; + return true; } - return SDL_FALSE; + return false; } -static void AttemptSensorFusion(SDL_Joystick *joystick, SDL_bool invert_sensors) +static void AttemptSensorFusion(SDL_Joystick *joystick, bool invert_sensors) { SDL_SensorID *sensors; unsigned int i, j; @@ -1065,7 +1065,7 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) SDL_Joystick *joysticklist; const char *joystickname = NULL; const char *joystickpath = NULL; - SDL_bool invert_sensors = SDL_FALSE; + bool invert_sensors = false; const SDL_SteamVirtualGamepadInfo *info; SDL_LockJoysticks(); @@ -1095,15 +1095,15 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) SDL_UnlockJoysticks(); return NULL; } - SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, SDL_TRUE); + SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, true); joystick->driver = driver; joystick->instance_id = instance_id; - joystick->attached = SDL_TRUE; + joystick->attached = true; joystick->led_expiration = SDL_GetTicks(); joystick->battery_percent = -1; if (driver->Open(joystick, device_index) < 0) { - SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, SDL_FALSE); + SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, false); SDL_free(joystick); SDL_UnlockJoysticks(); return NULL; @@ -1147,7 +1147,7 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) int i; for (i = 0; i < joystick->naxes; ++i) { - joystick->axes[i].has_initial_value = SDL_TRUE; + joystick->axes[i].has_initial_value = true; } } @@ -1208,19 +1208,19 @@ SDL_bool SDL_IsJoystickVirtual(SDL_JoystickID instance_id) #ifdef SDL_JOYSTICK_VIRTUAL SDL_JoystickDriver *driver; int device_index; - SDL_bool is_virtual = SDL_FALSE; + bool is_virtual = false; SDL_LockJoysticks(); if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) { if (driver == &SDL_VIRTUAL_JoystickDriver) { - is_virtual = SDL_TRUE; + is_virtual = true; } } SDL_UnlockJoysticks(); return is_virtual; #else - return SDL_FALSE; + return false; #endif } @@ -1341,17 +1341,17 @@ int SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType typ /* * Checks to make sure the joystick is valid. */ -SDL_bool SDL_IsJoystickValid(SDL_Joystick *joystick) +bool SDL_IsJoystickValid(SDL_Joystick *joystick) { SDL_AssertJoysticksLocked(); return SDL_ObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK); } -SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, SDL_GamepadMapping *out) +bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, SDL_GamepadMapping *out) { SDL_JoystickDriver *driver; int device_index; - SDL_bool is_ok = SDL_FALSE; + bool is_ok = false; SDL_LockJoysticks(); if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) { @@ -1454,15 +1454,15 @@ Sint16 SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis) */ SDL_bool SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state) { - SDL_bool retval; + bool retval; SDL_LockJoysticks(); { - CHECK_JOYSTICK_MAGIC(joystick, SDL_FALSE); + CHECK_JOYSTICK_MAGIC(joystick, false); if (axis >= joystick->naxes) { SDL_SetError("Joystick only has %d axes", joystick->naxes); - retval = SDL_FALSE; + retval = false; } else { if (state) { *state = joystick->axes[axis].initial_value; @@ -1548,15 +1548,15 @@ Uint8 SDL_GetJoystickButton(SDL_Joystick *joystick, int button) /* * Return if the joystick in question is currently attached to the system, - * \return SDL_FALSE if not plugged in, SDL_TRUE if still present. + * \return false if not plugged in, true if still present. */ SDL_bool SDL_JoystickConnected(SDL_Joystick *joystick) { - SDL_bool retval; + bool retval; SDL_LockJoysticks(); { - CHECK_JOYSTICK_MAGIC(joystick, SDL_FALSE); + CHECK_JOYSTICK_MAGIC(joystick, false); retval = joystick->attached; } @@ -1798,7 +1798,7 @@ int SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint1 int SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int retval; - SDL_bool isfreshvalue; + bool isfreshvalue; SDL_LockJoysticks(); { @@ -1873,7 +1873,7 @@ void SDL_CloseJoystick(SDL_Joystick *joystick) joystick->driver->Close(joystick); joystick->hwdata = NULL; - SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, SDL_FALSE); + SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, false); joysticklist = SDL_joysticks; joysticklistprev = NULL; @@ -1917,7 +1917,7 @@ void SDL_QuitJoysticks(void) SDL_LockJoysticks(); - SDL_joysticks_quitting = SDL_TRUE; + SDL_joysticks_quitting = true; joysticks = SDL_GetJoysticks(NULL); if (joysticks) { @@ -1961,23 +1961,23 @@ void SDL_QuitJoysticks(void) SDL_QuitGamepadMappings(); - SDL_joysticks_quitting = SDL_FALSE; - SDL_joysticks_initialized = SDL_FALSE; + SDL_joysticks_quitting = false; + SDL_joysticks_initialized = false; SDL_UnlockJoysticks(); } -static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent(void) +static bool SDL_PrivateJoystickShouldIgnoreEvent(void) { if (SDL_joystick_allows_background_events) { - return SDL_FALSE; + return false; } if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) { // We have windows but we don't have focus, ignore the event. - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } // These are global for SDL_sysjoystick.c and SDL_events.c @@ -2054,7 +2054,7 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id) return; } - SDL_joystick_being_added = SDL_TRUE; + SDL_joystick_being_added = true; if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) { player_index = driver->GetDeviceSteamVirtualGamepadSlot(device_index); @@ -2081,14 +2081,14 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id) } } - SDL_joystick_being_added = SDL_FALSE; + SDL_joystick_being_added = false; if (SDL_IsGamepad(instance_id)) { SDL_PrivateGamepadAdded(instance_id); } } -SDL_bool SDL_IsJoystickBeingAdded(void) +bool SDL_IsJoystickBeingAdded(void) { return SDL_joystick_being_added; } @@ -2136,7 +2136,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id) for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->instance_id == instance_id) { SDL_PrivateJoystickForceRecentering(joystick); - joystick->attached = SDL_FALSE; + joystick->attached = false; break; } } @@ -2177,11 +2177,11 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S info->initial_value = value; info->value = value; info->zero = value; - info->has_initial_value = SDL_TRUE; + info->has_initial_value = true; } else if (value == info->value && !info->sending_initial_value) { return 0; } else { - info->has_second_value = SDL_TRUE; + info->has_second_value = true; } if (!info->sent_initial_value) { // Make sure we don't send motion until there's real activity on this axis @@ -2190,10 +2190,10 @@ int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, S !SDL_IsJoystickVIRTUAL(joystick->guid)) { return 0; } - info->sent_initial_value = SDL_TRUE; - info->sending_initial_value = SDL_TRUE; + info->sent_initial_value = true; + info->sending_initial_value = true; SDL_SendJoystickAxis(timestamp, joystick, axis, info->initial_value); - info->sending_initial_value = SDL_FALSE; + info->sending_initial_value = false; } /* We ignore events if we don't have keyboard focus, except for centering @@ -2362,7 +2362,7 @@ static void SendSteamHandleUpdateEvents(void) // Check to see if any Steam handles changed for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { - SDL_bool changed = SDL_FALSE; + bool changed = false; if (!SDL_IsGamepad(joystick->instance_id)) { continue; @@ -2372,12 +2372,12 @@ static void SendSteamHandleUpdateEvents(void) if (info) { if (joystick->steam_handle != info->handle) { joystick->steam_handle = info->handle; - changed = SDL_TRUE; + changed = true; } } else { if (joystick->steam_handle != 0) { joystick->steam_handle = 0; - changed = SDL_TRUE; + changed = true; } } if (changed) { @@ -2490,7 +2490,7 @@ void SDL_SetJoystickEventsEnabled(SDL_bool enabled) SDL_bool SDL_JoystickEventsEnabled(void) { - SDL_bool enabled = SDL_FALSE; + bool enabled = false; unsigned int i; for (i = 0; i < SDL_arraysize(SDL_joystick_event_list); ++i) { @@ -2631,7 +2631,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n name = SDL_strdup(product_name); } else if (vendor || product) { // Couldn't find a controller name, try to give it one based on device type - switch (SDL_GetGamepadTypeFromVIDPID(vendor, product, NULL, SDL_TRUE)) { + switch (SDL_GetGamepadTypeFromVIDPID(vendor, product, NULL, true)) { case SDL_GAMEPAD_TYPE_XBOX360: name = SDL_strdup("Xbox 360 Controller"); break; @@ -2796,7 +2796,7 @@ void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc) guid16[1] = SDL_Swap16LE(crc); } -SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI) +SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, bool forUI) { SDL_GamepadType type = SDL_GAMEPAD_TYPE_STANDARD; @@ -2886,7 +2886,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name) Uint16 vendor, product; SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); - type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, SDL_TRUE); + type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, true); if (type == SDL_GAMEPAD_TYPE_STANDARD) { if (SDL_IsJoystickXInput(guid)) { // This is probably an Xbox One controller @@ -2901,54 +2901,54 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name) return type; } -SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid) +bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid) { Uint16 vendor, product; if (SDL_IsJoystickMFI(guid)) { // The version bits are used as button capability mask - return SDL_FALSE; + return false; } SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); if (vendor && product) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_XBoxOneController; } -SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_MICROSOFT) { if (product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 || product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 || product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH || product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLE) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_MICROSOFT) { if (product_id == USB_PRODUCT_XBOX_SERIES_X || product_id == USB_PRODUCT_XBOX_SERIES_X_BLE) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_PDP) { if (product_id == USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT || product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE || product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_POWERA_ALT) { @@ -2956,58 +2956,58 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) product_id == USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2 || product_id == USB_PRODUCT_XBOX_SERIES_X_POWERA_MOGA_XP_ULTRA || product_id == USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_HORI) { if (product_id == USB_PRODUCT_HORI_FIGHTING_COMMANDER_OCTA_SERIES_X || product_id == USB_PRODUCT_HORI_HORIPAD_PRO_SERIES_X) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_HP) { if (product_id == USB_PRODUCT_XBOX_SERIES_X_HP_HYPERX || product_id == USB_PRODUCT_XBOX_SERIES_X_HP_HYPERX_RGB) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_RAZER) { if (product_id == USB_PRODUCT_RAZER_WOLVERINE_V2 || product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_CHROMA) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_THRUSTMASTER) { if (product_id == USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_TURTLE_BEACH) { if (product_id == USB_PRODUCT_TURTLE_BEACH_SERIES_X_REACT_R || product_id == USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_8BITDO) { if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 || product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER2) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_GAMESIR) { if (product_id == USB_PRODUCT_GAMESIR_G7) { - return SDL_TRUE; + return true; } } if (vendor_id == USB_VENDOR_ASUS) { if (product_id == USB_PRODUCT_ROG_RAIKIRI) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_MICROSOFT) { if (product_id == USB_PRODUCT_XBOX_ONE_ADAPTIVE_BLUETOOTH || @@ -3018,155 +3018,155 @@ SDL_bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id) product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH || product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLE || product_id == USB_PRODUCT_XBOX_SERIES_X_BLE) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_PS4Controller; } -SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_PS5Controller; } -SDL_bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_SONY) { if (product_id == USB_PRODUCT_SONY_DS5_EDGE) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SwitchProController || eType == k_eControllerType_SwitchInputOnlyController; } -SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SwitchInputOnlyController; } -SDL_bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SwitchJoyConLeft || eType == k_eControllerType_SwitchJoyConRight; } -SDL_bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SwitchJoyConLeft; } -SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SwitchJoyConRight; } -SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id) { return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP; } -SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id) { return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR; } -SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id) { return SDL_VIDPIDInList(vendor_id, product_id, &gamecube_devices); } -SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id) { return ((vendor_id == USB_VENDOR_AMAZON && product_id == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) || (vendor_id == BLUETOOTH_VENDOR_AMAZON && product_id == BLUETOOTH_PRODUCT_LUNA_CONTROLLER)); } -SDL_bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id) { return vendor_id == USB_VENDOR_GOOGLE && product_id == USB_PRODUCT_GOOGLE_STADIA_CONTROLLER; } -SDL_bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id) { return (vendor_id == USB_VENDOR_NVIDIA && (product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 || product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104)); } -SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SteamController || eType == k_eControllerType_SteamControllerV2; } -SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id) +bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); return eType == k_eControllerType_SteamControllerNeptune; } -SDL_bool SDL_IsJoystickXInput(SDL_GUID guid) +bool SDL_IsJoystickXInput(SDL_GUID guid) { - return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'x') ? true : false; } -SDL_bool SDL_IsJoystickWGI(SDL_GUID guid) +bool SDL_IsJoystickWGI(SDL_GUID guid) { - return (guid.data[14] == 'w') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'w') ? true : false; } -SDL_bool SDL_IsJoystickHIDAPI(SDL_GUID guid) +bool SDL_IsJoystickHIDAPI(SDL_GUID guid) { - return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'h') ? true : false; } -SDL_bool SDL_IsJoystickMFI(SDL_GUID guid) +bool SDL_IsJoystickMFI(SDL_GUID guid) { - return (guid.data[14] == 'm') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'm') ? true : false; } -SDL_bool SDL_IsJoystickRAWINPUT(SDL_GUID guid) +bool SDL_IsJoystickRAWINPUT(SDL_GUID guid) { - return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'r') ? true : false; } -SDL_bool SDL_IsJoystickVIRTUAL(SDL_GUID guid) +bool SDL_IsJoystickVIRTUAL(SDL_GUID guid) { - return (guid.data[14] == 'v') ? SDL_TRUE : SDL_FALSE; + return (guid.data[14] == 'v') ? true : false; } -static SDL_bool SDL_IsJoystickWheel(Uint16 vendor_id, Uint16 product_id) +static bool SDL_IsJoystickWheel(Uint16 vendor_id, Uint16 product_id) { return SDL_VIDPIDInList(vendor_id, product_id, &wheel_devices); } -static SDL_bool SDL_IsJoystickArcadeStick(Uint16 vendor_id, Uint16 product_id) +static bool SDL_IsJoystickArcadeStick(Uint16 vendor_id, Uint16 product_id) { return SDL_VIDPIDInList(vendor_id, product_id, &arcadestick_devices); } -static SDL_bool SDL_IsJoystickFlightStick(Uint16 vendor_id, Uint16 product_id) +static bool SDL_IsJoystickFlightStick(Uint16 vendor_id, Uint16 product_id) { return SDL_VIDPIDInList(vendor_id, product_id, &flightstick_devices); } -static SDL_bool SDL_IsJoystickThrottle(Uint16 vendor_id, Uint16 product_id) +static bool SDL_IsJoystickThrottle(Uint16 vendor_id, Uint16 product_id) { return SDL_VIDPIDInList(vendor_id, product_id, &throttle_devices); } @@ -3241,7 +3241,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_GUID guid) return SDL_JOYSTICK_TYPE_UNKNOWN; } -SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid) +bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid) { Uint16 vendor; Uint16 product; @@ -3250,19 +3250,19 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid) // Check the joystick blacklist if (SDL_VIDPIDInList(vendor, product, &blacklist_devices)) { - return SDL_TRUE; + return true; } - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_ROG_CHAKRAM, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_ROG_CHAKRAM, false)) { if (SDL_VIDPIDInList(vendor, product, &rog_gamepad_mice)) { - return SDL_TRUE; + return true; } } if (SDL_ShouldIgnoreGamepad(name, guid)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } // return the guid for this index @@ -3775,7 +3775,7 @@ void SDL_LoadVIDPIDList(SDL_vidpid_list *list) SDL_AddHintCallback(list->excluded_hint_name, SDL_VIDPIDExcludedHintChanged, list); } - list->initialized = SDL_TRUE; + list->initialized = true; if (list->included_hint_name) { included_list = SDL_GetHint(list->included_hint_name); @@ -3786,22 +3786,22 @@ void SDL_LoadVIDPIDList(SDL_vidpid_list *list) SDL_LoadVIDPIDListFromHints(list, included_list, excluded_list); } -SDL_bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list) +bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list) { int i; Uint32 vidpid = MAKE_VIDPID(vendor_id, product_id); for (i = 0; i < list->num_excluded_entries; ++i) { if (vidpid == list->excluded_entries[i]) { - return SDL_FALSE; + return false; } } for (i = 0; i < list->num_included_entries; ++i) { if (vidpid == list->included_entries[i]) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } void SDL_FreeVIDPIDList(SDL_vidpid_list *list) @@ -3828,5 +3828,5 @@ void SDL_FreeVIDPIDList(SDL_vidpid_list *list) list->max_excluded_entries = 0; } - list->initialized = SDL_FALSE; + list->initialized = false; } diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h index 44ec8c3ffb..c91c2ad5eb 100644 --- a/src/joystick/SDL_joystick_c.h +++ b/src/joystick/SDL_joystick_c.h @@ -39,22 +39,22 @@ extern int SDL_InitJoysticks(void); extern void SDL_QuitJoysticks(void); // Return whether the joystick system is currently initialized -extern SDL_bool SDL_JoysticksInitialized(void); +extern bool SDL_JoysticksInitialized(void); // Return whether the joystick system is shutting down -extern SDL_bool SDL_JoysticksQuitting(void); +extern bool SDL_JoysticksQuitting(void); // Return whether the joysticks are currently locked -extern SDL_bool SDL_JoysticksLocked(void); +extern bool SDL_JoysticksLocked(void); // Make sure we currently have the joysticks locked extern void SDL_AssertJoysticksLocked(void) SDL_ASSERT_CAPABILITY(SDL_joystick_lock); // Function to return whether there are any joysticks opened by the application -extern SDL_bool SDL_JoysticksOpened(void); +extern bool SDL_JoysticksOpened(void); // Function to determine whether a device is currently detected by this driver -extern SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); +extern bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); /* Function to standardize the name for a controller This should be freed with SDL_free() when no longer needed @@ -80,85 +80,85 @@ extern void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version); extern void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc); // Function to return the type of a controller -extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI); +extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, bool forUI); extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name); // Function to return whether a joystick GUID uses the version field -extern SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid); +extern bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid); // Function to return whether a joystick is an Xbox One controller -extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is an Xbox One Elite controller -extern SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is an Xbox Series X controller -extern SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is an Xbox One controller connected via Bluetooth -extern SDL_bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a PS4 controller -extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a PS5 controller -extern SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a Nintendo Switch Pro controller -extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id); -extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a Nintendo GameCube style controller -extern SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is an Amazon Luna controller -extern SDL_bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a Google Stadia controller -extern SDL_bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is an NVIDIA SHIELD controller -extern SDL_bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a Steam Controller -extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick is a Steam Deck -extern SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); +extern bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); // Function to return whether a joystick guid comes from the XInput driver -extern SDL_bool SDL_IsJoystickXInput(SDL_GUID guid); +extern bool SDL_IsJoystickXInput(SDL_GUID guid); // Function to return whether a joystick guid comes from the WGI driver -extern SDL_bool SDL_IsJoystickWGI(SDL_GUID guid); +extern bool SDL_IsJoystickWGI(SDL_GUID guid); // Function to return whether a joystick guid comes from the HIDAPI driver -extern SDL_bool SDL_IsJoystickHIDAPI(SDL_GUID guid); +extern bool SDL_IsJoystickHIDAPI(SDL_GUID guid); // Function to return whether a joystick guid comes from the MFI driver -extern SDL_bool SDL_IsJoystickMFI(SDL_GUID guid); +extern bool SDL_IsJoystickMFI(SDL_GUID guid); // Function to return whether a joystick guid comes from the RAWINPUT driver -extern SDL_bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); +extern bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); // Function to return whether a joystick guid comes from the Virtual driver -extern SDL_bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); +extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); // Function to return whether a joystick should be ignored -extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid); +extern bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid); // Internal event queueing functions extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate); extern void SDL_PrivateJoystickSensorRate(SDL_Joystick *joystick, SDL_SensorType type, float rate); extern void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id); -extern SDL_bool SDL_IsJoystickBeingAdded(void); +extern bool SDL_IsJoystickBeingAdded(void); extern void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id); extern void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick); extern int SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value); @@ -173,7 +173,7 @@ extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState sta extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickVirtualGamepadInfoForID(SDL_JoystickID instance_id); // Internal sanity checking functions -extern SDL_bool SDL_IsJoystickValid(SDL_Joystick *joystick); +extern bool SDL_IsJoystickValid(SDL_Joystick *joystick); typedef enum { @@ -187,9 +187,9 @@ typedef struct SDL_InputMapping { EMappingKind kind; Uint8 target; - SDL_bool axis_reversed; - SDL_bool half_axis_positive; - SDL_bool half_axis_negative; + bool axis_reversed; + bool half_axis_positive; + bool half_axis_negative; } SDL_InputMapping; typedef struct SDL_GamepadMapping @@ -229,7 +229,7 @@ typedef struct SDL_GamepadMapping } SDL_GamepadMapping; // Function to get autodetected gamepad controller mapping from the driver -extern SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, +extern bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, SDL_GamepadMapping *out); @@ -248,12 +248,12 @@ typedef struct int num_initial_entries; Uint32 *initial_entries; - SDL_bool initialized; + bool initialized; } SDL_vidpid_list; extern void SDL_LoadVIDPIDList(SDL_vidpid_list *list); extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list); -extern SDL_bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); +extern bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); // Ends C function definitions when using C++ diff --git a/src/joystick/SDL_steam_virtual_gamepad.c b/src/joystick/SDL_steam_virtual_gamepad.c index 667ada77ad..7df021c553 100644 --- a/src/joystick/SDL_steam_virtual_gamepad.c +++ b/src/joystick/SDL_steam_virtual_gamepad.c @@ -134,14 +134,14 @@ void SDL_InitSteamVirtualGamepadInfo(void) SDL_UpdateSteamVirtualGamepadInfo(); } -SDL_bool SDL_SteamVirtualGamepadEnabled(void) +bool SDL_SteamVirtualGamepadEnabled(void) { SDL_AssertJoysticksLocked(); return (SDL_steam_virtual_gamepad_info != NULL); } -SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void) +bool SDL_UpdateSteamVirtualGamepadInfo(void) { const int UPDATE_CHECK_INTERVAL_MS = 3000; Uint64 now; @@ -154,24 +154,24 @@ SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void) SDL_AssertJoysticksLocked(); if (!SDL_steam_virtual_gamepad_info_file) { - return SDL_FALSE; + return false; } now = SDL_GetTicks(); if (SDL_steam_virtual_gamepad_info_check_time && now < (SDL_steam_virtual_gamepad_info_check_time + UPDATE_CHECK_INTERVAL_MS)) { - return SDL_FALSE; + return false; } SDL_steam_virtual_gamepad_info_check_time = now; mtime = GetFileModificationTime(SDL_steam_virtual_gamepad_info_file); if (mtime == 0 || mtime == SDL_steam_virtual_gamepad_info_file_mtime) { - return SDL_FALSE; + return false; } data = (char *)SDL_LoadFile(SDL_steam_virtual_gamepad_info_file, &size); if (!data) { - return SDL_FALSE; + return false; } SDL_FreeSteamVirtualGamepadInfo(); @@ -224,7 +224,7 @@ SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void) SDL_steam_virtual_gamepad_info_file_mtime = mtime; - return SDL_TRUE; + return true; } const SDL_SteamVirtualGamepadInfo *SDL_GetSteamVirtualGamepadInfo(int slot) diff --git a/src/joystick/SDL_steam_virtual_gamepad.h b/src/joystick/SDL_steam_virtual_gamepad.h index d683327181..ea46dd0fbc 100644 --- a/src/joystick/SDL_steam_virtual_gamepad.h +++ b/src/joystick/SDL_steam_virtual_gamepad.h @@ -30,7 +30,7 @@ typedef struct SDL_SteamVirtualGamepadInfo } SDL_SteamVirtualGamepadInfo; void SDL_InitSteamVirtualGamepadInfo(void); -SDL_bool SDL_SteamVirtualGamepadEnabled(void); -SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void); +bool SDL_SteamVirtualGamepadEnabled(void); +bool SDL_UpdateSteamVirtualGamepadInfo(void); const SDL_SteamVirtualGamepadInfo *SDL_GetSteamVirtualGamepadInfo(int slot); void SDL_QuitSteamVirtualGamepadInfo(void); diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 35f785d1cc..219df4375d 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -38,10 +38,10 @@ typedef struct SDL_JoystickAxisInfo Sint16 initial_value; // Initial axis state Sint16 value; // Current axis state Sint16 zero; // Zero point on the axis (-32768 for triggers) - SDL_bool has_initial_value; // Whether we've seen a value on the axis yet - SDL_bool has_second_value; // Whether we've seen a second value on the axis yet - SDL_bool sent_initial_value; // Whether we've sent the initial axis value - SDL_bool sending_initial_value; // Whether we are sending the initial axis value + bool has_initial_value; // Whether we've seen a value on the axis yet + bool has_second_value; // Whether we've seen a second value on the axis yet + bool sent_initial_value; // Whether we've sent the initial axis value + bool sending_initial_value; // Whether we are sending the initial axis value } SDL_JoystickAxisInfo; typedef struct SDL_JoystickBallData @@ -67,7 +67,7 @@ typedef struct SDL_JoystickTouchpadInfo typedef struct SDL_JoystickSensorInfo { SDL_SensorType type; - SDL_bool enabled; + bool enabled; float rate; float data[3]; // If this needs to expand, update SDL_GamepadSensorEvent } SDL_JoystickSensorInfo; @@ -117,12 +117,12 @@ struct SDL_Joystick Uint8 led_blue _guarded; Uint64 led_expiration _guarded; - SDL_bool attached _guarded; + bool attached _guarded; SDL_JoystickConnectionState connection_state _guarded; SDL_PowerState battery_state _guarded; int battery_percent _guarded; - SDL_bool delayed_guide_button _guarded; // SDL_TRUE if this device has the guide button event delayed + bool delayed_guide_button _guarded; // true if this device has the guide button event delayed SDL_SensorID accel_sensor _guarded; SDL_Sensor *accel _guarded; @@ -169,7 +169,7 @@ typedef struct SDL_JoystickDriver void (*Detect)(void); // Function to determine whether a device is currently detected by this driver - SDL_bool (*IsDevicePresent)(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); + bool (*IsDevicePresent)(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); // Function to get the device-dependent name of a joystick const char *(*GetDeviceName)(int device_index); @@ -210,7 +210,7 @@ typedef struct SDL_JoystickDriver int (*SendEffect)(SDL_Joystick *joystick, const void *data, int size); // Sensor functionality - int (*SetSensorsEnabled)(SDL_Joystick *joystick, SDL_bool enabled); + int (*SetSensorsEnabled)(SDL_Joystick *joystick, bool enabled); /* Function to update the state of a joystick - called as a device poll. * This function shouldn't update the joystick structure directly, @@ -226,7 +226,7 @@ typedef struct SDL_JoystickDriver void (*Quit)(void); // Function to get the autodetected controller mapping; returns false if there isn't any. - SDL_bool (*GetGamepadMapping)(int device_index, SDL_GamepadMapping *out); + bool (*GetGamepadMapping)(int device_index, SDL_GamepadMapping *out); } SDL_JoystickDriver; diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 37bae4a0f6..fa137f403d 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -301,7 +301,7 @@ int Android_OnHat(int device_id, int hat_id, int x, int y) return -1; } -int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, SDL_bool can_rumble) +int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, bool can_rumble) { SDL_joylist_item *item; SDL_GUID guid; @@ -310,7 +310,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v SDL_LockJoysticks(); - if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, true)) { // Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input if (naxes < 2 && nhats < 1) { goto done; @@ -480,10 +480,10 @@ static void ANDROID_JoystickDetect(void) } } -static SDL_bool ANDROID_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool ANDROID_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static SDL_joylist_item *GetJoystickByDevIndex(int device_index) @@ -580,7 +580,7 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->naxes = item->naxes; if (item->can_rumble) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } return 0; @@ -617,7 +617,7 @@ static int ANDROID_JoystickSendEffect(SDL_Joystick *joystick, const void *data, return SDL_Unsupported(); } -static int ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int ANDROID_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -655,9 +655,9 @@ static void ANDROID_JoystickQuit(void) #endif // 0 } -static SDL_bool ANDROID_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool ANDROID_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_ANDROID_JoystickDriver = { diff --git a/src/joystick/android/SDL_sysjoystick_c.h b/src/joystick/android/SDL_sysjoystick_c.h index f107856577..90b6f7d378 100644 --- a/src/joystick/android/SDL_sysjoystick_c.h +++ b/src/joystick/android/SDL_sysjoystick_c.h @@ -32,7 +32,7 @@ extern int Android_OnPadDown(int device_id, int keycode); extern int Android_OnPadUp(int device_id, int keycode); extern int Android_OnJoy(int device_id, int axisnum, float value); extern int Android_OnHat(int device_id, int hat_id, int x, int y); -extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, SDL_bool can_rumble); +extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, bool can_rumble); extern int Android_RemoveJoystick(int device_id); // A linked list of available joysticks @@ -45,7 +45,7 @@ typedef struct SDL_joylist_item SDL_Joystick *joystick; int nbuttons, naxes, nhats; int dpad_state; - SDL_bool can_rumble; + bool can_rumble; struct SDL_joylist_item *next; } SDL_joylist_item; diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m index 8c05f496dd..e1d1cfce14 100644 --- a/src/joystick/apple/SDL_mfijoystick.m +++ b/src/joystick/apple/SDL_mfijoystick.m @@ -406,9 +406,9 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle #endif CheckControllerSiriRemote(controller, &device->is_siri_remote); - if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { + if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, true)) { // Ignore remotes, they'll be handled as keyboard input - return SDL_FALSE; + return false; } #ifdef ENABLE_PHYSICAL_INPUT_PROFILE @@ -490,7 +490,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle #endif } else { // We don't know how to get input events from this device - return SDL_FALSE; + return false; } #ifdef ENABLE_PHYSICAL_INPUT_PROFILE @@ -636,12 +636,12 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->nhats = 0; // apparently the touch surface-as-dpad is buggy device->nbuttons = nbuttons; - controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_FALSE); + controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, false); } #endif else { // We don't know how to get input events from this device - return SDL_FALSE; + return false; } Uint16 signature; @@ -662,7 +662,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, signature, NULL, name, 'm', subtype); if (SDL_ShouldIgnoreJoystick(name, device->guid)) { - return SDL_FALSE; + return false; } /* This will be set when the first button press of the controller is @@ -798,7 +798,7 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char static int IOS_JoystickInit(void) { - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, true)) { return 0; } @@ -879,10 +879,10 @@ static void IOS_JoystickDetect(void) { } -static SDL_bool IOS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool IOS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers through this method - return SDL_FALSE; + return false; } static const char *IOS_JoystickGetDeviceName(int device_index) @@ -999,7 +999,7 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) GCController *controller = device->controller; #ifdef ENABLE_MFI_LIGHT if (controller.light) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true); } #endif @@ -1007,9 +1007,9 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) if (controller.haptics) { for (GCHapticsLocality locality in controller.haptics.supportedLocalities) { if ([locality isEqualToString:GCHapticsLocalityHandles]) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } else if ([locality isEqualToString:GCHapticsLocalityTriggers]) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } } } @@ -1116,7 +1116,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) } else #endif if (controller.extendedGamepad) { - SDL_bool isstack; + bool isstack; GCExtendedGamepad *gamepad = controller.extendedGamepad; // Axis order matches the XInput Windows mappings. @@ -1182,7 +1182,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_small_free(buttons, isstack); } else if (controller.gamepad) { - SDL_bool isstack; + bool isstack; GCGamepad *gamepad = controller.gamepad; // Button order matches the XInput Windows mappings. @@ -1608,7 +1608,7 @@ static int IOS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int return SDL_Unsupported(); } -static int IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { #ifdef ENABLE_MFI_SENSORS @autoreleasepool { @@ -1721,12 +1721,12 @@ static void IOS_JoystickQuit(void) numjoysticks = 0; } -static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { #ifdef ENABLE_PHYSICAL_INPUT_PROFILE SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); if (device == NULL) { - return SDL_FALSE; + return false; } if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { @@ -1740,22 +1740,22 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi [(NSString *)key isEqualToString:@"Direction Pad Y Axis"]) { out->lefty.kind = EMappingKind_Axis; out->lefty.target = axis; - out->lefty.axis_reversed = SDL_TRUE; + out->lefty.axis_reversed = true; } else if ([(NSString *)key isEqualToString:@"Right Thumbstick X Axis"]) { out->rightx.kind = EMappingKind_Axis; out->rightx.target = axis; } else if ([(NSString *)key isEqualToString:@"Right Thumbstick Y Axis"]) { out->righty.kind = EMappingKind_Axis; out->righty.target = axis; - out->righty.axis_reversed = SDL_TRUE; + out->righty.axis_reversed = true; } else if ([(NSString *)key isEqualToString:GCInputLeftTrigger]) { out->lefttrigger.kind = EMappingKind_Axis; out->lefttrigger.target = axis; - out->lefttrigger.half_axis_positive = SDL_TRUE; + out->lefttrigger.half_axis_positive = true; } else if ([(NSString *)key isEqualToString:GCInputRightTrigger]) { out->righttrigger.kind = EMappingKind_Axis; out->righttrigger.target = axis; - out->righttrigger.half_axis_positive = SDL_TRUE; + out->righttrigger.half_axis_positive = true; } ++axis; } @@ -1854,32 +1854,32 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi ++button; } - return SDL_TRUE; + return true; } #endif // ENABLE_PHYSICAL_INPUT_PROFILE - return SDL_FALSE; + return false; } #if defined(SDL_JOYSTICK_MFI) && defined(SDL_PLATFORM_MACOS) -SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) +bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) { - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { - return SDL_FALSE; + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, true)) { + return false; } if (@available(macOS 10.16, *)) { const int MAX_ATTEMPTS = 3; for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) { if ([GCController supportsHIDDevice:device]) { - return SDL_TRUE; + return true; } // The framework may not have seen the device yet SDL_Delay(10); } } - return SDL_FALSE; + return false; } #endif diff --git a/src/joystick/apple/SDL_mfijoystick_c.h b/src/joystick/apple/SDL_mfijoystick_c.h index abfde8eb8d..92cc1c0a14 100644 --- a/src/joystick/apple/SDL_mfijoystick_c.h +++ b/src/joystick/apple/SDL_mfijoystick_c.h @@ -46,24 +46,24 @@ typedef struct joystick_hwdata int nbuttons; int nhats; Uint32 button_mask; - SDL_bool is_xbox; - SDL_bool is_ps4; - SDL_bool is_ps5; - SDL_bool is_switch_pro; - SDL_bool is_switch_joycon_pair; - SDL_bool is_switch_joyconL; - SDL_bool is_switch_joyconR; - SDL_bool is_stadia; - SDL_bool is_backbone_one; + bool is_xbox; + bool is_ps4; + bool is_ps5; + bool is_switch_pro; + bool is_switch_joycon_pair; + bool is_switch_joyconL; + bool is_switch_joyconR; + bool is_stadia; + bool is_backbone_one; int is_siri_remote; NSArray __unsafe_unretained *axes; NSArray __unsafe_unretained *buttons; - SDL_bool has_dualshock_touchpad; - SDL_bool has_xbox_paddles; - SDL_bool has_xbox_share_button; - SDL_bool has_nintendo_buttons; + bool has_dualshock_touchpad; + bool has_xbox_paddles; + bool has_xbox_share_button; + bool has_nintendo_buttons; struct joystick_hwdata *next; } joystick_hwdata; diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 801b482764..26cf739729 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -509,10 +509,10 @@ static void BSD_JoystickDetect(void) { } -static SDL_bool BSD_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool BSD_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static SDL_joylist_item *GetJoystickByDevIndex(int device_index) @@ -822,9 +822,9 @@ static int BSD_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble return SDL_Unsupported(); } -static SDL_bool BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } static int BSD_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) @@ -837,7 +837,7 @@ static int BSD_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int return SDL_Unsupported(); } -static int BSD_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int BSD_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } diff --git a/src/joystick/darwin/SDL_iokitjoystick.c b/src/joystick/darwin/SDL_iokitjoystick.c index 3fe955bc55..fdefeb53fd 100644 --- a/src/joystick/darwin/SDL_iokitjoystick.c +++ b/src/joystick/darwin/SDL_iokitjoystick.c @@ -172,10 +172,10 @@ static recDevice *FreeDevice(recDevice *removeDevice) return pDeviceNext; } -static SDL_bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) +static bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) { SInt32 value = 0; - int returnValue = SDL_FALSE; + int returnValue = false; if (pDevice && pDevice->deviceRef && pElement) { IOHIDValueRef valueRef; @@ -191,23 +191,23 @@ static SDL_bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SIn } *pValue = value; - returnValue = SDL_TRUE; + returnValue = true; } } return returnValue; } -static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pElement, SInt32 min, SInt32 max, SInt32 *pValue) +static bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pElement, SInt32 min, SInt32 max, SInt32 *pValue) { const float deviceScale = max - min; const float readScale = pElement->maxReport - pElement->minReport; - int returnValue = SDL_FALSE; + int returnValue = false; if (GetHIDElementState(pDevice, pElement, pValue)) { if (readScale == 0) { - returnValue = SDL_TRUE; // no scaling at all + returnValue = true; // no scaling at all } else { *pValue = (Sint32)(((*pValue - pElement->minReport) * deviceScale / readScale) + min); - returnValue = SDL_TRUE; + returnValue = true; } } return returnValue; @@ -216,7 +216,7 @@ static SDL_bool GetHIDScaledCalibratedState(recDevice *pDevice, recElement *pEle static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) { recDevice *device = (recDevice *)ctx; - device->removed = SDL_TRUE; + device->removed = true; if (device->deviceRef) { // deviceRef was invalidated due to the remove CFRelease(device->deviceRef); @@ -233,7 +233,7 @@ static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *s if (device->ffdevice) { FFReleaseDevice(device->ffdevice); device->ffdevice = NULL; - device->ff_initialized = SDL_FALSE; + device->ff_initialized = false; } #ifdef SDL_HAPTIC_IOKIT MacHaptic_MaybeRemoveDevice(device->ffservice); @@ -251,15 +251,15 @@ static void AddHIDElements(CFArrayRef array, recDevice *pDevice) CFArrayApplyFunction(array, range, AddHIDElement, pDevice); } -static SDL_bool ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) +static bool ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) { while (listitem) { if (listitem->cookie == cookie) { - return SDL_TRUE; + return true; } listitem = listitem->pNext; } - return SDL_FALSE; + return false; } // See if we care about this HID element, and if so, note it in our recDevice. @@ -418,7 +418,7 @@ static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const return slot; } -static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) +static bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) { Sint32 vendor = 0; Sint32 product = 0; @@ -435,7 +435,7 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usagePage); } if (pDevice->usagePage != kHIDPage_GenericDesktop) { - return SDL_FALSE; // Filter device list to non-keyboard/mouse stuff + return false; // Filter device list to non-keyboard/mouse stuff } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsageKey)); @@ -446,7 +446,7 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) if ((pDevice->usage != kHIDUsage_GD_Joystick && pDevice->usage != kHIDUsage_GD_GamePad && pDevice->usage != kHIDUsage_GD_MultiAxisController)) { - return SDL_FALSE; // Filter device list to non-keyboard/mouse stuff + return false; // Filter device list to non-keyboard/mouse stuff } /* Make sure we retain the use of the IOKit-provided device-object, @@ -491,7 +491,7 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) } if (SDL_JoystickHandledByAnotherDriver(&SDL_DARWIN_JoystickDriver, vendor, product, version, pDevice->product)) { - return SDL_FALSE; + return false; } pDevice->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, (Uint16)vendor, (Uint16)product, (Uint16)version, manufacturer_string, product_string, 0, 0); @@ -503,26 +503,26 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) CFRelease(array); } - return SDL_TRUE; + return true; } -static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) +static bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) { recDevice *i; #ifdef SDL_JOYSTICK_MFI - extern SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device); + extern bool IOS_SupportedHIDDevice(IOHIDDeviceRef device); if (IOS_SupportedHIDDevice(ioHIDDeviceObject)) { - return SDL_TRUE; + return true; } #endif for (i = gpDeviceList; i; i = i->pNext) { if (i->deviceRef == ioHIDDeviceObject) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) @@ -556,7 +556,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender // Get notified when this device is disconnected. IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device); IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); - device->runLoopAttached = SDL_TRUE; + device->runLoopAttached = true; // Allocate an instance ID for this device device->instance_id = SDL_GetNextObjectID(); @@ -586,12 +586,12 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender SDL_PrivateJoystickAdded(device->instance_id); } -static SDL_bool ConfigHIDManager(CFArrayRef matchingArray) +static bool ConfigHIDManager(CFArrayRef matchingArray) { CFRunLoopRef runloop = CFRunLoopGetCurrent(); if (IOHIDManagerOpen(hidman, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { - return SDL_FALSE; + return false; } IOHIDManagerSetDeviceMatchingMultiple(hidman, matchingArray); @@ -604,7 +604,7 @@ static SDL_bool ConfigHIDManager(CFArrayRef matchingArray) // future hotplug events will come through SDL_JOYSTICK_RUNLOOP_MODE now. - return SDL_TRUE; // good to go. + return true; // good to go. } static CFDictionaryRef CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) @@ -633,9 +633,9 @@ static CFDictionaryRef CreateHIDDeviceMatchDictionary(const UInt32 page, const U return retval; } -static SDL_bool CreateHIDManager(void) +static bool CreateHIDManager(void) { - SDL_bool retval = SDL_FALSE; + bool retval = false; int okay = 1; const void *vals[] = { (void *)CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), @@ -665,7 +665,7 @@ static SDL_bool CreateHIDManager(void) static int DARWIN_JoystickInit(void) { - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_IOKIT, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_IOKIT, true)) { return 0; } @@ -711,10 +711,10 @@ static void DARWIN_JoystickDetect(void) } } -static SDL_bool DARWIN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool DARWIN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static const char *DARWIN_JoystickGetDeviceName(int device_index) @@ -774,7 +774,7 @@ static int DARWIN_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->nbuttons = device->buttons; if (device->ffservice) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } return 0; @@ -900,7 +900,7 @@ static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ru if (DARWIN_JoystickInitRumble(device, magnitude) < 0) { return -1; } - device->ff_initialized = SDL_TRUE; + device->ff_initialized = true; } result = FFEffectStart(device->ffeffect_ref, 1, 0); @@ -925,7 +925,7 @@ static int DARWIN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, i return SDL_Unsupported(); } -static int DARWIN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int DARWIN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -935,7 +935,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick) recDevice *device = joystick->hwdata; recElement *element; SInt32 value, range; - int i, goodRead = SDL_FALSE; + int i, goodRead = false; Uint64 timestamp = SDL_GetTicksNS(); if (!device) { @@ -1056,9 +1056,9 @@ static void DARWIN_JoystickQuit(void) } } -static SDL_bool DARWIN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool DARWIN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_DARWIN_JoystickDriver = { diff --git a/src/joystick/darwin/SDL_iokitjoystick_c.h b/src/joystick/darwin/SDL_iokitjoystick_c.h index 08bbedbc01..e57c14ca36 100644 --- a/src/joystick/darwin/SDL_iokitjoystick_c.h +++ b/src/joystick/darwin/SDL_iokitjoystick_c.h @@ -50,7 +50,7 @@ struct joystick_hwdata FFDeviceObjectReference ffdevice; FFEFFECT *ffeffect; FFEffectObjectReference ffeffect_ref; - SDL_bool ff_initialized; + bool ff_initialized; char product[256]; // name of product uint32_t usage; // usage page from IOUSBHID Parser.h which defines general usage @@ -65,9 +65,9 @@ struct joystick_hwdata recElement *firstButton; recElement *firstHat; - SDL_bool removed; + bool removed; SDL_Joystick *joystick; - SDL_bool runLoopAttached; // is 'deviceRef' attached to a CFRunLoop? + bool runLoopAttached; // is 'deviceRef' attached to a CFRunLoop? int instance_id; SDL_GUID guid; diff --git a/src/joystick/dummy/SDL_sysjoystick.c b/src/joystick/dummy/SDL_sysjoystick.c index b9ea111744..e5c7ddf0ab 100644 --- a/src/joystick/dummy/SDL_sysjoystick.c +++ b/src/joystick/dummy/SDL_sysjoystick.c @@ -41,9 +41,9 @@ static void DUMMY_JoystickDetect(void) { } -static SDL_bool DUMMY_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool DUMMY_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { - return SDL_FALSE; + return false; } static const char *DUMMY_JoystickGetDeviceName(int device_index) @@ -107,7 +107,7 @@ static int DUMMY_JoystickSendEffect(SDL_Joystick *joystick, const void *data, in return SDL_Unsupported(); } -static int DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -124,9 +124,9 @@ static void DUMMY_JoystickQuit(void) { } -static SDL_bool DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_DUMMY_JoystickDriver = { diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index a285f282b0..e6bf9e7f87 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -259,10 +259,10 @@ static void EMSCRIPTEN_JoystickDetect(void) { } -static SDL_bool EMSCRIPTEN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool EMSCRIPTEN_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static const char *EMSCRIPTEN_JoystickGetDeviceName(int device_index) @@ -395,9 +395,9 @@ static int EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left return SDL_Unsupported(); } -static SDL_bool EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } static int EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) @@ -410,7 +410,7 @@ static int EMSCRIPTEN_JoystickSendEffect(SDL_Joystick *joystick, const void *dat return SDL_Unsupported(); } -static int EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } diff --git a/src/joystick/gdk/SDL_gameinputjoystick.c b/src/joystick/gdk/SDL_gameinputjoystick.c index 14372530b1..7f0f6d48a2 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.c +++ b/src/joystick/gdk/SDL_gameinputjoystick.c @@ -42,8 +42,8 @@ typedef struct GAMEINPUT_InternalDevice SDL_GUID guid; // generated by SDL SDL_JoystickID device_instance; // generated by SDL const GameInputDeviceInfo *info; - SDL_bool isAdded; - SDL_bool isDeleteRequested; + bool isAdded; + bool isDeleteRequested; } GAMEINPUT_InternalDevice; typedef struct GAMEINPUT_InternalList @@ -55,7 +55,7 @@ typedef struct GAMEINPUT_InternalList typedef struct joystick_hwdata { GAMEINPUT_InternalDevice *devref; - SDL_bool report_sensors; + bool report_sensors; GameInputRumbleParams rumbleParams; GameInputCallbackToken system_button_callback_token; } GAMEINPUT_InternalJoystickHwdata; @@ -67,12 +67,12 @@ static GameInputCallbackToken g_GameInputCallbackToken = GAMEINPUT_INVALID_CALLB static Uint64 g_GameInputTimestampOffset; -static SDL_bool GAMEINPUT_InternalIsGamepad(const GameInputDeviceInfo *info) +static bool GAMEINPUT_InternalIsGamepad(const GameInputDeviceInfo *info) { if (info->supportedInput & GameInputKindGamepad) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) @@ -109,7 +109,7 @@ static int GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) elem = g_GameInputList.devices[idx]; if (elem && elem->device == pDevice) { // we're already added - elem->isDeleteRequested = SDL_FALSE; + elem->isDeleteRequested = false; return 0; } } @@ -219,7 +219,7 @@ static void CALLBACK GAMEINPUT_InternalJoystickDeviceCallback( elem = g_GameInputList.devices[idx]; if (elem && elem->device == device) { // will be deleted on the next Detect call - elem->isDeleteRequested = SDL_TRUE; + elem->isDeleteRequested = true; break; } } @@ -234,7 +234,7 @@ static int GAMEINPUT_JoystickInit(void) { HRESULT hR; - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, true)) { return 0; } @@ -302,7 +302,7 @@ static void GAMEINPUT_JoystickDetect(void) if (!elem->isAdded) { SDL_PrivateJoystickAdded(elem->device_instance); - elem->isAdded = SDL_TRUE; + elem->isAdded = true; } if (elem->isDeleteRequested || !(IGameInputDevice_GetDeviceStatus(elem->device) & GameInputDeviceConnected)) { @@ -312,7 +312,7 @@ static void GAMEINPUT_JoystickDetect(void) } } -static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { SDL_AssertJoysticksLocked(); @@ -320,17 +320,17 @@ static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produ if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) { // The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle - return SDL_TRUE; + return true; } for (int i = 0; i < g_GameInputList.count; ++i) { GAMEINPUT_InternalDevice *elem = g_GameInputList.devices[i]; if (elem && vendor_id == elem->info->vendorId && product_id == elem->info->productId) { - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } static const char *GAMEINPUT_JoystickGetDeviceName(int device_index) @@ -473,10 +473,10 @@ static int GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (info->supportedRumbleMotors & (GameInputRumbleLowFrequency | GameInputRumbleHighFrequency)) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } if (info->supportedRumbleMotors & (GameInputRumbleLeftTrigger | GameInputRumbleRightTrigger)) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } if (info->supportedInput & GameInputKindTouch) { @@ -529,7 +529,7 @@ static int GAMEINPUT_JoystickSendEffect(SDL_Joystick *joystick, const void *data return SDL_Unsupported(); } -static int GAMEINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int GAMEINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { joystick->hwdata->report_sensors = enabled; return 0; @@ -691,12 +691,12 @@ static void GAMEINPUT_JoystickQuit(void) } } -static SDL_bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { GAMEINPUT_InternalDevice *elem = GAMEINPUT_InternalFindByIndex(device_index); if (!GAMEINPUT_InternalIsGamepad(elem->info)) { - return SDL_FALSE; + return false; } out->a.kind = EMappingKind_Button; @@ -771,7 +771,7 @@ static SDL_bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_Gamepa out->righttrigger.kind = EMappingKind_Axis; out->righttrigger.target = SDL_GAMEPAD_AXIS_RIGHT_TRIGGER; - return SDL_TRUE; + return true; } diff --git a/src/joystick/haiku/SDL_haikujoystick.cc b/src/joystick/haiku/SDL_haikujoystick.cc index e2a050ad25..0ba9b3201a 100644 --- a/src/joystick/haiku/SDL_haikujoystick.cc +++ b/src/joystick/haiku/SDL_haikujoystick.cc @@ -93,10 +93,10 @@ extern "C" { } - static SDL_bool HAIKU_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) + static bool HAIKU_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static const char *HAIKU_JoystickGetDeviceName(int device_index) @@ -273,10 +273,10 @@ extern "C" return SDL_Unsupported(); } - static SDL_bool + static bool HAIKU_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } static int HAIKU_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) @@ -290,7 +290,7 @@ extern "C" return SDL_Unsupported(); } - static int HAIKU_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) + static int HAIKU_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } diff --git a/src/joystick/hidapi/SDL_hidapi_combined.c b/src/joystick/hidapi/SDL_hidapi_combined.c index e1b7844e72..36de70d4a5 100644 --- a/src/joystick/hidapi/SDL_hidapi_combined.c +++ b/src/joystick/hidapi/SDL_hidapi_combined.c @@ -34,18 +34,18 @@ static void HIDAPI_DriverCombined_UnregisterHints(SDL_HintCallback callback, voi { } -static SDL_bool HIDAPI_DriverCombined_IsEnabled(void) +static bool HIDAPI_DriverCombined_IsEnabled(void) { - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_DriverCombined_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverCombined_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { // This is always explicitly created for combined devices - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverCombined_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverCombined_InitDevice(SDL_HIDAPI_Device *device) { return HIDAPI_JoystickConnected(device, NULL); } @@ -59,7 +59,7 @@ static void HIDAPI_DriverCombined_SetDevicePlayerIndex(SDL_HIDAPI_Device *device { } -static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { int i; char *serial = NULL, *new_serial; @@ -77,7 +77,7 @@ static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SD if (serial) { SDL_free(serial); } - return SDL_FALSE; + return false; } // Extend the serial number with the child serial number @@ -105,7 +105,7 @@ static SDL_bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SD } joystick->serial = serial; - return SDL_TRUE; + return true; } static int HIDAPI_DriverCombined_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -167,7 +167,7 @@ static int HIDAPI_DriverCombined_SendJoystickEffect(SDL_HIDAPI_Device *device, S return SDL_Unsupported(); } -static int HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { int i; int result = -1; @@ -181,15 +181,15 @@ static int HIDAPI_DriverCombined_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *de return result; } -static SDL_bool HIDAPI_DriverCombined_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverCombined_UpdateDevice(SDL_HIDAPI_Device *device) { int i; - int result = SDL_TRUE; + int result = true; for (i = 0; i < device->num_children; ++i) { SDL_HIDAPI_Device *child = device->children[i]; if (!child->driver->UpdateDevice(child)) { - result = SDL_FALSE; + result = false; } } return result; @@ -211,7 +211,7 @@ static void HIDAPI_DriverCombined_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverCombined = { "SDL_JOYSTICK_HIDAPI_COMBINED", - SDL_TRUE, + true, HIDAPI_DriverCombined_RegisterHints, HIDAPI_DriverCombined_UnregisterHints, HIDAPI_DriverCombined_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 76b8690f36..270784cb6a 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -37,7 +37,7 @@ typedef struct { - SDL_bool pc_mode; + bool pc_mode; SDL_JoystickID joysticks[MAX_CONTROLLERS]; Uint8 wireless[MAX_CONTROLLERS]; Uint8 min_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_MAX]; @@ -45,8 +45,8 @@ typedef struct Uint8 rumbleAllowed[MAX_CONTROLLERS]; Uint8 rumble[1 + MAX_CONTROLLERS]; // Without this variable, hid_write starts to lag a TON - SDL_bool rumbleUpdate; - SDL_bool useRumbleBrake; + bool rumbleUpdate; + bool useRumbleBrake; } SDL_DriverGameCube_Context; static void HIDAPI_DriverGameCube_RegisterHints(SDL_HintCallback callback, void *userdata) @@ -59,26 +59,26 @@ static void HIDAPI_DriverGameCube_UnregisterHints(SDL_HintCallback callback, voi SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, callback, userdata); } -static SDL_bool HIDAPI_DriverGameCube_IsEnabled(void) +static bool HIDAPI_DriverGameCube_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) { // Nintendo Co., Ltd. Wii U GameCube Controller Adapter - return SDL_TRUE; + return true; } if (vendor_id == USB_VENDOR_DRAGONRISE && (product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 || product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2)) { // EVORETRO GameCube Controller Adapter - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static void ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) @@ -95,11 +95,11 @@ static void SDLCALL SDL_JoystickGameCubeRumbleBrakeHintChanged(void *userdata, c { if (hint) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)userdata; - ctx->useRumbleBrake = SDL_GetStringBoolean(hint, SDL_FALSE); + ctx->useRumbleBrake = SDL_GetStringBoolean(hint, false); } } -static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx; Uint8 packet[37]; @@ -115,7 +115,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } device->context = ctx; @@ -124,10 +124,10 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) ctx->joysticks[2] = 0; ctx->joysticks[3] = 0; ctx->rumble[0] = rumbleMagic; - ctx->useRumbleBrake = SDL_FALSE; + ctx->useRumbleBrake = false; if (device->vendor_id != USB_VENDOR_NINTENDO) { - ctx->pc_mode = SDL_TRUE; + ctx->pc_mode = true; } if (ctx->pc_mode) { @@ -140,7 +140,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) if (SDL_hid_write(device->dev, &initMagic, sizeof(initMagic)) != sizeof(initMagic)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverGameCube_InitDevice(): Couldn't initialize WUP-028"); - return SDL_FALSE; + return false; } // Wait for the adapter to initialize @@ -184,7 +184,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceName(device, "Nintendo GameCube Controller"); - return SDL_TRUE; + return true; } static int HIDAPI_DriverGameCube_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) @@ -353,7 +353,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device } } -static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 packet[USB_PACKET_LENGTH]; @@ -374,14 +374,14 @@ static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) // Write rumble packet if (ctx->rumbleUpdate) { SDL_HIDAPI_SendRumble(device, ctx->rumble, sizeof(ctx->rumble)); - ctx->rumbleUpdate = SDL_FALSE; + ctx->rumbleUpdate = false; } // If we got here, nothing bad happened! - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 i; @@ -397,10 +397,10 @@ static SDL_bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SD } else { joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED; } - return SDL_TRUE; + return true; } } - return SDL_FALSE; // Should never get here! + return false; // Should never get here! } static int HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -435,7 +435,7 @@ static int HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J } if (val != ctx->rumble[i + 1]) { ctx->rumble[i + 1] = val; - ctx->rumbleUpdate = SDL_TRUE; + ctx->rumbleUpdate = true; } return 0; } @@ -483,7 +483,7 @@ static int HIDAPI_DriverGameCube_SendJoystickEffect(SDL_HIDAPI_Device *device, S return SDL_Unsupported(); } -static int HIDAPI_DriverGameCube_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverGameCube_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -495,7 +495,7 @@ static void HIDAPI_DriverGameCube_CloseJoystick(SDL_HIDAPI_Device *device, SDL_J // Stop rumble activity if (ctx->rumbleUpdate) { SDL_HIDAPI_SendRumble(device, ctx->rumble, sizeof(ctx->rumble)); - ctx->rumbleUpdate = SDL_FALSE; + ctx->rumbleUpdate = false; } } @@ -509,7 +509,7 @@ static void HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube = { SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, - SDL_TRUE, + true, HIDAPI_DriverGameCube_RegisterHints, HIDAPI_DriverGameCube_UnregisterHints, HIDAPI_DriverGameCube_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 1730ac623f..24147ea412 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -57,23 +57,23 @@ static void HIDAPI_DriverLuna_UnregisterHints(SDL_HintCallback callback, void *u SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_LUNA, callback, userdata); } -static SDL_bool HIDAPI_DriverLuna_IsEnabled(void) +static bool HIDAPI_DriverLuna_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_LUNA, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverLuna_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverLuna_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return SDL_IsJoystickAmazonLunaController(vendor_id, product_id); } -static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverLuna_Context *ctx; ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } device->context = ctx; @@ -91,7 +91,7 @@ static void HIDAPI_DriverLuna_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SD { } -static SDL_bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverLuna_Context *ctx = (SDL_DriverLuna_Context *)device->context; @@ -104,7 +104,7 @@ static SDL_bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; - return SDL_TRUE; + return true; } static int HIDAPI_DriverLuna_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -158,7 +158,7 @@ static int HIDAPI_DriverLuna_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_J return SDL_Unsupported(); } -static int HIDAPI_DriverLuna_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverLuna_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -348,7 +348,7 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick, SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverLuna_Context *ctx = (SDL_DriverLuna_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -358,7 +358,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -396,7 +396,7 @@ static void HIDAPI_DriverLuna_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverLuna = { SDL_HINT_JOYSTICK_HIDAPI_LUNA, - SDL_TRUE, + true, HIDAPI_DriverLuna_RegisterHints, HIDAPI_DriverLuna_UnregisterHints, HIDAPI_DriverLuna_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index f99024552f..dab821e75b 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -79,10 +79,10 @@ typedef struct { SDL_HIDAPI_Device *device; SDL_Joystick *joystick; - SDL_bool is_shanwan; - SDL_bool has_analog_buttons; - SDL_bool report_sensors; - SDL_bool effects_updated; + bool is_shanwan; + bool has_analog_buttons; + bool report_sensors; + bool effects_updated; int player_index; Uint8 rumble_left; Uint8 rumble_right; @@ -101,19 +101,19 @@ static void HIDAPI_DriverPS3_UnregisterHints(SDL_HintCallback callback, void *us SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3, callback, userdata); } -static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) +static bool HIDAPI_DriverPS3_IsEnabled(void) { - SDL_bool default_value; + bool default_value; #ifdef SDL_PLATFORM_MACOS // This works well on macOS - default_value = SDL_TRUE; + default_value = true; #elif defined(SDL_PLATFORM_WIN32) /* For official Sony driver (sixaxis.sys) use SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER. * * See https://github.com/ViGEm/DsHidMini as an alternative driver */ - default_value = SDL_FALSE; + default_value = false; #elif defined(SDL_PLATFORM_LINUX) /* Linux drivers do a better job of managing the transition between * USB and Bluetooth. There are also some quirks in communicating @@ -121,10 +121,10 @@ static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) * for libusb, but are not possible to support using hidraw if the * kernel doesn't already know about them. */ - default_value = SDL_FALSE; + default_value = false; #else // Untested, default off - default_value = SDL_FALSE; + default_value = false; #endif if (default_value) { @@ -133,15 +133,15 @@ static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, default_value); } -static SDL_bool HIDAPI_DriverPS3_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverPS3_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_SONY && product_id == USB_PRODUCT_SONY_DS3) { - return SDL_TRUE; + return true; } if (vendor_id == USB_VENDOR_SHANWAN && product_id == USB_PRODUCT_SHANWAN_DS3) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report, size_t length) @@ -156,27 +156,27 @@ static int SendFeatureReport(SDL_hid_device *dev, Uint8 *report, size_t length) return SDL_hid_send_feature_report(dev, report, length); } -static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx; - SDL_bool is_shanwan = SDL_FALSE; + bool is_shanwan = false; if (device->vendor_id == USB_VENDOR_SONY && SDL_strncasecmp(device->name, "ShanWan", 7) == 0) { - is_shanwan = SDL_TRUE; + is_shanwan = true; } if (device->vendor_id == USB_VENDOR_SHANWAN || device->vendor_id == USB_VENDOR_SHANWAN_ALT) { - is_shanwan = SDL_TRUE; + is_shanwan = true; } ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; ctx->is_shanwan = is_shanwan; - ctx->has_analog_buttons = SDL_TRUE; + ctx->has_analog_buttons = true; device->context = ctx; @@ -195,7 +195,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) if (size < 0) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf2"); - return SDL_FALSE; + return false; } #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 0xF2 packet: size = %d", data, size); @@ -204,7 +204,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) if (size < 0) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverPS3_InitDevice(): Couldn't read feature report 0xf5"); - return SDL_FALSE; + return false; } #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 0xF5 packet: size = %d", data, size); @@ -262,14 +262,14 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL HIDAPI_DriverPS3_UpdateEffects(device); } -static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_AssertJoysticksLocked(); ctx->joystick = joystick; - ctx->effects_updated = SDL_FALSE; + ctx->effects_updated = false; ctx->rumble_left = 0; ctx->rumble_right = 0; SDL_zeroa(ctx->last_state); @@ -287,7 +287,7 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); - return SDL_TRUE; + return true; } static int HIDAPI_DriverPS3_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -333,7 +333,7 @@ static int HIDAPI_DriverPS3_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Jo return 0; } -static int HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS3_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -517,7 +517,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -527,7 +527,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -545,7 +545,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateEffects(device); - ctx->effects_updated = SDL_TRUE; + ctx->effects_updated = true; } continue; } @@ -561,7 +561,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateEffects(device); - ctx->effects_updated = SDL_TRUE; + ctx->effects_updated = true; } break; default: @@ -592,7 +592,7 @@ static void HIDAPI_DriverPS3_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 = { SDL_HINT_JOYSTICK_HIDAPI_PS3, - SDL_TRUE, + true, HIDAPI_DriverPS3_RegisterHints, HIDAPI_DriverPS3_UnregisterHints, HIDAPI_DriverPS3_IsEnabled, @@ -612,21 +612,21 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3 = { HIDAPI_DriverPS3_FreeDevice, }; -static SDL_bool HIDAPI_DriverPS3ThirdParty_IsEnabled(void) +static bool HIDAPI_DriverPS3ThirdParty_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; if (vendor_id == USB_VENDOR_LOGITECH && product_id == USB_PRODUCT_LOGITECH_CHILLSTREAM) { - return SDL_TRUE; + return true; } if ((type == SDL_GAMEPAD_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) || @@ -635,31 +635,31 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device * size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data)); if (size == 8 && data[2] == 0x26) { // Supported third party controller - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } else { // Might be supported by this driver, enumerate and find out - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx; ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) { - ctx->has_analog_buttons = SDL_FALSE; + ctx->has_analog_buttons = false; } else { - ctx->has_analog_buttons = SDL_TRUE; + ctx->has_analog_buttons = true; } device->context = ctx; @@ -683,7 +683,7 @@ static void HIDAPI_DriverPS3ThirdParty_SetDevicePlayerIndex(SDL_HIDAPI_Device *d { } -static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -705,7 +705,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS; } - return SDL_TRUE; + return true; } static int HIDAPI_DriverPS3ThirdParty_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -733,7 +733,7 @@ static int HIDAPI_DriverPS3ThirdParty_SendJoystickEffect(SDL_HIDAPI_Device *devi return SDL_Unsupported(); } -static int HIDAPI_DriverPS3ThirdParty_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS3ThirdParty_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -976,7 +976,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -986,7 +986,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -1029,7 +1029,7 @@ static void HIDAPI_DriverPS3ThirdParty_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3ThirdParty = { SDL_HINT_JOYSTICK_HIDAPI_PS3, - SDL_TRUE, + true, HIDAPI_DriverPS3_RegisterHints, HIDAPI_DriverPS3_UnregisterHints, HIDAPI_DriverPS3ThirdParty_IsEnabled, @@ -1062,33 +1062,33 @@ static void HIDAPI_DriverPS3SonySixaxis_UnregisterHints(SDL_HintCallback callbac SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER, callback, userdata); } -static SDL_bool HIDAPI_DriverPS3SonySixaxis_IsEnabled(void) +static bool HIDAPI_DriverPS3SonySixaxis_IsEnabled(void) { #ifdef SDL_PLATFORM_WIN32 - return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER, false); #else - return SDL_FALSE; + return false; #endif } -static SDL_bool HIDAPI_DriverPS3SonySixaxis_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverPS3SonySixaxis_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_SONY && product_id == USB_PRODUCT_SONY_DS3) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverPS3SonySixaxis_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3SonySixaxis_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx; ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; - ctx->has_analog_buttons = SDL_TRUE; + ctx->has_analog_buttons = true; device->context = ctx; @@ -1103,7 +1103,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_InitDevice(SDL_HIDAPI_Device *device if (size < 0) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverPS3SonySixaxis_InitDevice(): Couldn't read feature report 0x00."); - return SDL_FALSE; + return false; } #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 0x0 packet: size = %d", data, size); @@ -1138,14 +1138,14 @@ static void HIDAPI_DriverPS3SonySixaxis_SetDevicePlayerIndex(SDL_HIDAPI_Device * HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(device); } -static SDL_bool HIDAPI_DriverPS3SonySixaxis_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverPS3SonySixaxis_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_AssertJoysticksLocked(); ctx->joystick = joystick; - ctx->effects_updated = SDL_FALSE; + ctx->effects_updated = false; ctx->rumble_left = 0; ctx->rumble_right = 0; SDL_zeroa(ctx->last_state); @@ -1163,7 +1163,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_OpenJoystick(SDL_HIDAPI_Device *devi SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); - return SDL_TRUE; + return true; } static int HIDAPI_DriverPS3SonySixaxis_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -1210,7 +1210,7 @@ static int HIDAPI_DriverPS3SonySixaxis_SendJoystickEffect(SDL_HIDAPI_Device *dev return 0; } -static int HIDAPI_DriverPS3SonySixaxis_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS3SonySixaxis_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; @@ -1319,7 +1319,7 @@ static void HIDAPI_DriverPS3SonySixaxis_HandleStatePacket(SDL_Joystick *joystick SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1329,11 +1329,11 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } if (!joystick) { - return SDL_FALSE; + return false; } // With sixaxis.sys driver we need to use hid_get_feature_report instead of hid_read @@ -1341,7 +1341,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi if (size < 0) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "HIDAPI_DriverPS3SonySixaxis_UpdateDevice(): Couldn't read feature report 0x00"); - return SDL_FALSE; + return false; } switch (data[0]) { @@ -1351,7 +1351,7 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_UpdateDevice(SDL_HIDAPI_Device *devi // Wait for the first report to set the LED state after the controller stops blinking if (!ctx->effects_updated) { HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(device); - ctx->effects_updated = SDL_TRUE; + ctx->effects_updated = true; } break; @@ -1421,7 +1421,7 @@ static int HIDAPI_DriverPS3_UpdateLEDsSonySixaxis(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS3SonySixaxis = { SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER, - SDL_TRUE, + true, HIDAPI_DriverPS3SonySixaxis_RegisterHints, HIDAPI_DriverPS3SonySixaxis_UnregisterHints, HIDAPI_DriverPS3SonySixaxis_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index 01ea841a6b..ef4a905123 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -146,29 +146,29 @@ typedef struct { SDL_HIDAPI_Device *device; SDL_Joystick *joystick; - SDL_bool is_dongle; - SDL_bool is_nacon_dongle; - SDL_bool official_controller; - SDL_bool sensors_supported; - SDL_bool lightbar_supported; - SDL_bool vibration_supported; - SDL_bool touchpad_supported; - SDL_bool effects_supported; + bool is_dongle; + bool is_nacon_dongle; + bool official_controller; + bool sensors_supported; + bool lightbar_supported; + bool vibration_supported; + bool touchpad_supported; + bool effects_supported; SDL_PS4_RumbleHintMode rumble_hint; - SDL_bool enhanced_reports; - SDL_bool enhanced_mode; - SDL_bool enhanced_mode_available; + bool enhanced_reports; + bool enhanced_mode; + bool enhanced_mode_available; Uint8 report_interval; - SDL_bool report_sensors; - SDL_bool report_touchpad; - SDL_bool report_battery; - SDL_bool hardware_calibration; + bool report_sensors; + bool report_touchpad; + bool report_battery; + bool hardware_calibration; IMUCalibrationData calibration[6]; Uint64 last_packet; int player_index; Uint8 rumble_left; Uint8 rumble_right; - SDL_bool color_set; + bool color_set; Uint8 led_red; Uint8 led_green; Uint8 led_blue; @@ -182,7 +182,7 @@ typedef struct PS4StatePacket_t last_state; } SDL_DriverPS4_Context; -static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ctx, const void *effect, int size, SDL_bool application_usage); +static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ctx, const void *effect, int size, bool application_usage); static void HIDAPI_DriverPS4_RegisterHints(SDL_HintCallback callback, void *userdata) { @@ -194,7 +194,7 @@ static void HIDAPI_DriverPS4_UnregisterHints(SDL_HintCallback callback, void *us SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4, callback, userdata); } -static SDL_bool HIDAPI_DriverPS4_IsEnabled(void) +static bool HIDAPI_DriverPS4_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS4, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } @@ -206,13 +206,13 @@ static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report return SDL_hid_get_feature_report(dev, report, length); } -static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; if (type == SDL_GAMEPAD_TYPE_PS4) { - return SDL_TRUE; + return true; } if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { @@ -220,17 +220,17 @@ static SDL_bool HIDAPI_DriverPS4_IsSupportedDevice(SDL_HIDAPI_Device *device, co size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data)); if (size == 48 && data[2] == 0x27) { // Supported third party controller - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } else { // Might be supported by this driver, enumerate and find out - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) @@ -259,7 +259,7 @@ static void SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index) effects->ucLedBlue = colors[player_index][2]; } -static SDL_bool ReadWiredSerial(SDL_HIDAPI_Device *device, char *serial, size_t serial_size) +static bool ReadWiredSerial(SDL_HIDAPI_Device *device, char *serial, size_t serial_size) { Uint8 data[USB_PACKET_LENGTH]; int size; @@ -268,12 +268,12 @@ static SDL_bool ReadWiredSerial(SDL_HIDAPI_Device *device, char *serial, size_t if (size >= 7 && (data[1] || data[2] || data[3] || data[4] || data[5] || data[6])) { (void)SDL_snprintf(serial, serial_size, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", data[6], data[5], data[4], data[3], data[2], data[1]); - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx; Uint8 data[USB_PACKET_LENGTH]; @@ -283,7 +283,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; @@ -313,9 +313,9 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) ctx->is_dongle = (device->vendor_id == USB_VENDOR_SONY && device->product_id == USB_PRODUCT_SONY_DS4_DONGLE); if (ctx->is_dongle) { ReadWiredSerial(device, serial, sizeof(serial)); - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } else if (device->vendor_id == USB_VENDOR_SONY && device->product_id == USB_PRODUCT_SONY_DS4_STRIKEPAD) { - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } else if (device->vendor_id == USB_VENDOR_SONY) { if (device->is_bluetooth) { @@ -331,23 +331,23 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) if (size > 0 && data[0] >= k_EPS4ReportIdBluetoothState1 && data[0] <= k_EPS4ReportIdBluetoothState9) { - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } } else { ReadWiredSerial(device, serial, sizeof(serial)); - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } } else { // Third party controllers appear to all be wired - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } if (device->vendor_id == USB_VENDOR_SONY) { - ctx->official_controller = SDL_TRUE; - ctx->sensors_supported = SDL_TRUE; - ctx->lightbar_supported = SDL_TRUE; - ctx->vibration_supported = SDL_TRUE; - ctx->touchpad_supported = SDL_TRUE; + ctx->official_controller = true; + ctx->sensors_supported = true; + ctx->lightbar_supported = true; + ctx->vibration_supported = true; + ctx->touchpad_supported = true; } else { // Third party controller capability request size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data)); @@ -364,16 +364,16 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_DumpPacket("PS4 capabilities: size = %d", data, size); #endif if (capabilities & 0x02) { - ctx->sensors_supported = SDL_TRUE; + ctx->sensors_supported = true; } if (capabilities & 0x04) { - ctx->lightbar_supported = SDL_TRUE; + ctx->lightbar_supported = true; } if (capabilities & 0x08) { - ctx->vibration_supported = SDL_TRUE; + ctx->vibration_supported = true; } if (capabilities & 0x40) { - ctx->touchpad_supported = SDL_TRUE; + ctx->touchpad_supported = true; } switch (device_type) { @@ -413,15 +413,15 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) } } else if (device->vendor_id == USB_VENDOR_RAZER) { // The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration - ctx->vibration_supported = SDL_TRUE; - ctx->touchpad_supported = SDL_TRUE; + ctx->vibration_supported = true; + ctx->touchpad_supported = true; } } ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported); if (device->vendor_id == USB_VENDOR_NACON_ALT && device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS4_WIRELESS) { - ctx->is_nacon_dongle = SDL_TRUE; + ctx->is_nacon_dongle = true; } if (device->vendor_id == USB_VENDOR_PDP && @@ -431,7 +431,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) * but it doesn't respond to the effects packet, and will hang * on reboot if we send it. */ - ctx->effects_supported = SDL_FALSE; + ctx->effects_supported = false; } device->joystick_type = joystick_type; @@ -444,14 +444,14 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { - return SDL_TRUE; + return true; } } else { HIDAPI_DisconnectBluetoothDevice(device->serial); } if ((ctx->is_dongle || ctx->is_nacon_dongle) && serial[0] == '\0') { // Not yet connected - return SDL_TRUE; + return true; } return HIDAPI_JoystickConnected(device, NULL); } @@ -461,18 +461,18 @@ static int HIDAPI_DriverPS4_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_ return -1; } -static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; int i, tries, size; - SDL_bool have_data = SDL_FALSE; + bool have_data = false; Uint8 data[USB_PACKET_LENGTH]; if (!ctx->official_controller) { #ifdef DEBUG_PS4_CALIBRATION SDL_Log("Not an official controller, ignoring calibration\n"); #endif - return SDL_FALSE; + return false; } for (tries = 0; tries < 5; ++tries) { @@ -482,7 +482,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * #ifdef DEBUG_PS4_CALIBRATION SDL_Log("Short read of calibration data: %d, ignoring calibration\n", size); #endif - return SDL_FALSE; + return false; } if (device->is_bluetooth) { @@ -491,14 +491,14 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * #ifdef DEBUG_PS4_CALIBRATION SDL_Log("Short read of calibration data: %d, ignoring calibration\n", size); #endif - return SDL_FALSE; + return false; } } // In some cases this report returns all zeros. Usually immediately after connection with the PS4 Dongle for (i = 0; i < size; ++i) { if (data[i]) { - have_data = SDL_TRUE; + have_data = true; break; } } @@ -589,7 +589,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * ctx->calibration[5].bias = sAccZPlus - sRange2g / 2; ctx->calibration[5].scale = (2.0f * ctx->accel_denominator / ctx->accel_numerator) / sRange2g; - ctx->hardware_calibration = SDL_TRUE; + ctx->hardware_calibration = true; for (i = 0; i < 6; ++i) { #ifdef DEBUG_PS4_CALIBRATION SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].scale); @@ -599,7 +599,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device * #ifdef DEBUG_PS4_CALIBRATION SDL_Log("invalid calibration, ignoring\n"); #endif - ctx->hardware_calibration = SDL_FALSE; + ctx->hardware_calibration = false; } } } else { @@ -655,7 +655,7 @@ static float HIDAPI_DriverPS4_ApplyCalibrationData(SDL_DriverPS4_Context *ctx, i return ((float)value - calibration->bias) * calibration->scale; } -static int HIDAPI_DriverPS4_UpdateEffects(SDL_DriverPS4_Context *ctx, SDL_bool application_usage) +static int HIDAPI_DriverPS4_UpdateEffects(SDL_DriverPS4_Context *ctx, bool application_usage) { DS4EffectsState_t effects; @@ -709,11 +709,11 @@ static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) static void HIDAPI_DriverPS4_SetEnhancedModeAvailable(SDL_DriverPS4_Context *ctx) { - ctx->enhanced_mode_available = SDL_TRUE; + ctx->enhanced_mode_available = true; if (ctx->touchpad_supported) { SDL_PrivateJoystickAddTouchpad(ctx->joystick, 2); - ctx->report_touchpad = SDL_TRUE; + ctx->report_touchpad = true; } if (ctx->sensors_supported) { @@ -722,7 +722,7 @@ static void HIDAPI_DriverPS4_SetEnhancedModeAvailable(SDL_DriverPS4_Context *ctx } if (ctx->official_controller) { - ctx->report_battery = SDL_TRUE; + ctx->report_battery = true; } HIDAPI_UpdateDeviceProperties(ctx->device); @@ -735,10 +735,10 @@ static void HIDAPI_DriverPS4_SetEnhancedMode(SDL_DriverPS4_Context *ctx) } if (!ctx->enhanced_mode) { - ctx->enhanced_mode = SDL_TRUE; + ctx->enhanced_mode = true; // Switch into enhanced report mode - HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE); + HIDAPI_DriverPS4_UpdateEffects(ctx, false); } } @@ -765,7 +765,7 @@ static void HIDAPI_DriverPS4_SetRumbleHintMode(SDL_DriverPS4_Context *ctx, SDL_P static void HIDAPI_DriverPS4_UpdateEnhancedModeOnEnhancedReport(SDL_DriverPS4_Context *ctx) { - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; if (ctx->rumble_hint == PS4_RUMBLE_HINT_DEFAULT) { HIDAPI_DriverPS4_SetRumbleHintMode(ctx, PS4_RUMBLE_HINT_ON); @@ -787,7 +787,7 @@ static void SDLCALL SDL_PS4RumbleHintChanged(void *userdata, const char *name, c HIDAPI_DriverPS4_SetRumbleHintMode(ctx, PS4_RUMBLE_HINT_DEFAULT); } else if (SDL_strcasecmp(hint, "auto") == 0) { HIDAPI_DriverPS4_SetRumbleHintMode(ctx, PS4_RUMBLE_HINT_AUTO); - } else if (SDL_GetStringBoolean(hint, SDL_FALSE)) { + } else if (SDL_GetStringBoolean(hint, false)) { HIDAPI_DriverPS4_SetRumbleHintMode(ctx, PS4_RUMBLE_HINT_ON); } else { HIDAPI_DriverPS4_SetRumbleHintMode(ctx, PS4_RUMBLE_HINT_OFF); @@ -817,7 +817,7 @@ static void SDLCALL SDL_PS4ReportIntervalHintChanged(void *userdata, const char if (new_report_interval != ctx->report_interval) { ctx->report_interval = (Uint8)new_report_interval; - HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE); + HIDAPI_DriverPS4_UpdateEffects(ctx, false); SDL_LockJoysticks(); SDL_PrivateJoystickSensorRate(ctx->joystick, SDL_SENSOR_GYRO, (float)(1000 / ctx->report_interval)); SDL_PrivateJoystickSensorRate(ctx->joystick, SDL_SENSOR_ACCEL, (float)(1000 / ctx->report_interval)); @@ -837,10 +837,10 @@ static void HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL // This will set the new LED state based on the new player index // SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode - HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_FALSE); + HIDAPI_DriverPS4_UpdateEffects(ctx, false); } -static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -848,11 +848,11 @@ static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->joystick = joystick; ctx->last_packet = SDL_GetTicks(); - ctx->report_sensors = SDL_FALSE; - ctx->report_touchpad = SDL_FALSE; + ctx->report_sensors = false; + ctx->report_touchpad = false; ctx->rumble_left = 0; ctx->rumble_right = 0; - ctx->color_set = SDL_FALSE; + ctx->color_set = false; SDL_zero(ctx->last_state); // Initialize player index (needed for setting LEDs) @@ -870,7 +870,7 @@ static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_PS4ReportIntervalHintChanged, ctx); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, SDL_PS4RumbleHintChanged, ctx); - return SDL_TRUE; + return true; } static int HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -884,7 +884,7 @@ static int HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joysti ctx->rumble_left = (low_frequency_rumble >> 8); ctx->rumble_right = (high_frequency_rumble >> 8); - return HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_TRUE); + return HIDAPI_DriverPS4_UpdateEffects(ctx, true); } static int HIDAPI_DriverPS4_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) @@ -917,15 +917,15 @@ static int HIDAPI_DriverPS4_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joysti return SDL_Unsupported(); } - ctx->color_set = SDL_TRUE; + ctx->color_set = true; ctx->led_red = red; ctx->led_green = green; ctx->led_blue = blue; - return HIDAPI_DriverPS4_UpdateEffects(ctx, SDL_TRUE); + return HIDAPI_DriverPS4_UpdateEffects(ctx, true); } -static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ctx, const void *effect, int size, SDL_bool application_usage) +static int HIDAPI_DriverPS4_InternalSendJoystickEffect(SDL_DriverPS4_Context *ctx, const void *effect, int size, bool application_usage) { Uint8 data[78]; int report_size, offset; @@ -984,10 +984,10 @@ static int HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Jo { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; - return HIDAPI_DriverPS4_InternalSendJoystickEffect(ctx, effect, size, SDL_TRUE); + return HIDAPI_DriverPS4_InternalSendJoystickEffect(ctx, effect, size, true); } -static int HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; @@ -1167,7 +1167,7 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state)); } -static SDL_bool VerifyCRC(Uint8 *data, int size) +static bool VerifyCRC(Uint8 *data, int size) { Uint8 ubHdr = 0xA1; // hidp header is part of the CRC calculation Uint32 unCRC, unPacketCRC; @@ -1182,27 +1182,27 @@ static SDL_bool VerifyCRC(Uint8 *data, int size) return (unCRC == unPacketCRC); } -static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size) +static bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size) { switch (data[0]) { case k_EPS4ReportIdUsbState: if (size == 10) { // This is non-enhanced mode, this packet is fine - return SDL_TRUE; + return true; } if (ctx->is_nacon_dongle && size >= (1 + sizeof(PS4StatePacket_t))) { // The report timestamp doesn't change when the controller isn't connected PS4StatePacket_t *packet = (PS4StatePacket_t *)&data[1]; if (SDL_memcmp(packet->rgucTimestamp, ctx->last_state.rgucTimestamp, sizeof(packet->rgucTimestamp)) == 0) { - return SDL_FALSE; + return false; } if (ctx->last_state.rgucAccelX[0] == 0 && ctx->last_state.rgucAccelX[1] == 0 && ctx->last_state.rgucAccelY[0] == 0 && ctx->last_state.rgucAccelY[1] == 0 && ctx->last_state.rgucAccelZ[0] == 0 && ctx->last_state.rgucAccelZ[1] == 0) { // We don't have any state to compare yet, go ahead and copy it SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS4StatePacket_t)); - return SDL_FALSE; + return false; } } @@ -1212,7 +1212,7 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 * packet over BT with a size of 128 */ if (size >= 64 && !(data[31] & 0x04)) { - return SDL_TRUE; + return true; } break; case k_EPS4ReportIdBluetoothState1: @@ -1234,19 +1234,19 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 } if (ctx->valid_crc_packets >= 3) { // We're generally getting valid CRC, but failed one - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } break; default: break; } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1364,7 +1364,7 @@ static void HIDAPI_DriverPS4_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 = { SDL_HINT_JOYSTICK_HIDAPI_PS4, - SDL_TRUE, + true, HIDAPI_DriverPS4_RegisterHints, HIDAPI_DriverPS4_UnregisterHints, HIDAPI_DriverPS4_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index 6811aea73e..de1e543089 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -232,30 +232,30 @@ typedef struct { SDL_HIDAPI_Device *device; SDL_Joystick *joystick; - SDL_bool is_nacon_dongle; - SDL_bool use_alternate_report; - SDL_bool sensors_supported; - SDL_bool lightbar_supported; - SDL_bool vibration_supported; - SDL_bool playerled_supported; - SDL_bool touchpad_supported; - SDL_bool effects_supported; + bool is_nacon_dongle; + bool use_alternate_report; + bool sensors_supported; + bool lightbar_supported; + bool vibration_supported; + bool playerled_supported; + bool touchpad_supported; + bool effects_supported; SDL_PS5_RumbleHintMode rumble_hint; - SDL_bool enhanced_reports; - SDL_bool enhanced_mode; - SDL_bool enhanced_mode_available; - SDL_bool report_sensors; - SDL_bool report_touchpad; - SDL_bool report_battery; - SDL_bool hardware_calibration; + bool enhanced_reports; + bool enhanced_mode; + bool enhanced_mode_available; + bool report_sensors; + bool report_touchpad; + bool report_battery; + bool hardware_calibration; IMUCalibrationData calibration[6]; Uint16 firmware_version; Uint64 last_packet; int player_index; - SDL_bool player_lights; + bool player_lights; Uint8 rumble_left; Uint8 rumble_right; - SDL_bool color_set; + bool color_set; Uint8 led_red; Uint8 led_green; Uint8 led_blue; @@ -272,7 +272,7 @@ typedef struct } last_state; } SDL_DriverPS5_Context; -static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ctx, const void *effect, int size, SDL_bool application_usage); +static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ctx, const void *effect, int size, bool application_usage); static void HIDAPI_DriverPS5_RegisterHints(SDL_HintCallback callback, void *userdata) { @@ -284,7 +284,7 @@ static void HIDAPI_DriverPS5_UnregisterHints(SDL_HintCallback callback, void *us SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5, callback, userdata); } -static SDL_bool HIDAPI_DriverPS5_IsEnabled(void) +static bool HIDAPI_DriverPS5_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } @@ -296,13 +296,13 @@ static int ReadFeatureReport(SDL_hid_device *dev, Uint8 report_id, Uint8 *report return SDL_hid_get_feature_report(dev, report, length); } -static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { Uint8 data[USB_PACKET_LENGTH]; int size; if (type == SDL_GAMEPAD_TYPE_PS5) { - return SDL_TRUE; + return true; } if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { @@ -310,16 +310,16 @@ static SDL_bool HIDAPI_DriverPS5_IsSupportedDevice(SDL_HIDAPI_Device *device, co size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data)); if (size == 48 && data[2] == 0x28) { // Supported third party controller - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } else { // Might be supported by this driver, enumerate and find out - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) @@ -367,7 +367,7 @@ static void SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index } } -static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx; Uint8 data[USB_PACKET_LENGTH * 2]; @@ -377,7 +377,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; @@ -409,10 +409,10 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) #endif if (size == 64) { // Connected over USB - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } else if (size > 0 && data[0] == k_EPS5ReportIdBluetoothEffects) { // Connected over Bluetooth, using enhanced reports - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; } else { // Connected over Bluetooth, using simple reports (DirectInput enabled) } @@ -436,11 +436,11 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) // Get the device capabilities if (device->vendor_id == USB_VENDOR_SONY) { - ctx->sensors_supported = SDL_TRUE; - ctx->lightbar_supported = SDL_TRUE; - ctx->vibration_supported = SDL_TRUE; - ctx->playerled_supported = SDL_TRUE; - ctx->touchpad_supported = SDL_TRUE; + ctx->sensors_supported = true; + ctx->lightbar_supported = true; + ctx->vibration_supported = true; + ctx->playerled_supported = true; + ctx->touchpad_supported = true; } else { // Third party controller capability request size = ReadFeatureReport(device->dev, k_EPS5FeatureReportIdCapabilities, data, sizeof(data)); @@ -453,19 +453,19 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_DumpPacket("PS5 capabilities: size = %d", data, size); #endif if (capabilities & 0x02) { - ctx->sensors_supported = SDL_TRUE; + ctx->sensors_supported = true; } if (capabilities & 0x04) { - ctx->lightbar_supported = SDL_TRUE; + ctx->lightbar_supported = true; } if (capabilities & 0x08) { - ctx->vibration_supported = SDL_TRUE; + ctx->vibration_supported = true; } if (capabilities & 0x40) { - ctx->touchpad_supported = SDL_TRUE; + ctx->touchpad_supported = true; } if (capabilities2 & 0x80) { - ctx->playerled_supported = SDL_TRUE; + ctx->playerled_supported = true; } switch (device_type) { @@ -492,34 +492,34 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) break; } - ctx->use_alternate_report = SDL_TRUE; + ctx->use_alternate_report = true; if (device->vendor_id == USB_VENDOR_NACON_ALT && (device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRED || device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS)) { // This doesn't report vibration capability, but it can do rumble - ctx->vibration_supported = SDL_TRUE; + ctx->vibration_supported = true; } } else if (device->vendor_id == USB_VENDOR_RAZER && (device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRED || device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS)) { // The Razer Wolverine V2 Pro doesn't respond to the detection protocol, but has a touchpad and sensors and no vibration - ctx->sensors_supported = SDL_TRUE; - ctx->touchpad_supported = SDL_TRUE; - ctx->use_alternate_report = SDL_TRUE; + ctx->sensors_supported = true; + ctx->touchpad_supported = true; + ctx->use_alternate_report = true; } else if (device->vendor_id == USB_VENDOR_RAZER && device->product_id == USB_PRODUCT_RAZER_KITSUNE) { // The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK; - ctx->touchpad_supported = SDL_TRUE; - ctx->use_alternate_report = SDL_TRUE; + ctx->touchpad_supported = true; + ctx->use_alternate_report = true; } } ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported || ctx->playerled_supported); if (device->vendor_id == USB_VENDOR_NACON_ALT && device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS) { - ctx->is_nacon_dongle = SDL_TRUE; + ctx->is_nacon_dongle = true; } device->joystick_type = joystick_type; @@ -535,13 +535,13 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) if (ctx->is_nacon_dongle) { // We don't know if this is connected yet, wait for reports - return SDL_TRUE; + return true; } // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { - return SDL_TRUE; + return true; } } else { HIDAPI_DisconnectBluetoothDevice(device->serial); @@ -629,7 +629,7 @@ static void HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) ctx->calibration[5].bias = sAccZPlus - sRange2g / 2; ctx->calibration[5].sensitivity = 2.0f * ACCEL_RES_PER_G / (float)sRange2g; - ctx->hardware_calibration = SDL_TRUE; + ctx->hardware_calibration = true; for (i = 0; i < 6; ++i) { float divisor = (i < 3 ? 64.0f : 1.0f); #ifdef DEBUG_PS5_CALIBRATION @@ -640,7 +640,7 @@ static void HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS5_CALIBRATION SDL_Log("invalid calibration, ignoring\n"); #endif - ctx->hardware_calibration = SDL_FALSE; + ctx->hardware_calibration = false; } } } @@ -669,7 +669,7 @@ static float HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, i return result; } -static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect_mask, SDL_bool application_usage) +static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect_mask, bool application_usage) { DS5EffectsState_t effects; @@ -749,7 +749,7 @@ static int HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effect static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_DriverPS5_Context *ctx) { - SDL_bool led_reset_complete = SDL_FALSE; + bool led_reset_complete = false; if (ctx->enhanced_reports && ctx->sensors_supported && !ctx->use_alternate_report) { const PS5StatePacketCommon_t *packet = &ctx->last_state.state; @@ -761,19 +761,19 @@ static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_DriverPS5_Context *ctx) packet->rgucSensorTimestamp[2], packet->rgucSensorTimestamp[3]); if (timestamp >= connection_complete) { - led_reset_complete = SDL_TRUE; + led_reset_complete = true; } } else { // We don't know how to check the timer, just assume it's complete for now - led_reset_complete = SDL_TRUE; + led_reset_complete = true; } if (led_reset_complete) { - HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectLEDReset, SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectLEDReset, false); ctx->led_reset_state = k_EDS5LEDResetStateComplete; - HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), false); } } @@ -803,11 +803,11 @@ static void HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx) { - ctx->enhanced_mode_available = SDL_TRUE; + ctx->enhanced_mode_available = true; if (ctx->touchpad_supported) { SDL_PrivateJoystickAddTouchpad(ctx->joystick, 2); - ctx->report_touchpad = SDL_TRUE; + ctx->report_touchpad = true; } if (ctx->sensors_supported) { @@ -821,7 +821,7 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx } } - ctx->report_battery = SDL_TRUE; + ctx->report_battery = true; HIDAPI_UpdateDeviceProperties(ctx->device); } @@ -833,13 +833,13 @@ static void HIDAPI_DriverPS5_SetEnhancedMode(SDL_DriverPS5_Context *ctx) } if (!ctx->enhanced_mode && ctx->enhanced_mode_available) { - ctx->enhanced_mode = SDL_TRUE; + ctx->enhanced_mode = true; // Switch into enhanced report mode - HIDAPI_DriverPS5_UpdateEffects(ctx, 0, SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, 0, false); // Update the light effects - HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), false); } } @@ -866,7 +866,7 @@ static void HIDAPI_DriverPS5_SetRumbleHintMode(SDL_DriverPS5_Context *ctx, SDL_P static void HIDAPI_DriverPS5_UpdateEnhancedModeOnEnhancedReport(SDL_DriverPS5_Context *ctx) { - ctx->enhanced_reports = SDL_TRUE; + ctx->enhanced_reports = true; if (ctx->rumble_hint == PS5_RUMBLE_HINT_DEFAULT) { HIDAPI_DriverPS5_SetRumbleHintMode(ctx, PS5_RUMBLE_HINT_ON); @@ -896,7 +896,7 @@ static void SDLCALL SDL_PS5RumbleHintChanged(void *userdata, const char *name, c HIDAPI_DriverPS5_SetRumbleHintMode(ctx, PS5_RUMBLE_HINT_DEFAULT); } else if (SDL_strcasecmp(hint, "auto") == 0) { HIDAPI_DriverPS5_SetRumbleHintMode(ctx, PS5_RUMBLE_HINT_AUTO); - } else if (SDL_GetStringBoolean(hint, SDL_FALSE)) { + } else if (SDL_GetStringBoolean(hint, false)) { HIDAPI_DriverPS5_SetRumbleHintMode(ctx, PS5_RUMBLE_HINT_ON); } else { HIDAPI_DriverPS5_SetRumbleHintMode(ctx, PS5_RUMBLE_HINT_OFF); @@ -906,12 +906,12 @@ static void SDLCALL SDL_PS5RumbleHintChanged(void *userdata, const char *name, c static void SDLCALL SDL_PS5PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)userdata; - SDL_bool player_lights = SDL_GetStringBoolean(hint, SDL_TRUE); + bool player_lights = SDL_GetStringBoolean(hint, true); if (player_lights != ctx->player_lights) { ctx->player_lights = player_lights; - HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectPadLights, SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectPadLights, false); } } @@ -927,10 +927,10 @@ static void HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL // This will set the new LED state based on the new player index // SDL automatically calls this, so it doesn't count as an application action to enable enhanced mode - HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), SDL_FALSE); + HIDAPI_DriverPS5_UpdateEffects(ctx, (k_EDS5EffectLED | k_EDS5EffectPadLights), false); } -static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -938,17 +938,17 @@ static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->joystick = joystick; ctx->last_packet = SDL_GetTicks(); - ctx->report_sensors = SDL_FALSE; - ctx->report_touchpad = SDL_FALSE; + ctx->report_sensors = false; + ctx->report_touchpad = false; ctx->rumble_left = 0; ctx->rumble_right = 0; - ctx->color_set = SDL_FALSE; + ctx->color_set = false; ctx->led_reset_state = k_EDS5LEDResetStateNone; SDL_zero(ctx->last_state); // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, SDL_TRUE); + ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, true); // Initialize the joystick capabilities if (SDL_IsJoystickDualSenseEdge(device->vendor_id, device->product_id)) { @@ -967,7 +967,7 @@ static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, SDL_PS5PlayerLEDHintChanged, ctx); - return SDL_TRUE; + return true; } static int HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -979,13 +979,13 @@ static int HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joysti } if (!ctx->rumble_left && !ctx->rumble_right) { - HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectRumbleStart, SDL_TRUE); + HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectRumbleStart, true); } ctx->rumble_left = (low_frequency_rumble >> 8); ctx->rumble_right = (high_frequency_rumble >> 8); - return HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectRumble, SDL_TRUE); + return HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectRumble, true); } static int HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) @@ -1021,15 +1021,15 @@ static int HIDAPI_DriverPS5_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joysti return SDL_Unsupported(); } - ctx->color_set = SDL_TRUE; + ctx->color_set = true; ctx->led_red = red; ctx->led_green = green; ctx->led_blue = blue; - return HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectLED, SDL_TRUE); + return HIDAPI_DriverPS5_UpdateEffects(ctx, k_EDS5EffectLED, true); } -static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ctx, const void *effect, int size, SDL_bool application_usage) +static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ctx, const void *effect, int size, bool application_usage) { Uint8 data[78]; int report_size, offset; @@ -1108,10 +1108,10 @@ static int HIDAPI_DriverPS5_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Jo { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; - return HIDAPI_DriverPS5_InternalSendJoystickEffect(ctx, effect, size, SDL_TRUE); + return HIDAPI_DriverPS5_InternalSendJoystickEffect(ctx, effect, size, true); } -static int HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; @@ -1436,7 +1436,7 @@ static void HIDAPI_DriverPS5_HandleStatePacketAlt(SDL_Joystick *joystick, SDL_hi SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state)); } -static SDL_bool VerifyCRC(Uint8 *data, int size) +static bool VerifyCRC(Uint8 *data, int size) { Uint8 ubHdr = 0xA1; // hidp header is part of the CRC calculation Uint32 unCRC, unPacketCRC; @@ -1451,7 +1451,7 @@ static SDL_bool VerifyCRC(Uint8 *data, int size) return (unCRC == unPacketCRC); } -static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size) +static bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 *data, int size) { switch (data[0]) { case k_EPS5ReportIdState: @@ -1459,30 +1459,30 @@ static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 // The report timestamp doesn't change when the controller isn't connected PS5StatePacketAlt_t *packet = (PS5StatePacketAlt_t *)&data[1]; if (SDL_memcmp(packet->rgucPacketSequence, ctx->last_state.state.rgucPacketSequence, sizeof(packet->rgucPacketSequence)) == 0) { - return SDL_FALSE; + return false; } if (ctx->last_state.alt_state.rgucAccelX[0] == 0 && ctx->last_state.alt_state.rgucAccelX[1] == 0 && ctx->last_state.alt_state.rgucAccelY[0] == 0 && ctx->last_state.alt_state.rgucAccelY[1] == 0 && ctx->last_state.alt_state.rgucAccelZ[0] == 0 && ctx->last_state.alt_state.rgucAccelZ[1] == 0) { // We don't have any state to compare yet, go ahead and copy it SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS5StatePacketAlt_t)); - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; case k_EPS5ReportIdBluetoothState: if (VerifyCRC(data, size)) { - return SDL_TRUE; + return true; } break; default: break; } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1604,7 +1604,7 @@ static void HIDAPI_DriverPS5_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5 = { SDL_HINT_JOYSTICK_HIDAPI_PS5, - SDL_TRUE, + true, HIDAPI_DriverPS5_RegisterHints, HIDAPI_DriverPS5_UnregisterHints, HIDAPI_DriverPS5_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index 78121c259f..38b34adbec 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -102,7 +102,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) { SDL_HIDAPI_RumbleRequest *request; - SDL_AtomicSet(&ctx->running, SDL_FALSE); + SDL_AtomicSet(&ctx->running, false); if (ctx->thread) { int result; @@ -138,7 +138,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) SDL_HIDAPI_rumble_lock = NULL; } - SDL_AtomicSet(&ctx->initialized, SDL_FALSE); + SDL_AtomicSet(&ctx->initialized, false); } static int SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx) @@ -155,7 +155,7 @@ static int SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx) return -1; } - SDL_AtomicSet(&ctx->running, SDL_TRUE); + SDL_AtomicSet(&ctx->running, true); ctx->thread = SDL_CreateThread(SDL_HIDAPI_RumbleThread, "HIDAPI Rumble", ctx); if (!ctx->thread) { SDL_HIDAPI_StopRumbleThread(ctx); @@ -168,7 +168,7 @@ int SDL_HIDAPI_LockRumble(void) { SDL_HIDAPI_RumbleContext *ctx = &rumble_context; - if (SDL_AtomicCompareAndSwap(&ctx->initialized, SDL_FALSE, SDL_TRUE)) { + if (SDL_AtomicCompareAndSwap(&ctx->initialized, false, true)) { if (SDL_HIDAPI_StartRumbleThread(ctx) < 0) { return -1; } @@ -178,7 +178,7 @@ int SDL_HIDAPI_LockRumble(void) return 0; } -SDL_bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **data, int **size, int *maximum_size) +bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **data, int **size, int *maximum_size) { SDL_HIDAPI_RumbleContext *ctx = &rumble_context; SDL_HIDAPI_RumbleRequest *request, *found; @@ -193,9 +193,9 @@ SDL_bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **da *data = found->data; *size = &found->size; *maximum_size = sizeof(found->data); - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } int SDL_HIDAPI_SendRumbleAndUnlock(SDL_HIDAPI_Device *device, const Uint8 *data, int size) diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.h b/src/joystick/hidapi/SDL_hidapi_rumble.h index 2c9bc85761..7bbfcdfe92 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.h +++ b/src/joystick/hidapi/SDL_hidapi_rumble.h @@ -29,7 +29,7 @@ extern SDL_Mutex *SDL_HIDAPI_rumble_lock; #endif int SDL_HIDAPI_LockRumble(void) SDL_TRY_ACQUIRE(0, SDL_HIDAPI_rumble_lock); -SDL_bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **data, int **size, int *maximum_size); +bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **data, int **size, int *maximum_size); int SDL_HIDAPI_SendRumbleAndUnlock(SDL_HIDAPI_Device *device, const Uint8 *data, int size) SDL_RELEASE(SDL_HIDAPI_rumble_lock); typedef void (*SDL_HIDAPI_RumbleSentCallback)(void *userdata); int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const Uint8 *data, int size, SDL_HIDAPI_RumbleSentCallback callback, void *userdata) SDL_RELEASE(SDL_HIDAPI_rumble_lock); diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index 6251d1c789..576d9578ef 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -77,14 +77,14 @@ typedef struct { Uint8 seq_num; - SDL_bool has_charging; + bool has_charging; Uint8 charging; - SDL_bool has_battery_level; + bool has_battery_level; Uint8 battery_level; Uint64 last_battery_query_time; - SDL_bool rumble_report_pending; - SDL_bool rumble_update_pending; + bool rumble_report_pending; + bool rumble_update_pending; Uint8 left_motor_amplitude; Uint8 right_motor_amplitude; Uint64 last_rumble_time; @@ -102,23 +102,23 @@ static void HIDAPI_DriverShield_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SHIELD, callback, userdata); } -static SDL_bool HIDAPI_DriverShield_IsEnabled(void) +static bool HIDAPI_DriverShield_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SHIELD, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverShield_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverShield_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return SDL_IsJoystickNVIDIASHIELDController(vendor_id, product_id); } -static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverShield_Context *ctx; ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } device->context = ctx; @@ -168,14 +168,14 @@ static int HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, return 0; } -static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; SDL_AssertJoysticksLocked(); - ctx->rumble_report_pending = SDL_FALSE; - ctx->rumble_update_pending = SDL_FALSE; + ctx->rumble_report_pending = false; + ctx->rumble_update_pending = false; ctx->left_motor_amplitude = 0; ctx->right_motor_amplitude = 0; ctx->last_rumble_time = 0; @@ -199,7 +199,7 @@ static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ HIDAPI_DriverShield_SendCommand(device, CMD_CHARGE_STATE, NULL, 0); HIDAPI_DriverShield_SendCommand(device, CMD_BATTERY_STATE, NULL, 0); - return SDL_TRUE; + return true; } static int HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) @@ -215,7 +215,7 @@ static int HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device) rumble_data[1] = ctx->left_motor_amplitude; rumble_data[2] = ctx->right_motor_amplitude; - ctx->rumble_update_pending = SDL_FALSE; + ctx->rumble_update_pending = false; ctx->last_rumble_time = SDL_GetTicks(); return HIDAPI_DriverShield_SendCommand(device, CMD_RUMBLE, rumble_data, sizeof(rumble_data)); @@ -240,7 +240,7 @@ static int HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy // The rumble motors are quite intense, so tone down the intensity like the official driver does ctx->left_motor_amplitude = low_frequency_rumble >> 11; ctx->right_motor_amplitude = high_frequency_rumble >> 11; - ctx->rumble_update_pending = SDL_TRUE; + ctx->rumble_update_pending = true; if (ctx->rumble_report_pending) { // We will service this after the hardware acknowledges the previous request @@ -281,7 +281,7 @@ static int HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL } } -static int HIDAPI_DriverShield_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverShield_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -462,7 +462,7 @@ static void HIDAPI_DriverShield_UpdatePowerInfo(SDL_Joystick *joystick, SDL_Driv SDL_SendJoystickPowerInfo(joystick, state, percent); } -static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -473,7 +473,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -503,16 +503,16 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) cmd_resp_report = (ShieldCommandReport_t *)data; switch (cmd_resp_report->cmd) { case CMD_RUMBLE: - ctx->rumble_report_pending = SDL_FALSE; + ctx->rumble_report_pending = false; HIDAPI_DriverShield_SendNextRumble(device); break; case CMD_CHARGE_STATE: - ctx->has_charging = SDL_TRUE; + ctx->has_charging = true; ctx->charging = cmd_resp_report->payload[0]; HIDAPI_DriverShield_UpdatePowerInfo(joystick, ctx); break; case CMD_BATTERY_STATE: - ctx->has_battery_level = SDL_TRUE; + ctx->has_battery_level = true; ctx->battery_level = cmd_resp_report->payload[2]; HIDAPI_DriverShield_UpdatePowerInfo(joystick, ctx); break; @@ -530,7 +530,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) // Retransmit rumble packets if they've lasted longer than the hardware supports if ((ctx->left_motor_amplitude != 0 || ctx->right_motor_amplitude != 0) && SDL_GetTicks() >= (ctx->last_rumble_time + RUMBLE_REFRESH_INTERVAL_MS)) { - ctx->rumble_update_pending = SDL_TRUE; + ctx->rumble_update_pending = true; HIDAPI_DriverShield_SendNextRumble(device); } @@ -551,7 +551,7 @@ static void HIDAPI_DriverShield_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverShield = { SDL_HINT_JOYSTICK_HIDAPI_SHIELD, - SDL_TRUE, + true, HIDAPI_DriverShield_RegisterHints, HIDAPI_DriverShield_UnregisterHints, HIDAPI_DriverShield_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index 8584a1e38f..ccc9f1a9ab 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -40,7 +40,7 @@ enum typedef struct { - SDL_bool rumble_supported; + bool rumble_supported; Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverStadia_Context; @@ -54,23 +54,23 @@ static void HIDAPI_DriverStadia_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STADIA, callback, userdata); } -static SDL_bool HIDAPI_DriverStadia_IsEnabled(void) +static bool HIDAPI_DriverStadia_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STADIA, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverStadia_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverStadia_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return SDL_IsJoystickGoogleStadiaController(vendor_id, product_id); } -static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverStadia_Context *ctx; ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } device->context = ctx; @@ -79,7 +79,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) Uint8 rumble_packet[] = { 0x05, 0x00, 0x00, 0x00, 0x00 }; if (SDL_hid_write(device->dev, rumble_packet, sizeof(rumble_packet)) >= 0) { - ctx->rumble_supported = SDL_TRUE; + ctx->rumble_supported = true; } } @@ -97,7 +97,7 @@ static void HIDAPI_DriverStadia_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, { } -static SDL_bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverStadia_Context *ctx = (SDL_DriverStadia_Context *)device->context; @@ -110,7 +110,7 @@ static SDL_bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; - return SDL_TRUE; + return true; } static int HIDAPI_DriverStadia_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -161,7 +161,7 @@ static int HIDAPI_DriverStadia_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL return SDL_Unsupported(); } -static int HIDAPI_DriverStadia_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverStadia_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -258,7 +258,7 @@ static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverStadia_Context *ctx = (SDL_DriverStadia_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -268,7 +268,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -299,7 +299,7 @@ static void HIDAPI_DriverStadia_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia = { SDL_HINT_JOYSTICK_HIDAPI_STADIA, - SDL_TRUE, + true, HIDAPI_DriverStadia_RegisterHints, HIDAPI_DriverStadia_UnregisterHints, HIDAPI_DriverStadia_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 08b22a84dc..2be41e9baa 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -29,10 +29,6 @@ /*****************************************************************************************************/ -#define bool SDL_bool -#define true SDL_TRUE -#define false SDL_FALSE - #include "steam/controller_constants.h" #include "steam/controller_structs.h" @@ -941,7 +937,7 @@ static bool UpdateSteamControllerState(const uint8_t *pData, int nDataSize, Stea typedef struct { - SDL_bool report_sensors; + bool report_sensors; uint32_t update_rate_in_us; Uint64 sensor_timestamp; @@ -960,23 +956,23 @@ static void HIDAPI_DriverSteam_UnregisterHints(SDL_HintCallback callback, void * SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAM, callback, userdata); } -static SDL_bool HIDAPI_DriverSteam_IsEnabled(void) +static bool HIDAPI_DriverSteam_IsEnabled(void) { - return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAM, false); } -static SDL_bool HIDAPI_DriverSteam_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverSteam_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { return SDL_IsJoystickSteamController(vendor_id, product_id); } -static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverSteam_Context *ctx; ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } device->context = ctx; @@ -1002,21 +998,21 @@ static void HIDAPI_DriverSteam_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, S { } -static SDL_bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; float update_rate_in_hz = 0.0f; SDL_AssertJoysticksLocked(); - ctx->report_sensors = SDL_FALSE; + ctx->report_sensors = false; SDL_zero(ctx->m_assembler); SDL_zero(ctx->m_state); SDL_zero(ctx->m_last_state); if (!ResetSteamController(device->dev, false, &ctx->update_rate_in_us)) { SDL_SetError("Couldn't reset controller"); - return SDL_FALSE; + return false; } if (ctx->update_rate_in_us > 0) { update_rate_in_hz = 1000000.0f / ctx->update_rate_in_us; @@ -1032,7 +1028,7 @@ static SDL_bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_J SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, update_rate_in_hz); SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, update_rate_in_hz); - return SDL_TRUE; + return true; } static int HIDAPI_DriverSteam_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -1063,7 +1059,7 @@ static int HIDAPI_DriverSteam_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_ return SDL_Unsupported(); } -static int HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; unsigned char buf[65]; @@ -1086,7 +1082,7 @@ static int HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_J return 0; } -static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1094,7 +1090,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } for (;;) { @@ -1203,10 +1199,10 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) if (r <= 0) { // Failed to read from controller HIDAPI_JoystickDisconnected(device, device->joysticks[0]); - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } static void HIDAPI_DriverSteam_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) @@ -1220,7 +1216,7 @@ static void HIDAPI_DriverSteam_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam = { SDL_HINT_JOYSTICK_HIDAPI_STEAM, - SDL_TRUE, + true, HIDAPI_DriverSteam_RegisterHints, HIDAPI_DriverSteam_UnregisterHints, HIDAPI_DriverSteam_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_steamdeck.c b/src/joystick/hidapi/SDL_hidapi_steamdeck.c index c3673a76d5..7992383c1c 100644 --- a/src/joystick/hidapi/SDL_hidapi_steamdeck.c +++ b/src/joystick/hidapi/SDL_hidapi_steamdeck.c @@ -79,7 +79,7 @@ typedef struct Uint8 watchdog_counter; } SDL_DriverSteamDeck_Context; -static SDL_bool DisableDeckLizardMode(SDL_hid_device *dev) +static bool DisableDeckLizardMode(SDL_hid_device *dev) { int rc; Uint8 buffer[HID_FEATURE_REPORT_BYTES + 1] = { 0 }; @@ -89,7 +89,7 @@ static SDL_bool DisableDeckLizardMode(SDL_hid_device *dev) rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); if (rc != sizeof(buffer)) - return SDL_FALSE; + return false; msg->header.type = ID_SET_SETTINGS_VALUES; msg->header.length = 5 * sizeof(ControllerSetting); @@ -106,16 +106,16 @@ static SDL_bool DisableDeckLizardMode(SDL_hid_device *dev) rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); if (rc != sizeof(buffer)) - return SDL_FALSE; + return false; // There may be a lingering report read back after changing settings. // Discard it. SDL_hid_get_feature_report(dev, buffer, sizeof(buffer)); - return SDL_TRUE; + return true; } -static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev) +static bool FeedDeckLizardWatchdog(SDL_hid_device *dev) { int rc; Uint8 buffer[HID_FEATURE_REPORT_BYTES + 1] = { 0 }; @@ -125,7 +125,7 @@ static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev) rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); if (rc != sizeof(buffer)) - return SDL_FALSE; + return false; msg->header.type = ID_SET_SETTINGS_VALUES; msg->header.length = 1 * sizeof(ControllerSetting); @@ -134,13 +134,13 @@ static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev) rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); if (rc != sizeof(buffer)) - return SDL_FALSE; + return false; // There may be a lingering report read back after changing settings. // Discard it. SDL_hid_get_feature_report(dev, buffer, sizeof(buffer)); - return SDL_TRUE; + return true; } static void HIDAPI_DriverSteamDeck_HandleState(SDL_HIDAPI_Device *device, @@ -247,13 +247,13 @@ static void HIDAPI_DriverSteamDeck_UnregisterHints(SDL_HintCallback callback, vo SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata); } -static SDL_bool HIDAPI_DriverSteamDeck_IsEnabled(void) +static bool HIDAPI_DriverSteamDeck_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverSteamDeck_IsSupportedDevice( +static bool HIDAPI_DriverSteamDeck_IsSupportedDevice( SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, @@ -268,7 +268,7 @@ static SDL_bool HIDAPI_DriverSteamDeck_IsSupportedDevice( return SDL_IsJoystickSteamDeck(vendor_id, product_id); } -static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device) { int size; Uint8 data[64]; @@ -276,7 +276,7 @@ static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device) ctx = (SDL_DriverSteamDeck_Context *)SDL_calloc(1, sizeof(*ctx)); if (ctx == NULL) { - return SDL_FALSE; + return false; } // Always 1kHz according to USB descriptor, but actually about 4 ms. @@ -289,10 +289,10 @@ static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device) // only the controller hidraw device receives hid reports. size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16); if (size == 0) - return SDL_FALSE; + return false; if (!DisableDeckLizardMode(device->dev)) - return SDL_FALSE; + return false; HIDAPI_SetDeviceName(device, "Steam Deck"); @@ -308,7 +308,7 @@ static void HIDAPI_DriverSteamDeck_SetDevicePlayerIndex(SDL_HIDAPI_Device *devic { } -static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -319,16 +319,16 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); if (joystick == NULL) { - return SDL_FALSE; + return false; } } else { - return SDL_FALSE; + return false; } if (ctx->watchdog_counter++ > 200) { ctx->watchdog_counter = 0; if (!FeedDeckLizardWatchdog(device->dev)) - return SDL_FALSE; + return false; } SDL_memset(data, 0, sizeof(data)); @@ -339,7 +339,7 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) if (r < 0) { // Failed to read from controller HIDAPI_JoystickDisconnected(device, device->joysticks[0]); - return SDL_FALSE; + return false; } else if (r == 64 && pInReport->header.unReportVersion == k_ValveInReportMsgVersion && pInReport->header.ucType == ID_CONTROLLER_DECK_STATE && @@ -348,10 +348,10 @@ static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) } } while (r > 0); - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_DriverSteamDeck_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverSteamDeck_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context; float update_rate_in_hz = 1.0f / (float)(ctx->update_rate_us) * 1.0e6f; @@ -366,7 +366,7 @@ static SDL_bool HIDAPI_DriverSteamDeck_OpenJoystick(SDL_HIDAPI_Device *device, S SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, update_rate_in_hz); SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, update_rate_in_hz); - return SDL_TRUE; + return true; } static int HIDAPI_DriverSteamDeck_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -409,7 +409,7 @@ static int HIDAPI_DriverSteamDeck_SendJoystickEffect(SDL_HIDAPI_Device *device, return SDL_Unsupported(); } -static int HIDAPI_DriverSteamDeck_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverSteamDeck_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { // On steam deck, sensors are enabled by default. Nothing to do here. return 0; @@ -426,7 +426,7 @@ static void HIDAPI_DriverSteamDeck_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteamDeck = { SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, - SDL_TRUE, + true, HIDAPI_DriverSteamDeck_RegisterHints, HIDAPI_DriverSteamDeck_UnregisterHints, HIDAPI_DriverSteamDeck_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 6f67d8358d..99d76ac5e2 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -272,11 +272,11 @@ typedef struct { SDL_HIDAPI_Device *device; SDL_Joystick *joystick; - SDL_bool m_bInputOnly; - SDL_bool m_bUseButtonLabels; - SDL_bool m_bPlayerLights; + bool m_bInputOnly; + bool m_bUseButtonLabels; + bool m_bPlayerLights; int m_nPlayerIndex; - SDL_bool m_bSyncWrite; + bool m_bSyncWrite; int m_nMaxWriteAttempts; ESwitchDeviceInfoControllerType m_eControllerType; Uint8 m_nInitialInputMode; @@ -285,20 +285,20 @@ typedef struct Uint8 m_nCommandNumber; SwitchCommonOutputPacket_t m_RumblePacket; Uint8 m_rgucReadBuffer[k_unSwitchMaxOutputPacketLength]; - SDL_bool m_bRumbleActive; + bool m_bRumbleActive; Uint64 m_ulRumbleSent; - SDL_bool m_bRumblePending; - SDL_bool m_bRumbleZeroPending; + bool m_bRumblePending; + bool m_bRumbleZeroPending; Uint32 m_unRumblePending; - SDL_bool m_bReportSensors; - SDL_bool m_bHasSensorData; + bool m_bReportSensors; + bool m_bHasSensorData; Uint64 m_ulLastInput; Uint64 m_ulLastIMUReset; Uint64 m_ulIMUSampleTimestampNS; Uint32 m_unIMUSamples; Uint64 m_ulIMUUpdateIntervalNS; Uint64 m_ulTimestampNS; - SDL_bool m_bVerticalMode; + bool m_bVerticalMode; SwitchInputOnlyControllerStatePacket_t m_lastInputOnlyState; SwitchSimpleStatePacket_t m_lastSimpleState; @@ -399,7 +399,7 @@ static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Conte return NULL; } -static SDL_bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchProprietaryCommandIDs expectedID) +static bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchProprietaryCommandIDs expectedID) { // Average response time for messages is ~30ms Uint64 endTicks = SDL_GetTicks() + 100; @@ -408,7 +408,7 @@ static SDL_bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchPropr while ((nRead = ReadInput(ctx)) != -1) { if (nRead > 0) { if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_CommandAck && ctx->m_rgucReadBuffer[1] == expectedID) { - return SDL_TRUE; + return true; } } else { SDL_Delay(1); @@ -418,7 +418,7 @@ static SDL_bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchPropr break; } } - return SDL_FALSE; + return false; } static void ConstructSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, const Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandOutputPacket_t *outPacket) @@ -438,13 +438,13 @@ static void ConstructSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand ctx->m_nCommandNumber = (ctx->m_nCommandNumber + 1) & 0xF; } -static SDL_bool WritePacket(SDL_DriverSwitch_Context *ctx, void *pBuf, Uint8 ucLen) +static bool WritePacket(SDL_DriverSwitch_Context *ctx, void *pBuf, Uint8 ucLen) { Uint8 rgucBuf[k_unSwitchMaxOutputPacketLength]; const size_t unWriteSize = ctx->device->is_bluetooth ? k_unSwitchBluetoothPacketLength : k_unSwitchUSBPacketLength; if (ucLen > k_unSwitchOutputPacketDataLength) { - return SDL_FALSE; + return false; } if (ucLen < unWriteSize) { @@ -460,7 +460,7 @@ static SDL_bool WritePacket(SDL_DriverSwitch_Context *ctx, void *pBuf, Uint8 ucL } } -static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, const Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandInputPacket_t **ppReply) +static bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, const Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandInputPacket_t **ppReply) { SwitchSubcommandInputPacket_t *reply = NULL; int nTries; @@ -482,7 +482,7 @@ static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand return reply != NULL; } -static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprietaryCommandIDs ucCommand, Uint8 *pBuf, Uint8 ucLen, SDL_bool waitForReply) +static bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprietaryCommandIDs ucCommand, Uint8 *pBuf, Uint8 ucLen, bool waitForReply) { int nTries; @@ -490,7 +490,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta SwitchProprietaryOutputPacket_t packet; if ((!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { - return SDL_FALSE; + return false; } SDL_zero(packet); @@ -506,11 +506,11 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta if (!waitForReply || ReadProprietaryReply(ctx, ucCommand)) { // SDL_Log("Succeeded%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); - return SDL_TRUE; + return true; } } // SDL_Log("Failed%s after %d tries\n", ctx->m_bSyncWrite ? " (sync)" : "", nTries); - return SDL_FALSE; + return false; } static Uint8 EncodeRumbleHighAmplitude(Uint16 amplitude) @@ -572,7 +572,7 @@ static void EncodeRumble(SwitchRumbleData_t *pRumble, Uint16 usHighFreq, Uint8 u } } -static SDL_bool WriteRumble(SDL_DriverSwitch_Context *ctx) +static bool WriteRumble(SDL_DriverSwitch_Context *ctx) { /* Write into m_RumblePacket rather than a temporary buffer to allow the current rumble state * to be retained for subsequent rumble or subcommand packets sent to the controller @@ -610,7 +610,7 @@ static ESwitchDeviceInfoControllerType CalculateControllerType(SDL_DriverSwitch_ return eControllerType; } -static SDL_bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx) +static bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx) { SwitchSubcommandInputPacket_t *reply = NULL; @@ -622,10 +622,10 @@ static SDL_bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx) // Bytes 4-9: MAC address (big-endian) SDL_memcpy(ctx->m_rgucMACAddress, reply->deviceInfo.rgucMACAddress, sizeof(ctx->m_rgucMACAddress)); - return SDL_TRUE; + return true; } } else { - if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) { + if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, true)) { SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0]; size_t i; @@ -635,41 +635,41 @@ static SDL_bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx) ctx->m_rgucMACAddress[i] = status->rgucMACAddress[sizeof(ctx->m_rgucMACAddress) - i - 1]; } - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) +static bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) { /* We have to send a connection handshake to the controller when communicating over USB * before we're able to send it other commands. Luckily this command is not supported * over Bluetooth, so we can use the controller's lack of response as a way to * determine if the connection is over USB or Bluetooth */ - if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) { - return SDL_FALSE; + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, true)) { + return false; } - if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_HighSpeed, NULL, 0, SDL_TRUE)) { + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_HighSpeed, NULL, 0, true)) { // The 8BitDo M30 and SF30 Pro don't respond to this command, but otherwise work correctly - // return SDL_FALSE; + // return false; } - if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) { + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, true)) { // This fails on the right Joy-Con when plugged into the charging grip - // return SDL_FALSE; + // return false; } - if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE)) { - return SDL_FALSE; + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, false)) { + return false; } - return SDL_TRUE; + return true; } -static SDL_bool SetVibrationEnabled(SDL_DriverSwitch_Context *ctx, Uint8 enabled) +static bool SetVibrationEnabled(SDL_DriverSwitch_Context *ctx, Uint8 enabled) { return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableVibration, &enabled, sizeof(enabled), NULL); } -static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) +static bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) { #ifdef FORCE_SIMPLE_REPORTS input_mode = k_eSwitchInputReportIDs_SimpleControllerState; @@ -679,7 +679,7 @@ static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) #endif if (input_mode == ctx->m_nCurrentInputMode) { - return SDL_TRUE; + return true; } else { ctx->m_nCurrentInputMode = input_mode; @@ -687,7 +687,7 @@ static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) } } -static SDL_bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness) +static bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness) { Uint8 ucLedIntensity = 0; Uint8 rgucBuffer[4]; @@ -720,7 +720,7 @@ static void SDLCALL SDL_HomeLEDHintChanged(void *userdata, const char *name, con if (value > 255) { value = 255; } - } else if (SDL_GetStringBoolean(hint, SDL_TRUE)) { + } else if (SDL_GetStringBoolean(hint, true)) { value = 100; } else { value = 0; @@ -744,7 +744,7 @@ static void UpdateSlotLED(SDL_DriverSwitch_Context *ctx) static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)userdata; - SDL_bool bPlayerLights = SDL_GetStringBoolean(hint, SDL_TRUE); + bool bPlayerLights = SDL_GetStringBoolean(hint, true); if (bPlayerLights != ctx->m_bPlayerLights) { ctx->m_bPlayerLights = bPlayerLights; @@ -813,13 +813,13 @@ static Uint8 GetSensorInputMode(SDL_DriverSwitch_Context *ctx) return input_mode; } -static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, SDL_bool enabled) +static bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, bool enabled) { Uint8 imu_data = enabled ? 1 : 0; return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL); } -static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) +static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) { Uint8 *pLeftStickCal; Uint8 *pRightStickCal; @@ -841,7 +841,7 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) readFactoryParams.ucLength = k_unSPIStickFactoryCalibrationLength; if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) { - return SDL_FALSE; + return false; } // Automatically select the user calibration if magic bytes are set @@ -908,10 +908,10 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx) } } - return SDL_TRUE; + return true; } -static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) +static bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) { SwitchSubcommandInputPacket_t *reply = NULL; @@ -973,7 +973,7 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx) ctx->m_IMUScaleData.fGyroScaleY = gyroScale; ctx->m_IMUScaleData.fGyroScaleZ = gyroScale; } - return SDL_TRUE; + return true; } static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue) @@ -1048,7 +1048,7 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); if (ctx) { ctx->device = device; - ctx->m_bSyncWrite = SDL_TRUE; + ctx->m_bSyncWrite = true; ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device); for ( ; ; ) { @@ -1060,7 +1060,7 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType); } } else { - if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) { + if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, true)) { SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0]; eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)status->ucDeviceType); @@ -1078,41 +1078,41 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic return eControllerType; } -static SDL_bool HasHomeLED(SDL_DriverSwitch_Context *ctx) +static bool HasHomeLED(SDL_DriverSwitch_Context *ctx) { Uint16 vendor_id = ctx->device->vendor_id; Uint16 product_id = ctx->device->product_id; // The Power A Nintendo Switch Pro controllers don't have a Home LED if (vendor_id == 0 && product_id == 0) { - return SDL_FALSE; + return false; } // HORI Wireless Switch Pad if (vendor_id == 0x0f0d && product_id == 0x00f6) { - return SDL_FALSE; + return false; } // Third party controllers don't have a home LED and will shut off if we try to set it if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_Unknown || ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_LicProController) { - return SDL_FALSE; + return false; } // The Nintendo Online classic controllers don't have a Home LED if (vendor_id == USB_VENDOR_NINTENDO && ctx->m_eControllerType > k_eSwitchDeviceInfoControllerType_ProController) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } -static SDL_bool AlwaysUsesLabels(Uint16 vendor_id, Uint16 product_id, ESwitchDeviceInfoControllerType eControllerType) +static bool AlwaysUsesLabels(Uint16 vendor_id, Uint16 product_id, ESwitchDeviceInfoControllerType eControllerType) { // Some controllers don't have a diamond button configuration, so should always use labels if (SDL_IsJoystickGameCube(vendor_id, product_id)) { - return SDL_TRUE; + return true; } switch (eControllerType) { case k_eSwitchDeviceInfoControllerType_HVCLeft: @@ -1121,9 +1121,9 @@ static SDL_bool AlwaysUsesLabels(Uint16 vendor_id, Uint16 product_id, ESwitchDev case k_eSwitchDeviceInfoControllerType_NESRight: case k_eSwitchDeviceInfoControllerType_N64: case k_eSwitchDeviceInfoControllerType_SEGA_Genesis: - return SDL_TRUE; + return true; default: - return SDL_FALSE; + return false; } } @@ -1137,35 +1137,35 @@ static void HIDAPI_DriverNintendoClassic_UnregisterHints(SDL_HintCallback callba SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, callback, userdata); } -static SDL_bool HIDAPI_DriverNintendoClassic_IsEnabled(void) +static bool HIDAPI_DriverNintendoClassic_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO) { if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) { if (SDL_strncmp(name, "NES Controller", 14) == 0 || SDL_strncmp(name, "HVC Controller", 14) == 0) { - return SDL_TRUE; + return true; } } if (product_id == USB_PRODUCT_NINTENDO_N64_CONTROLLER) { - return SDL_TRUE; + return true; } if (product_id == USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER) { - return SDL_TRUE; + return true; } if (product_id == USB_PRODUCT_NINTENDO_SNES_CONTROLLER) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void HIDAPI_DriverJoyCons_RegisterHints(SDL_HintCallback callback, void *userdata) @@ -1178,12 +1178,12 @@ static void HIDAPI_DriverJoyCons_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, callback, userdata); } -static SDL_bool HIDAPI_DriverJoyCons_IsEnabled(void) +static bool HIDAPI_DriverJoyCons_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO) { if (product_id == USB_PRODUCT_NINTENDO_SWITCH_PRO && device && device->dev) { @@ -1191,17 +1191,17 @@ static SDL_bool HIDAPI_DriverJoyCons_IsSupportedDevice(SDL_HIDAPI_Device *device ESwitchDeviceInfoControllerType eControllerType = ReadJoyConControllerType(device); if (eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft || eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { - return SDL_TRUE; + return true; } } if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT || product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT || product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_GRIP) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void HIDAPI_DriverSwitch_RegisterHints(SDL_HintCallback callback, void *userdata) @@ -1214,12 +1214,12 @@ static void HIDAPI_DriverSwitch_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, callback, userdata); } -static SDL_bool HIDAPI_DriverSwitch_IsEnabled(void) +static bool HIDAPI_DriverSwitch_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); } -static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { /* The HORI Wireless Switch Pad enumerates as a HID device when connected via USB with the same VID/PID as when connected over Bluetooth but doesn't actually @@ -1228,13 +1228,13 @@ static SDL_bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, Note that the controller does have a different product string when connected over Bluetooth. */ if (SDL_strcmp(name, "HORI Wireless Switch Pad") == 0) { - return SDL_FALSE; + return false; } // If it's handled by another driver, it's not handled here if (HIDAPI_DriverNintendoClassic_IsSupportedDevice(device, name, type, vendor_id, product_id, version, interface_number, interface_class, interface_subclass, interface_protocol) || HIDAPI_DriverJoyCons_IsSupportedDevice(device, name, type, vendor_id, product_id, version, interface_number, interface_class, interface_subclass, interface_protocol)) { - return SDL_FALSE; + return false; } return (type == SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO); @@ -1340,19 +1340,19 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) } } -static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverSwitch_Context *ctx; ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; device->context = ctx; ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device); - ctx->m_bSyncWrite = SDL_TRUE; + ctx->m_bSyncWrite = true; // Find out whether or not we can send output reports ctx->m_bInputOnly = SDL_IsJoystickNintendoSwitchProInputOnly(device->vendor_id, device->product_id); @@ -1368,7 +1368,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) // Prefer the USB device over the Bluetooth device if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { - return SDL_TRUE; + return true; } } else { HIDAPI_DisconnectBluetoothDevice(device->serial); @@ -1394,7 +1394,7 @@ static void HIDAPI_DriverSwitch_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, UpdateSlotLED(ctx); } -static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; @@ -1402,7 +1402,7 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->joystick = joystick; - ctx->m_bSyncWrite = SDL_TRUE; + ctx->m_bSyncWrite = true; if (!ctx->m_bInputOnly) { GetInitialInputMode(ctx); @@ -1415,13 +1415,13 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ if (!device->is_bluetooth) { if (!BTrySetupUSB(ctx)) { SDL_SetError("Couldn't setup USB mode"); - return SDL_FALSE; + return false; } } if (!LoadStickCalibration(ctx)) { SDL_SetError("Couldn't load stick calibration"); - return SDL_FALSE; + return false; } if (ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCLeft && @@ -1453,21 +1453,21 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ if (!SetVibrationEnabled(ctx, 1)) { SDL_SetError("Couldn't enable vibration"); - return SDL_FALSE; + return false; } // Set desired input mode if (!SetInputMode(ctx, GetDefaultInputMode(ctx))) { SDL_SetError("Couldn't set input mode"); - return SDL_FALSE; + return false; } // Start sending USB reports if (!device->is_bluetooth) { // ForceUSB doesn't generate an ACK, so don't wait for a reply - if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE)) { + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, false)) { SDL_SetError("Couldn't start USB reports"); - return SDL_FALSE; + return false; } } @@ -1485,12 +1485,12 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ } if (AlwaysUsesLabels(device->vendor_id, device->product_id, ctx->m_eControllerType)) { - ctx->m_bUseButtonLabels = SDL_TRUE; + ctx->m_bUseButtonLabels = true; } // Initialize player index (needed for setting LEDs) ctx->m_nPlayerIndex = SDL_GetJoystickPlayerIndex(joystick); - ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED, SDL_TRUE); + ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED, true); UpdateSlotLED(ctx); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED, @@ -1502,14 +1502,14 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ joystick->nhats = 1; // Set up for input - ctx->m_bSyncWrite = SDL_FALSE; + ctx->m_bSyncWrite = false; ctx->m_ulLastIMUReset = ctx->m_ulLastInput = SDL_GetTicks(); ctx->m_ulIMUUpdateIntervalNS = SDL_MS_TO_NS(5); // Start off at 5 ms update rate // Set up for vertical mode - ctx->m_bVerticalMode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, SDL_FALSE); + ctx->m_bVerticalMode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS, false); - return SDL_TRUE; + return true; } static int HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -1554,14 +1554,14 @@ static int HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) #ifdef DEBUG_RUMBLE SDL_Log("Sent pending rumble %d/%d, %d ms after previous rumble\n", low_frequency_rumble, high_frequency_rumble, SDL_GetTicks() - ctx->m_ulRumbleSent); #endif - ctx->m_bRumblePending = SDL_FALSE; + ctx->m_bRumblePending = false; ctx->m_unRumblePending = 0; return HIDAPI_DriverSwitch_ActuallyRumbleJoystick(ctx, low_frequency_rumble, high_frequency_rumble); } if (ctx->m_bRumbleZeroPending) { - ctx->m_bRumbleZeroPending = SDL_FALSE; + ctx->m_bRumbleZeroPending = false; #ifdef DEBUG_RUMBLE SDL_Log("Sent pending zero rumble, %d ms after previous rumble\n", SDL_GetTicks() - ctx->m_ulRumbleSent); @@ -1604,11 +1604,11 @@ static int HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy if (unRumblePending > ctx->m_unRumblePending) { ctx->m_unRumblePending = unRumblePending; } - ctx->m_bRumblePending = SDL_TRUE; - ctx->m_bRumbleZeroPending = SDL_FALSE; + ctx->m_bRumblePending = true; + ctx->m_bRumbleZeroPending = false; } else { // When rumble is complete, turn it off - ctx->m_bRumbleZeroPending = SDL_TRUE; + ctx->m_bRumbleZeroPending = true; } return 0; } @@ -1667,8 +1667,8 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL } // This overwrites any internal rumble - ctx->m_bRumblePending = SDL_FALSE; - ctx->m_bRumbleZeroPending = SDL_FALSE; + ctx->m_bRumblePending = false; + ctx->m_bRumbleZeroPending = false; return 0; } else if (size >= 2 && size <= 256) { const Uint8 *payload = (const Uint8 *)data; @@ -1691,7 +1691,7 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL return SDL_Unsupported(); } -static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; Uint8 input_mode; @@ -2461,14 +2461,14 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_SendJoystickPowerInfo(joystick, state, percent); if (ctx->m_bReportSensors) { - SDL_bool bHasSensorData = (packet->imuState[0].sAccelZ != 0 || + bool bHasSensorData = (packet->imuState[0].sAccelZ != 0 || packet->imuState[0].sAccelY != 0 || packet->imuState[0].sAccelX != 0); if (bHasSensorData) { const Uint32 IMU_UPDATE_RATE_SAMPLE_FREQUENCY = 1000; Uint64 sensor_timestamp[3]; - ctx->m_bHasSensorData = SDL_TRUE; + ctx->m_bHasSensorData = true; // We got three IMU samples, calculate the IMU update rate and timestamps ctx->m_unIMUSamples += 3; @@ -2537,7 +2537,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_UnlockMutex(device->dev_lock); } - SetIMUEnabled(ctx, SDL_TRUE); + SetIMUEnabled(ctx, true); if (device->updating) { SDL_LockMutex(device->dev_lock); @@ -2553,7 +2553,7 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C ctx->m_lastFullState = *packet; } -static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -2606,10 +2606,10 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) const int INPUT_WAIT_TIMEOUT_MS = 100; if (now >= (ctx->m_ulLastInput + INPUT_WAIT_TIMEOUT_MS)) { // Steam may have put the controller back into non-reporting mode - SDL_bool wasSyncWrite = ctx->m_bSyncWrite; + bool wasSyncWrite = ctx->m_bSyncWrite; - ctx->m_bSyncWrite = SDL_TRUE; - WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE); + ctx->m_bSyncWrite = true; + WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, false); ctx->m_bSyncWrite = wasSyncWrite; } } else if (device->is_bluetooth && @@ -2679,7 +2679,7 @@ static void HIDAPI_DriverSwitch_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverNintendoClassic = { SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC, - SDL_TRUE, + true, HIDAPI_DriverNintendoClassic_RegisterHints, HIDAPI_DriverNintendoClassic_UnregisterHints, HIDAPI_DriverNintendoClassic_IsEnabled, @@ -2701,7 +2701,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverNintendoClassic = { SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons = { SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, - SDL_TRUE, + true, HIDAPI_DriverJoyCons_RegisterHints, HIDAPI_DriverJoyCons_UnregisterHints, HIDAPI_DriverJoyCons_IsEnabled, @@ -2723,7 +2723,7 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverJoyCons = { SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch = { SDL_HINT_JOYSTICK_HIDAPI_SWITCH, - SDL_TRUE, + true, HIDAPI_DriverSwitch_RegisterHints, HIDAPI_DriverSwitch_UnregisterHints, HIDAPI_DriverSwitch_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 62556b8f49..2e60081cf4 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -33,7 +33,7 @@ // Define this if you want to log all packets from the controller // #define DEBUG_WII_PROTOCOL -#define ENABLE_CONTINUOUS_REPORTING SDL_TRUE +#define ENABLE_CONTINUOUS_REPORTING true #define INPUT_WAIT_TIMEOUT_MS (3 * 1000) #define MOTION_PLUS_UPDATE_TIME_MS (8 * 1000) @@ -123,8 +123,8 @@ typedef struct Uint8 rgucBaseButtons[2]; Uint8 rgucAccelerometer[3]; Uint8 rgucExtension[21]; - SDL_bool hasBaseButtons; - SDL_bool hasAccelerometer; + bool hasBaseButtons; + bool hasAccelerometer; Uint8 ucNExtensionBytes; } WiiButtonData; @@ -143,17 +143,17 @@ typedef struct Uint64 timestamp; EWiiCommunicationState m_eCommState; EWiiExtensionControllerType m_eExtensionControllerType; - SDL_bool m_bPlayerLights; + bool m_bPlayerLights; int m_nPlayerIndex; - SDL_bool m_bRumbleActive; - SDL_bool m_bMotionPlusPresent; + bool m_bRumbleActive; + bool m_bMotionPlusPresent; Uint8 m_ucMotionPlusMode; - SDL_bool m_bReportSensors; + bool m_bReportSensors; Uint8 m_rgucReadBuffer[k_unWiiPacketDataLength]; Uint64 m_ulLastInput; Uint64 m_ulLastStatus; Uint64 m_ulNextMotionPlusCheck; - SDL_bool m_bDisconnected; + bool m_bDisconnected; StickCalibrationData m_StickCalibrationData[6]; } SDL_DriverWii_Context; @@ -168,10 +168,10 @@ static void HIDAPI_DriverWii_UnregisterHints(SDL_HintCallback callback, void *us SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII, callback, userdata); } -static SDL_bool HIDAPI_DriverWii_IsEnabled(void) +static bool HIDAPI_DriverWii_IsEnabled(void) { #if 1 // This doesn't work with the dolphinbar, so don't enable by default right now - return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII, false); #else return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, @@ -179,14 +179,14 @@ static SDL_bool HIDAPI_DriverWii_IsEnabled(void) #endif } -static SDL_bool HIDAPI_DriverWii_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverWii_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { if (vendor_id == USB_VENDOR_NINTENDO && (product_id == USB_PRODUCT_NINTENDO_WII_REMOTE || product_id == USB_PRODUCT_NINTENDO_WII_REMOTE2)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static int ReadInput(SDL_DriverWii_Context *ctx) @@ -207,7 +207,7 @@ static int ReadInput(SDL_DriverWii_Context *ctx) return size; } -static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int size, SDL_bool sync) +static bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int size, bool sync) { #ifdef DEBUG_WII_PROTOCOL if (size > 0) { @@ -219,13 +219,13 @@ static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int s } else { // Use the rumble thread for general asynchronous writes if (SDL_HIDAPI_LockRumble() < 0) { - return SDL_FALSE; + return false; } return SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) >= 0; } } -static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs expectedID, SDL_bool (*isMine)(const Uint8 *)) +static bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs expectedID, bool (*isMine)(const Uint8 *)) { Uint64 endTicks = SDL_GetTicks() + 250; // Seeing successful reads after about 200 ms @@ -233,7 +233,7 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp while ((nRead = ReadInput(ctx)) != -1) { if (nRead > 0) { if (ctx->m_rgucReadBuffer[0] == expectedID && (!isMine || isMine(ctx->m_rgucReadBuffer))) { - return SDL_TRUE; + return true; } } else { if (SDL_GetTicks() >= endTicks) { @@ -243,15 +243,15 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp } } SDL_SetError("Read timed out"); - return SDL_FALSE; + return false; } -static SDL_bool IsWriteMemoryResponse(const Uint8 *data) +static bool IsWriteMemoryResponse(const Uint8 *data) { return data[3] == k_eWiiOutputReportIDs_WriteMemory; } -static SDL_bool WriteRegister(SDL_DriverWii_Context *ctx, Uint32 address, const Uint8 *data, int size, SDL_bool sync) +static bool WriteRegister(SDL_DriverWii_Context *ctx, Uint32 address, const Uint8 *data, int size, bool sync) { Uint8 writeRequest[k_unWiiPacketDataLength]; @@ -266,22 +266,22 @@ static SDL_bool WriteRegister(SDL_DriverWii_Context *ctx, Uint32 address, const SDL_memcpy(writeRequest + 6, data, size); if (!WriteOutput(ctx, writeRequest, sizeof(writeRequest), sync)) { - return SDL_FALSE; + return false; } if (sync) { // Wait for response if (!ReadInputSync(ctx, k_eWiiInputReportIDs_Acknowledge, IsWriteMemoryResponse)) { - return SDL_FALSE; + return false; } if (ctx->m_rgucReadBuffer[4]) { SDL_SetError("Write memory failed: %u", ctx->m_rgucReadBuffer[4]); - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } -static SDL_bool ReadRegister(SDL_DriverWii_Context *ctx, Uint32 address, int size, SDL_bool sync) +static bool ReadRegister(SDL_DriverWii_Context *ctx, Uint32 address, int size, bool sync) { Uint8 readRequest[7]; @@ -296,35 +296,35 @@ static SDL_bool ReadRegister(SDL_DriverWii_Context *ctx, Uint32 address, int siz SDL_assert(size > 0 && size <= 0xffff); if (!WriteOutput(ctx, readRequest, sizeof(readRequest), sync)) { - return SDL_FALSE; + return false; } if (sync) { SDL_assert(size <= 16); // Only waiting for one packet is supported right now // Wait for response if (!ReadInputSync(ctx, k_eWiiInputReportIDs_ReadMemory, NULL)) { - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } -static SDL_bool SendExtensionIdentify(SDL_DriverWii_Context *ctx, SDL_bool sync) +static bool SendExtensionIdentify(SDL_DriverWii_Context *ctx, bool sync) { return ReadRegister(ctx, 0xA400FE, 2, sync); } -static SDL_bool ParseExtensionIdentifyResponse(SDL_DriverWii_Context *ctx, Uint16 *extension) +static bool ParseExtensionIdentifyResponse(SDL_DriverWii_Context *ctx, Uint16 *extension) { int i; if (ctx->m_rgucReadBuffer[0] != k_eWiiInputReportIDs_ReadMemory) { SDL_SetError("Unexpected extension response type"); - return SDL_FALSE; + return false; } if (ctx->m_rgucReadBuffer[4] != 0x00 || ctx->m_rgucReadBuffer[5] != 0xFE) { SDL_SetError("Unexpected extension response address"); - return SDL_FALSE; + return false; } if (ctx->m_rgucReadBuffer[3] != 0x10) { @@ -333,7 +333,7 @@ static SDL_bool ParseExtensionIdentifyResponse(SDL_DriverWii_Context *ctx, Uint1 if (error == 7) { // The extension memory isn't mapped *extension = WII_EXTENSION_NONE; - return SDL_TRUE; + return true; } if (error) { @@ -341,14 +341,14 @@ static SDL_bool ParseExtensionIdentifyResponse(SDL_DriverWii_Context *ctx, Uint1 } else { SDL_SetError("Unexpected read length when reading extension type: %d", (ctx->m_rgucReadBuffer[3] >> 4) + 1); } - return SDL_FALSE; + return false; } *extension = 0; for (i = 6; i < 8; i++) { *extension = *extension << 8 | ctx->m_rgucReadBuffer[i]; } - return SDL_TRUE; + return true; } static EWiiExtensionControllerType GetExtensionType(Uint16 extension_id) @@ -367,9 +367,9 @@ static EWiiExtensionControllerType GetExtensionType(Uint16 extension_id) } } -static SDL_bool SendExtensionReset(SDL_DriverWii_Context *ctx, SDL_bool sync) +static bool SendExtensionReset(SDL_DriverWii_Context *ctx, bool sync) { - SDL_bool result = SDL_TRUE; + bool result = true; { Uint8 data = 0x55; result = result && WriteRegister(ctx, 0xA400F0, &data, sizeof(data), sync); @@ -382,12 +382,12 @@ static SDL_bool SendExtensionReset(SDL_DriverWii_Context *ctx, SDL_bool sync) return result; } -static SDL_bool GetMotionPlusState(SDL_DriverWii_Context *ctx, SDL_bool *connected, Uint8 *mode) +static bool GetMotionPlusState(SDL_DriverWii_Context *ctx, bool *connected, Uint8 *mode) { Uint16 extension; if (connected) { - *connected = SDL_FALSE; + *connected = false; } if (mode) { *mode = 0; @@ -395,51 +395,51 @@ static SDL_bool GetMotionPlusState(SDL_DriverWii_Context *ctx, SDL_bool *connect if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_WiiUPro) { // The Wii U Pro controller never has the Motion Plus extension - return SDL_TRUE; + return true; } - if (SendExtensionIdentify(ctx, SDL_TRUE) && + if (SendExtensionIdentify(ctx, true) && ParseExtensionIdentifyResponse(ctx, &extension)) { if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { // Motion Plus is currently active if (connected) { - *connected = SDL_TRUE; + *connected = true; } if (mode) { *mode = (extension >> 8); } - return SDL_TRUE; + return true; } } - if (ReadRegister(ctx, 0xA600FE, 2, SDL_TRUE) && + if (ReadRegister(ctx, 0xA600FE, 2, true) && ParseExtensionIdentifyResponse(ctx, &extension)) { if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { // Motion Plus is currently connected if (connected) { - *connected = SDL_TRUE; + *connected = true; } } - return SDL_TRUE; + return true; } // Failed to read the register or parse the response - return SDL_FALSE; + return false; } -static SDL_bool NeedsPeriodicMotionPlusCheck(SDL_DriverWii_Context *ctx, SDL_bool status_update) +static bool NeedsPeriodicMotionPlusCheck(SDL_DriverWii_Context *ctx, bool status_update) { if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_WiiUPro) { // The Wii U Pro controller never has the Motion Plus extension - return SDL_FALSE; + return false; } if (ctx->m_ucMotionPlusMode != WII_MOTIONPLUS_MODE_NONE && !status_update) { // We'll get a status update when Motion Plus is disconnected - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static void SchedulePeriodicMotionPlusCheck(SDL_DriverWii_Context *ctx) @@ -449,7 +449,7 @@ static void SchedulePeriodicMotionPlusCheck(SDL_DriverWii_Context *ctx) static void CheckMotionPlusConnection(SDL_DriverWii_Context *ctx) { - SendExtensionIdentify(ctx, SDL_FALSE); + SendExtensionIdentify(ctx, false); ctx->m_eCommState = k_eWiiCommunicationState_CheckMotionPlusStage1; } @@ -461,7 +461,7 @@ static void ActivateMotionPlusWithMode(SDL_DriverWii_Context *ctx, Uint8 mode) * extension, so don't mess with it here. */ #else - WriteRegister(ctx, 0xA600FE, &mode, sizeof(mode), SDL_TRUE); + WriteRegister(ctx, 0xA600FE, &mode, sizeof(mode), true); ctx->m_ucMotionPlusMode = mode; #endif // LINUX @@ -483,7 +483,7 @@ static void ActivateMotionPlus(SDL_DriverWii_Context *ctx) static void DeactivateMotionPlus(SDL_DriverWii_Context *ctx) { Uint8 data = 0x55; - WriteRegister(ctx, 0xA400F0, &data, sizeof(data), SDL_TRUE); + WriteRegister(ctx, 0xA400F0, &data, sizeof(data), true); // Wait for the deactivation status message ReadInputSync(ctx, k_eWiiInputReportIDs_Status, NULL); @@ -508,8 +508,8 @@ static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte) static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryByte) { - SDL_bool charging = !(extensionBatteryByte & 0x08); - SDL_bool pluggedIn = !(extensionBatteryByte & 0x04); + bool charging = !(extensionBatteryByte & 0x08); + bool pluggedIn = !(extensionBatteryByte & 0x04); Uint8 batteryLevel = extensionBatteryByte >> 4; if (pluggedIn) { @@ -568,7 +568,7 @@ static EWiiInputReportIDs GetButtonPacketType(SDL_DriverWii_Context *ctx) } } -static SDL_bool RequestButtonPacketType(SDL_DriverWii_Context *ctx, EWiiInputReportIDs type) +static bool RequestButtonPacketType(SDL_DriverWii_Context *ctx, EWiiInputReportIDs type) { Uint8 data[3]; Uint8 tt = (Uint8)ctx->m_bRumbleActive; @@ -581,7 +581,7 @@ static SDL_bool RequestButtonPacketType(SDL_DriverWii_Context *ctx, EWiiInputRep data[0] = k_eWiiOutputReportIDs_DataReportingMode; data[1] = tt; data[2] = type; - return WriteOutput(ctx, data, sizeof(data), SDL_FALSE); + return WriteOutput(ctx, data, sizeof(data), false); } static void ResetButtonPacketType(SDL_DriverWii_Context *ctx) @@ -624,7 +624,7 @@ static void InitStickCalibrationData(SDL_DriverWii_Context *ctx) static void InitializeExtension(SDL_DriverWii_Context *ctx) { - SendExtensionReset(ctx, SDL_TRUE); + SendExtensionReset(ctx, true); InitStickCalibrationData(ctx); ResetButtonPacketType(ctx); } @@ -659,13 +659,13 @@ static void UpdateSlotLED(SDL_DriverWii_Context *ctx) data[0] = k_eWiiOutputReportIDs_LEDs; data[1] = leds; - WriteOutput(ctx, data, sizeof(data), SDL_FALSE); + WriteOutput(ctx, data, sizeof(data), false); } static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)userdata; - SDL_bool bPlayerLights = SDL_GetStringBoolean(hint, SDL_TRUE); + bool bPlayerLights = SDL_GetStringBoolean(hint, true); if (bPlayerLights != ctx->m_bPlayerLights) { ctx->m_bPlayerLights = bPlayerLights; @@ -684,15 +684,15 @@ static EWiiExtensionControllerType ReadExtensionControllerType(SDL_HIDAPI_Device // Create enough of a context to read the controller type from the device for (attempts = 0; attempts < MAX_ATTEMPTS; ++attempts) { Uint16 extension; - if (SendExtensionIdentify(ctx, SDL_TRUE) && + if (SendExtensionIdentify(ctx, true) && ParseExtensionIdentifyResponse(ctx, &extension)) { Uint8 motion_plus_mode = 0; if ((extension & WII_EXTENSION_MOTIONPLUS_MASK) == WII_EXTENSION_MOTIONPLUS_ID) { motion_plus_mode = (Uint8)(extension >> 8); } if (motion_plus_mode || extension == WII_EXTENSION_UNINITIALIZED) { - SendExtensionReset(ctx, SDL_TRUE); - if (SendExtensionIdentify(ctx, SDL_TRUE)) { + SendExtensionReset(ctx, true); + if (SendExtensionIdentify(ctx, true)) { ParseExtensionIdentifyResponse(ctx, &extension); } } @@ -733,13 +733,13 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) device->guid.data[15] = ctx->m_eExtensionControllerType; } -static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx; ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; device->context = ctx; @@ -770,7 +770,7 @@ static void HIDAPI_DriverWii_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL UpdateSlotLED(ctx); } -static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -782,7 +782,7 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy GetMotionPlusState(ctx, &ctx->m_bMotionPlusPresent, &ctx->m_ucMotionPlusMode); - if (NeedsPeriodicMotionPlusCheck(ctx, SDL_FALSE)) { + if (NeedsPeriodicMotionPlusCheck(ctx, false)) { SchedulePeriodicMotionPlusCheck(ctx); } @@ -800,7 +800,7 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy // Initialize player index (needed for setting LEDs) ctx->m_nPlayerIndex = SDL_GetJoystickPlayerIndex(joystick); - ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, SDL_TRUE); + ctx->m_bPlayerLights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, true); UpdateSlotLED(ctx); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED, @@ -817,20 +817,20 @@ static SDL_bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy ctx->m_ulLastInput = SDL_GetTicks(); - return SDL_TRUE; + return true; } static int HIDAPI_DriverWii_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; - SDL_bool active = (low_frequency_rumble || high_frequency_rumble); + bool active = (low_frequency_rumble || high_frequency_rumble); if (active != ctx->m_bRumbleActive) { Uint8 data[2]; data[0] = k_eWiiOutputReportIDs_Rumble; data[1] = (Uint8)active; - WriteOutput(ctx, data, sizeof(data), SDL_FALSE); + WriteOutput(ctx, data, sizeof(data), false); ctx->m_bRumbleActive = active; } @@ -857,7 +857,7 @@ static int HIDAPI_DriverWii_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Jo return SDL_Unsupported(); } -static int HIDAPI_DriverWii_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverWii_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; @@ -1280,12 +1280,12 @@ static void HandleButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, if (data->rgucExtension[4] & 0x01) { if (ctx->m_eExtensionControllerType == k_eWiiExtensionControllerType_None) { // Something was plugged into the extension port, reinitialize to get new state - ctx->m_bDisconnected = SDL_TRUE; + ctx->m_bDisconnected = true; } } else { if (ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None) { // Something was removed from the extension port, reinitialize to get new state - ctx->m_bDisconnected = SDL_TRUE; + ctx->m_bDisconnected = true; } } @@ -1317,18 +1317,18 @@ static void HandleButtonData(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick, static void GetBaseButtons(WiiButtonData *dst, const Uint8 *src) { SDL_memcpy(dst->rgucBaseButtons, src, 2); - dst->hasBaseButtons = SDL_TRUE; + dst->hasBaseButtons = true; } static void GetAccelerometer(WiiButtonData *dst, const Uint8 *src) { SDL_memcpy(dst->rgucAccelerometer, src, 3); - dst->hasAccelerometer = SDL_TRUE; + dst->hasAccelerometer = true; } static void GetExtensionData(WiiButtonData *dst, const Uint8 *src, int size) { - SDL_bool valid_data = SDL_FALSE; + bool valid_data = false; int i; if (size > sizeof(dst->rgucExtension)) { @@ -1337,7 +1337,7 @@ static void GetExtensionData(WiiButtonData *dst, const Uint8 *src, int size) for (i = 0; i < size; ++i) { if (src[i] != 0xFF) { - valid_data = SDL_TRUE; + valid_data = true; break; } } @@ -1349,8 +1349,8 @@ static void GetExtensionData(WiiButtonData *dst, const Uint8 *src, int size) static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) { - SDL_bool hadExtension = ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None; - SDL_bool hasExtension = (ctx->m_rgucReadBuffer[3] & 2) ? SDL_TRUE : SDL_FALSE; + bool hadExtension = ctx->m_eExtensionControllerType != k_eWiiExtensionControllerType_None; + bool hasExtension = (ctx->m_rgucReadBuffer[3] & 2) ? true : false; WiiButtonData data; SDL_zero(data); GetBaseButtons(&data, ctx->m_rgucReadBuffer + 1); @@ -1374,13 +1374,13 @@ static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) * otherwise we'll get extension connect/disconnect status through * Motion Plus packets. */ - if (NeedsPeriodicMotionPlusCheck(ctx, SDL_TRUE)) { + if (NeedsPeriodicMotionPlusCheck(ctx, true)) { ctx->m_ulNextMotionPlusCheck = SDL_GetTicks(); } } else if (hadExtension != hasExtension) { // Reinitialize to get new state - ctx->m_bDisconnected = SDL_TRUE; + ctx->m_bDisconnected = true; } } @@ -1408,13 +1408,13 @@ static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) if (!ctx->m_bMotionPlusPresent) { // Reinitialize to get new sensor availability - ctx->m_bDisconnected = SDL_TRUE; + ctx->m_bDisconnected = true; } ctx->m_eCommState = k_eWiiCommunicationState_None; } else if (ctx->m_eCommState == k_eWiiCommunicationState_CheckMotionPlusStage1) { // Check to see if Motion Plus is present - ReadRegister(ctx, 0xA600FE, 2, SDL_FALSE); + ReadRegister(ctx, 0xA600FE, 2, false); ctx->m_eCommState = k_eWiiCommunicationState_CheckMotionPlusStage2; @@ -1424,7 +1424,7 @@ static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) if (ctx->m_bMotionPlusPresent) { // Reinitialize to get new sensor availability - ctx->m_bDisconnected = SDL_TRUE; + ctx->m_bDisconnected = true; } ctx->m_eCommState = k_eWiiCommunicationState_None; } @@ -1509,7 +1509,7 @@ static void HandleInput(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick) } } -static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverWii_Context *ctx = (SDL_DriverWii_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1519,7 +1519,7 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } now = SDL_GetTicks(); @@ -1549,7 +1549,7 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) // Check to see if the Motion Plus extension status has changed if (ctx->m_ulNextMotionPlusCheck && now >= ctx->m_ulNextMotionPlusCheck) { CheckMotionPlusConnection(ctx); - if (NeedsPeriodicMotionPlusCheck(ctx, SDL_FALSE)) { + if (NeedsPeriodicMotionPlusCheck(ctx, false)) { SchedulePeriodicMotionPlusCheck(ctx); } else { ctx->m_ulNextMotionPlusCheck = 0; @@ -1562,7 +1562,7 @@ static SDL_bool HIDAPI_DriverWii_UpdateDevice(SDL_HIDAPI_Device *device) data[0] = k_eWiiOutputReportIDs_StatusRequest; data[1] = (Uint8)ctx->m_bRumbleActive; - WriteOutput(ctx, data, sizeof(data), SDL_FALSE); + WriteOutput(ctx, data, sizeof(data), false); ctx->m_ulLastStatus = now; } @@ -1592,7 +1592,7 @@ static void HIDAPI_DriverWii_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverWii = { SDL_HINT_JOYSTICK_HIDAPI_WII, - SDL_TRUE, + true, HIDAPI_DriverWii_RegisterHints, HIDAPI_DriverWii_UnregisterHints, HIDAPI_DriverWii_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index 5793045399..4973f74b5a 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -37,7 +37,7 @@ typedef struct SDL_HIDAPI_Device *device; SDL_Joystick *joystick; int player_index; - SDL_bool player_lights; + bool player_lights; Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXbox360_Context; @@ -53,37 +53,37 @@ static void HIDAPI_DriverXbox360_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, callback, userdata); } -static SDL_bool HIDAPI_DriverXbox360_IsEnabled(void) +static bool HIDAPI_DriverXbox360_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT))); } -static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { const int XB360W_IFACE_PROTOCOL = 129; // Wireless if (vendor_id == USB_VENDOR_ASTRO && product_id == USB_PRODUCT_ASTRO_C40_XBOX360) { // This is the ASTRO C40 in Xbox 360 mode - return SDL_TRUE; + return true; } if (vendor_id == USB_VENDOR_NVIDIA) { // This is the NVIDIA Shield controller which doesn't talk Xbox controller protocol - return SDL_FALSE; + return false; } if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY2 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER)) || (type == SDL_GAMEPAD_TYPE_XBOX360 && interface_protocol == XB360W_IFACE_PROTOCOL)) { // This is the wireless dongle, which talks a different protocol - return SDL_FALSE; + return false; } if (interface_number > 0) { // This is the chatpad or other input interface, not the Xbox 360 interface - return SDL_FALSE; + return false; } #ifdef SDL_PLATFORM_MACOS if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0) { // This is the Steam Virtual Gamepad, which isn't supported by this driver - return SDL_FALSE; + return false; } /* Wired Xbox One controllers are handled by this driver, interfacing with the 360Controller driver available from: @@ -92,7 +92,7 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device Bluetooth Xbox One controllers are handled by the SDL Xbox One driver */ if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { - return SDL_FALSE; + return false; } return (type == SDL_GAMEPAD_TYPE_XBOX360 || type == SDL_GAMEPAD_TYPE_XBOXONE); #else @@ -100,32 +100,32 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device #endif } -static SDL_bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, SDL_bool on) +static bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, bool on) { - const SDL_bool blink = SDL_FALSE; + const bool blink = false; Uint8 mode = on ? ((blink ? 0x02 : 0x06) + slot) : 0; Uint8 led_packet[] = { 0x01, 0x03, 0x00 }; led_packet[2] = mode; if (SDL_hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static void UpdateSlotLED(SDL_DriverXbox360_Context *ctx) { if (ctx->player_lights && ctx->player_index >= 0) { - SetSlotLED(ctx->device->dev, (ctx->player_index % 4), SDL_TRUE); + SetSlotLED(ctx->device->dev, (ctx->player_index % 4), true); } else { - SetSlotLED(ctx->device->dev, 0, SDL_FALSE); + SetSlotLED(ctx->device->dev, 0, false); } } static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)userdata; - SDL_bool player_lights = SDL_GetStringBoolean(hint, SDL_TRUE); + bool player_lights = SDL_GetStringBoolean(hint, true); if (player_lights != ctx->player_lights) { ctx->player_lights = player_lights; @@ -135,13 +135,13 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } -static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360_Context *ctx; ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; @@ -170,7 +170,7 @@ static void HIDAPI_DriverXbox360_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, UpdateSlotLED(ctx); } -static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; @@ -181,7 +181,7 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_TRUE); + ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, true); UpdateSlotLED(ctx); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, @@ -192,7 +192,7 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL joystick->naxes = SDL_GAMEPAD_AXIS_MAX; joystick->nhats = 1; - return SDL_TRUE; + return true; } static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -259,7 +259,7 @@ static int HIDAPI_DriverXbox360_SendJoystickEffect(SDL_HIDAPI_Device *device, SD return SDL_Unsupported(); } -static int HIDAPI_DriverXbox360_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXbox360_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -268,9 +268,9 @@ static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_D { Sint16 axis; #ifdef SDL_PLATFORM_MACOS - const SDL_bool invert_y_axes = SDL_FALSE; + const bool invert_y_axes = false; #else - const SDL_bool invert_y_axes = SDL_TRUE; + const bool invert_y_axes = true; #endif Uint64 timestamp = SDL_GetTicksNS(); @@ -329,7 +329,7 @@ static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_D SDL_memcpy(ctx->last_state, data, SDL_min((size_t)size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -339,7 +339,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -378,7 +378,7 @@ static void HIDAPI_DriverXbox360_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, - SDL_TRUE, + true, HIDAPI_DriverXbox360_RegisterHints, HIDAPI_DriverXbox360_UnregisterHints, HIDAPI_DriverXbox360_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 674f6cdc4f..ea452d7571 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -35,9 +35,9 @@ typedef struct { SDL_HIDAPI_Device *device; - SDL_bool connected; + bool connected; int player_index; - SDL_bool player_lights; + bool player_lights; Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXbox360W_Context; @@ -55,49 +55,49 @@ static void HIDAPI_DriverXbox360W_UnregisterHints(SDL_HintCallback callback, voi SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, callback, userdata); } -static SDL_bool HIDAPI_DriverXbox360W_IsEnabled(void) +static bool HIDAPI_DriverXbox360W_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)))); } -static SDL_bool HIDAPI_DriverXbox360W_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverXbox360W_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { const int XB360W_IFACE_PROTOCOL = 129; // Wireless if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY2 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY1 || product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER) && interface_protocol == 0) || (type == SDL_GAMEPAD_TYPE_XBOX360 && interface_protocol == XB360W_IFACE_PROTOCOL)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, SDL_bool on) +static bool SetSlotLED(SDL_hid_device *dev, Uint8 slot, bool on) { - const SDL_bool blink = SDL_FALSE; + const bool blink = false; Uint8 mode = on ? ((blink ? 0x02 : 0x06) + slot) : 0; Uint8 led_packet[] = { 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; led_packet[3] = 0x40 + (mode % 0x0e); if (SDL_hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static void UpdateSlotLED(SDL_DriverXbox360W_Context *ctx) { if (ctx->player_lights && ctx->player_index >= 0) { - SetSlotLED(ctx->device->dev, (ctx->player_index % 4), SDL_TRUE); + SetSlotLED(ctx->device->dev, (ctx->player_index % 4), true); } else { - SetSlotLED(ctx->device->dev, 0, SDL_FALSE); + SetSlotLED(ctx->device->dev, 0, false); } } static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)userdata; - SDL_bool player_lights = SDL_GetStringBoolean(hint, SDL_TRUE); + bool player_lights = SDL_GetStringBoolean(hint, true); if (player_lights != ctx->player_lights) { ctx->player_lights = player_lights; @@ -113,7 +113,7 @@ static void UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level) SDL_SendJoystickPowerInfo(joystick, SDL_POWERSTATE_ON_BATTERY, percent); } -static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360W_Context *ctx; @@ -124,7 +124,7 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; @@ -132,12 +132,12 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) if (SDL_hid_write(device->dev, init_packet, sizeof(init_packet)) != sizeof(init_packet)) { SDL_SetError("Couldn't write init packet"); - return SDL_FALSE; + return false; } device->type = SDL_GAMEPAD_TYPE_XBOX360; - return SDL_TRUE; + return true; } static int HIDAPI_DriverXbox360W_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) @@ -158,7 +158,7 @@ static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device UpdateSlotLED(ctx); } -static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; @@ -168,7 +168,7 @@ static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SD // Initialize player index (needed for setting LEDs) ctx->player_index = SDL_GetJoystickPlayerIndex(joystick); - ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, SDL_TRUE); + ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, true); UpdateSlotLED(ctx); SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED, @@ -178,7 +178,7 @@ static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SD joystick->nbuttons = 15; joystick->naxes = SDL_GAMEPAD_AXIS_MAX; - return SDL_TRUE; + return true; } static int HIDAPI_DriverXbox360W_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -220,7 +220,7 @@ static int HIDAPI_DriverXbox360W_SendJoystickEffect(SDL_HIDAPI_Device *device, S return SDL_Unsupported(); } -static int HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -228,7 +228,7 @@ static int HIDAPI_DriverXbox360W_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *de static void HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev, SDL_DriverXbox360W_Context *ctx, Uint8 *data, int size) { Sint16 axis; - const SDL_bool invert_y_axes = SDL_TRUE; + const bool invert_y_axes = true; Uint64 timestamp = SDL_GetTicksNS(); if (ctx->last_state[2] != data[2]) { @@ -286,7 +286,7 @@ static void HIDAPI_DriverXbox360W_HandleStatePacket(SDL_Joystick *joystick, SDL_ SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); } -static SDL_bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -302,7 +302,7 @@ static SDL_bool HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device) HIDAPI_DumpPacket("Xbox 360 wireless packet: size = %d", data, size); #endif if (size == 2 && data[0] == 0x08) { - SDL_bool connected = (data[1] & 0x80) ? SDL_TRUE : SDL_FALSE; + bool connected = (data[1] & 0x80) ? true : false; #ifdef DEBUG_JOYSTICK SDL_Log("Connected = %s\n", connected ? "TRUE" : "FALSE"); #endif @@ -361,7 +361,7 @@ static void HIDAPI_DriverXbox360W_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS, - SDL_TRUE, + true, HIDAPI_DriverXbox360W_RegisterHints, HIDAPI_DriverXbox360W_UnregisterHints, HIDAPI_DriverXbox360W_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index b3b9eb6424..5b24d97fac 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -126,12 +126,12 @@ typedef struct Uint64 start_time; Uint8 sequence; Uint64 send_time; - SDL_bool has_guide_packet; - SDL_bool has_color_led; - SDL_bool has_paddles; - SDL_bool has_unmapped_state; - SDL_bool has_trigger_rumble; - SDL_bool has_share_button; + bool has_guide_packet; + bool has_color_led; + bool has_paddles; + bool has_unmapped_state; + bool has_trigger_rumble; + bool has_share_button; Uint8 last_paddle_state; Uint8 low_frequency_rumble; Uint8 high_frequency_rumble; @@ -139,27 +139,27 @@ typedef struct Uint8 right_trigger_rumble; SDL_XboxOneRumbleState rumble_state; Uint64 rumble_time; - SDL_bool rumble_pending; + bool rumble_pending; Uint8 last_state[USB_PACKET_LENGTH]; Uint8 *chunk_buffer; Uint32 chunk_length; } SDL_DriverXboxOne_Context; -static SDL_bool ControllerHasColorLED(Uint16 vendor_id, Uint16 product_id) +static bool ControllerHasColorLED(Uint16 vendor_id, Uint16 product_id) { return vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2; } -static SDL_bool ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) +static bool ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) { return SDL_IsJoystickXboxOneElite(vendor_id, product_id); } -static SDL_bool ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) +static bool ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) { // All the Microsoft Xbox One controllers have trigger rumble if (vendor_id == USB_VENDOR_MICROSOFT) { - return SDL_TRUE; + return true; } /* It turns out other controllers a mixed bag as to whether they support @@ -167,10 +167,10 @@ static SDL_bool ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) the vibration of the Microsoft trigger rumble, so for now just pretend that it is not available. */ - return SDL_FALSE; + return false; } -static SDL_bool ControllerHasShareButton(Uint16 vendor_id, Uint16 product_id) +static bool ControllerHasShareButton(Uint16 vendor_id, Uint16 product_id) { return SDL_IsJoystickXboxSeriesX(vendor_id, product_id); } @@ -183,7 +183,7 @@ static int GetHomeLEDBrightness(const char *hint) if (hint && *hint) { if (SDL_strchr(hint, '.') != NULL) { value = (int)(MAX_VALUE * SDL_atof(hint)); - } else if (!SDL_GetStringBoolean(hint, SDL_TRUE)) { + } else if (!SDL_GetStringBoolean(hint, true)) { value = 0; } } @@ -227,7 +227,7 @@ static Uint8 GetNextPacketSequence(SDL_DriverXboxOne_Context *ctx) return ctx->sequence; } -static SDL_bool SendProtocolPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size) +static bool SendProtocolPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size) { #ifdef DEBUG_XBOX_PROTOCOL HIDAPI_DumpPacket("Xbox One sending packet: size = %d", data, size); @@ -236,16 +236,16 @@ static SDL_bool SendProtocolPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 * ctx->send_time = SDL_GetTicks(); if (SDL_HIDAPI_LockRumble() < 0) { - return SDL_FALSE; + return false; } if (SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) != size) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } #if 0 -static SDL_bool SendSerialRequest(SDL_DriverXboxOne_Context *ctx) +static bool SendSerialRequest(SDL_DriverXboxOne_Context *ctx) { Uint8 packet[] = { 0x1E, 0x20, 0x00, 0x01, 0x04 }; @@ -258,22 +258,22 @@ static SDL_bool SendSerialRequest(SDL_DriverXboxOne_Context *ctx) */ if (!SendProtocolPacket(ctx, packet, sizeof(packet))) { SDL_SetError("Couldn't send serial request packet"); - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } #endif -static SDL_bool ControllerSendsAnnouncement(Uint16 vendor_id, Uint16 product_id) +static bool ControllerSendsAnnouncement(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_PDP && product_id == 0x0246) { // The PDP Rock Candy (PID 0x0246) doesn't send the announce packet on Linux for some reason - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } -static SDL_bool SendIdentificationRequest(SDL_DriverXboxOne_Context *ctx) +static bool SendIdentificationRequest(SDL_DriverXboxOne_Context *ctx) { // Request identification, sent in response to announce packet Uint8 packet[] = { @@ -284,12 +284,12 @@ static SDL_bool SendIdentificationRequest(SDL_DriverXboxOne_Context *ctx) if (!SendProtocolPacket(ctx, packet, sizeof(packet))) { SDL_SetError("Couldn't send identification request packet"); - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } -static SDL_bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) +static bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) { Uint16 vendor_id = ctx->vendor_id; Uint16 product_id = ctx->product_id; @@ -319,7 +319,7 @@ static SDL_bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) if (!SendProtocolPacket(ctx, init_packet, packet->size)) { SDL_SetError("Couldn't send initialization packet"); - return SDL_FALSE; + return false; } // Wait to process the rumble packet @@ -327,7 +327,7 @@ static SDL_bool SendControllerStartup(SDL_DriverXboxOne_Context *ctx) SDL_Delay(10); } } - return SDL_TRUE; + return true; } static void HIDAPI_DriverXboxOne_RegisterHints(SDL_HintCallback callback, void *userdata) @@ -342,30 +342,30 @@ static void HIDAPI_DriverXboxOne_UnregisterHints(SDL_HintCallback callback, void SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, callback, userdata); } -static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void) +static bool HIDAPI_DriverXboxOne_IsEnabled(void) { return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_XBOX, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT))); } -static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +static bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { #ifdef SDL_PLATFORM_MACOS // Wired Xbox One controllers are handled by the 360Controller driver if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { - return SDL_FALSE; + return false; } #endif return (type == SDL_GAMEPAD_TYPE_XBOXONE); } -static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) { SDL_DriverXboxOne_Context *ctx; ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { - return SDL_FALSE; + return false; } ctx->device = device; @@ -406,7 +406,7 @@ static void HIDAPI_DriverXboxOne_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, { } -static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +static bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; @@ -418,7 +418,7 @@ static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL ctx->right_trigger_rumble = 0; ctx->rumble_state = XBOX_ONE_RUMBLE_STATE_IDLE; ctx->rumble_time = 0; - ctx->rumble_pending = SDL_FALSE; + ctx->rumble_pending = false; SDL_zeroa(ctx->last_state); // Initialize the joystick capabilities @@ -434,7 +434,7 @@ static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED, SDL_HomeLEDHintChanged, ctx); - return SDL_TRUE; + return true; } static void HIDAPI_DriverXboxOne_RumbleSent(void *userdata) @@ -468,7 +468,7 @@ static int HIDAPI_DriverXboxOne_UpdateRumble(SDL_DriverXboxOne_Context *ctx) } // We're no longer pending, even if we fail to send the rumble below - ctx->rumble_pending = SDL_FALSE; + ctx->rumble_pending = false; if (SDL_HIDAPI_LockRumble() < 0) { return -1; @@ -510,7 +510,7 @@ static int HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Jo // Magnitude is 1..100 so scale the 16-bit input here ctx->low_frequency_rumble = (Uint8)(low_frequency_rumble / 655); ctx->high_frequency_rumble = (Uint8)(high_frequency_rumble / 655); - ctx->rumble_pending = SDL_TRUE; + ctx->rumble_pending = true; return HIDAPI_DriverXboxOne_UpdateRumble(ctx); } @@ -526,7 +526,7 @@ static int HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device // Magnitude is 1..100 so scale the 16-bit input here ctx->left_trigger_rumble = (Uint8)(left_rumble / 655); ctx->right_trigger_rumble = (Uint8)(right_rumble / 655); - ctx->rumble_pending = SDL_TRUE; + ctx->rumble_pending = true; return HIDAPI_DriverXboxOne_UpdateRumble(ctx); } @@ -574,7 +574,7 @@ static int HIDAPI_DriverXboxOne_SendJoystickEffect(SDL_HIDAPI_Device *device, SD return SDL_Unsupported(); } -static int HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_DriverXboxOne_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -591,7 +591,7 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic int button2_bit; int button3_bit; int button4_bit; - SDL_bool paddles_mapped; + bool paddles_mapped; Uint64 timestamp = SDL_GetTicksNS(); if (size == 17) { @@ -604,13 +604,13 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic profile = data[15]; if (profile == 0) { - paddles_mapped = SDL_FALSE; + paddles_mapped = false; } else if (SDL_memcmp(&data[0], &ctx->last_state[0], 14) == 0) { // We're using a profile, but paddles aren't mapped - paddles_mapped = SDL_FALSE; + paddles_mapped = false; } else { // Something is mapped, we can't use the paddles - paddles_mapped = SDL_TRUE; + paddles_mapped = true; } } else { @@ -639,7 +639,7 @@ static void HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(SDL_Joystick *joystic SDL_SendJoystickButton(timestamp, joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED); ctx->last_paddle_state = data[paddle_index]; } - ctx->has_unmapped_state = SDL_TRUE; + ctx->has_unmapped_state = true; } static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) @@ -745,7 +745,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D int button2_bit; int button3_bit; int button4_bit; - SDL_bool paddles_mapped; + bool paddles_mapped; if (size == 29) { // XBox One Elite Series 1 @@ -838,7 +838,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); // We don't have the unmapped state for this packet - ctx->has_unmapped_state = SDL_FALSE; + ctx->has_unmapped_state = false; } static void HIDAPI_DriverXboxOne_HandleStatusPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size) @@ -923,7 +923,7 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleButtons(Uint64 timestamp, SDL_Jo int button2_bit; int button3_bit; int button4_bit; - SDL_bool paddles_mapped; + bool paddles_mapped; if (size == 55) { // Initial firmware for the Xbox Elite Series 2 controller @@ -1056,14 +1056,14 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joysti { Uint64 timestamp = SDL_GetTicksNS(); - ctx->has_guide_packet = SDL_TRUE; + ctx->has_guide_packet = true; SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED); } static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size) { Uint8 flags = data[1]; - SDL_bool on_usb = (((flags & 0x0C) >> 2) == 0); + bool on_usb = (((flags & 0x0C) >> 2) == 0); SDL_PowerState state; int percent = 0; @@ -1107,7 +1107,7 @@ static void HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_DriverXboxOne_Context HIDAPI_SetDeviceSerial(ctx->device, serial); } -static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context *ctx) +static bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context *ctx) { SDL_XboxOneInitState prev_state; do { @@ -1155,7 +1155,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateInitState(SDL_DriverXboxOne_Context * } while (ctx->init_state != prev_state); - return SDL_TRUE; + return true; } /* GIP protocol handling adapted under the Zlib license with permission from @medusalix: @@ -1313,7 +1313,7 @@ static int HIDAPI_GIP_DecodeHeader(struct gip_header *hdr, const Uint8 *data, in return hdr_len; } -static SDL_bool HIDAPI_GIP_SendPacket(SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, const void *data) +static bool HIDAPI_GIP_SendPacket(SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, const void *data) { Uint8 packet[USB_PACKET_LENGTH]; int hdr_len, size; @@ -1322,7 +1322,7 @@ static SDL_bool HIDAPI_GIP_SendPacket(SDL_DriverXboxOne_Context *ctx, struct gip size = (hdr_len + hdr->packet_length); if (size > sizeof(packet)) { SDL_SetError("Couldn't send GIP packet, size (%d) too large\n", size); - return SDL_FALSE; + return false; } if (!hdr->sequence) { @@ -1336,16 +1336,16 @@ static SDL_bool HIDAPI_GIP_SendPacket(SDL_DriverXboxOne_Context *ctx, struct gip if (!SendProtocolPacket(ctx, packet, size)) { SDL_SetError("Couldn't send protocol packet"); - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_GIP_AcknowledgePacket(SDL_DriverXboxOne_Context *ctx, struct gip_header *ack) +static bool HIDAPI_GIP_AcknowledgePacket(SDL_DriverXboxOne_Context *ctx, struct gip_header *ack) { if (XBOX_ONE_DRIVER_ACTIVE) { // The driver is taking care of acks - return SDL_TRUE; + return true; } else { struct gip_header hdr; struct gip_pkt_acknowledge pkt; @@ -1369,11 +1369,11 @@ static SDL_bool HIDAPI_GIP_AcknowledgePacket(SDL_DriverXboxOne_Context *ctx, str } } -static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data, Uint32 size) +static bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data, Uint32 size) { if ((hdr->options & 0x0F) != 0) { // This is a packet for a device plugged into the controller, skip it - return SDL_TRUE; + return true; } if (hdr->options & GIP_OPT_INTERNAL) { @@ -1472,7 +1472,7 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox break; } } - return SDL_TRUE; + return true; } static void HIDAPI_GIP_DestroyChunkBuffer(SDL_DriverXboxOne_Context *ctx) @@ -1484,34 +1484,34 @@ static void HIDAPI_GIP_DestroyChunkBuffer(SDL_DriverXboxOne_Context *ctx) } } -static SDL_bool HIDAPI_GIP_CreateChunkBuffer(SDL_DriverXboxOne_Context *ctx, Uint32 size) +static bool HIDAPI_GIP_CreateChunkBuffer(SDL_DriverXboxOne_Context *ctx, Uint32 size) { HIDAPI_GIP_DestroyChunkBuffer(ctx); ctx->chunk_buffer = (Uint8 *)SDL_malloc(size); if (ctx->chunk_buffer) { ctx->chunk_length = size; - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } -static SDL_bool HIDAPI_GIP_ProcessPacketChunked(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data) +static bool HIDAPI_GIP_ProcessPacketChunked(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data) { - SDL_bool result; + bool result; if (!ctx->chunk_buffer) { - return SDL_FALSE; + return false; } if ((hdr->chunk_offset + hdr->packet_length) > ctx->chunk_length) { - return SDL_FALSE; + return false; } if (hdr->packet_length) { SDL_memcpy(ctx->chunk_buffer + hdr->chunk_offset, data, hdr->packet_length); - return SDL_TRUE; + return true; } result = HIDAPI_GIP_DispatchPacket(joystick, ctx, hdr, ctx->chunk_buffer, ctx->chunk_length); @@ -1521,11 +1521,11 @@ static SDL_bool HIDAPI_GIP_ProcessPacketChunked(SDL_Joystick *joystick, SDL_Driv return result; } -static SDL_bool HIDAPI_GIP_ProcessPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data) +static bool HIDAPI_GIP_ProcessPacket(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, struct gip_header *hdr, Uint8 *data) { if (hdr->options & GIP_OPT_CHUNK_START) { if (!HIDAPI_GIP_CreateChunkBuffer(ctx, hdr->chunk_offset)) { - return SDL_FALSE; + return false; } ctx->chunk_length = hdr->chunk_offset; @@ -1534,7 +1534,7 @@ static SDL_bool HIDAPI_GIP_ProcessPacket(SDL_Joystick *joystick, SDL_DriverXboxO if (hdr->options & GIP_OPT_ACKNOWLEDGE) { if (!HIDAPI_GIP_AcknowledgePacket(ctx, hdr)) { - return SDL_FALSE; + return false; } } @@ -1545,7 +1545,7 @@ static SDL_bool HIDAPI_GIP_ProcessPacket(SDL_Joystick *joystick, SDL_DriverXboxO } } -static SDL_bool HIDAPI_GIP_ProcessData(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) +static bool HIDAPI_GIP_ProcessData(SDL_Joystick *joystick, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size) { struct gip_header hdr; int hdr_len; @@ -1553,20 +1553,20 @@ static SDL_bool HIDAPI_GIP_ProcessData(SDL_Joystick *joystick, SDL_DriverXboxOne while (size > GIP_HEADER_MIN_LENGTH) { hdr_len = HIDAPI_GIP_DecodeHeader(&hdr, data, size); if ((hdr_len + hdr.packet_length) > (size_t)size) { - return SDL_FALSE; + return false; } if (!HIDAPI_GIP_ProcessPacket(joystick, ctx, &hdr, data + hdr_len)) { - return SDL_FALSE; + return false; } data += hdr_len + hdr.packet_length; size -= hdr_len + hdr.packet_length; } - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) +static bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context; SDL_Joystick *joystick = NULL; @@ -1576,7 +1576,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) if (device->num_joysticks > 0) { joystick = SDL_GetJoystickFromID(device->joysticks[0]); } else { - return SDL_FALSE; + return false; } while ((size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { @@ -1647,7 +1647,7 @@ static void HIDAPI_DriverXboxOne_FreeDevice(SDL_HIDAPI_Device *device) SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne = { SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE, - SDL_TRUE, + true, HIDAPI_DriverXboxOne_RegisterHints, HIDAPI_DriverXboxOne_UnregisterHints, HIDAPI_DriverXboxOne_IsEnabled, diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 1def0181aa..56a31fa12b 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -88,13 +88,13 @@ static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = { }; static int SDL_HIDAPI_numdrivers = 0; static SDL_SpinLock SDL_HIDAPI_spinlock; -static SDL_bool SDL_HIDAPI_hints_changed = SDL_FALSE; +static bool SDL_HIDAPI_hints_changed = false; static Uint32 SDL_HIDAPI_change_count = 0; static SDL_HIDAPI_Device *SDL_HIDAPI_devices SDL_GUARDED_BY(SDL_joystick_lock); static int SDL_HIDAPI_numjoysticks = 0; -static SDL_bool SDL_HIDAPI_combine_joycons = SDL_TRUE; -static SDL_bool initialized = SDL_FALSE; -static SDL_bool shutting_down = SDL_FALSE; +static bool SDL_HIDAPI_combine_joycons = true; +static bool initialized = false; +static bool shutting_down = false; static char *HIDAPI_ConvertString(const wchar_t *wide_string) { @@ -137,46 +137,46 @@ void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size) SDL_free(buffer); } -SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) +bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) { /* If we already know the controller is a different type, don't try to detect it. * This fixes a hang with the HORIPAD for Nintendo Switch (0x0f0d/0x00c1) */ - if (SDL_GetGamepadTypeFromVIDPID(vendor, product, NULL, SDL_FALSE) != SDL_GAMEPAD_TYPE_STANDARD) { - return SDL_FALSE; + if (SDL_GetGamepadTypeFromVIDPID(vendor, product, NULL, false) != SDL_GAMEPAD_TYPE_STANDARD) { + return false; } switch (vendor) { case USB_VENDOR_DRAGONRISE: - return SDL_TRUE; + return true; case USB_VENDOR_HORI: - return SDL_TRUE; + return true; case USB_VENDOR_LOGITECH: /* Most Logitech devices are not PlayStation controllers, and some of them * lock up or reset when we send them the Sony third-party query feature * report, so don't include that vendor here. Instead add devices as * appropriate to controller_list.h */ - return SDL_FALSE; + return false; case USB_VENDOR_MADCATZ: if (product == USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK) { // This is not a Playstation compatible device - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; case USB_VENDOR_MAYFLASH: - return SDL_TRUE; + return true; case USB_VENDOR_NACON: case USB_VENDOR_NACON_ALT: - return SDL_TRUE; + return true; case USB_VENDOR_PDP: - return SDL_TRUE; + return true; case USB_VENDOR_POWERA: - return SDL_TRUE; + return true; case USB_VENDOR_POWERA_ALT: - return SDL_TRUE; + return true; case USB_VENDOR_QANBA: - return SDL_TRUE; + return true; case USB_VENDOR_RAZER: /* Most Razer devices are not PlayStation controllers, and some of them * lock up or reset when we send them the Sony third-party query feature @@ -186,19 +186,19 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) * Reference: https://github.com/libsdl-org/SDL/issues/6733 * https://github.com/libsdl-org/SDL/issues/6799 */ - return SDL_FALSE; + return false; case USB_VENDOR_SHANWAN: - return SDL_TRUE; + return true; case USB_VENDOR_SHANWAN_ALT: - return SDL_TRUE; + return true; case USB_VENDOR_THRUSTMASTER: - return SDL_TRUE; + return true; case USB_VENDOR_ZEROPLUS: - return SDL_TRUE; + return true; case 0x7545 /* SZ-MYPOWER */: - return SDL_TRUE; + return true; default: - return SDL_FALSE; + return false; } } @@ -297,12 +297,12 @@ static SDL_GamepadType SDL_GetJoystickGameControllerProtocol(const char *name, U } if (type == SDL_GAMEPAD_TYPE_STANDARD) { - type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, SDL_FALSE); + type = SDL_GetGamepadTypeFromVIDPID(vendor, product, name, false); } return type; } -static SDL_bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { int i; SDL_GamepadType type = SDL_GetJoystickGameControllerProtocol(name, vendor_id, product_id, -1, 0, 0, 0); @@ -310,10 +310,10 @@ static SDL_bool HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Ui for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) { SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i]; if (driver->enabled && driver->IsSupportedDevice(NULL, name, type, vendor_id, product_id, version, -1, 0, 0, 0)) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static SDL_HIDAPI_DeviceDriver *HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device) @@ -417,12 +417,12 @@ static void HIDAPI_CleanupDeviceDriver(SDL_HIDAPI_Device *device) SDL_UnlockMutex(device->dev_lock); } -static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed) SDL_NO_THREAD_SAFETY_ANALYSIS // We unlock the joystick lock to be able to open the HID device on Android +static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, bool *removed) SDL_NO_THREAD_SAFETY_ANALYSIS // We unlock the joystick lock to be able to open the HID device on Android { - *removed = SDL_FALSE; + *removed = false; if (device->driver) { - SDL_bool enabled; + bool enabled; if (device->vendor_id == USB_VENDOR_NINTENDO && device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR) { enabled = SDL_HIDAPI_combine_joycons; @@ -435,7 +435,7 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove for (i = 0; i < device->num_children; ++i) { SDL_HIDAPI_Device *child = device->children[i]; if (!child->driver || !child->driver->enabled) { - enabled = SDL_FALSE; + enabled = false; break; } } @@ -485,7 +485,7 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove continue; } if (curr == NULL) { - *removed = SDL_TRUE; + *removed = true; if (dev) { SDL_hid_close(dev); } @@ -536,7 +536,7 @@ static void SDL_HIDAPI_UpdateDrivers(void) { int i; SDL_HIDAPI_Device *device; - SDL_bool removed; + bool removed; SDL_AssertJoysticksLocked(); @@ -549,7 +549,7 @@ static void SDL_HIDAPI_UpdateDrivers(void) } } - removed = SDL_FALSE; + removed = false; do { for (device = SDL_HIDAPI_devices; device; device = device->next) { HIDAPI_SetupDeviceDriver(device, &removed); @@ -563,9 +563,9 @@ static void SDL_HIDAPI_UpdateDrivers(void) static void SDLCALL SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { if (SDL_strcmp(name, SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS) == 0) { - SDL_HIDAPI_combine_joycons = SDL_GetStringBoolean(hint, SDL_TRUE); + SDL_HIDAPI_combine_joycons = SDL_GetStringBoolean(hint, true); } - SDL_HIDAPI_hints_changed = SDL_TRUE; + SDL_HIDAPI_hints_changed = true; SDL_HIDAPI_change_count = 0; } @@ -579,7 +579,7 @@ static int HIDAPI_JoystickInit(void) #ifdef SDL_USE_LIBUDEV if (linux_enumeration_method == ENUMERATION_UNSET) { - if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_UDEV, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_HIDAPI_UDEV, true)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "udev disabled by SDL_HINT_HIDAPI_UDEV"); linux_enumeration_method = ENUMERATION_FALLBACK; @@ -612,24 +612,24 @@ static int HIDAPI_JoystickInit(void) HIDAPI_UpdateDeviceList(); HIDAPI_UpdateDevices(); - initialized = SDL_TRUE; + initialized = true; return 0; } -static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks)); if (!joysticks) { - return SDL_FALSE; + return false; } device->joysticks = joysticks; device->joysticks[device->num_joysticks++] = joystickID; - return SDL_TRUE; + return true; } -static SDL_bool HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static bool HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { int i, size; @@ -642,19 +642,19 @@ static SDL_bool HIDAPI_DelJoystickInstanceFromDevice(SDL_HIDAPI_Device *device, SDL_free(device->joysticks); device->joysticks = NULL; } - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool HIDAPI_JoystickInstanceIsUnique(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) +static bool HIDAPI_JoystickInstanceIsUnique(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { if (device->parent && device->num_joysticks == 1 && device->parent->num_joysticks == 1 && device->joysticks[0] == device->parent->joysticks[0]) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) @@ -687,15 +687,15 @@ static void HIDAPI_UpdateJoystickSerial(SDL_HIDAPI_Device *device) } } -static SDL_bool HIDAPI_SerialIsEmpty(SDL_HIDAPI_Device *device) +static bool HIDAPI_SerialIsEmpty(SDL_HIDAPI_Device *device) { - SDL_bool all_zeroes = SDL_TRUE; + bool all_zeroes = true; if (device->serial) { const char *serial = device->serial; for (serial = device->serial; *serial; ++serial) { if (*serial != '0') { - all_zeroes = SDL_FALSE; + all_zeroes = false; break; } } @@ -736,14 +736,14 @@ static void HIDAPI_SetDeviceSerialW(SDL_HIDAPI_Device *device, const wchar_t *se } } -SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial) +bool HIDAPI_HasConnectedUSBDevice(const char *serial) { SDL_HIDAPI_Device *device; SDL_AssertJoysticksLocked(); if (!serial) { - return SDL_FALSE; + return false; } for (device = SDL_HIDAPI_devices; device; device = device->next) { @@ -756,10 +756,10 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial) } if (device->serial && SDL_strcmp(serial, device->serial) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } void HIDAPI_DisconnectBluetoothDevice(const char *serial) @@ -789,7 +789,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial) } } -SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID) +bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID) { int i, j; SDL_JoystickID joystickID; @@ -818,7 +818,7 @@ SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJo if (pJoystickID) { *pJoystickID = joystickID; } - return SDL_TRUE; + return true; } void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) @@ -866,29 +866,29 @@ static void HIDAPI_UpdateJoystickProperties(SDL_HIDAPI_Device *device, SDL_Joyst Uint32 caps = device->driver->GetJoystickCapabilities(device, joystick); if (caps & SDL_JOYSTICK_CAP_MONO_LED) { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, true); } else { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN, false); } if (caps & SDL_JOYSTICK_CAP_RGB_LED) { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true); } else { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, false); } if (caps & SDL_JOYSTICK_CAP_PLAYER_LED) { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, true); } else { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN, false); } if (caps & SDL_JOYSTICK_CAP_RUMBLE) { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } else { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, false); } if (caps & SDL_JOYSTICK_CAP_TRIGGER_RUMBLE) { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } else { - SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(props, SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, false); } } @@ -917,7 +917,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf { SDL_HIDAPI_Device *device; SDL_HIDAPI_Device *curr, *last = NULL; - SDL_bool removed; + bool removed; Uint16 bus; SDL_AssertJoysticksLocked(); @@ -929,13 +929,13 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf if (!device) { return NULL; } - SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, SDL_TRUE); + SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, true); device->path = SDL_strdup(info->path); if (!device->path) { SDL_free(device); return NULL; } - device->seen = SDL_TRUE; + device->seen = true; device->vendor_id = info->vendor_id; device->product_id = info->product_id; device->version = info->release_number; @@ -998,7 +998,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf SDL_HIDAPI_devices = device; } - removed = SDL_FALSE; + removed = false; HIDAPI_SetupDeviceDriver(device, &removed); if (removed) { return NULL; @@ -1041,7 +1041,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) device->children[i]->parent = NULL; } - SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, SDL_FALSE); + SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, false); SDL_DestroyMutex(device->dev_lock); SDL_free(device->manufacturer_string); SDL_free(device->product_string); @@ -1055,7 +1055,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) } } -static SDL_bool HIDAPI_CreateCombinedJoyCons(void) +static bool HIDAPI_CreateCombinedJoyCons(void) { SDL_HIDAPI_Device *device, *combined; SDL_HIDAPI_Device *joycons[2] = { NULL, NULL }; @@ -1063,7 +1063,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void) SDL_AssertJoysticksLocked(); if (!SDL_HIDAPI_combine_joycons) { - return SDL_FALSE; + return false; } for (device = SDL_HIDAPI_devices; device; device = device->next) { @@ -1096,7 +1096,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void) SDL_hid_device_info info; SDL_HIDAPI_Device **children = (SDL_HIDAPI_Device **)SDL_malloc(2 * sizeof(SDL_HIDAPI_Device *)); if (!children) { - return SDL_FALSE; + return false; } children[0] = joycons[0]; children[1] = joycons[1]; @@ -1113,18 +1113,18 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void) combined = HIDAPI_AddDevice(&info, 2, children); if (combined && combined->driver) { - return SDL_TRUE; + return true; } else { if (combined) { HIDAPI_DelDevice(combined); } else { SDL_free(children); } - return SDL_FALSE; + return false; } } } - return SDL_FALSE; + return false; } static void HIDAPI_UpdateDeviceList(void) @@ -1136,7 +1136,7 @@ static void HIDAPI_UpdateDeviceList(void) if (SDL_HIDAPI_hints_changed) { SDL_HIDAPI_UpdateDrivers(); - SDL_HIDAPI_hints_changed = SDL_FALSE; + SDL_HIDAPI_hints_changed = false; } // Prepare the existing device list @@ -1144,7 +1144,7 @@ static void HIDAPI_UpdateDeviceList(void) if (device->children) { continue; } - device->seen = SDL_FALSE; + device->seen = false; } // Enumerate the devices @@ -1154,7 +1154,7 @@ static void HIDAPI_UpdateDeviceList(void) for (info = devs; info; info = info->next) { device = HIDAPI_GetJoystickByInfo(info->path, info->vendor_id, info->product_id); if (device) { - device->seen = SDL_TRUE; + device->seen = true; // Check to see if the serial number is available now if(HIDAPI_SerialIsEmpty(device)) { @@ -1207,28 +1207,28 @@ check_removed: SDL_UnlockJoysticks(); } -static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Device *device) +static bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Device *device) { if (vendor_id == device->vendor_id && product_id == device->product_id) { - return SDL_TRUE; + return true; } if (vendor_id == USB_VENDOR_MICROSOFT) { // If we're looking for the wireless XBox 360 controller, also look for the dongle if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER && device->product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER) { - return SDL_TRUE; + return true; } // If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller if (product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER && device->type == SDL_GAMEPAD_TYPE_XBOXONE) { - return SDL_TRUE; + return true; } // If we're looking for an XInput controller, match it against any other Xbox controller if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER) { if (device->type == SDL_GAMEPAD_TYPE_XBOX360 || device->type == SDL_GAMEPAD_TYPE_XBOXONE) { - return SDL_TRUE; + return true; } } } @@ -1237,20 +1237,20 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, // If we're looking for the NVIDIA SHIELD controller Xbox interface, match it against any NVIDIA SHIELD controller if (product_id == 0xb400 && SDL_IsJoystickNVIDIASHIELDController(vendor_id, product_id)) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type) +bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type) { SDL_HIDAPI_Device *device; - SDL_bool result = SDL_FALSE; + bool result = false; // Make sure we're initialized, as this could be called from other drivers during startup if (HIDAPI_JoystickInit() < 0) { - return SDL_FALSE; + return false; } if (SDL_TryLockSpinlock(&SDL_HIDAPI_spinlock)) { @@ -1261,7 +1261,7 @@ SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type) SDL_LockJoysticks(); for (device = SDL_HIDAPI_devices; device; device = device->next) { if (device->driver && device->type == type) { - result = SDL_TRUE; + result = true; break; } } @@ -1273,15 +1273,15 @@ SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type) return result; } -SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { SDL_HIDAPI_Device *device; - SDL_bool supported = SDL_FALSE; - SDL_bool result = SDL_FALSE; + bool supported = false; + bool result = false; // Make sure we're initialized, as this could be called from other drivers during startup if (HIDAPI_JoystickInit() < 0) { - return SDL_FALSE; + return false; } /* Only update the device list for devices we know might be supported. @@ -1294,7 +1294,7 @@ SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 vers #if defined(SDL_JOYSTICK_HIDAPI_XBOX360) || defined(SDL_JOYSTICK_HIDAPI_XBOXONE) if (!supported && (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box") || SDL_strstr(name, "XBOX"))) { - supported = SDL_TRUE; + supported = true; } #endif // SDL_JOYSTICK_HIDAPI_XBOX360 || SDL_JOYSTICK_HIDAPI_XBOXONE if (supported) { @@ -1312,7 +1312,7 @@ SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 vers for (device = SDL_HIDAPI_devices; device; device = device->next) { if (device->driver && HIDAPI_IsEquivalentToDevice(vendor_id, product_id, device)) { - result = SDL_TRUE; + result = true; break; } } @@ -1386,9 +1386,9 @@ void HIDAPI_UpdateDevices(void) } if (device->driver) { if (SDL_TryLockMutex(device->dev_lock) == 0) { - device->updating = SDL_TRUE; + device->updating = true; device->driver->UpdateDevice(device); - device->updating = SDL_FALSE; + device->updating = false; SDL_UnlockMutex(device->dev_lock); } } @@ -1498,9 +1498,9 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) // Process any pending reports before opening the device SDL_LockMutex(device->dev_lock); - device->updating = SDL_TRUE; + device->updating = true; device->driver->UpdateDevice(device); - device->updating = SDL_FALSE; + device->updating = false; SDL_UnlockMutex(device->dev_lock); // UpdateDevice() may have called HIDAPI_JoystickDisconnected() if the device went away @@ -1533,17 +1533,17 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static SDL_bool HIDAPI_GetJoystickDevice(SDL_Joystick *joystick, SDL_HIDAPI_Device **device) +static bool HIDAPI_GetJoystickDevice(SDL_Joystick *joystick, SDL_HIDAPI_Device **device) { SDL_AssertJoysticksLocked(); if (joystick && joystick->hwdata) { *device = joystick->hwdata->device; if (SDL_ObjectValid(*device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK) && (*device)->driver != NULL) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static int HIDAPI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) @@ -1602,7 +1602,7 @@ static int HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, i return result; } -static int HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { int result; SDL_HIDAPI_Device *device = NULL; @@ -1657,7 +1657,7 @@ static void HIDAPI_JoystickQuit(void) SDL_AssertJoysticksLocked(); - shutting_down = SDL_TRUE; + shutting_down = true; SDL_HIDAPI_QuitRumble(); @@ -1690,13 +1690,13 @@ static void HIDAPI_JoystickQuit(void) SDL_hid_exit(); SDL_HIDAPI_change_count = 0; - shutting_down = SDL_FALSE; - initialized = SDL_FALSE; + shutting_down = false; + initialized = false; } -static SDL_bool HIDAPI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool HIDAPI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = { diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h index d5c243ea0a..2c2c3c7466 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -53,9 +53,9 @@ defined(SDL_PLATFORM_TVOS) || \ defined(SDL_PLATFORM_VISIONOS) // On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers, so we'll leave it off by default. -#define SDL_HIDAPI_DEFAULT SDL_FALSE +#define SDL_HIDAPI_DEFAULT false #else -#define SDL_HIDAPI_DEFAULT SDL_TRUE +#define SDL_HIDAPI_DEFAULT true #endif // The maximum size of a USB packet for HID devices @@ -81,7 +81,7 @@ typedef struct SDL_HIDAPI_Device int interface_protocol; Uint16 usage_page; // Available on Windows and macOS Uint16 usage; // Available on Windows and macOS - SDL_bool is_bluetooth; + bool is_bluetooth; SDL_JoystickType joystick_type; SDL_GamepadType type; @@ -94,10 +94,10 @@ typedef struct SDL_HIDAPI_Device SDL_JoystickID *joysticks; // Used during scanning for device changes - SDL_bool seen; + bool seen; // Used to flag that the device is being updated - SDL_bool updating; + bool updating; struct SDL_HIDAPI_Device *parent; int num_children; @@ -109,22 +109,22 @@ typedef struct SDL_HIDAPI_Device typedef struct SDL_HIDAPI_DeviceDriver { const char *name; - SDL_bool enabled; + bool enabled; void (*RegisterHints)(SDL_HintCallback callback, void *userdata); void (*UnregisterHints)(SDL_HintCallback callback, void *userdata); - SDL_bool (*IsEnabled)(void); - SDL_bool (*IsSupportedDevice)(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol); - SDL_bool (*InitDevice)(SDL_HIDAPI_Device *device); + bool (*IsEnabled)(void); + bool (*IsSupportedDevice)(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol); + bool (*InitDevice)(SDL_HIDAPI_Device *device); int (*GetDevicePlayerIndex)(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id); void (*SetDevicePlayerIndex)(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index); - SDL_bool (*UpdateDevice)(SDL_HIDAPI_Device *device); - SDL_bool (*OpenJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); + bool (*UpdateDevice)(SDL_HIDAPI_Device *device); + bool (*OpenJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); int (*RumbleJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); int (*RumbleJoystickTriggers)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble); Uint32 (*GetJoystickCapabilities)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); int (*SetJoystickLED)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); int (*SendJoystickEffect)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size); - int (*SetJoystickSensorsEnabled)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled); + int (*SetJoystickSensorsEnabled)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, bool enabled); void (*CloseJoystick)(SDL_HIDAPI_Device *device, SDL_Joystick *joystick); void (*FreeDevice)(SDL_HIDAPI_Device *device); @@ -152,10 +152,10 @@ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne; // Return true if a HID device is present and supported as a joystick of the given type -extern SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type); +extern bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type); // Return true if a HID device is present and supported as a joystick -extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); +extern bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); // Return the type of a joystick if it's present and supported extern SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_GUID guid); @@ -167,15 +167,15 @@ extern void HIDAPI_UpdateDevices(void); extern void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name); extern void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 vendor_id, Uint16 product_id); extern void HIDAPI_SetDeviceSerial(SDL_HIDAPI_Device *device, const char *serial); -extern SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial); +extern bool HIDAPI_HasConnectedUSBDevice(const char *serial); extern void HIDAPI_DisconnectBluetoothDevice(const char *serial); -extern SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID); +extern bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID); extern void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID); extern void HIDAPI_UpdateDeviceProperties(SDL_HIDAPI_Device *device); extern void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size); -extern SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product); +extern bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product); extern float HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max); diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index c81ff250cf..f736b64ca4 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -143,7 +143,7 @@ typedef enum static EnumerationMethod enumeration_method = ENUMERATION_UNSET; -static SDL_bool IsJoystickJSNode(const char *node); +static bool IsJoystickJSNode(const char *node); static void MaybeAddDevice(const char *path); static void MaybeRemoveDevice(const char *path); @@ -160,9 +160,9 @@ typedef struct SDL_joylist_item struct SDL_joylist_item *next; // Steam Controller support - SDL_bool m_bSteamController; + bool m_bSteamController; - SDL_bool checked_mapping; + bool checked_mapping; SDL_GamepadMapping *mapping; } SDL_joylist_item; @@ -175,7 +175,7 @@ typedef struct SDL_sensorlist_item struct SDL_sensorlist_item *next; } SDL_sensorlist_item; -static SDL_bool SDL_classic_joysticks = SDL_FALSE; +static bool SDL_classic_joysticks = false; static SDL_joylist_item *SDL_joylist SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static SDL_joylist_item *SDL_joylist_tail SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static int numjoysticks SDL_GUARDED_BY(SDL_joystick_lock) = 0; @@ -208,18 +208,18 @@ static void FixupDeviceInfoForMapping(int fd, struct input_id *inpid) } #ifdef SDL_JOYSTICK_HIDAPI -static SDL_bool IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name) +static bool IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name) { if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_S && version == 0 && SDL_strcmp(name, "Xbox One S Controller") == 0) { // This is the virtual device created by the xow driver - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } #endif // SDL_JOYSTICK_HIDAPI -static SDL_bool GetSteamVirtualGamepadSlot(int fd, int *slot) +static bool GetSteamVirtualGamepadSlot(int fd, int *slot) { char name[128]; @@ -229,11 +229,11 @@ static SDL_bool GetSteamVirtualGamepadSlot(int fd, int *slot) digits += 4; if (SDL_isdigit(*digits)) { *slot = SDL_atoi(digits); - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } static int GuessDeviceClass(int fd) @@ -663,23 +663,23 @@ static void HandlePendingRemovals(void) } } -static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance) +static bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance) { SDL_joylist_item *item; item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); if (!item) { - return SDL_FALSE; + return false; } item->path = SDL_strdup(""); item->name = SDL_strdup(name); item->guid = guid; - item->m_bSteamController = SDL_TRUE; + item->m_bSteamController = true; if ((!item->path) || (!item->name)) { FreeJoylistItem(item); - return SDL_FALSE; + return false; } *device_instance = item->device_instance = SDL_GetNextObjectID(); @@ -697,7 +697,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid SDL_PrivateJoystickAdded(item->device_instance); SDL_UnlockJoysticks(); - return SDL_TRUE; + return true; } static void SteamControllerDisconnectedCallback(SDL_JoystickID device_instance) @@ -739,7 +739,7 @@ static int StrIsInteger(const char *string) return 1; } -static SDL_bool IsJoystickJSNode(const char *node) +static bool IsJoystickJSNode(const char *node) { const char *last_slash = SDL_strrchr(node, '/'); if (last_slash) { @@ -748,7 +748,7 @@ static SDL_bool IsJoystickJSNode(const char *node) return StrHasPrefix(node, "js") && StrIsInteger(node + 2); } -static SDL_bool IsJoystickEventNode(const char *node) +static bool IsJoystickEventNode(const char *node) { const char *last_slash = SDL_strrchr(node, '/'); if (last_slash) { @@ -757,7 +757,7 @@ static SDL_bool IsJoystickEventNode(const char *node) return StrHasPrefix(node, "event") && StrIsInteger(node + 5); } -static SDL_bool IsJoystickDeviceNode(const char *node) +static bool IsJoystickDeviceNode(const char *node) { if (SDL_classic_joysticks) { return IsJoystickJSNode(node); @@ -1027,10 +1027,10 @@ static void LINUX_JoystickDetect(void) SDL_UpdateSteamControllers(); } -static SDL_bool LINUX_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool LINUX_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static int LINUX_JoystickInit(void) @@ -1040,7 +1040,7 @@ static int LINUX_JoystickInit(void) int udev_status = SDL_UDEV_Init(); #endif - SDL_classic_joysticks = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_CLASSIC, SDL_FALSE); + SDL_classic_joysticks = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_CLASSIC, false); enumeration_method = ENUMERATION_UNSET; @@ -1072,7 +1072,7 @@ static int LINUX_JoystickInit(void) #ifdef SDL_USE_LIBUDEV if (enumeration_method == ENUMERATION_UNSET) { - if (SDL_GetHintBoolean("SDL_JOYSTICK_DISABLE_UDEV", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_JOYSTICK_DISABLE_UDEV", false)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "udev disabled by SDL_JOYSTICK_DISABLE_UDEV"); enumeration_method = ENUMERATION_FALLBACK; @@ -1226,7 +1226,7 @@ static int allocate_hatdata(SDL_Joystick *joystick) return 0; } -static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo *absinfo_y) +static bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo *absinfo_y) { /* A "hat" is assumed to be a digital input with at most 9 possible states * (3 per axis: negative/zero/positive), as opposed to a true "axis" which @@ -1236,26 +1236,26 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct // If both axes are missing, they're not anything. if (!absinfo_x && !absinfo_y) { - return SDL_FALSE; + return false; } // If the hint says so, treat all hats as digital. - if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS, SDL_FALSE)) { - return SDL_TRUE; + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS, false)) { + return true; } // If both axes have ranges constrained between -1 and 1, they're definitely digital. if ((!absinfo_x || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (!absinfo_y || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { - return SDL_TRUE; + return true; } // If both axes lack fuzz, flat, and resolution values, they're probably digital. if ((!absinfo_x || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (!absinfo_y || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { - return SDL_TRUE; + return true; } // Otherwise, treat them as analog. - return SDL_FALSE; + return false; } static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) @@ -1266,8 +1266,8 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) unsigned long relbit[NBITS(REL_MAX)] = { 0 }; unsigned long ffbit[NBITS(FF_MAX)] = { 0 }; Uint8 key_pam_size, abs_pam_size; - SDL_bool use_deadzones = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_DEADZONES, SDL_FALSE); - SDL_bool use_hat_deadzones = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES, SDL_TRUE); + bool use_deadzones = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_DEADZONES, false); + bool use_hat_deadzones = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES, true); SDL_AssertJoysticksLocked(); @@ -1283,7 +1283,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Joystick has button: 0x%x\n", i); #endif joystick->hwdata->key_map[i] = joystick->nbuttons; - joystick->hwdata->has_key[i] = SDL_TRUE; + joystick->hwdata->has_key[i] = true; ++joystick->nbuttons; } } @@ -1293,7 +1293,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Joystick has button: 0x%x\n", i); #endif joystick->hwdata->key_map[i] = joystick->nbuttons; - joystick->hwdata->has_key[i] = SDL_TRUE; + joystick->hwdata->has_key[i] = true; ++joystick->nbuttons; } } @@ -1326,7 +1326,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) } #endif // DEBUG_INPUT_EVENTS joystick->hwdata->hats_indices[hat_index] = joystick->nhats; - joystick->hwdata->has_hat[hat_index] = SDL_TRUE; + joystick->hwdata->has_hat[hat_index] = true; correct->use_deadzones = use_hat_deadzones; correct->minimum[0] = (hat_x < 0) ? -1 : absinfo_x.minimum; correct->maximum[0] = (hat_x < 0) ? 1 : absinfo_x.maximum; @@ -1354,13 +1354,13 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) absinfo.fuzz, absinfo.flat, absinfo.resolution); #endif // DEBUG_INPUT_EVENTS joystick->hwdata->abs_map[i] = joystick->naxes; - joystick->hwdata->has_abs[i] = SDL_TRUE; + joystick->hwdata->has_abs[i] = true; correct->minimum = absinfo.minimum; correct->maximum = absinfo.maximum; if (correct->minimum != correct->maximum) { if (use_deadzones) { - correct->use_deadzones = SDL_TRUE; + correct->use_deadzones = true; correct->coef[0] = (absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat; correct->coef[1] = (absinfo.maximum + absinfo.minimum) + 2 * absinfo.flat; t = ((absinfo.maximum - absinfo.minimum) - 4 * absinfo.flat); @@ -1387,7 +1387,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) (ioctl(fd, JSIOCGAXES, &abs_pam_size, sizeof(abs_pam_size)) >= 0)) { size_t len; - joystick->hwdata->classic = SDL_TRUE; + joystick->hwdata->classic = true; len = (KEY_MAX - BTN_MISC + 1) * sizeof(*joystick->hwdata->key_pam); joystick->hwdata->key_pam = (Uint16 *)SDL_calloc(1, len); @@ -1406,7 +1406,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Joystick has button: 0x%x\n", code); #endif joystick->hwdata->key_map[code] = joystick->nbuttons; - joystick->hwdata->has_key[code] = SDL_TRUE; + joystick->hwdata->has_key[code] = true; ++joystick->nbuttons; } @@ -1432,7 +1432,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Joystick has digital hat: #%d\n", hat_index); #endif joystick->hwdata->hats_indices[hat_index] = joystick->nhats++; - joystick->hwdata->has_hat[hat_index] = SDL_TRUE; + joystick->hwdata->has_hat[hat_index] = true; joystick->hwdata->hat_correct[hat_index].minimum[0] = -1; joystick->hwdata->hat_correct[hat_index].maximum[0] = 1; joystick->hwdata->hat_correct[hat_index].minimum[1] = -1; @@ -1443,7 +1443,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) SDL_Log("Joystick has absolute axis: 0x%.2x\n", code); #endif joystick->hwdata->abs_map[code] = joystick->naxes; - joystick->hwdata->has_abs[code] = SDL_TRUE; + joystick->hwdata->has_abs[code] = true; ++joystick->naxes; } } @@ -1452,11 +1452,11 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) // Sensors are only available through the new unified event API if (fd_sensor >= 0 && (ioctl(fd_sensor, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0)) { if (test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) && test_bit(ABS_Z, absbit)) { - joystick->hwdata->has_accelerometer = SDL_TRUE; + joystick->hwdata->has_accelerometer = true; for (i = 0; i < 3; ++i) { struct input_absinfo absinfo; if (ioctl(fd_sensor, EVIOCGABS(ABS_X + i), &absinfo) < 0) { - joystick->hwdata->has_accelerometer = SDL_FALSE; + joystick->hwdata->has_accelerometer = false; break; // do not report an accelerometer if we can't read all axes } joystick->hwdata->accelerometer_scale[i] = absinfo.resolution; @@ -1470,11 +1470,11 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) } if (test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit) && test_bit(ABS_RZ, absbit)) { - joystick->hwdata->has_gyro = SDL_TRUE; + joystick->hwdata->has_gyro = true; for (i = 0; i < 3; ++i) { struct input_absinfo absinfo; if (ioctl(fd_sensor, EVIOCGABS(ABS_RX + i), &absinfo) < 0) { - joystick->hwdata->has_gyro = SDL_FALSE; + joystick->hwdata->has_gyro = false; break; // do not report a gyro if we can't read all axes } joystick->hwdata->gyro_scale[i] = absinfo.resolution; @@ -1502,10 +1502,10 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) >= 0) { if (test_bit(FF_RUMBLE, ffbit)) { - joystick->hwdata->ff_rumble = SDL_TRUE; + joystick->hwdata->ff_rumble = true; } if (test_bit(FF_SINE, ffbit)) { - joystick->hwdata->ff_sine = SDL_TRUE; + joystick->hwdata->ff_sine = true; } } } @@ -1664,7 +1664,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) } // mark joystick as fresh and ready - joystick->hwdata->fresh = SDL_TRUE; + joystick->hwdata->fresh = true; if (joystick->hwdata->has_gyro) { SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 0.0f); @@ -1679,7 +1679,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (joystick->hwdata->ff_rumble || joystick->hwdata->ff_sine) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } return 0; } @@ -1742,7 +1742,7 @@ static int LINUX_JoystickSendEffect(SDL_Joystick *joystick, const void *data, in return SDL_Unsupported(); } -static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { SDL_AssertJoysticksLocked(); @@ -1968,7 +1968,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) if (joystick->hwdata->report_sensor) { PollAllSensors(ticks, joystick); } - joystick->hwdata->fresh = SDL_FALSE; + joystick->hwdata->fresh = false; } errno = 0; @@ -2043,11 +2043,11 @@ static void HandleInputEvents(SDL_Joystick *joystick) #ifdef DEBUG_INPUT_EVENTS SDL_Log("Event SYN_DROPPED detected\n"); #endif - joystick->hwdata->recovering_from_dropped = SDL_TRUE; + joystick->hwdata->recovering_from_dropped = true; break; case SYN_REPORT: if (joystick->hwdata->recovering_from_dropped) { - joystick->hwdata->recovering_from_dropped = SDL_FALSE; + joystick->hwdata->recovering_from_dropped = false; PollAllValues(SDL_GetTicksNS(), joystick); // try to sync up to current state now } break; @@ -2063,7 +2063,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) if (errno == ENODEV) { // We have to wait until the JoystickDetect callback to remove this - joystick->hwdata->gone = SDL_TRUE; + joystick->hwdata->gone = true; errno = 0; } @@ -2126,11 +2126,11 @@ static void HandleInputEvents(SDL_Joystick *joystick) #ifdef DEBUG_INPUT_EVENTS SDL_Log("Event SYN_DROPPED detected\n"); #endif - joystick->hwdata->recovering_from_dropped_sensor = SDL_TRUE; + joystick->hwdata->recovering_from_dropped_sensor = true; break; case SYN_REPORT: if (joystick->hwdata->recovering_from_dropped_sensor) { - joystick->hwdata->recovering_from_dropped_sensor = SDL_FALSE; + joystick->hwdata->recovering_from_dropped_sensor = false; PollAllSensors(SDL_GetTicksNS(), joystick); // try to sync up to current state now } else { Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event); @@ -2155,7 +2155,7 @@ static void HandleInputEvents(SDL_Joystick *joystick) if (errno == ENODEV) { // We have to wait until the JoystickDetect callback to remove this - joystick->hwdata->sensor_gone = SDL_TRUE; + joystick->hwdata->sensor_gone = true; } } @@ -2167,7 +2167,7 @@ static void HandleClassicEvents(SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - joystick->hwdata->fresh = SDL_FALSE; + joystick->hwdata->fresh = false; while ((len = read(joystick->hwdata->fd, events, sizeof(events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { @@ -2313,7 +2313,7 @@ static void LINUX_JoystickQuit(void) and the Android gamepad documentation, https://developer.android.com/develop/ui/views/touch-and-input/game-controllers/controller-input */ -static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { SDL_Joystick *joystick; SDL_joylist_item *item = GetJoystickByDevIndex(device_index); @@ -2329,7 +2329,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap MAPPED_DPAD_ALL = 0xF, }; unsigned int mapped; - SDL_bool result = SDL_FALSE; + bool result = false; SDL_AssertJoysticksLocked(); @@ -2339,9 +2339,9 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #ifdef DEBUG_GAMEPAD_MAPPING SDL_Log("Prior mapping for device %d", device_index); #endif - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } @@ -2349,18 +2349,18 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap a fake SDL_Joystick object to do so. */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); if (!joystick) { - return SDL_FALSE; + return false; } SDL_memcpy(&joystick->guid, &item->guid, sizeof(item->guid)); joystick->hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*joystick->hwdata)); if (!joystick->hwdata) { SDL_free(joystick); - return SDL_FALSE; + return false; } - SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, SDL_TRUE); + SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, true); - item->checked_mapping = SDL_TRUE; + item->checked_mapping = true; if (PrepareJoystickHwdata(joystick, item, NULL) < 0) { goto done; // SDL_SetError will already have been called @@ -2776,11 +2776,11 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap #ifdef DEBUG_GAMEPAD_MAPPING SDL_Log("Generated mapping for device %d", device_index); #endif - result = SDL_TRUE; + result = true; done: LINUX_JoystickClose(joystick); - SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, SDL_FALSE); + SDL_SetObjectValid(joystick, SDL_OBJECT_TYPE_JOYSTICK, false); SDL_free(joystick); return result; diff --git a/src/joystick/linux/SDL_sysjoystick_c.h b/src/joystick/linux/SDL_sysjoystick_c.h index f7004b5c8e..517854d6d7 100644 --- a/src/joystick/linux/SDL_sysjoystick_c.h +++ b/src/joystick/linux/SDL_sysjoystick_c.h @@ -38,8 +38,8 @@ struct joystick_hwdata SDL_GUID guid; char *fname; // Used in haptic subsystem - SDL_bool ff_rumble; - SDL_bool ff_sine; + bool ff_rumble; + bool ff_sine; struct ff_effect effect; Uint32 effect_expiration; @@ -58,19 +58,19 @@ struct joystick_hwdata // Support for the Linux 2.4 unified input interface Uint8 key_map[KEY_MAX]; Uint8 abs_map[ABS_MAX]; - SDL_bool has_key[KEY_MAX]; - SDL_bool has_abs[ABS_MAX]; - SDL_bool has_accelerometer; - SDL_bool has_gyro; + bool has_key[KEY_MAX]; + bool has_abs[ABS_MAX]; + bool has_accelerometer; + bool has_gyro; // Support for the classic joystick interface - SDL_bool classic; + bool classic; Uint16 *key_pam; Uint8 *abs_pam; struct axis_correct { - SDL_bool use_deadzones; + bool use_deadzones; // Deadzone coefficients int coef[3]; @@ -91,27 +91,27 @@ struct joystick_hwdata Uint64 sensor_tick; Sint32 last_tick; - SDL_bool report_sensor; - SDL_bool fresh; - SDL_bool recovering_from_dropped; - SDL_bool recovering_from_dropped_sensor; + bool report_sensor; + bool fresh; + bool recovering_from_dropped; + bool recovering_from_dropped_sensor; // Steam Controller support - SDL_bool m_bSteamController; + bool m_bSteamController; // 4 = (ABS_HAT3X-ABS_HAT0X)/2 (see input-event-codes.h in kernel) int hats_indices[4]; - SDL_bool has_hat[4]; + bool has_hat[4]; struct hat_axis_correct { - SDL_bool use_deadzones; + bool use_deadzones; int minimum[2]; int maximum[2]; } hat_correct[4]; // Set when gamepad is pending removal due to ENODEV read error - SDL_bool gone; - SDL_bool sensor_gone; + bool gone; + bool sensor_gone; }; #endif // SDL_sysjoystick_c_h_ diff --git a/src/joystick/n3ds/SDL_sysjoystick.c b/src/joystick/n3ds/SDL_sysjoystick.c index 1607475af8..db161b8a46 100644 --- a/src/joystick/n3ds/SDL_sysjoystick.c +++ b/src/joystick/n3ds/SDL_sysjoystick.c @@ -96,7 +96,7 @@ static int N3DS_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } -static int N3DS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int N3DS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -188,7 +188,7 @@ static void N3DS_JoystickQuit(void) hidExit(); } -static SDL_bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { // There is only one possible mapping. *out = (SDL_GamepadMapping){ @@ -219,17 +219,17 @@ static SDL_bool N3DS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapp .lefttrigger = { EMappingKind_Button, 14 }, .righttrigger = { EMappingKind_Button, 15 }, }; - return SDL_TRUE; + return true; } static void N3DS_JoystickDetect(void) { } -static SDL_bool N3DS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool N3DS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static const char *N3DS_JoystickGetDevicePath(int device_index) diff --git a/src/joystick/ps2/SDL_sysjoystick.c b/src/joystick/ps2/SDL_sysjoystick.c index 0ee58d5afb..64e5f8fd84 100644 --- a/src/joystick/ps2/SDL_sysjoystick.c +++ b/src/joystick/ps2/SDL_sysjoystick.c @@ -141,10 +141,10 @@ static void PS2_JoystickDetect(void) { } -static SDL_bool PS2_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool PS2_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } // Function to get the device-dependent name of a joystick @@ -216,7 +216,7 @@ static int PS2_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->naxes = PS2_TOTAL_AXIS; joystick->nhats = 0; - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); return 0; } @@ -264,7 +264,7 @@ static int PS2_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int } // Sensor functionality -static int PS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int PS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -338,9 +338,9 @@ static void PS2_JoystickQuit(void) deinit_joystick_driver(true); } -static SDL_bool PS2_GetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool PS2_GetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_PS2_JoystickDriver = { diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index 77c63d3993..a97f094598 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -101,10 +101,10 @@ static void PSP_JoystickDetect(void) { } -static SDL_bool PSP_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool PSP_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } // Function to get the device-dependent name of a joystick @@ -184,7 +184,7 @@ static int PSP_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int return SDL_Unsupported(); } -static int PSP_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int PSP_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -245,9 +245,9 @@ static void PSP_JoystickQuit(void) { } -static SDL_bool PSP_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool PSP_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_PSP_JoystickDriver = { diff --git a/src/joystick/steam/SDL_steamcontroller.h b/src/joystick/steam/SDL_steamcontroller.h index f38f33d39f..8468aa0a90 100644 --- a/src/joystick/steam/SDL_steamcontroller.h +++ b/src/joystick/steam/SDL_steamcontroller.h @@ -24,7 +24,7 @@ #include "SDL_internal.h" -typedef SDL_bool (*SteamControllerConnectedCallback_t)(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance); +typedef bool (*SteamControllerConnectedCallback_t)(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance); typedef void (*SteamControllerDisconnectedCallback_t)(SDL_JoystickID device_instance); void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback, diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index 69f1ca34fa..3579b463bf 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -495,10 +495,10 @@ static void VIRTUAL_JoystickDetect(void) { } -static SDL_bool VIRTUAL_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool VIRTUAL_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers... or do we? - return SDL_FALSE; + return false; } static const char *VIRTUAL_JoystickGetDeviceName(int device_index) @@ -580,13 +580,13 @@ static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (hwdata->desc.SetLED) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true); } if (hwdata->desc.Rumble) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } if (hwdata->desc.RumbleTriggers) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } return 0; } @@ -671,7 +671,7 @@ static int VIRTUAL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, return result; } -static int VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int VIRTUAL_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { int result; @@ -780,14 +780,14 @@ static void VIRTUAL_JoystickQuit(void) } } -static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); Uint8 current_button = 0; Uint8 current_axis = 0; if (!hwdata || hwdata->desc.type != SDL_JOYSTICK_TYPE_GAMEPAD) { - return SDL_FALSE; + return false; } if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_SOUTH))) { @@ -950,7 +950,7 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM out->righttrigger.target = current_axis++; } - return SDL_TRUE; + return true; } SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = { diff --git a/src/joystick/virtual/SDL_virtualjoystick_c.h b/src/joystick/virtual/SDL_virtualjoystick_c.h index b453223f08..e8a94fa88e 100644 --- a/src/joystick/virtual/SDL_virtualjoystick_c.h +++ b/src/joystick/virtual/SDL_virtualjoystick_c.h @@ -47,7 +47,7 @@ typedef struct VirtualSensorEvent typedef struct joystick_hwdata { SDL_JoystickID instance_id; - SDL_bool attached; + bool attached; char *name; SDL_JoystickType type; SDL_GUID guid; @@ -59,7 +59,7 @@ typedef struct joystick_hwdata SDL_JoystickBallData *balls; SDL_JoystickTouchpadInfo *touchpads; SDL_JoystickSensorInfo *sensors; - SDL_bool sensors_enabled; + bool sensors_enabled; int num_sensor_events; int max_sensor_events; VirtualSensorEvent *sensor_events; diff --git a/src/joystick/vita/SDL_sysjoystick.c b/src/joystick/vita/SDL_sysjoystick.c index eccf950d60..1e401ce604 100644 --- a/src/joystick/vita/SDL_sysjoystick.c +++ b/src/joystick/vita/SDL_sysjoystick.c @@ -143,10 +143,10 @@ static void VITA_JoystickDetect(void) { } -static SDL_bool VITA_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool VITA_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } // Function to perform the mapping from device index to the instance id for this index @@ -207,8 +207,8 @@ static int VITA_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->naxes = 6; joystick->nhats = 0; - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, SDL_TRUE); - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); return 0; } @@ -364,14 +364,14 @@ static int VITA_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int return SDL_Unsupported(); } -static int VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } -static SDL_bool VITA_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool VITA_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_VITA_JoystickDriver = { diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index a80fe2197d..2df803236a 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -47,7 +47,7 @@ static const HWND SDL_HelperWindow = NULL; #endif // local variables -static SDL_bool coinitialized = SDL_FALSE; +static bool coinitialized = false; static LPDIRECTINPUT8 dinput = NULL; // Taken from Wine - Thanks! @@ -236,7 +236,7 @@ static int SetDIerror(const char *function, HRESULT code) return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code); } -static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char *hidPath) +static bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char *hidPath) { #if defined(SDL_JOYSTICK_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT) SDL_GamepadType type; @@ -247,32 +247,32 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const ch && !RAWINPUT_IsEnabled() #endif ) { - return SDL_FALSE; + return false; } // If device path contains "IG_" then its an XInput device // See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput if (SDL_strstr(hidPath, "IG_") != NULL) { - return SDL_TRUE; + return true; } - type = SDL_GetGamepadTypeFromVIDPID(vendor_id, product_id, NULL, SDL_FALSE); + type = SDL_GetGamepadTypeFromVIDPID(vendor_id, product_id, NULL, false); if (type == SDL_GAMEPAD_TYPE_XBOX360 || type == SDL_GAMEPAD_TYPE_XBOXONE || (vendor_id == USB_VENDOR_VALVE && product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) { - return SDL_TRUE; + return true; } #endif // SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT - return SDL_FALSE; + return false; } -static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) +static bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) { DIPROPSTRING dipstr; if (!device || !device_name) { - return SDL_FALSE; + return false; } dipstr.diph.dwSize = sizeof(dipstr); @@ -281,20 +281,20 @@ static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) dipstr.diph.dwHow = DIPH_DEVICE; if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_PRODUCTNAME, &dipstr.diph))) { - return SDL_FALSE; + return false; } *device_name = WIN_StringToUTF8(dipstr.wsz); - return SDL_TRUE; + return true; } -static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) +static bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) { DIPROPGUIDANDPATH dippath; if (!device || !device_path) { - return SDL_FALSE; + return false; } dippath.diph.dwSize = sizeof(dippath); @@ -303,7 +303,7 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) dippath.diph.dwHow = DIPH_DEVICE; if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_GUIDANDPATH, &dippath.diph))) { - return SDL_FALSE; + return false; } *device_path = WIN_StringToUTF8W(dippath.wszPath); @@ -311,15 +311,15 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) // Normalize path to upper case. SDL_strupr(*device_path); - return SDL_TRUE; + return true; } -static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, Uint16 *product_id) +static bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, Uint16 *product_id) { DIPROPDWORD dipdw; if (!device || !vendor_id || !product_id) { - return SDL_FALSE; + return false; } dipdw.diph.dwSize = sizeof(dipdw); @@ -329,13 +329,13 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, dipdw.dwData = 0; if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_VIDPID, &dipdw.diph))) { - return SDL_FALSE; + return false; } *vendor_id = LOWORD(dipdw.dwData); *product_id = HIWORD(dipdw.dwData); - return SDL_TRUE; + return true; } void FreeRumbleEffectData(DIEFFECT *effect) @@ -398,7 +398,7 @@ int SDL_DINPUT_JoystickInit(void) HRESULT result; HINSTANCE instance; - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, true)) { // In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. dinput = NULL; return 0; @@ -409,7 +409,7 @@ int SDL_DINPUT_JoystickInit(void) return SetDIerror("CoInitialize", result); } - coinitialized = SDL_TRUE; + coinitialized = true; result = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8, (LPVOID *)&dinput); @@ -552,7 +552,7 @@ typedef struct { Uint16 vendor; Uint16 product; - SDL_bool present; + bool present; } Joystick_PresentData; static BOOL CALLBACK EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) @@ -575,7 +575,7 @@ static BOOL CALLBACK EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInst CHECK(QueryDeviceInfo(device, &vendor, &product)); if (vendor == pData->vendor && product == pData->product) { - pData->present = SDL_TRUE; + pData->present = true; result = DIENUM_STOP; // found it } @@ -588,17 +588,17 @@ err: #undef CHECK } -SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 version_number) +bool SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 version_number) { Joystick_PresentData data; if (!dinput) { - return SDL_FALSE; + return false; } data.vendor = vendor_id; data.product = product_id; - data.present = SDL_FALSE; + data.present = false; IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickPresentCallback, &data, DIEDFL_ATTACHEDONLY); return data.present; } @@ -739,7 +739,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic HRESULT result; DIPROPDWORD dipdw; - joystick->hwdata->buffered = SDL_TRUE; + joystick->hwdata->buffered = true; joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); SDL_zero(dipdw); @@ -821,7 +821,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic } */ - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } // What buttons and axes does it have? @@ -845,11 +845,11 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic if (result == DI_POLLEDDEVICE) { /* This device doesn't support buffering, so we're forced * to use less reliable polling. */ - joystick->hwdata->buffered = SDL_FALSE; + joystick->hwdata->buffered = false; } else if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::SetProperty", result); } - joystick->hwdata->first_update = SDL_TRUE; + joystick->hwdata->first_update = true; // Poll and wait for initial device state to be populated result = IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); @@ -926,7 +926,7 @@ int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumbl if (SDL_DINPUT_JoystickInitRumble(joystick, magnitude) < 0) { return -1; } - joystick->hwdata->ff_initialized = SDL_TRUE; + joystick->hwdata->ff_initialized = true; } result = IDirectInputEffect_Start(joystick->hwdata->ffeffect_ref, 1, 0); @@ -1119,7 +1119,7 @@ void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick) if (joystick->hwdata->first_update) { // Poll to get the initial state of the joystick UpdateDINPUTJoystickState_Polled(joystick); - joystick->hwdata->first_update = SDL_FALSE; + joystick->hwdata->first_update = false; return; } @@ -1142,7 +1142,7 @@ void SDL_DINPUT_JoystickClose(SDL_Joystick *joystick) } IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); IDirectInputDevice8_Release(joystick->hwdata->InputDevice); - joystick->hwdata->ff_initialized = SDL_FALSE; + joystick->hwdata->ff_initialized = false; } void SDL_DINPUT_JoystickQuit(void) @@ -1154,7 +1154,7 @@ void SDL_DINPUT_JoystickQuit(void) if (coinitialized) { WIN_CoUninitialize(); - coinitialized = SDL_FALSE; + coinitialized = false; } } @@ -1171,9 +1171,9 @@ void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { } -SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) +bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) { - return SDL_FALSE; + return false; } int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) diff --git a/src/joystick/windows/SDL_dinputjoystick_c.h b/src/joystick/windows/SDL_dinputjoystick_c.h index 614f783781..3cc28c6bd1 100644 --- a/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/src/joystick/windows/SDL_dinputjoystick_c.h @@ -27,7 +27,7 @@ extern "C" { extern int SDL_DINPUT_JoystickInit(void); extern void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext); -extern SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); +extern bool SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); extern int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_DINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); extern void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick); diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 7801537376..4b0213c0b8 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -97,8 +97,8 @@ typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState; extern void WINDOWS_RAWINPUTEnabledChanged(void); extern void WINDOWS_JoystickDetect(void); -static SDL_bool SDL_RAWINPUT_inited = SDL_FALSE; -static SDL_bool SDL_RAWINPUT_remote_desktop = SDL_FALSE; +static bool SDL_RAWINPUT_inited = false; +static bool SDL_RAWINPUT_remote_desktop = false; static int SDL_RAWINPUT_numjoysticks = 0; static void RAWINPUT_JoystickClose(SDL_Joystick *joystick); @@ -112,8 +112,8 @@ typedef struct SDL_RAWINPUT_Device Uint16 product_id; Uint16 version; SDL_GUID guid; - SDL_bool is_xinput; - SDL_bool is_xboxone; + bool is_xinput; + bool is_xboxone; int steam_virtual_gamepad_slot; PHIDP_PREPARSED_DATA preparsed_data; @@ -126,16 +126,16 @@ typedef struct SDL_RAWINPUT_Device struct joystick_hwdata { - SDL_bool is_xinput; - SDL_bool is_xboxone; + bool is_xinput; + bool is_xboxone; PHIDP_PREPARSED_DATA preparsed_data; ULONG max_data_length; HIDP_DATA *data; USHORT *button_indices; USHORT *axis_indices; USHORT *hat_indices; - SDL_bool guide_hack; - SDL_bool trigger_hack; + bool guide_hack; + bool trigger_hack; USHORT trigger_hack_index; #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING @@ -144,8 +144,8 @@ struct joystick_hwdata #endif #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - SDL_bool xinput_enabled; - SDL_bool xinput_correlated; + bool xinput_enabled; + bool xinput_correlated; Uint8 xinput_correlation_id; Uint8 xinput_correlation_count; Uint8 xinput_uncorrelate_count; @@ -153,7 +153,7 @@ struct joystick_hwdata #endif #ifdef SDL_JOYSTICK_RAWINPUT_WGI - SDL_bool wgi_correlated; + bool wgi_correlated; Uint8 wgi_correlation_id; Uint8 wgi_correlation_count; Uint8 wgi_uncorrelate_count; @@ -194,7 +194,7 @@ typedef struct WindowsMatchState #ifdef SDL_JOYSTICK_RAWINPUT_WGI Uint32 wgi_buttons; #endif - SDL_bool any_data; + bool any_data; } WindowsMatchState; static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state) @@ -203,7 +203,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state int ii; #endif - SDL_bool any_axes_data = SDL_FALSE; + bool any_axes_data = false; #ifdef SDL_JOYSTICK_RAWINPUT_MATCH_AXES /* SHORT state->match_axes[4] = { (match_state & 0x000F0000) >> 4, @@ -267,7 +267,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state */ if (state->xinput_buttons) { - state->any_data = SDL_TRUE; + state->any_data = true; } #endif @@ -306,7 +306,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state ((match_state & (1<wgi_buttons) { - state->any_data = SDL_TRUE; + state->any_data = true; } #endif } @@ -319,12 +319,12 @@ static struct { XINPUT_STATE state; XINPUT_BATTERY_INFORMATION_EX battery; - SDL_bool connected; // Currently has an active XInput device - SDL_bool used; // Is currently mapped to an SDL device + bool connected; // Currently has an active XInput device + bool used; // Is currently mapped to an SDL device Uint8 correlation_id; } xinput_state[XUSER_MAX_COUNT]; -static SDL_bool xinput_device_change = SDL_TRUE; -static SDL_bool xinput_state_dirty = SDL_TRUE; +static bool xinput_device_change = true; +static bool xinput_state_dirty = true; static void RAWINPUT_UpdateXInput(void) { @@ -334,15 +334,15 @@ static void RAWINPUT_UpdateXInput(void) XINPUT_CAPABILITIES capabilities; xinput_state[user_index].connected = (XINPUTGETCAPABILITIES(user_index, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS); } - xinput_device_change = SDL_FALSE; - xinput_state_dirty = SDL_TRUE; + xinput_device_change = false; + xinput_state_dirty = true; } if (xinput_state_dirty) { - xinput_state_dirty = SDL_FALSE; + xinput_state_dirty = false; for (user_index = 0; user_index < SDL_arraysize(xinput_state); ++user_index) { if (xinput_state[user_index].connected) { if (XINPUTGETSTATE(user_index, &xinput_state[user_index].state) != ERROR_SUCCESS) { - xinput_state[user_index].connected = SDL_FALSE; + xinput_state[user_index].connected = false; } xinput_state[user_index].battery.BatteryType = BATTERY_TYPE_UNKNOWN; if (XINPUTGETBATTERYINFORMATION) { @@ -356,28 +356,28 @@ static void RAWINPUT_UpdateXInput(void) static void RAWINPUT_MarkXInputSlotUsed(Uint8 xinput_slot) { if (xinput_slot != XUSER_INDEX_ANY) { - xinput_state[xinput_slot].used = SDL_TRUE; + xinput_state[xinput_slot].used = true; } } static void RAWINPUT_MarkXInputSlotFree(Uint8 xinput_slot) { if (xinput_slot != XUSER_INDEX_ANY) { - xinput_state[xinput_slot].used = SDL_FALSE; + xinput_state[xinput_slot].used = false; } } -static SDL_bool RAWINPUT_MissingXInputSlot(void) +static bool RAWINPUT_MissingXInputSlot(void) { int ii; for (ii = 0; ii < SDL_arraysize(xinput_state); ii++) { if (xinput_state[ii].connected && !xinput_state[ii].used) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 slot_idx) +static bool RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 slot_idx) { if (xinput_state[slot_idx].connected) { WORD xinput_buttons = xinput_state[slot_idx].state.Gamepad.wButtons; @@ -389,13 +389,13 @@ static SDL_bool RAWINPUT_XInputSlotMatches(const WindowsMatchState *state, Uint8 && XInputTriggersMatch(xinput_state[slot_idx].state.Gamepad) #endif ) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } -static SDL_bool RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx) +static bool RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx) { Uint8 user_index; int match_count; @@ -412,7 +412,7 @@ static SDL_bool RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 * } if (match_count == 1) { *correlation_id = ++xinput_state[*slot_idx].correlation_id; - return SDL_TRUE; + return true; } *slot_idx = 0; @@ -430,9 +430,9 @@ static SDL_bool RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 * Note that we're still invalidating *other* potential correlations if we have more than one match or we have no data. */ if (match_count == 1 && state->any_data) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } #endif // SDL_JOYSTICK_RAWINPUT_XINPUT @@ -444,8 +444,8 @@ typedef struct WindowsGamingInputGamepadState __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad; struct __x_ABI_CWindows_CGaming_CInput_CGamepadReading state; RAWINPUT_DeviceContext *correlated_context; - SDL_bool used; // Is currently mapped to an SDL device - SDL_bool connected; // Just used during update to track disconnected + bool used; // Is currently mapped to an SDL device + bool connected; // Just used during update to track disconnected Uint8 correlation_id; struct __x_ABI_CWindows_CGaming_CInput_CGamepadVibration vibration; } WindowsGamingInputGamepadState; @@ -454,9 +454,9 @@ static struct { WindowsGamingInputGamepadState **per_gamepad; int per_gamepad_count; - SDL_bool initialized; - SDL_bool dirty; - SDL_bool need_device_list_update; + bool initialized; + bool dirty; + bool need_device_list_update; int ref_count; __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics *gamepad_statics; EventRegistrationToken gamepad_added_token; @@ -507,13 +507,13 @@ static ULONG STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_Release(__FIEventHandl static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIGamepad *e) { - wgi_state.need_device_list_update = SDL_TRUE; + wgi_state.need_device_list_update = true; return S_OK; } static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_InvokeRemoved(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIGamepad *e) { - wgi_state.need_device_list_update = SDL_TRUE; + wgi_state.need_device_list_update = true; return S_OK; } @@ -551,25 +551,25 @@ static GamepadDelegate gamepad_removed = { static void RAWINPUT_MarkWindowsGamingInputSlotUsed(WindowsGamingInputGamepadState *wgi_slot, RAWINPUT_DeviceContext *ctx) { - wgi_slot->used = SDL_TRUE; + wgi_slot->used = true; wgi_slot->correlated_context = ctx; } static void RAWINPUT_MarkWindowsGamingInputSlotFree(WindowsGamingInputGamepadState *wgi_slot) { - wgi_slot->used = SDL_FALSE; + wgi_slot->used = false; wgi_slot->correlated_context = NULL; } -static SDL_bool RAWINPUT_MissingWindowsGamingInputSlot(void) +static bool RAWINPUT_MissingWindowsGamingInputSlot(void) { int ii; for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { if (!wgi_state.per_gamepad[ii]->used) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static int RAWINPUT_UpdateWindowsGamingInput(void) @@ -583,14 +583,14 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) return 0; } - wgi_state.dirty = SDL_FALSE; + wgi_state.dirty = false; if (wgi_state.need_device_list_update) { HRESULT hr; __FIVectorView_1_Windows__CGaming__CInput__CGamepad *gamepads; - wgi_state.need_device_list_update = SDL_FALSE; + wgi_state.need_device_list_update = false; for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { - wgi_state.per_gamepad[ii]->connected = SDL_FALSE; + wgi_state.per_gamepad[ii]->connected = false; } hr = __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics_get_Gamepads(wgi_state.gamepad_statics, &gamepads); @@ -605,12 +605,12 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) hr = __FIVectorView_1_Windows__CGaming__CInput__CGamepad_GetAt(gamepads, i, &gamepad); if (SUCCEEDED(hr)) { - SDL_bool found = SDL_FALSE; + bool found = false; int jj; for (jj = 0; jj < wgi_state.per_gamepad_count; jj++) { if (wgi_state.per_gamepad[jj]->gamepad == gamepad) { - found = SDL_TRUE; - wgi_state.per_gamepad[jj]->connected = SDL_TRUE; + found = true; + wgi_state.per_gamepad[jj]->connected = true; break; } } @@ -631,7 +631,7 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) wgi_state.per_gamepad_count++; wgi_state.per_gamepad[wgi_state.per_gamepad_count - 1] = gamepad_state; gamepad_state->gamepad = gamepad; - gamepad_state->connected = SDL_TRUE; + gamepad_state->connected = true; } else { // Already tracked __x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(gamepad); @@ -643,7 +643,7 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) if (!gamepad_state->connected) { // Device missing, must be disconnected if (gamepad_state->correlated_context) { - gamepad_state->correlated_context->wgi_correlated = SDL_FALSE; + gamepad_state->correlated_context->wgi_correlated = false; gamepad_state->correlated_context->wgi_slot = NULL; } __x_ABI_CWindows_CGaming_CInput_CIGamepad_Release(gamepad_state->gamepad); @@ -660,14 +660,14 @@ static int RAWINPUT_UpdateWindowsGamingInput(void) for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { HRESULT hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_GetCurrentReading(wgi_state.per_gamepad[ii]->gamepad, &wgi_state.per_gamepad[ii]->state); if (!SUCCEEDED(hr)) { - wgi_state.per_gamepad[ii]->connected = SDL_FALSE; // Not used by anything, currently + wgi_state.per_gamepad[ii]->connected = false; // Not used by anything, currently } } return 0; } static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) { - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, true)) { return; } @@ -679,8 +679,8 @@ static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) if (FAILED(WIN_RoInitialize())) { return; } - wgi_state.initialized = SDL_TRUE; - wgi_state.dirty = SDL_TRUE; + wgi_state.initialized = true; + wgi_state.dirty = true; { typedef HRESULT(WINAPI * WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER * hstringHeader, HSTRING * string); @@ -704,7 +704,7 @@ static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) } if (wgi_state.gamepad_statics) { - wgi_state.need_device_list_update = SDL_TRUE; + wgi_state.need_device_list_update = true; hr = __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics_add_GamepadAdded(wgi_state.gamepad_statics, &gamepad_added.iface, &wgi_state.gamepad_added_token); if (!SUCCEEDED(hr)) { @@ -721,7 +721,7 @@ static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) } } -static SDL_bool RAWINPUT_WindowsGamingInputSlotMatches(const WindowsMatchState *state, WindowsGamingInputGamepadState *slot, SDL_bool xinput_correlated) +static bool RAWINPUT_WindowsGamingInputSlotMatches(const WindowsMatchState *state, WindowsGamingInputGamepadState *slot, bool xinput_correlated) { Uint32 wgi_buttons = slot->state.Buttons; if ((wgi_buttons & 0x3FFF) == state->wgi_buttons @@ -733,12 +733,12 @@ static SDL_bool RAWINPUT_WindowsGamingInputSlotMatches(const WindowsMatchState * && (xinput_correlated || WindowsGamingInputTriggersMatch(slot->state)) #endif ) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, WindowsGamingInputGamepadState **slot, SDL_bool xinput_correlated) +static bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, WindowsGamingInputGamepadState **slot, bool xinput_correlated) { int match_count, user_index; WindowsGamingInputGamepadState *gamepad_state = NULL; @@ -756,7 +756,7 @@ static SDL_bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *st } if (match_count == 1) { *correlation_id = ++gamepad_state->correlation_id; - return SDL_TRUE; + return true; } match_count = 0; @@ -773,9 +773,9 @@ static SDL_bool RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *st Note that we're still invalidating *other* potential correlations if we have more than one match or we have no data. */ if (match_count == 1 && state->any_data) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static void RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) @@ -798,7 +798,7 @@ static void RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) wgi_state.gamepad_statics = NULL; } WIN_RoUninitialize(); - wgi_state.initialized = SDL_FALSE; + wgi_state.initialized = false; } } @@ -818,7 +818,7 @@ static void RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) if (ctx->xinput_enabled && ctx->xinput_correlated) { RAWINPUT_MarkXInputSlotFree(ctx->xinput_slot); - ctx->xinput_correlated = SDL_FALSE; + ctx->xinput_correlated = false; } } #endif // SDL_JOYSTICK_RAWINPUT_XINPUT @@ -893,7 +893,7 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) device->vendor_id = (Uint16)rdi.hid.dwVendorId; device->product_id = (Uint16)rdi.hid.dwProductId; device->version = (Uint16)rdi.hid.dwVersionNumber; - device->is_xinput = SDL_TRUE; + device->is_xinput = true; device->is_xboxone = SDL_IsJoystickXboxOne(device->vendor_id, device->product_id); device->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(device->vendor_id, device->product_id, dev_name); @@ -973,7 +973,7 @@ err: #undef CHECK } -static void RAWINPUT_DelDevice(SDL_RAWINPUT_Device *device, SDL_bool send_event) +static void RAWINPUT_DelDevice(SDL_RAWINPUT_Device *device, bool send_event) { SDL_RAWINPUT_Device *curr, *last; for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) { @@ -1020,7 +1020,7 @@ static void RAWINPUT_DetectDevices(void) static void RAWINPUT_RemoveDevices(void) { while (SDL_RAWINPUT_devices) { - RAWINPUT_DelDevice(SDL_RAWINPUT_devices, SDL_FALSE); + RAWINPUT_DelDevice(SDL_RAWINPUT_devices, false); } SDL_assert(SDL_RAWINPUT_numjoysticks == 0); } @@ -1029,7 +1029,7 @@ static int RAWINPUT_JoystickInit(void) { SDL_assert(!SDL_RAWINPUT_inited); - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, true)) { return 0; } @@ -1042,7 +1042,7 @@ static int RAWINPUT_JoystickInit(void) return -1; } - SDL_RAWINPUT_inited = SDL_TRUE; + SDL_RAWINPUT_inited = true; RAWINPUT_DetectDevices(); @@ -1054,7 +1054,7 @@ static int RAWINPUT_JoystickGetCount(void) return SDL_RAWINPUT_numjoysticks; } -SDL_bool RAWINPUT_IsEnabled(void) +bool RAWINPUT_IsEnabled(void) { return SDL_RAWINPUT_inited && !SDL_RAWINPUT_remote_desktop; } @@ -1062,7 +1062,7 @@ SDL_bool RAWINPUT_IsEnabled(void) static void RAWINPUT_PostUpdate(void) { #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING - SDL_bool unmapped_guide_pressed = SDL_FALSE; + bool unmapped_guide_pressed = false; #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!wgi_state.dirty) { @@ -1070,12 +1070,12 @@ static void RAWINPUT_PostUpdate(void) for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { WindowsGamingInputGamepadState *gamepad_state = wgi_state.per_gamepad[ii]; if (!gamepad_state->used && (gamepad_state->state.Buttons & GamepadButtons_GUIDE)) { - unmapped_guide_pressed = SDL_TRUE; + unmapped_guide_pressed = true; break; } } } - wgi_state.dirty = SDL_TRUE; + wgi_state.dirty = true; #endif #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT @@ -1083,12 +1083,12 @@ static void RAWINPUT_PostUpdate(void) int ii; for (ii = 0; ii < SDL_arraysize(xinput_state); ii++) { if (xinput_state[ii].connected && !xinput_state[ii].used && (xinput_state[ii].state.Gamepad.wButtons & XINPUT_GAMEPAD_GUIDE)) { - unmapped_guide_pressed = SDL_TRUE; + unmapped_guide_pressed = true; break; } } } - xinput_state_dirty = SDL_TRUE; + xinput_state_dirty = true; #endif if (unmapped_guide_pressed) { @@ -1119,13 +1119,13 @@ static void RAWINPUT_PostUpdate(void) static void RAWINPUT_JoystickDetect(void) { - SDL_bool remote_desktop; + bool remote_desktop; if (!SDL_RAWINPUT_inited) { return; } - remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? SDL_TRUE : SDL_FALSE; + remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? true : false; if (remote_desktop != SDL_RAWINPUT_remote_desktop) { SDL_RAWINPUT_remote_desktop = remote_desktop; @@ -1142,19 +1142,19 @@ static void RAWINPUT_JoystickDetect(void) RAWINPUT_PostUpdate(); } -static SDL_bool RAWINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool RAWINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { SDL_RAWINPUT_Device *device; // If we're being asked about a device, that means another API just detected one, so rescan #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - xinput_device_change = SDL_TRUE; + xinput_device_change = true; #endif device = SDL_RAWINPUT_devices; while (device) { if (vendor_id == device->vendor_id && product_id == device->product_id) { - return SDL_TRUE; + return true; } /* The Xbox 360 wireless controller shows up as product 0 in WGI. @@ -1163,19 +1163,19 @@ static SDL_bool RAWINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produc ((name && SDL_strstr(device->name, name) != NULL) || (device->vendor_id == USB_VENDOR_MICROSOFT && device->product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER))) { - return SDL_TRUE; + return true; } // The Xbox One controller shows up as a hardcoded raw input VID/PID if (name && SDL_strcmp(name, "Xbox One Game Controller") == 0 && device->vendor_id == USB_VENDOR_MICROSOFT && device->product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) { - return SDL_TRUE; + return true; } device = device->next; } - return SDL_FALSE; + return false; } static SDL_RAWINPUT_Device *RAWINPUT_GetDeviceByIndex(int device_index) @@ -1255,10 +1255,10 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) if (device->is_xinput) { // We'll try to get guide button and trigger axes from XInput #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - xinput_device_change = SDL_TRUE; - ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE); + xinput_device_change = true; + ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, true); if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || !XINPUTGETSTATE)) { - ctx->xinput_enabled = SDL_FALSE; + ctx->xinput_enabled = false; } ctx->xinput_slot = XUSER_INDEX_ANY; #endif @@ -1342,7 +1342,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) } } if (ctx->is_xinput && joystick->nbuttons == 10) { - ctx->guide_hack = SDL_TRUE; + ctx->guide_hack = true; joystick->nbuttons += 1; } @@ -1390,7 +1390,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) } if (ctx->is_xinput && cap->NotRange.Usage == USB_USAGE_GENERIC_Z) { - ctx->trigger_hack = SDL_TRUE; + ctx->trigger_hack = true; ctx->trigger_hack_index = cap->NotRange.DataIndex; continue; } @@ -1428,15 +1428,15 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT if (ctx->is_xinput) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); } #endif #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (ctx->is_xinput) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); if (ctx->is_xboxone) { - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } } #endif @@ -1449,7 +1449,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ #if defined(SDL_JOYSTICK_RAWINPUT_WGI) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT) RAWINPUT_DeviceContext *ctx = joystick->hwdata; #endif - SDL_bool rumbled = SDL_FALSE; + bool rumbled = false; #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT // Prefer XInput over WGI because it allows rumble in the background @@ -1463,7 +1463,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ XVibration.wLeftMotorSpeed = low_frequency_rumble; XVibration.wRightMotorSpeed = high_frequency_rumble; if (XINPUTSETSTATE(ctx->xinput_slot, &XVibration) == ERROR_SUCCESS) { - rumbled = SDL_TRUE; + rumbled = true; } else { return SDL_SetError("XInputSetState() failed"); } @@ -1478,7 +1478,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ gamepad_state->vibration.RightMotor = (DOUBLE)high_frequency_rumble / SDL_MAX_UINT16; hr = __x_ABI_CWindows_CGaming_CInput_CIGamepad_put_Vibration(gamepad_state->gamepad, gamepad_state->vibration); if (SUCCEEDED(hr)) { - rumbled = SDL_TRUE; + rumbled = true; } } #endif @@ -1526,7 +1526,7 @@ static int RAWINPUT_JoystickSendEffect(SDL_Joystick *joystick, const void *data, return SDL_Unsupported(); } -static int RAWINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int RAWINPUT_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -1680,20 +1680,20 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int #endif // SDL_JOYSTICK_RAWINPUT_MATCH_TRIGGERS if (ctx->trigger_hack) { - SDL_bool has_trigger_data = SDL_FALSE; + bool has_trigger_data = false; int left_trigger = joystick->naxes - 2; int right_trigger = joystick->naxes - 1; #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT // Prefer XInput over WindowsGamingInput, it continues to provide data in the background if (!has_trigger_data && ctx->xinput_enabled && ctx->xinput_correlated) { - has_trigger_data = SDL_TRUE; + has_trigger_data = true; } #endif // SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!has_trigger_data && ctx->wgi_correlated) { - has_trigger_data = SDL_TRUE; + has_trigger_data = true; } #endif // SDL_JOYSTICK_RAWINPUT_WGI @@ -1739,14 +1739,14 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) { #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING RAWINPUT_DeviceContext *ctx = joystick->hwdata; - SDL_bool has_trigger_data = SDL_FALSE; - SDL_bool correlated = SDL_FALSE; + bool has_trigger_data = false; + bool correlated = false; WindowsMatchState match_state_xinput; int guide_button = joystick->nbuttons - 1; int left_trigger = joystick->naxes - 2; int right_trigger = joystick->naxes - 1; #ifdef SDL_JOYSTICK_RAWINPUT_WGI - SDL_bool xinput_correlated; + bool xinput_correlated; #endif RAWINPUT_FillMatchState(&match_state_xinput, ctx->match_state); @@ -1755,7 +1755,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_correlated = ctx->xinput_correlated; #else - xinput_correlated = SDL_FALSE; + xinput_correlated = false; #endif // Parallel logic to WINDOWS_XINPUT below RAWINPUT_UpdateWindowsGamingInput(); @@ -1776,7 +1776,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) SDL_Log("UN-Correlated joystick %d to WindowsGamingInput device #%d\n", joystick->instance_id, ctx->wgi_slot); #endif RAWINPUT_MarkWindowsGamingInputSlotFree(ctx->wgi_slot); - ctx->wgi_correlated = SDL_FALSE; + ctx->wgi_correlated = false; ctx->wgi_correlation_count = 0; // Force release of Guide button, it can't possibly be down on this device now. /* It gets left down if we were actually correlated incorrectly and it was released on the WindowsGamingInput @@ -1803,11 +1803,11 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) new_correlation_count = ctx->wgi_correlation_count + 1; if (new_correlation_count == 2) { // correlation stayed steady and uncontested across multiple frames, guaranteed match - ctx->wgi_correlated = SDL_TRUE; + ctx->wgi_correlated = true; #ifdef DEBUG_RAWINPUT SDL_Log("Correlated joystick %d to WindowsGamingInput device #%d\n", joystick->instance_id, slot_idx); #endif - correlated = SDL_TRUE; + correlated = true; RAWINPUT_MarkWindowsGamingInputSlotUsed(ctx->wgi_slot, ctx); // If the generalized Guide button was using us, it doesn't need to anymore if (guide_button_candidate.joystick == joystick) { @@ -1833,7 +1833,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) } ctx->wgi_correlation_count = new_correlation_count; } else { - correlated = SDL_TRUE; + correlated = true; } #endif // SDL_JOYSTICK_RAWINPUT_WGI @@ -1872,7 +1872,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) SDL_Log("UN-Correlated joystick %d to XInput device #%d\n", joystick->instance_id, ctx->xinput_slot); #endif RAWINPUT_MarkXInputSlotFree(ctx->xinput_slot); - ctx->xinput_correlated = SDL_FALSE; + ctx->xinput_correlated = false; ctx->xinput_correlation_count = 0; // Force release of Guide button, it can't possibly be down on this device now. /* It gets left down if we were actually correlated incorrectly and it was released on the XInput @@ -1899,11 +1899,11 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) new_correlation_count = ctx->xinput_correlation_count + 1; if (new_correlation_count == 2) { // correlation stayed steady and uncontested across multiple frames, guaranteed match - ctx->xinput_correlated = SDL_TRUE; + ctx->xinput_correlated = true; #ifdef DEBUG_RAWINPUT SDL_Log("Correlated joystick %d to XInput device #%d\n", joystick->instance_id, slot_idx); #endif - correlated = SDL_TRUE; + correlated = true; RAWINPUT_MarkXInputSlotUsed(ctx->xinput_slot); // If the generalized Guide button was using us, it doesn't need to anymore if (guide_button_candidate.joystick == joystick) { @@ -1929,7 +1929,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) } ctx->xinput_correlation_count = new_correlation_count; } else { - correlated = SDL_TRUE; + correlated = true; } } #endif // SDL_JOYSTICK_RAWINPUT_XINPUT @@ -1957,7 +1957,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) SDL_SendJoystickAxis(timestamp, joystick, (Uint8)left_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bLeftTrigger * 257) - 32768); SDL_SendJoystickAxis(timestamp, joystick, (Uint8)right_trigger, ((int)xinput_state[ctx->xinput_slot].state.Gamepad.bRightTrigger * 257) - 32768); } - has_trigger_data = SDL_TRUE; + has_trigger_data = true; SDL_PowerState state; int percent; @@ -2014,7 +2014,7 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) SDL_SendJoystickAxis(timestamp, joystick, (Uint8)left_trigger, (Sint16)(((int)(state->LeftTrigger * SDL_MAX_UINT16)) - 32768)); SDL_SendJoystickAxis(timestamp, joystick, (Uint8)right_trigger, (Sint16)(((int)(state->RightTrigger * SDL_MAX_UINT16)) - 32768)); } - has_trigger_data = SDL_TRUE; + has_trigger_data = true; } } #endif // SDL_JOYSTICK_RAWINPUT_WGI @@ -2052,7 +2052,7 @@ static void RAWINPUT_JoystickClose(SDL_Joystick *joystick) SDL_RAWINPUT_Device *device; #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT - xinput_device_change = SDL_TRUE; + xinput_device_change = true; if (ctx->xinput_enabled) { if (ctx->xinput_correlated) { RAWINPUT_MarkXInputSlotFree(ctx->xinput_slot); @@ -2145,7 +2145,7 @@ RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_RAWINPUT_Device *device; device = RAWINPUT_DeviceFromHandle(hDevice); if (device) { - RAWINPUT_DelDevice(device, SDL_TRUE); + RAWINPUT_DelDevice(device, true); } break; } @@ -2195,12 +2195,12 @@ static void RAWINPUT_JoystickQuit(void) WIN_UnloadHIDDLL(); - SDL_RAWINPUT_inited = SDL_FALSE; + SDL_RAWINPUT_inited = false; } -static SDL_bool RAWINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool RAWINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = { diff --git a/src/joystick/windows/SDL_rawinputjoystick_c.h b/src/joystick/windows/SDL_rawinputjoystick_c.h index de4fc11616..4a79afd52c 100644 --- a/src/joystick/windows/SDL_rawinputjoystick_c.h +++ b/src/joystick/windows/SDL_rawinputjoystick_c.h @@ -22,7 +22,7 @@ #include "../../core/windows/SDL_windows.h" // Return true if the RawInput driver is enabled -extern SDL_bool RAWINPUT_IsEnabled(); +extern bool RAWINPUT_IsEnabled(); // Registers for input events extern int RAWINPUT_RegisterNotifications(HWND hWnd); diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index 8c1536ee11..4876d28956 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -105,10 +105,10 @@ DEFINE_GUID(IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController, 0x7cad6d91, DEFINE_GUID(IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController2, 0x43c0c035, 0xbb73, 0x4756, 0xa7, 0x87, 0x3e, 0xd6, 0xbe, 0xa6, 0x17, 0xbd); DEFINE_GUID(IID___x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics, 0xeb8d0792, 0xe95a, 0x4b19, 0xaf, 0xc7, 0x0a, 0x59, 0xf8, 0xbf, 0x75, 0x9e); -extern SDL_bool SDL_XINPUT_Enabled(void); +extern bool SDL_XINPUT_Enabled(void); -static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) +static bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) { #if defined(SDL_JOYSTICK_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT) PRAWINPUTDEVICELIST raw_devices = NULL; @@ -121,24 +121,24 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) && !RAWINPUT_IsEnabled() #endif ) { - return SDL_FALSE; + return false; } // Go through RAWINPUT (WinXP and later) to find HID devices. if ((GetRawInputDeviceList(NULL, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!raw_device_count)) { - return SDL_FALSE; // oh well. + return false; // oh well. } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); if (!raw_devices) { - return SDL_FALSE; + return false; } raw_device_count = GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)); if (raw_device_count == (UINT)-1) { SDL_free(raw_devices); raw_devices = NULL; - return SDL_FALSE; // oh well. + return false; // oh well. } for (i = 0; i < raw_device_count; i++) { @@ -163,7 +163,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) // First check for a simple VID/PID match. This will work for Xbox 360 controllers. if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == vidpid) { SDL_free(raw_devices); - return SDL_TRUE; + return true; } /* For Xbox One controllers, Microsoft doesn't propagate the VID/PID down to the HID stack. @@ -202,7 +202,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) (SDL_strstr(deviceId, devVidPidString) != NULL)) { // The VID/PID matched a parent device SDL_free(raw_devices); - return SDL_TRUE; + return true; } } } @@ -210,7 +210,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) SDL_free(raw_devices); #endif // SDL_JOYSTICK_XINPUT || SDL_JOYSTICK_RAWINPUT - return SDL_FALSE; + return false; } static void WGI_LoadRawGameControllerStatics(void) @@ -408,7 +408,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde SDL_JoystickType type = SDL_JOYSTICK_TYPE_UNKNOWN; __x_ABI_CWindows_CGaming_CInput_CIRawGameController2 *controller2 = NULL; __x_ABI_CWindows_CGaming_CInput_CIGameController *game_controller = NULL; - SDL_bool ignore_joystick = SDL_FALSE; + bool ignore_joystick = false; __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_HardwareVendorId(controller, &vendor); __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_HardwareProductId(controller, &product); @@ -448,12 +448,12 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } if (!ignore_joystick && SDL_JoystickHandledByAnotherDriver(&SDL_WGI_JoystickDriver, vendor, product, version, name)) { - ignore_joystick = SDL_TRUE; + ignore_joystick = true; } if (!ignore_joystick && SDL_IsXInputDevice(vendor, product)) { // This hasn't been detected by the RAWINPUT driver yet, but it will be picked up later. - ignore_joystick = SDL_TRUE; + ignore_joystick = true; } if (!ignore_joystick) { @@ -464,7 +464,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, name, 'w', (Uint8)type); if (SDL_ShouldIgnoreJoystick(name, guid)) { - ignore_joystick = SDL_TRUE; + ignore_joystick = true; } } @@ -584,7 +584,7 @@ static int WGI_JoystickInit(void) { HRESULT hr; - if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, true)) { return 0; } @@ -673,10 +673,10 @@ static void WGI_JoystickDetect(void) { } -static SDL_bool WGI_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool WGI_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { // We don't override any other drivers - return SDL_FALSE; + return false; } static const char *WGI_JoystickGetDeviceName(int device_index) @@ -717,7 +717,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) { WindowsGamingInputControllerState *state = &wgi.controllers[device_index]; struct joystick_hwdata *hwdata; - boolean wireless = SDL_FALSE; + boolean wireless = false; hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); if (!hwdata) { @@ -750,8 +750,8 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) if (hwdata->gamepad) { // FIXME: Can WGI even tell us if trigger rumble is supported? - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN, true); } return 0; } @@ -808,7 +808,7 @@ static int WGI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int return SDL_Unsupported(); } -static int WGI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int WGI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -862,16 +862,16 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick) hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_GetCurrentReading(hwdata->controller, nbuttons, buttons, nhats, hats, naxes, axes, ×tamp); if (SUCCEEDED(hr) && (!timestamp || timestamp != hwdata->timestamp)) { UINT32 i; - SDL_bool all_zero = SDL_FALSE; + bool all_zero = false; hwdata->timestamp = timestamp; // The axes are all zero when the application loses focus if (naxes > 0) { - all_zero = SDL_TRUE; + all_zero = true; for (i = 0; i < naxes; ++i) { if (axes[i] != 0.0f) { - all_zero = SDL_FALSE; + all_zero = false; break; } } @@ -1016,9 +1016,9 @@ static void WGI_JoystickQuit(void) SDL_zero(wgi); } -static SDL_bool WGI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool WGI_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_WGI_JoystickDriver = { diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index d42d0218a2..0fcb13909e 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -53,18 +53,18 @@ #endif // local variables -static SDL_bool s_bJoystickThread = SDL_FALSE; +static bool s_bJoystickThread = false; static SDL_Condition *s_condJoystickThread = NULL; static SDL_Mutex *s_mutexJoyStickEnum = NULL; static SDL_Thread *s_joystickThread = NULL; -static SDL_bool s_bJoystickThreadQuit = SDL_FALSE; +static bool s_bJoystickThreadQuit = false; static Uint64 s_lastDeviceChange = 0; static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } }; JoyStick_DeviceData *SYS_Joystick; // array to hold joystick ID values -static SDL_bool WindowsDeviceChanged(void) +static bool WindowsDeviceChanged(void) { return (s_lastDeviceChange != WIN_GetLastDeviceNotification()); } @@ -190,13 +190,13 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) return 0; } -static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_Mutex *mutex) +static bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_Mutex *mutex) { MSG msg; int lastret = 1; if (!data->messageWindow) { - return SDL_FALSE; // device notifications require a window + return false; // device notifications require a window } SDL_UnlockMutex(mutex); @@ -223,7 +223,7 @@ static SDL_DeviceNotificationData s_notification_data; static int SDLCALL SDL_JoystickThread(void *_data) { #ifdef SDL_JOYSTICK_XINPUT - SDL_bool bOpenedXInputDevices[XUSER_MAX_COUNT]; + bool bOpenedXInputDevices[XUSER_MAX_COUNT]; SDL_zeroa(bOpenedXInputDevices); #endif @@ -234,9 +234,9 @@ static int SDLCALL SDL_JoystickThread(void *_data) #endif SDL_LockMutex(s_mutexJoyStickEnum); - while (s_bJoystickThreadQuit == SDL_FALSE) { + while (s_bJoystickThreadQuit == false) { #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - if (SDL_WaitForDeviceNotification(&s_notification_data, s_mutexJoyStickEnum) == SDL_FALSE) { + if (SDL_WaitForDeviceNotification(&s_notification_data, s_mutexJoyStickEnum) == false) { #else { #endif @@ -249,7 +249,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) for (userId = 0; userId < XUSER_MAX_COUNT; userId++) { XINPUT_CAPABILITIES capabilities; const DWORD result = XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities); - const SDL_bool available = (result == ERROR_SUCCESS); + const bool available = (result == ERROR_SUCCESS); if (bOpenedXInputDevices[userId] != available) { SetWindowsDeviceChanged(); bOpenedXInputDevices[userId] = available; @@ -285,7 +285,7 @@ static int SDL_StartJoystickThread(void) return -1; } - s_bJoystickThreadQuit = SDL_FALSE; + s_bJoystickThreadQuit = false; s_joystickThread = SDL_CreateThreadWithStackSize(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL); if (!s_joystickThread) { return -1; @@ -300,7 +300,7 @@ static void SDL_StopJoystickThread(void) } SDL_LockMutex(s_mutexJoyStickEnum); - s_bJoystickThreadQuit = SDL_TRUE; + s_bJoystickThreadQuit = true; SDL_BroadcastCondition(s_condJoystickThread); // signal the joystick thread to quit SDL_UnlockMutex(s_mutexJoyStickEnum); PostThreadMessage((DWORD)SDL_GetThreadID(s_joystickThread), WM_QUIT, 0, 0); @@ -324,7 +324,7 @@ static void SDL_StopJoystickThread(void) void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device) { - device->send_add_event = SDL_TRUE; + device->send_add_event = true; device->nInstanceID = SDL_GetNextObjectID(); device->pNext = SYS_Joystick; SYS_Joystick = device; @@ -352,7 +352,7 @@ static int WINDOWS_JoystickInit(void) WIN_InitDeviceNotification(); #if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, SDL_FALSE); + s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, false); if (s_bJoystickThread) { if (SDL_StartJoystickThread() < 0) { return -1; @@ -366,7 +366,7 @@ static int WINDOWS_JoystickInit(void) #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) // On Xbox, force create the joystick thread for device detection (since other methods don't work - s_bJoystickThread = SDL_TRUE; + s_bJoystickThread = true; if (SDL_StartJoystickThread() < 0) { return -1; } @@ -448,20 +448,20 @@ void WINDOWS_JoystickDetect(void) SDL_PrivateJoystickAdded(pCurList->nInstanceID); - pCurList->send_add_event = SDL_FALSE; + pCurList->send_add_event = false; } } } -static SDL_bool WINDOWS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) +static bool WINDOWS_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name) { if (SDL_DINPUT_JoystickPresent(vendor_id, product_id, version)) { - return SDL_TRUE; + return true; } if (SDL_XINPUT_JoystickPresent(vendor_id, product_id, version)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static const char *WINDOWS_JoystickGetDeviceName(int device_index) @@ -599,7 +599,7 @@ static int WINDOWS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, return SDL_Unsupported(); } -static int WINDOWS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +static int WINDOWS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled) { return SDL_Unsupported(); } @@ -662,9 +662,9 @@ void WINDOWS_JoystickQuit(void) WIN_QuitDeviceNotification(); } -static SDL_bool WINDOWS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +static bool WINDOWS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return false; } SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = { diff --git a/src/joystick/windows/SDL_windowsjoystick_c.h b/src/joystick/windows/SDL_windowsjoystick_c.h index 75f9c2a72f..61f5c62336 100644 --- a/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/src/joystick/windows/SDL_windowsjoystick_c.h @@ -37,7 +37,7 @@ typedef struct JoyStick_DeviceData char *joystickname; Uint8 send_add_event; SDL_JoystickID nInstanceID; - SDL_bool bXInputDevice; + bool bXInputDevice; BYTE SubType; Uint8 XInputUserId; DIDEVICEINSTANCE dxdevice; @@ -75,18 +75,18 @@ struct joystick_hwdata #ifdef SDL_JOYSTICK_DINPUT LPDIRECTINPUTDEVICE8 InputDevice; DIDEVCAPS Capabilities; - SDL_bool buffered; - SDL_bool first_update; + bool buffered; + bool first_update; input_t Inputs[MAX_INPUTS]; int NumInputs; int NumSliders; - SDL_bool ff_initialized; + bool ff_initialized; DIEFFECT *ffeffect; LPDIRECTINPUTEFFECT ffeffect_ref; #endif - SDL_bool bXInputDevice; // SDL_TRUE if this device supports using the xinput API rather than DirectInput - SDL_bool bXInputHaptic; // Supports force feedback via XInput. + bool bXInputDevice; // true if this device supports using the xinput API rather than DirectInput + bool bXInputHaptic; // Supports force feedback via XInput. Uint8 userid; // XInput userid index for this joystick DWORD dwPacketNumber; }; diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 6b4a0d2bd4..300aef9671 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -37,19 +37,19 @@ extern "C" { /* * Internal stuff. */ -static SDL_bool s_bXInputEnabled = SDL_TRUE; +static bool s_bXInputEnabled = true; -SDL_bool SDL_XINPUT_Enabled(void) +bool SDL_XINPUT_Enabled(void) { return s_bXInputEnabled; } int SDL_XINPUT_JoystickInit(void) { - s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE); + s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, true); if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) { - s_bXInputEnabled = SDL_FALSE; // oh well. + s_bXInputEnabled = false; // oh well. } return 0; } @@ -92,7 +92,7 @@ static const char *GetXInputName(const Uint8 userid, BYTE SubType) return name; } -static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) +static bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) { SDL_XINPUT_CAPABILITIES_EX capabilities; @@ -104,7 +104,7 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui if (pPID) { *pPID = USB_PRODUCT_XBOX360_XUSB_CONTROLLER; } - return SDL_FALSE; + return false; } // Fixup for Wireless Xbox 360 Controller @@ -122,7 +122,7 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui if (pVersion) { *pVersion = capabilities.ProductVersion; } - return SDL_TRUE; + return true; } int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid) @@ -190,7 +190,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC name = GetXInputName(userid, SubType); GetXInputDeviceInfo(userid, &vendor, &product, &version); - pNewJoystick->bXInputDevice = SDL_TRUE; + pNewJoystick->bXInputDevice = true; pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name); if (!pNewJoystick->joystickname) { SDL_free(pNewJoystick); @@ -232,12 +232,12 @@ void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) } } -SDL_bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) +bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) { int iuserid; if (!s_bXInputEnabled) { - return SDL_FALSE; + return false; } // iterate in reverse, so these are in the final list in ascending numeric order. @@ -248,11 +248,11 @@ SDL_bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 versio Uint16 slot_version; if (GetXInputDeviceInfo(userid, &slot_vendor, &slot_product, &slot_version)) { if (vendor == slot_vendor && product == slot_product && version == slot_version) { - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) @@ -266,7 +266,7 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic SDL_assert(XINPUTSETSTATE); SDL_assert(userId < XUSER_MAX_COUNT); - joystick->hwdata->bXInputDevice = SDL_TRUE; + joystick->hwdata->bXInputDevice = true; if (XINPUTGETCAPABILITIES(userId, XINPUT_FLAG_GAMEPAD, &capabilities) != ERROR_SUCCESS) { SDL_free(joystick->hwdata); @@ -282,7 +282,7 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic joystick->nbuttons = 11; joystick->nhats = 1; - SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, true); return 0; } @@ -417,7 +417,7 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick) void SDL_XINPUT_JoystickQuit(void) { if (s_bXInputEnabled) { - s_bXInputEnabled = SDL_FALSE; + s_bXInputEnabled = false; WIN_UnloadXInputDLL(); } } @@ -431,9 +431,9 @@ void SDL_XINPUT_JoystickQuit(void) typedef struct JoyStick_DeviceData JoyStick_DeviceData; -SDL_bool SDL_XINPUT_Enabled(void) +bool SDL_XINPUT_Enabled(void) { - return SDL_FALSE; + return false; } int SDL_XINPUT_JoystickInit(void) @@ -445,9 +445,9 @@ void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { } -SDL_bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) +bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version) { - return SDL_FALSE; + return false; } int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice) diff --git a/src/joystick/windows/SDL_xinputjoystick_c.h b/src/joystick/windows/SDL_xinputjoystick_c.h index c7ce1bcb9f..edf5d2bd8d 100644 --- a/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/src/joystick/windows/SDL_xinputjoystick_c.h @@ -27,10 +27,10 @@ extern "C" { #endif -extern SDL_bool SDL_XINPUT_Enabled(void); +extern bool SDL_XINPUT_Enabled(void); extern int SDL_XINPUT_JoystickInit(void); extern void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext); -extern SDL_bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); +extern bool SDL_XINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version); extern int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystickdevice); extern int SDL_XINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick); diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index e6f7012d95..66c64b12c9 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -57,7 +57,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) void *symbol = dlsym(handle, name); if (!symbol) { // prepend an underscore for platforms that need that. - SDL_bool isstack; + bool isstack; size_t len = SDL_strlen(name) + 1; char *_name = SDL_small_alloc(char, len + 1, &isstack); _name[0] = '_'; diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index d14bad6517..6e253504e3 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -62,7 +62,7 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) i = 0; retval[i++] = loc; - while (SDL_TRUE) { // parse out the string + while (true) { // parse out the string while (SDL_isspace(*ptr)) { ptr++; // skip whitespace. } @@ -71,7 +71,7 @@ static SDL_Locale **build_locales_from_csv_string(char *csv, int *count) break; } loc->language = ptr++; - while (SDL_TRUE) { + while (true) { const char ch = *ptr; if (ch == '_' || ch == '-') { *(ptr++) = '\0'; diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index 639e1f30b8..2cea3deed3 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -65,7 +65,7 @@ static void normalize_locales(char *dst, char *src, size_t buflen) int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { // !!! FIXME: should we be using setlocale()? Or some D-Bus thing? - SDL_bool isstack; + bool isstack; const char *envr; char *tmp; diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index df3ae06e06..feafc55dd7 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -59,7 +59,7 @@ static int SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) ULONG numlangs = 0; WCHAR *wbuf = NULL; ULONG wbuflen = 0; - SDL_bool isstack; + bool isstack; SDL_assert(pGetUserPreferredUILanguages != NULL); pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen); diff --git a/src/main/SDL_main_callbacks.c b/src/main/SDL_main_callbacks.c index 68ca4f425d..b3491bd60b 100644 --- a/src/main/SDL_main_callbacks.c +++ b/src/main/SDL_main_callbacks.c @@ -29,7 +29,7 @@ static SDL_AtomicInt apprc; // use an atomic, since events might land from any static void *SDL_main_appstate = NULL; // Return true if this event needs to be processed before returning from the event watcher -static SDL_bool ShouldDispatchImmediately(SDL_Event *event) +static bool ShouldDispatchImmediately(SDL_Event *event) { switch (event->type) { case SDL_EVENT_TERMINATING: @@ -38,9 +38,9 @@ static SDL_bool ShouldDispatchImmediately(SDL_Event *event) case SDL_EVENT_DID_ENTER_BACKGROUND: case SDL_EVENT_WILL_ENTER_FOREGROUND: case SDL_EVENT_DID_ENTER_FOREGROUND: - return SDL_TRUE; + return true; default: - return SDL_FALSE; + return false; } } @@ -78,15 +78,15 @@ static SDL_bool SDLCALL SDL_MainCallbackEventWatcher(void *userdata, SDL_Event * } else { // We'll process this event later from the main event queue } - return SDL_TRUE; + return true; } -SDL_bool SDL_HasMainCallbacks(void) +bool SDL_HasMainCallbacks(void) { if (SDL_main_iteration_callback) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit) @@ -113,7 +113,7 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func app return SDL_AtomicGet(&apprc); } -SDL_AppResult SDL_IterateMainCallbacks(SDL_bool pump_events) +SDL_AppResult SDL_IterateMainCallbacks(bool pump_events) { if (pump_events) { SDL_PumpEvents(); diff --git a/src/main/SDL_main_callbacks.h b/src/main/SDL_main_callbacks.h index c27925b2ea..0bac5a5c63 100644 --- a/src/main/SDL_main_callbacks.h +++ b/src/main/SDL_main_callbacks.h @@ -22,9 +22,9 @@ #ifndef SDL_main_callbacks_h_ #define SDL_main_callbacks_h_ -SDL_bool SDL_HasMainCallbacks(void); +bool SDL_HasMainCallbacks(void); SDL_AppResult SDL_InitMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func _appiter, SDL_AppEvent_func _appevent, SDL_AppQuit_func _appquit); -SDL_AppResult SDL_IterateMainCallbacks(SDL_bool pump_events); +SDL_AppResult SDL_IterateMainCallbacks(bool pump_events); void SDL_QuitMainCallbacks(void); #endif // SDL_main_callbacks_h_ diff --git a/src/main/emscripten/SDL_sysmain_callbacks.c b/src/main/emscripten/SDL_sysmain_callbacks.c index 29901044c5..9da67f38c1 100644 --- a/src/main/emscripten/SDL_sysmain_callbacks.c +++ b/src/main/emscripten/SDL_sysmain_callbacks.c @@ -26,7 +26,7 @@ static void EmscriptenInternalMainloop(void) { - const SDL_AppResult rc = SDL_IterateMainCallbacks(SDL_TRUE); + const SDL_AppResult rc = SDL_IterateMainCallbacks(true); if (rc != SDL_APP_CONTINUE) { SDL_QuitMainCallbacks(); emscripten_cancel_main_loop(); // kill" the mainloop, so it stops calling back into it. diff --git a/src/main/generic/SDL_sysmain_callbacks.c b/src/main/generic/SDL_sysmain_callbacks.c index 36f943b6aa..4b38b96d2c 100644 --- a/src/main/generic/SDL_sysmain_callbacks.c +++ b/src/main/generic/SDL_sysmain_callbacks.c @@ -45,7 +45,7 @@ int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, Uint64 next_iteration = callback_rate_increment ? (SDL_GetTicksNS() + callback_rate_increment) : 0; - while ((rc = SDL_IterateMainCallbacks(SDL_TRUE)) == SDL_APP_CONTINUE) { + while ((rc = SDL_IterateMainCallbacks(true)) == SDL_APP_CONTINUE) { // !!! FIXME: this can be made more complicated if we decide to // !!! FIXME: optionally hand off callback responsibility to the // !!! FIXME: video subsystem (for example, if Wayland has a diff --git a/src/main/ios/SDL_sysmain_callbacks.m b/src/main/ios/SDL_sysmain_callbacks.m index 6afae4d908..ee37af36a7 100644 --- a/src/main/ios/SDL_sysmain_callbacks.m +++ b/src/main/ios/SDL_sysmain_callbacks.m @@ -50,7 +50,7 @@ static SDLIosMainCallbacksDisplayLink *globalDisplayLink; - (void)appIteration:(CADisplayLink *)sender { - const SDL_AppResult rc = SDL_IterateMainCallbacks(SDL_TRUE); + const SDL_AppResult rc = SDL_IterateMainCallbacks(true); if (rc != SDL_APP_CONTINUE) { [self.displayLink invalidate]; self.displayLink = nil; diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 9efe094e56..b964862ee7 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -22,21 +22,21 @@ #include "SDL_syspower.h" /* - * Returns SDL_TRUE if we have a definitive answer. - * SDL_FALSE to try next implementation. + * Returns true if we have a definitive answer. + * false to try next implementation. */ -typedef SDL_bool (*SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, +typedef bool (*SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, int *percent); #ifndef SDL_POWER_DISABLED #ifdef SDL_POWER_HARDWIRED // This is for things that _never_ have a battery -static SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, int *percent) +static bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, int *percent) { *seconds = -1; *percent = -1; *state = SDL_POWERSTATE_NO_BATTERY; - return SDL_TRUE; + return true; } #endif diff --git a/src/power/SDL_syspower.h b/src/power/SDL_syspower.h index 2be338f583..f62ebf6ab0 100644 --- a/src/power/SDL_syspower.h +++ b/src/power/SDL_syspower.h @@ -26,22 +26,22 @@ #define SDL_syspower_h_ // Not all of these are available in a given build. Use #ifdefs, etc. -SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); -SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); +bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); // this one is static in SDL_power.c -/* SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *, int *, int *);*/ +/* bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *, int *, int *);*/ #endif // SDL_syspower_h_ diff --git a/src/power/android/SDL_syspower.c b/src/power/android/SDL_syspower.c index cf5b3a4609..80cfdc7ac5 100644 --- a/src/power/android/SDL_syspower.c +++ b/src/power/android/SDL_syspower.c @@ -27,7 +27,7 @@ #include "../../core/android/SDL_android.h" -SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Android(SDL_PowerState *state, int *seconds, int *percent) { int battery; int plugged; @@ -53,7 +53,7 @@ SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *state, int *seconds, int *perc *percent = -1; } - return SDL_TRUE; + return true; } #endif // SDL_POWER_ANDROID diff --git a/src/power/emscripten/SDL_syspower.c b/src/power/emscripten/SDL_syspower.c index d2c5cd3297..24965cc73c 100644 --- a/src/power/emscripten/SDL_syspower.c +++ b/src/power/emscripten/SDL_syspower.c @@ -25,13 +25,13 @@ #include -SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *percent) { EmscriptenBatteryEvent batteryState; int haveBattery = 0; if (emscripten_get_battery_status(&batteryState) == EMSCRIPTEN_RESULT_NOT_SUPPORTED) { - return SDL_FALSE; + return false; } haveBattery = batteryState.level != 1.0 || !batteryState.charging || batteryState.chargingTime != 0.0; @@ -40,7 +40,7 @@ SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *p *state = SDL_POWERSTATE_NO_BATTERY; *seconds = -1; *percent = -1; - return SDL_TRUE; + return true; } if (batteryState.charging) { @@ -52,7 +52,7 @@ SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *state, int *seconds, int *p *seconds = (int)batteryState.dischargingTime; *percent = (int)batteryState.level * 100; - return SDL_TRUE; + return true; } #endif // SDL_POWER_EMSCRIPTEN diff --git a/src/power/haiku/SDL_syspower.c b/src/power/haiku/SDL_syspower.c index 4fb7e790dd..cea4bb326d 100644 --- a/src/power/haiku/SDL_syspower.c +++ b/src/power/haiku/SDL_syspower.c @@ -40,10 +40,10 @@ #define APM_DEVICE_ALL 1 #define APM_BIOS_CALL (B_DEVICE_OP_CODES_END + 3) -SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percent) { const int fd = open("/dev/misc/apm", O_RDONLY | O_CLOEXEC); - SDL_bool need_details = SDL_FALSE; + bool need_details = false; uint16 regs[6]; uint8 ac_status; uint8 battery_status; @@ -53,7 +53,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen int rc; if (fd == -1) { - return SDL_FALSE; // maybe some other method will work? + return false; // maybe some other method will work? } SDL_memset(regs, '\0', sizeof(regs)); @@ -63,7 +63,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen close(fd); if (rc < 0) { - return SDL_FALSE; + return false; } ac_status = regs[1] >> 8; @@ -93,13 +93,13 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen *state = SDL_POWERSTATE_NO_BATTERY; } else if (battery_flags & (1 << 3)) { // charging *state = SDL_POWERSTATE_CHARGING; - need_details = SDL_TRUE; + need_details = true; } else if (ac_status == 1) { *state = SDL_POWERSTATE_CHARGED; // on AC, not charging. - need_details = SDL_TRUE; + need_details = true; } else { *state = SDL_POWERSTATE_ON_BATTERY; // not on AC. - need_details = SDL_TRUE; + need_details = true; } *percent = -1; @@ -116,7 +116,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *state, int *seconds, int *percen } } - return SDL_TRUE; // the definitive answer if APM driver replied. + return true; // the definitive answer if APM driver replied. } #endif // SDL_POWER_HAIKU diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index 03a82aa60e..dd7cad6ddb 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -55,24 +55,24 @@ static int open_power_file(const char *base, const char *node, const char *key) return fd; } -static SDL_bool read_power_file(const char *base, const char *node, const char *key, +static bool read_power_file(const char *base, const char *node, const char *key, char *buf, size_t buflen) { ssize_t br = 0; const int fd = open_power_file(base, node, key); if (fd == -1) { - return SDL_FALSE; + return false; } br = read(fd, buf, buflen - 1); close(fd); if (br < 0) { - return SDL_FALSE; + return false; } buf[br] = '\0'; // null-terminate the string. - return SDL_TRUE; + return true; } -static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) +static bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) { char *ptr = *_ptr; @@ -81,7 +81,7 @@ static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } if (*ptr == '\0') { - return SDL_FALSE; // EOF. + return false; // EOF. } *_key = ptr; @@ -91,7 +91,7 @@ static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } if (*ptr == '\0') { - return SDL_FALSE; // (unexpected) EOF. + return false; // (unexpected) EOF. } *(ptr++) = '\0'; // terminate the key. @@ -101,7 +101,7 @@ static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } if (*ptr == '\0') { - return SDL_FALSE; // (unexpected) EOF. + return false; // (unexpected) EOF. } *_val = ptr; @@ -115,11 +115,11 @@ static SDL_bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) } *_ptr = ptr; // store for next time. - return SDL_TRUE; + return true; } -static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, - SDL_bool *charging, int *seconds, int *percent) +static void check_proc_acpi_battery(const char *node, bool *have_battery, + bool *charging, int *seconds, int *percent) { const char *base = proc_acpi_battery_path; char info[1024]; @@ -127,8 +127,8 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, char *ptr = NULL; char *key = NULL; char *val = NULL; - SDL_bool charge = SDL_FALSE; - SDL_bool choose = SDL_FALSE; + bool charge = false; + bool choose = false; int maximum = -1; int remaining = -1; int secs = -1; @@ -144,14 +144,14 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, while (make_proc_acpi_key_val(&ptr, &key, &val)) { if (SDL_strcasecmp(key, "present") == 0) { if (SDL_strcasecmp(val, "yes") == 0) { - *have_battery = SDL_TRUE; + *have_battery = true; } } else if (SDL_strcasecmp(key, "charging state") == 0) { // !!! FIXME: what exactly _does_ charging/discharging mean? if (SDL_strcasecmp(val, "charging/discharging") == 0) { - charge = SDL_TRUE; + charge = true; } else if (SDL_strcasecmp(val, "charging") == 0) { - charge = SDL_TRUE; + charge = true; } } else if (SDL_strcasecmp(key, "remaining capacity") == 0) { char *endptr = NULL; @@ -190,13 +190,13 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; // at least we know there's a battery. + choose = true; // at least we know there's a battery. } if (pct > *percent) { - choose = SDL_TRUE; + choose = true; } } else if (secs > *seconds) { - choose = SDL_TRUE; + choose = true; } if (choose) { @@ -206,7 +206,7 @@ static void check_proc_acpi_battery(const char *node, SDL_bool *have_battery, } } -static void check_proc_acpi_ac_adapter(const char *node, SDL_bool *have_ac) +static void check_proc_acpi_ac_adapter(const char *node, bool *have_ac) { const char *base = proc_acpi_ac_adapter_path; char state[256]; @@ -222,19 +222,19 @@ static void check_proc_acpi_ac_adapter(const char *node, SDL_bool *have_ac) while (make_proc_acpi_key_val(&ptr, &key, &val)) { if (SDL_strcasecmp(key, "state") == 0) { if (SDL_strcasecmp(val, "on-line") == 0) { - *have_ac = SDL_TRUE; + *have_ac = true; } } } } -SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, int *percent) { struct dirent *dent = NULL; DIR *dirp = NULL; - SDL_bool have_battery = SDL_FALSE; - SDL_bool have_ac = SDL_FALSE; - SDL_bool charging = SDL_FALSE; + bool have_battery = false; + bool have_ac = false; + bool charging = false; *seconds = -1; *percent = -1; @@ -242,7 +242,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i dirp = opendir(proc_acpi_battery_path); if (!dirp) { - return SDL_FALSE; // can't use this interface. + return false; // can't use this interface. } else { while ((dent = readdir(dirp)) != NULL) { const char *node = dent->d_name; @@ -254,7 +254,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i dirp = opendir(proc_acpi_ac_adapter_path); if (!dirp) { - return SDL_FALSE; // can't use this interface. + return false; // can't use this interface. } else { while ((dent = readdir(dirp)) != NULL) { const char *node = dent->d_name; @@ -273,10 +273,10 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i *state = SDL_POWERSTATE_ON_BATTERY; } - return SDL_TRUE; // definitive answer. + return true; // definitive answer. } -static SDL_bool next_string(char **_ptr, char **_str) +static bool next_string(char **_ptr, char **_str) { char *ptr = *_ptr; char *str; @@ -286,7 +286,7 @@ static SDL_bool next_string(char **_ptr, char **_str) } if (*ptr == '\0') { - return SDL_FALSE; + return false; } str = ptr; @@ -300,10 +300,10 @@ static SDL_bool next_string(char **_ptr, char **_str) *_str = str; *_ptr = ptr; - return SDL_TRUE; + return true; } -static SDL_bool int_string(char *str, int *val) +static bool int_string(char *str, int *val) { char *endptr = NULL; *val = (int)SDL_strtol(str, &endptr, 0); @@ -311,9 +311,9 @@ static SDL_bool int_string(char *str, int *val) } // http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c -SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, int *percent) { - SDL_bool need_details = SDL_FALSE; + bool need_details = false; int ac_status = 0; int battery_status = 0; int battery_flag = 0; @@ -326,61 +326,61 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in ssize_t br; if (fd == -1) { - return SDL_FALSE; // can't use this interface. + return false; // can't use this interface. } br = read(fd, buf, sizeof(buf) - 1); close(fd); if (br < 0) { - return SDL_FALSE; + return false; } buf[br] = '\0'; // null-terminate the string. if (!next_string(&ptr, &str)) { // driver version - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // BIOS version - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // APM flags - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // AC line status - return SDL_FALSE; + return false; } else if (!int_string(str, &ac_status)) { - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // battery status - return SDL_FALSE; + return false; } else if (!int_string(str, &battery_status)) { - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // battery flag - return SDL_FALSE; + return false; } else if (!int_string(str, &battery_flag)) { - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // remaining battery life percent - return SDL_FALSE; + return false; } if (str[SDL_strlen(str) - 1] == '%') { str[SDL_strlen(str) - 1] = '\0'; } if (!int_string(str, &battery_percent)) { - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // remaining battery life time - return SDL_FALSE; + return false; } else if (!int_string(str, &battery_time)) { - return SDL_FALSE; + return false; } if (!next_string(&ptr, &str)) { // remaining battery life time units - return SDL_FALSE; + return false; } else if (SDL_strcasecmp(str, "min") == 0) { battery_time *= 60; } @@ -391,13 +391,13 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in *state = SDL_POWERSTATE_NO_BATTERY; } else if (battery_flag & (1 << 3)) { // charging *state = SDL_POWERSTATE_CHARGING; - need_details = SDL_TRUE; + need_details = true; } else if (ac_status == 1) { *state = SDL_POWERSTATE_CHARGED; // on AC, not charging. - need_details = SDL_TRUE; + need_details = true; } else { *state = SDL_POWERSTATE_ON_BATTERY; - need_details = SDL_TRUE; + need_details = true; } *percent = -1; @@ -414,10 +414,10 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state, int *seconds, in } } - return SDL_TRUE; + return true; } -SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, int *seconds, int *percent) { const char *base = sys_class_power_supply_path; struct dirent *dent; @@ -425,7 +425,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in dirp = opendir(base); if (!dirp) { - return SDL_FALSE; + return false; } *state = SDL_POWERSTATE_NO_BATTERY; // assume we're just plugged in. @@ -434,7 +434,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in while ((dent = readdir(dirp)) != NULL) { const char *name = dent->d_name; - SDL_bool choose = SDL_FALSE; + bool choose = false; char str[64]; SDL_PowerState st; int secs; @@ -500,12 +500,12 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; // at least we know there's a battery. + choose = true; // at least we know there's a battery. } else if (pct > *percent) { - choose = SDL_TRUE; + choose = true; } } else if (secs > *seconds) { - choose = SDL_TRUE; + choose = true; } if (choose) { @@ -516,7 +516,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in } closedir(dirp); - return SDL_TRUE; // don't look any further. + return true; // don't look any further. } // d-bus queries to org.freedesktop.UPower. @@ -528,7 +528,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in static void check_upower_device(DBusConnection *conn, const char *path, SDL_PowerState *state, int *seconds, int *percent) { - SDL_bool choose = SDL_FALSE; + bool choose = false; SDL_PowerState st; int secs; int pct; @@ -598,12 +598,12 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; // at least we know there's a battery. + choose = true; // at least we know there's a battery. } else if (pct > *percent) { - choose = SDL_TRUE; + choose = true; } } else if (secs > *seconds) { - choose = SDL_TRUE; + choose = true; } if (choose) { @@ -614,9 +614,9 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe } #endif -SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, int *seconds, int *percent) { - SDL_bool retval = SDL_FALSE; + bool retval = false; #ifdef SDL_USE_LIBDBUS SDL_DBusContext *dbus = SDL_DBus_GetContext(); @@ -626,10 +626,10 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { - return SDL_FALSE; // try a different approach than UPower. + return false; // try a different approach than UPower. } - retval = SDL_TRUE; // Clearly we can use this interface. + retval = true; // Clearly we can use this interface. *state = SDL_POWERSTATE_NO_BATTERY; // assume we're just plugged in. *seconds = -1; *percent = -1; diff --git a/src/power/macos/SDL_syspower.c b/src/power/macos/SDL_syspower.c index 056263bec6..c9a7f9eacb 100644 --- a/src/power/macos/SDL_syspower.c +++ b/src/power/macos/SDL_syspower.c @@ -33,15 +33,15 @@ CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **)v) // Note that AC power sources also include a laptop battery it is charging. -static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_battery, - SDL_bool *charging, int *seconds, int *percent) +static void checkps(CFDictionaryRef dict, bool *have_ac, bool *have_battery, + bool *charging, int *seconds, int *percent) { CFStringRef strval; // don't CFRelease() this. CFBooleanRef bval; CFNumberRef numval; - SDL_bool charge = SDL_FALSE; - SDL_bool choose = SDL_FALSE; - SDL_bool is_ac = SDL_FALSE; + bool charge = false; + bool choose = false; + bool is_ac = false; int secs = -1; int maxpct = -1; int pct = -1; @@ -55,20 +55,20 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt } if (STRMATCH(strval, CFSTR(kIOPSACPowerValue))) { - is_ac = *have_ac = SDL_TRUE; + is_ac = *have_ac = true; } else if (!STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) { return; // not a battery? } if ((GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) { - charge = SDL_TRUE; + charge = true; } if (GETVAL(kIOPSMaxCapacityKey, &numval)) { SInt32 val = -1; CFNumberGetValue(numval, kCFNumberSInt32Type, &val); if (val > 0) { - *have_battery = SDL_TRUE; + *have_battery = true; maxpct = (int)val; } } @@ -77,7 +77,7 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt SInt32 val = -1; CFNumberGetValue(numval, kCFNumberSInt32Type, &val); if (val > 0) { - *have_battery = SDL_TRUE; + *have_battery = true; maxpct = (int)val; } } @@ -117,13 +117,13 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt */ if ((secs < 0) && (*seconds < 0)) { if ((pct < 0) && (*percent < 0)) { - choose = SDL_TRUE; // at least we know there's a battery. + choose = true; // at least we know there's a battery. } if (pct > *percent) { - choose = SDL_TRUE; + choose = true; } } else if (secs > *seconds) { - choose = SDL_TRUE; + choose = true; } if (choose) { @@ -136,7 +136,7 @@ static void checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_batt #undef GETVAL #undef STRMATCH -SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *percent) { CFTypeRef blob = IOPSCopyPowerSourcesInfo(); @@ -148,9 +148,9 @@ SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *perce CFArrayRef list = IOPSCopyPowerSourcesList(blob); if (list != NULL) { // don't CFRelease() the list items, or dictionaries! - SDL_bool have_ac = SDL_FALSE; - SDL_bool have_battery = SDL_FALSE; - SDL_bool charging = SDL_FALSE; + bool have_ac = false; + bool have_battery = false; + bool charging = false; const CFIndex total = CFArrayGetCount(list); CFIndex i; for (i = 0; i < total; i++) { @@ -178,7 +178,7 @@ SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *perce CFRelease(blob); } - return SDL_TRUE; // always the definitive answer on macOS. + return true; // always the definitive answer on macOS. } #endif // SDL_POWER_MACOSX diff --git a/src/power/n3ds/SDL_syspower.c b/src/power/n3ds/SDL_syspower.c index ddac2b4ee9..6ee762a4da 100644 --- a/src/power/n3ds/SDL_syspower.c +++ b/src/power/n3ds/SDL_syspower.c @@ -32,13 +32,13 @@ static int GetBatteryPercentage(void); #define BATTERY_PERCENT_REG 0xB #define BATTERY_PERCENT_REG_SIZE 2 -SDL_bool SDL_GetPowerInfo_N3DS(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_N3DS(SDL_PowerState *state, int *seconds, int *percent) { *state = GetPowerState(); *percent = GetBatteryPercentage(); *seconds = -1; // libctru doesn't provide a way to estimate battery life - return SDL_TRUE; + return true; } static SDL_PowerState GetPowerState(void) diff --git a/src/power/psp/SDL_syspower.c b/src/power/psp/SDL_syspower.c index 845905a79e..2c3d265e0c 100644 --- a/src/power/psp/SDL_syspower.c +++ b/src/power/psp/SDL_syspower.c @@ -26,7 +26,7 @@ #include -SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_PSP(SDL_PowerState *state, int *seconds, int *percent) { int battery = scePowerIsBatteryExist(); int plugged = scePowerIsPowerOnline(); @@ -54,7 +54,7 @@ SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *state, int *seconds, int *percent) *seconds = scePowerGetBatteryLifeTime() * 60; } - return SDL_TRUE; // always the definitive answer on PSP. + return true; // always the definitive answer on PSP. } #endif // SDL_POWER_PSP diff --git a/src/power/uikit/SDL_syspower.h b/src/power/uikit/SDL_syspower.h index 5215fb59ba..5bc75e0c2a 100644 --- a/src/power/uikit/SDL_syspower.h +++ b/src/power/uikit/SDL_syspower.h @@ -23,6 +23,6 @@ #ifdef SDL_POWER_UIKIT void SDL_UIKit_UpdateBatteryMonitoring(void); -SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent); +bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent); #endif // SDL_POWER_UIKIT diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 7cafee4ee1..e29f79a25b 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -50,7 +50,7 @@ void SDL_UIKit_UpdateBatteryMonitoring(void) } #endif // !SDL_PLATFORM_TVOS -SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percent) { #ifdef SDL_PLATFORM_TVOS *state = SDL_POWERSTATE_NO_BATTERY; @@ -98,7 +98,7 @@ SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *state, int *seconds, int *percen } #endif // SDL_PLATFORM_TVOS - return SDL_TRUE; // always the definitive answer on iOS. + return true; // always the definitive answer on iOS. } #endif // SDL_POWER_UIKIT diff --git a/src/power/vita/SDL_syspower.c b/src/power/vita/SDL_syspower.c index a8947b6114..ab66f18e27 100644 --- a/src/power/vita/SDL_syspower.c +++ b/src/power/vita/SDL_syspower.c @@ -26,7 +26,7 @@ #include -SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_VITA(SDL_PowerState *state, int *seconds, int *percent) { int battery = 1; int plugged = scePowerIsPowerOnline(); @@ -54,7 +54,7 @@ SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *state, int *seconds, int *percent *seconds = scePowerGetBatteryLifeTime() * 60; } - return SDL_TRUE; // always the definitive answer on VITA. + return true; // always the definitive answer on VITA. } #endif // SDL_POWER_VITA diff --git a/src/power/windows/SDL_syspower.c b/src/power/windows/SDL_syspower.c index d412935792..b05a6e2fc3 100644 --- a/src/power/windows/SDL_syspower.c +++ b/src/power/windows/SDL_syspower.c @@ -25,10 +25,10 @@ #include "../../core/windows/SDL_windows.h" -SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *percent) +bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *percent) { SYSTEM_POWER_STATUS status; - SDL_bool need_details = SDL_FALSE; + bool need_details = false; // This API should exist back to Win95. if (!GetSystemPowerStatus(&status)) { @@ -40,13 +40,13 @@ SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *perc *state = SDL_POWERSTATE_NO_BATTERY; } else if (status.BatteryFlag & (1 << 3)) { // charging *state = SDL_POWERSTATE_CHARGING; - need_details = SDL_TRUE; + need_details = true; } else if (status.ACLineStatus == 1) { *state = SDL_POWERSTATE_CHARGED; // on AC, not charging. - need_details = SDL_TRUE; + need_details = true; } else { *state = SDL_POWERSTATE_ON_BATTERY; // not on AC. - need_details = SDL_TRUE; + need_details = true; } *percent = -1; @@ -63,7 +63,7 @@ SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *perc } } - return SDL_TRUE; // always the definitive answer on Windows. + return true; // always the definitive answer on Windows. } #endif // SDL_POWER_WINDOWS diff --git a/src/power/winrt/SDL_syspower.cpp b/src/power/winrt/SDL_syspower.cpp index 3313f995f0..031e0073f1 100644 --- a/src/power/winrt/SDL_syspower.cpp +++ b/src/power/winrt/SDL_syspower.cpp @@ -23,7 +23,7 @@ #ifndef SDL_POWER_DISABLED #if SDL_POWER_WINRT -extern "C" SDL_bool +extern "C" bool SDL_GetPowerInfo_WinRT(SDL_PowerState *state, int *seconds, int *percent) { // TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement SDL_GetPowerInfo_WinRT as appropriate. @@ -32,7 +32,7 @@ SDL_GetPowerInfo_WinRT(SDL_PowerState *state, int *seconds, int *percent) - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231 */ - return SDL_FALSE; + return false; } #endif // SDL_POWER_WINRT diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 5ebd8d26b8..07a737ddb7 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -179,7 +179,7 @@ static float sRGBfromLinear(float v) return v <= 0.0031308f ? (v * 12.92f) : (SDL_powf(v, 1.0f / 2.4f) * 1.055f - 0.055f); } -SDL_bool SDL_RenderingLinearSpace(SDL_Renderer *renderer) +bool SDL_RenderingLinearSpace(SDL_Renderer *renderer) { SDL_Colorspace colorspace; @@ -189,9 +189,9 @@ SDL_bool SDL_RenderingLinearSpace(SDL_Renderer *renderer) colorspace = renderer->output_colorspace; } if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } void SDL_ConvertToLinear(SDL_FColor *color) @@ -332,10 +332,10 @@ static int FlushRenderCommands(SDL_Renderer *renderer) } renderer->vertex_data_used = 0; renderer->render_command_generation++; - renderer->color_queued = SDL_FALSE; - renderer->color_scale_queued = SDL_FALSE; - renderer->viewport_queued = SDL_FALSE; - renderer->cliprect_queued = SDL_FALSE; + renderer->color_queued = false; + renderer->color_scale_queued = false; + renderer->viewport_queued = false; + renderer->cliprect_queued = false; return retval; } @@ -454,7 +454,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) cmd->command = SDL_RENDERCMD_NO_OP; } else { SDL_copyp(&renderer->last_queued_viewport, &viewport); - renderer->viewport_queued = SDL_TRUE; + renderer->viewport_queued = true; } } else { retval = -1; @@ -488,7 +488,7 @@ static int QueueCmdSetClipRect(SDL_Renderer *renderer) SDL_copyp(&cmd->data.cliprect.rect, &clip_rect); SDL_copyp(&renderer->last_queued_cliprect, &clip_rect); renderer->last_queued_cliprect_enabled = renderer->view->clipping_enabled; - renderer->cliprect_queued = SDL_TRUE; + renderer->cliprect_queued = true; } else { retval = -1; } @@ -518,7 +518,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_FColor *color) cmd->command = SDL_RENDERCMD_NO_OP; } else { renderer->last_queued_color = *color; - renderer->color_queued = SDL_TRUE; + renderer->color_queued = true; } } } @@ -619,8 +619,8 @@ static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, con if (cmd) { if (use_rendergeometry) { - SDL_bool isstack1; - SDL_bool isstack2; + bool isstack1; + bool isstack2; float *xy = SDL_small_alloc(float, 4 * 2 * count, &isstack1); int *indices = SDL_small_alloc(int, 6 * count, &isstack2); @@ -781,9 +781,9 @@ static void UpdateHDRProperties(SDL_Renderer *renderer) } if (renderer->HDR_headroom > 1.0f) { - SDL_SetBooleanProperty(renderer_props, SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN, SDL_TRUE); + SDL_SetBooleanProperty(renderer_props, SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN, true); } else { - SDL_SetBooleanProperty(renderer_props, SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN, SDL_FALSE); + SDL_SetBooleanProperty(renderer_props, SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN, false); } SDL_SetFloatProperty(renderer_props, SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT, renderer->SDR_white_point); SDL_SetFloatProperty(renderer_props, SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT, renderer->HDR_headroom); @@ -835,17 +835,17 @@ static SDL_bool SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event) UpdateMainViewDimensions(renderer); UpdateLogicalPresentation(renderer); } else if (event->type == SDL_EVENT_WINDOW_HIDDEN) { - renderer->hidden = SDL_TRUE; + renderer->hidden = true; } else if (event->type == SDL_EVENT_WINDOW_SHOWN) { if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) { - renderer->hidden = SDL_FALSE; + renderer->hidden = false; } } else if (event->type == SDL_EVENT_WINDOW_MINIMIZED) { - renderer->hidden = SDL_TRUE; + renderer->hidden = true; } else if (event->type == SDL_EVENT_WINDOW_RESTORED || event->type == SDL_EVENT_WINDOW_MAXIMIZED) { if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) { - renderer->hidden = SDL_FALSE; + renderer->hidden = false; } } else if (event->type == SDL_EVENT_WINDOW_DISPLAY_CHANGED) { UpdateHDRProperties(renderer); @@ -855,12 +855,12 @@ static SDL_bool SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event) UpdateHDRProperties(renderer); } - return SDL_TRUE; + return true; } int SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer) { - SDL_bool hidden = (window_flags & SDL_WINDOW_HIDDEN) != 0; + bool hidden = (window_flags & SDL_WINDOW_HIDDEN) != 0; if (!window) { return SDL_InvalidParamError("window"); @@ -973,7 +973,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) goto error; } - SDL_SetObjectValid(renderer, SDL_OBJECT_TYPE_RENDERER, SDL_TRUE); + SDL_SetObjectValid(renderer, SDL_OBJECT_TYPE_RENDERER, true); if ((!window && !surface) || (window && surface)) { SDL_InvalidParamError("window"); @@ -992,7 +992,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); if (hint && *hint) { - SDL_SetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)); + SDL_SetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, true)); } if (surface) { @@ -1087,11 +1087,11 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) if (window) { if (SDL_GetWindowFlags(window) & SDL_WINDOW_TRANSPARENT) { - renderer->transparent_window = SDL_TRUE; + renderer->transparent_window = true; } if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED)) { - renderer->hidden = SDL_TRUE; + renderer->hidden = true; } } @@ -1256,7 +1256,7 @@ int SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h) return 0; } -static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { switch (blendMode) { // These are required to be supported by all renderers @@ -1267,23 +1267,23 @@ static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend case SDL_BLENDMODE_ADD_PREMULTIPLIED: case SDL_BLENDMODE_MOD: case SDL_BLENDMODE_MUL: - return SDL_TRUE; + return true; default: return renderer->SupportsBlendMode && renderer->SupportsBlendMode(renderer, blendMode); } } -static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format) +static bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format) { int i; for (i = 0; i < renderer->num_texture_formats; ++i) { if (renderer->texture_formats[i] == format) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format) @@ -1311,7 +1311,7 @@ static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat } } } else { - SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); + bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); // We just want to match the first format that has the same channels for (i = 0; i < renderer->num_texture_formats; ++i) { @@ -1332,7 +1332,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert int w = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, 0); int h = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, 0); SDL_Colorspace default_colorspace; - SDL_bool texture_is_fourcc_and_target; + bool texture_is_fourcc_and_target; CHECK_RENDERER_MAGIC(renderer, NULL); @@ -1365,7 +1365,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert if (!texture) { return NULL; } - SDL_SetObjectValid(texture, SDL_OBJECT_TYPE_TEXTURE, SDL_TRUE); + SDL_SetObjectValid(texture, SDL_OBJECT_TYPE_TEXTURE, true); texture->colorspace = (SDL_Colorspace)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, default_colorspace); texture->format = format; texture->access = access; @@ -1498,7 +1498,7 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, S static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SDL_Surface *surface) { SDL_TextureAccess access; - SDL_bool direct_update; + bool direct_update; SDL_PixelFormat tex_format; SDL_PropertiesID surface_props; SDL_PropertiesID tex_props; @@ -1544,14 +1544,14 @@ static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SD if (SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) { /* Surface and Renderer formats are identical. * Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */ - direct_update = SDL_FALSE; + direct_update = false; } else { // Update Texture directly - direct_update = SDL_TRUE; + direct_update = true; } } else { // Surface and Renderer formats are different, it needs an intermediate conversion. - direct_update = SDL_FALSE; + direct_update = false; } if (direct_update) { @@ -1599,7 +1599,7 @@ static int SDL_UpdateTextureFromSurface(SDL_Texture *texture, SDL_Rect *rect, SD SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface) { - SDL_bool needAlpha; + bool needAlpha; int i; SDL_PixelFormat format = SDL_PIXELFORMAT_UNKNOWN; SDL_Palette *palette; @@ -1617,18 +1617,18 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s // See what the best texture format is if (SDL_ISPIXELFORMAT_ALPHA(surface->format) || SDL_SurfaceHasColorKey(surface)) { - needAlpha = SDL_TRUE; + needAlpha = true; } else { - needAlpha = SDL_FALSE; + needAlpha = false; } // If Palette contains alpha values, promotes to alpha format palette = SDL_GetSurfacePalette(surface); if (palette) { - SDL_bool is_opaque, has_alpha_channel; + bool is_opaque, has_alpha_channel; SDL_DetectPalette(palette, &is_opaque, &has_alpha_channel); if (!is_opaque) { - needAlpha = SDL_TRUE; + needAlpha = true; } } @@ -3028,9 +3028,9 @@ SDL_bool SDL_RenderViewportSet(SDL_Renderer *renderer) if (renderer->view->viewport.w >= 0 && renderer->view->viewport.h >= 0) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } static void GetRenderViewportSize(SDL_Renderer *renderer, SDL_FRect *rect) @@ -3101,10 +3101,10 @@ int SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect) CHECK_RENDERER_MAGIC(renderer, -1) if (rect && rect->w >= 0 && rect->h >= 0) { - renderer->view->clipping_enabled = SDL_TRUE; + renderer->view->clipping_enabled = true; SDL_copyp(&renderer->view->clip_rect, rect); } else { - renderer->view->clipping_enabled = SDL_FALSE; + renderer->view->clipping_enabled = false; SDL_zero(renderer->view->clip_rect); } UpdatePixelClipRect(renderer, renderer->view); @@ -3128,7 +3128,7 @@ int SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect) SDL_bool SDL_RenderClipEnabled(SDL_Renderer *renderer) { - CHECK_RENDERER_MAGIC(renderer, SDL_FALSE) + CHECK_RENDERER_MAGIC(renderer, false) return renderer->view->clipping_enabled; } @@ -3340,7 +3340,7 @@ int SDL_RenderPoint(SDL_Renderer *renderer, float x, float y) static int RenderPointsWithRects(SDL_Renderer *renderer, const SDL_FPoint *fpoints, const int count) { int retval; - SDL_bool isstack; + bool isstack; SDL_FRect *frects; int i; @@ -3405,7 +3405,7 @@ int SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y return SDL_RenderLines(renderer, points, 2); } -static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, int y2, SDL_bool draw_last) +static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, int y2, bool draw_last) { const int MAX_PIXELS = SDL_max(renderer->view->pixel_w, renderer->view->pixel_h) * 4; int i, deltax, deltay, numpixels; @@ -3413,7 +3413,7 @@ static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, i int x, xinc1, xinc2; int y, yinc1, yinc2; int retval; - SDL_bool isstack; + bool isstack; SDL_FPoint *points; SDL_Rect viewport; @@ -3509,9 +3509,9 @@ static int RenderLinesWithRectsF(SDL_Renderer *renderer, SDL_FRect *frects; int i, nrects = 0; int retval = 0; - SDL_bool isstack; - SDL_bool drew_line = SDL_FALSE; - SDL_bool draw_last = SDL_FALSE; + bool isstack; + bool drew_line = false; + bool draw_last = false; frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack); if (!frects) { @@ -3519,12 +3519,12 @@ static int RenderLinesWithRectsF(SDL_Renderer *renderer, } for (i = 0; i < count - 1; ++i) { - SDL_bool same_x = (points[i].x == points[i + 1].x); - SDL_bool same_y = (points[i].y == points[i + 1].y); + bool same_x = (points[i].x == points[i + 1].x); + bool same_y = (points[i].y == points[i + 1].y); if (i == (count - 2)) { if (!drew_line || points[i + 1].x != points[0].x || points[i + 1].y != points[0].y) { - draw_last = SDL_TRUE; + draw_last = true; } } else { if (same_x && same_y) { @@ -3559,7 +3559,7 @@ static int RenderLinesWithRectsF(SDL_Renderer *renderer, retval += RenderLineBresenham(renderer, (int)SDL_roundf(points[i].x), (int)SDL_roundf(points[i].y), (int)SDL_roundf(points[i + 1].x), (int)SDL_roundf(points[i + 1].y), draw_last); } - drew_line = SDL_TRUE; + drew_line = true; } if (nrects) { @@ -3597,8 +3597,8 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) if (renderer->line_method == SDL_RENDERLINEMETHOD_POINTS) { retval = RenderLinesWithRectsF(renderer, points, count); } else if (renderer->line_method == SDL_RENDERLINEMETHOD_GEOMETRY) { - SDL_bool isstack1; - SDL_bool isstack2; + bool isstack1; + bool isstack2; const float scale_x = renderer->view->scale.x; const float scale_y = renderer->view->scale.y; float *xy = SDL_small_alloc(float, 4 * 2 * count, &isstack1); @@ -3798,7 +3798,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun SDL_FRect *frects; int i; int retval; - SDL_bool isstack; + bool isstack; CHECK_RENDERER_MAGIC(renderer, -1); @@ -3837,7 +3837,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun static int SDL_RenderTextureInternal(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect) { int retval; - SDL_bool use_rendergeometry = (!renderer->QueueCopy); + bool use_rendergeometry = (!renderer->QueueCopy); if (use_rendergeometry) { float xy[8]; @@ -4998,7 +4998,7 @@ static void SDL_SimulateRenderVSync(SDL_Renderer *renderer) int SDL_RenderPresent(SDL_Renderer *renderer) { - SDL_bool presented = SDL_TRUE; + bool presented = true; CHECK_RENDERER_MAGIC(renderer, -1); @@ -5016,11 +5016,11 @@ int SDL_RenderPresent(SDL_Renderer *renderer) #if DONT_DRAW_WHILE_HIDDEN // Don't present while we're hidden if (renderer->hidden) { - presented = SDL_FALSE; + presented = false; } else #endif if (renderer->RenderPresent(renderer) < 0) { - presented = SDL_FALSE; + presented = false; } if (renderer->logical_target) { @@ -5034,7 +5034,7 @@ int SDL_RenderPresent(SDL_Renderer *renderer) return 0; } -static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroying) +static int SDL_DestroyTextureInternal(SDL_Texture *texture, bool is_destroying) { SDL_Renderer *renderer; @@ -5063,7 +5063,7 @@ static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroyi renderer->logical_target = NULL; } - SDL_SetObjectValid(texture, SDL_OBJECT_TYPE_TEXTURE, SDL_FALSE); + SDL_SetObjectValid(texture, SDL_OBJECT_TYPE_TEXTURE, false); if (texture->next) { texture->next->prev = texture->prev; @@ -5095,7 +5095,7 @@ static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroyi void SDL_DestroyTexture(SDL_Texture *texture) { - SDL_DestroyTextureInternal(texture, SDL_FALSE /* is_destroying */); + SDL_DestroyTextureInternal(texture, false /* is_destroying */); } static void SDL_DiscardAllCommands(SDL_Renderer *renderer) @@ -5125,7 +5125,7 @@ void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer) SDL_assert(renderer != NULL); SDL_assert(!renderer->destroyed); - renderer->destroyed = SDL_TRUE; + renderer->destroyed = true; SDL_DelEventWatch(SDL_RendererEventWatch, renderer); @@ -5141,7 +5141,7 @@ void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer) // Free existing textures for this renderer while (renderer->textures) { SDL_Texture *tex = renderer->textures; - SDL_DestroyTextureInternal(renderer->textures, SDL_TRUE /* is_destroying */); + SDL_DestroyTextureInternal(renderer->textures, true /* is_destroying */); SDL_assert(tex != renderer->textures); // satisfy static analysis. } @@ -5194,7 +5194,7 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer) curr = curr->next; } - SDL_SetObjectValid(renderer, SDL_OBJECT_TYPE_RENDERER, SDL_FALSE); // It's no longer magical... + SDL_SetObjectValid(renderer, SDL_OBJECT_TYPE_RENDERER, false); // It's no longer magical... SDL_free(renderer); } @@ -5333,7 +5333,7 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) { CHECK_RENDERER_MAGIC(renderer, -1); - renderer->wanted_vsync = vsync ? SDL_TRUE : SDL_FALSE; + renderer->wanted_vsync = vsync ? true : false; // for the software renderer, forward the call to the WindowTexture renderer #if SDL_VIDEO_RENDER_SW @@ -5346,7 +5346,7 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) } } if (SDL_SetWindowTextureVSync(NULL, renderer->window, vsync) == 0) { - renderer->simulate_vsync = SDL_FALSE; + renderer->simulate_vsync = false; return 0; } } @@ -5355,17 +5355,17 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) if (!renderer->SetVSync) { switch (vsync) { case 0: - renderer->simulate_vsync = SDL_FALSE; + renderer->simulate_vsync = false; break; case 1: - renderer->simulate_vsync = SDL_TRUE; + renderer->simulate_vsync = true; break; default: return SDL_Unsupported(); } } else if (renderer->SetVSync(renderer, vsync) < 0) { if (vsync == 1) { - renderer->simulate_vsync = SDL_TRUE; + renderer->simulate_vsync = true; } else { return -1; } diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index bb7441e790..cba77ea60e 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -61,7 +61,7 @@ typedef struct SDL_RenderViewState SDL_Rect pixel_viewport; SDL_Rect clip_rect; SDL_Rect pixel_clip_rect; - SDL_bool clipping_enabled; + bool clipping_enabled; SDL_FPoint scale; } SDL_RenderViewState; @@ -128,7 +128,7 @@ typedef struct SDL_RenderCommand } viewport; struct { - SDL_bool enabled; + bool enabled; SDL_Rect rect; } cliprect; struct @@ -169,7 +169,7 @@ struct SDL_Renderer { void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event); int (*GetOutputSize)(SDL_Renderer *renderer, int *w, int *h); - SDL_bool (*SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode); + bool (*SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode); int (*CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props); int (*QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd); int (*QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd); @@ -227,15 +227,15 @@ struct SDL_Renderer const char *name; SDL_PixelFormat *texture_formats; int num_texture_formats; - SDL_bool software; + bool software; // The window associated with the renderer SDL_Window *window; - SDL_bool hidden; + bool hidden; // Whether we should simulate vsync - SDL_bool wanted_vsync; - SDL_bool simulate_vsync; + bool wanted_vsync; + bool simulate_vsync; Uint64 simulate_vsync_interval_ns; Uint64 last_present; @@ -280,24 +280,24 @@ struct SDL_Renderer float last_queued_color_scale; SDL_Rect last_queued_viewport; SDL_Rect last_queued_cliprect; - SDL_bool last_queued_cliprect_enabled; - SDL_bool color_queued; - SDL_bool color_scale_queued; - SDL_bool viewport_queued; - SDL_bool cliprect_queued; + bool last_queued_cliprect_enabled; + bool color_queued; + bool color_scale_queued; + bool viewport_queued; + bool cliprect_queued; void *vertex_data; size_t vertex_data_used; size_t vertex_data_allocation; // Shaped window support - SDL_bool transparent_window; + bool transparent_window; SDL_Surface *shape_surface; SDL_Texture *shape_texture; SDL_PropertiesID props; - SDL_bool destroyed; // already destroyed by SDL_DestroyWindow; just free this struct in SDL_DestroyRenderer. + bool destroyed; // already destroyed by SDL_DestroyWindow; just free this struct in SDL_DestroyRenderer. void *internal; @@ -335,7 +335,7 @@ extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat extern void SDL_SetupRendererColorspace(SDL_Renderer *renderer, SDL_PropertiesID props); // Colorspace conversion functions -extern SDL_bool SDL_RenderingLinearSpace(SDL_Renderer *renderer); +extern bool SDL_RenderingLinearSpace(SDL_Renderer *renderer); extern void SDL_ConvertToLinear(SDL_FColor *color); extern void SDL_ConvertFromLinear(SDL_FColor *color); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index b4482fbeff..1dc361136a 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -39,13 +39,13 @@ typedef struct { SDL_Rect viewport; - SDL_bool viewport_dirty; + bool viewport_dirty; SDL_Texture *texture; SDL_BlendMode blend; - SDL_bool cliprect_enabled; - SDL_bool cliprect_enabled_dirty; + bool cliprect_enabled; + bool cliprect_enabled_dirty; SDL_Rect cliprect; - SDL_bool cliprect_dirty; + bool cliprect_dirty; D3D9_Shader shader; const float *shader_params; } D3D_DrawStateCache; @@ -59,9 +59,9 @@ typedef struct IDirect3DDevice9 *device; UINT adapter; D3DPRESENT_PARAMETERS pparams; - SDL_bool updateSize; - SDL_bool beginScene; - SDL_bool enableSeparateAlphaBlend; + bool updateSize; + bool beginScene; + bool enableSeparateAlphaBlend; D3DTEXTUREFILTERTYPE scaleMode[3]; SDL_TextureAddressMode addressMode[3]; IDirect3DSurface9 *defaultRenderTarget; @@ -73,13 +73,13 @@ typedef struct LPDIRECT3DVERTEXBUFFER9 vertexBuffers[8]; size_t vertexBufferSize[8]; int currentVertexBuffer; - SDL_bool reportedVboProblem; + bool reportedVboProblem; D3D_DrawStateCache drawstate; } D3D_RenderData; typedef struct { - SDL_bool dirty; + bool dirty; int w, h; DWORD usage; Uint32 format; @@ -97,7 +97,7 @@ typedef struct #if SDL_HAVE_YUV // YV12 texture support - SDL_bool yuv; + bool yuv; D3D_TextureRep utexture; D3D_TextureRep vtexture; Uint8 *pixels; @@ -282,7 +282,7 @@ static void D3D_InitRenderState(D3D_RenderData *data) SDL_zeroa(data->addressMode); // Start the render with beginScene - data->beginScene = SDL_TRUE; + data->beginScene = true; } static int D3D_Reset(SDL_Renderer *renderer); @@ -316,7 +316,7 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer) return -1; } - data->updateSize = SDL_FALSE; + data->updateSize = false; } if (data->beginScene) { result = IDirect3DDevice9_BeginScene(data->device); @@ -329,7 +329,7 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer) if (FAILED(result)) { return D3D_SetError("BeginScene()", result); } - data->beginScene = SDL_FALSE; + data->beginScene = false; } return 0; } @@ -339,7 +339,7 @@ static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event D3D_RenderData *data = (D3D_RenderData *)renderer->internal; if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { - data->updateSize = SDL_TRUE; + data->updateSize = true; } } @@ -391,7 +391,7 @@ static D3DBLENDOP GetBlendEquation(SDL_BlendOperation operation) return (D3DBLENDOP)0; } -static SDL_bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { D3D_RenderData *data = (D3D_RenderData *)renderer->internal; SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); @@ -405,22 +405,22 @@ static SDL_bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blen !GetBlendEquation(colorOperation) || !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) || !GetBlendEquation(alphaOperation)) { - return SDL_FALSE; + return false; } if (!data->enableSeparateAlphaBlend) { if ((srcColorFactor != srcAlphaFactor) || (dstColorFactor != dstAlphaFactor) || (colorOperation != alphaOperation)) { - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h) { HRESULT result; - texture->dirty = SDL_FALSE; + texture->dirty = false; texture->w = w; texture->h = h; texture->usage = usage; @@ -458,7 +458,7 @@ static int D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *text } if (texture->staging) { IDirect3DTexture9_AddDirtyRect(texture->staging, NULL); - texture->dirty = SDL_TRUE; + texture->dirty = true; } return 0; } @@ -508,7 +508,7 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur if (FAILED(result)) { return D3D_SetError("UnlockRect()", result); } - texture->dirty = SDL_TRUE; + texture->dirty = true; return 0; } @@ -551,7 +551,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P #if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - texturedata->yuv = SDL_TRUE; + texturedata->yuv = true; if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) { return -1; @@ -727,7 +727,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) #endif { IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0); - texturedata->texture.dirty = SDL_TRUE; + texturedata->texture.dirty = true; if (data->drawstate.texture == texture) { data->drawstate.texture = NULL; data->drawstate.shader = SHADER_NONE; @@ -788,7 +788,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text if (FAILED(result)) { return D3D_SetError("UpdateTexture()", result); } - texturerep->dirty = SDL_FALSE; + texturerep->dirty = false; } result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget); @@ -912,7 +912,7 @@ static int UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) if (FAILED(result)) { return D3D_SetError("UpdateTexture()", result); } - texture->dirty = SDL_FALSE; + texture->dirty = false; } return 0; } @@ -1099,12 +1099,12 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) IDirect3DDevice9_SetTransform(data->device, D3DTS_PROJECTION, &d3dmatrix); } - data->drawstate.viewport_dirty = SDL_FALSE; + data->drawstate.viewport_dirty = false; } if (data->drawstate.cliprect_enabled_dirty) { IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, data->drawstate.cliprect_enabled ? TRUE : FALSE); - data->drawstate.cliprect_enabled_dirty = SDL_FALSE; + data->drawstate.cliprect_enabled_dirty = false; } if (data->drawstate.cliprect_dirty) { @@ -1116,7 +1116,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) d3drect.right = (LONG)viewport->x + rect->x + rect->w; d3drect.bottom = (LONG)viewport->y + rect->y + rect->h; IDirect3DDevice9_SetScissorRect(data->device, &d3drect); - data->drawstate.cliprect_dirty = SDL_FALSE; + data->drawstate.cliprect_dirty = false; } return 0; @@ -1125,9 +1125,9 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) static void D3D_InvalidateCachedState(SDL_Renderer *renderer) { D3D_RenderData *data = (D3D_RenderData *)renderer->internal; - data->drawstate.viewport_dirty = SDL_TRUE; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; + data->drawstate.cliprect_enabled_dirty = true; + data->drawstate.cliprect_dirty = true; data->drawstate.blend = SDL_BLENDMODE_INVALID; data->drawstate.texture = NULL; data->drawstate.shader = SHADER_NONE; @@ -1139,7 +1139,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v D3D_RenderData *data = (D3D_RenderData *)renderer->internal; const int vboidx = data->currentVertexBuffer; IDirect3DVertexBuffer9 *vbo = NULL; - const SDL_bool istarget = renderer->target != NULL; + const bool istarget = renderer->target != NULL; if (D3D_ActivateRenderer(renderer) < 0) { return -1; @@ -1185,7 +1185,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Dropping back to a slower method."); SDL_LogError(SDL_LOG_CATEGORY_RENDER, "This might be a brief hiccup, but if performance is bad, this is probably why."); SDL_LogError(SDL_LOG_CATEGORY_RENDER, "This error will not be logged again for this renderer."); - data->reportedVboProblem = SDL_TRUE; + data->reportedVboProblem = true; } } @@ -1206,8 +1206,8 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v SDL_Rect *viewport = &data->drawstate.viewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; + data->drawstate.cliprect_dirty = true; } break; } @@ -1217,12 +1217,12 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v const SDL_Rect *rect = &cmd->data.cliprect.rect; if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + data->drawstate.cliprect_enabled_dirty = true; } if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = true; } break; } @@ -1236,7 +1236,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v const SDL_Rect *viewport = &data->drawstate.viewport; const int backw = istarget ? renderer->target->w : data->pparams.BackBufferWidth; const int backh = istarget ? renderer->target->h : data->pparams.BackBufferHeight; - const SDL_bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)); + const bool viewport_equal = ((viewport->x == 0) && (viewport->y == 0) && (viewport->w == backw) && (viewport->h == backh)); if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); @@ -1252,7 +1252,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v wholeviewport.Width = backw; wholeviewport.Height = backh; IDirect3DDevice9_SetViewport(data->device, &wholeviewport); - data->drawstate.viewport_dirty = SDL_TRUE; // we still need to (re)set orthographic projection, so always mark it dirty. + data->drawstate.viewport_dirty = true; // we still need to (re)set orthographic projection, so always mark it dirty. IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); } @@ -1282,7 +1282,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v /* DirectX 9 has the same line rasterization semantics as GDI, so we need to close the endpoint of the line with a second draw call. NOLINTNEXTLINE(clang-analyzer-core.NullDereference): FIXME: Can verts truly not be NULL ? */ - const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y)); + const bool close_endpoint = ((count == 2) || (verts[0].x != verts[count - 1].x) || (verts[0].y != verts[count - 1].y)); SetDrawState(data, cmd); @@ -1397,7 +1397,7 @@ static int D3D_RenderPresent(SDL_Renderer *renderer) if (!data->beginScene) { IDirect3DDevice9_EndScene(data->device); - data->beginScene = SDL_TRUE; + data->beginScene = true; } result = IDirect3DDevice9_TestCooperativeLevel(data->device); @@ -1502,7 +1502,7 @@ static int D3D_Reset(SDL_Renderer *renderer) // Cancel any scene that we've started if (!data->beginScene) { IDirect3DDevice9_EndScene(data->device); - data->beginScene = SDL_TRUE; + data->beginScene = true; } // Release the default render target before reset @@ -1713,7 +1713,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; } - if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, false)) { device_flags |= D3DCREATE_MULTITHREADED; } @@ -1743,7 +1743,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, SDL_min(caps.MaxTextureWidth, caps.MaxTextureHeight)); if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND) { - data->enableSeparateAlphaBlend = SDL_TRUE; + data->enableSeparateAlphaBlend = true; } // Store the default render target diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index ded8070efc..891096b2dd 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -145,14 +145,14 @@ typedef struct const float *YCbCr_matrix; #if SDL_HAVE_YUV // YV12 texture support - SDL_bool yuv; + bool yuv; ID3D11Texture2D *mainTextureU; ID3D11ShaderResourceView *mainTextureResourceViewU; ID3D11Texture2D *mainTextureV; ID3D11ShaderResourceView *mainTextureResourceViewV; // NV12 texture support - SDL_bool nv12; + bool nv12; ID3D11ShaderResourceView *mainTextureResourceViewNV; Uint8 *pixels; @@ -193,7 +193,7 @@ typedef struct D3D11_BlendMode *blendModes; ID3D11SamplerState *samplers[SDL_NUM_D3D11_SAMPLERS]; D3D_FEATURE_LEVEL featureLevel; - SDL_bool pixelSizeChanged; + bool pixelSizeChanged; // Rasterizers ID3D11RasterizerState *mainRasterizer; @@ -212,12 +212,12 @@ typedef struct PixelShaderState currentShaderState[NUM_SHADERS]; ID3D11ShaderResourceView *currentShaderResource; ID3D11SamplerState *currentSampler; - SDL_bool cliprectDirty; - SDL_bool currentCliprectEnabled; + bool cliprectDirty; + bool currentCliprectEnabled; SDL_Rect currentCliprect; SDL_Rect currentViewport; int currentViewportRotation; - SDL_bool viewportDirty; + bool viewportDirty; Float4X4 identity; int currentVertexBuffer; } D3D11_RenderData; @@ -531,7 +531,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) IDXGIDevice1 *dxgiDevice = NULL; HRESULT result = S_OK; UINT creationFlags = 0; - SDL_bool createDebug; + bool createDebug; /* This array defines the set of DirectX hardware feature levels this app will support. * Note the ordering should be preserved. @@ -553,7 +553,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) D3D11_RASTERIZER_DESC rasterDesc; // See if we need debug interfaces - createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); + createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, false); #ifdef SDL_PLATFORM_WINRT CreateDXGIFactory2Func = CreateDXGIFactory2; @@ -646,7 +646,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) } // Create a single-threaded device unless the app requests otherwise. - if (!SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, false)) { creationFlags |= D3D11_CREATE_DEVICE_SINGLETHREADED; } @@ -1200,7 +1200,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) &data->mainRenderTargetView, NULL); - data->viewportDirty = SDL_TRUE; + data->viewportDirty = true; done: SAFE_RELEASE(backBuffer); @@ -1238,11 +1238,11 @@ static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { - data->pixelSizeChanged = SDL_TRUE; + data->pixelSizeChanged = true; } } -static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -1255,9 +1255,9 @@ static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode bl !GetBlendEquation(colorOperation) || !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) || !GetBlendEquation(alphaOperation)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D11Texture2D **texture) @@ -1349,7 +1349,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL #if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - textureData->yuv = SDL_TRUE; + textureData->yuv = true; textureDesc.Width = (textureDesc.Width + 1) / 2; textureDesc.Height = (textureDesc.Height + 1) / 2; @@ -1392,7 +1392,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL texture->format == SDL_PIXELFORMAT_P010) { int bits_per_pixel; - textureData->nv12 = SDL_TRUE; + textureData->nv12 = true; switch (texture->format) { case SDL_PIXELFORMAT_P010: @@ -1958,7 +1958,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); int i; SDL_FColor color = cmd->data.draw.color; - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); if (!verts) { return -1; @@ -1990,7 +1990,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int i; int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); D3D11_TextureData *textureData = texture ? (D3D11_TextureData *)texture->internal : NULL; float u_scale = textureData ? (float)texture->w / textureData->w : 0.0f; float v_scale = textureData ? (float)texture->h / textureData->h : 0.0f; @@ -2194,7 +2194,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer) // SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &d3dviewport); - data->viewportDirty = SDL_FALSE; + data->viewportDirty = false; return 0; } @@ -2284,7 +2284,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c ID3D11ShaderResourceView *shaderResource; const SDL_BlendMode blendMode = cmd->data.draw.blend; ID3D11BlendState *blendState = NULL; - SDL_bool updateSubresource = SDL_FALSE; + bool updateSubresource = false; PixelShaderState *shader_state = &rendererData->currentShaderState[shader]; PixelShaderConstants solid_constants; @@ -2312,7 +2312,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c if (rendererData->viewportDirty) { if (D3D11_UpdateViewport(renderer) == 0) { // vertexShaderConstantsData.projectionAndView has changed - updateSubresource = SDL_TRUE; + updateSubresource = true; } } @@ -2327,7 +2327,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c } ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 1, &scissorRect); } - rendererData->cliprectDirty = SDL_FALSE; + rendererData->cliprectDirty = false; } if (!rendererData->currentCliprectEnabled) { @@ -2410,7 +2410,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c rendererData->currentSampler = sampler; } - if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { + if (updateSubresource == true || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { SDL_copyp(&rendererData->vertexShaderConstantsData.model, newmatrix); ID3D11DeviceContext_UpdateSubresource(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexShaderConstants, @@ -2507,8 +2507,8 @@ static void D3D11_InvalidateCachedState(SDL_Renderer *renderer) data->currentShader = SHADER_NONE; data->currentShaderResource = NULL; data->currentSampler = NULL; - data->cliprectDirty = SDL_TRUE; - data->viewportDirty = SDL_TRUE; + data->cliprectDirty = true; + data->viewportDirty = true; } static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -2518,12 +2518,12 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (rendererData->pixelSizeChanged) { D3D11_UpdateForWindowSizeChange(renderer); - rendererData->pixelSizeChanged = SDL_FALSE; + rendererData->pixelSizeChanged = false; } if (rendererData->currentViewportRotation != viewportRotation) { rendererData->currentViewportRotation = viewportRotation; - rendererData->viewportDirty = SDL_TRUE; + rendererData->viewportDirty = true; } if (D3D11_UpdateVertexBuffer(renderer, vertices, vertsize) < 0) { @@ -2542,8 +2542,8 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Rect *viewport = &rendererData->currentViewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = SDL_TRUE; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->viewportDirty = true; + rendererData->cliprectDirty = true; } break; } @@ -2553,18 +2553,18 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_Rect *rect = &cmd->data.cliprect.rect; if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } break; } case SDL_RENDERCMD_CLEAR: { - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); SDL_FColor color = cmd->data.color.color; if (convert_color) { SDL_ConvertToLinear(&color); diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 889e91e0f2..b86c52fc40 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -129,7 +129,7 @@ typedef struct const float *YCbCr_matrix; #if SDL_HAVE_YUV // YV12 texture support - SDL_bool yuv; + bool yuv; ID3D12Resource *mainTextureU; D3D12_CPU_DESCRIPTOR_HANDLE mainTextureResourceViewU; D3D12_RESOURCE_STATES mainResourceStateU; @@ -140,7 +140,7 @@ typedef struct SIZE_T mainSRVIndexV; // NV12 texture support - SDL_bool nv12; + bool nv12; D3D12_CPU_DESCRIPTOR_HANDLE mainTextureResourceViewNV; SIZE_T mainSRVIndexNV; @@ -198,7 +198,7 @@ typedef struct UINT syncInterval; UINT presentFlags; DXGI_FORMAT renderTargetFormat; - SDL_bool pixelSizeChanged; + bool pixelSizeChanged; // Descriptor heaps ID3D12DescriptorHeap *rtvDescriptorHeap; @@ -245,15 +245,15 @@ typedef struct D3D12_CPU_DESCRIPTOR_HANDLE currentRenderTargetView; D3D12_CPU_DESCRIPTOR_HANDLE currentShaderResource; D3D12_CPU_DESCRIPTOR_HANDLE currentSampler; - SDL_bool cliprectDirty; - SDL_bool currentCliprectEnabled; + bool cliprectDirty; + bool currentCliprectEnabled; SDL_Rect currentCliprect; SDL_Rect currentViewport; int currentViewportRotation; - SDL_bool viewportDirty; + bool viewportDirty; Float4X4 identity; int currentVertexBuffer; - SDL_bool issueBatch; + bool issueBatch; } D3D12_RenderData; // Define D3D GUIDs here so we don't have to include uuid.lib. @@ -529,9 +529,9 @@ static void D3D12_ResetCommandList(D3D12_RenderData *data) ID3D12GraphicsCommandList2_Reset(data->commandList, commandAllocator, NULL); data->currentPipelineState = NULL; data->currentVertexBuffer = 0; - data->issueBatch = SDL_FALSE; - data->cliprectDirty = SDL_TRUE; - data->viewportDirty = SDL_TRUE; + data->issueBatch = false; + data->cliprectDirty = true; + data->viewportDirty = true; data->currentRenderTargetView.ptr = 0; // FIXME should we also clear currentSampler.ptr and currentRenderTargetView.ptr ? (and use D3D12_InvalidateCachedState() instead) @@ -774,7 +774,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) HRESULT result = S_OK; UINT creationFlags = 0; int i; - SDL_bool createDebug; + bool createDebug; D3D12_COMMAND_QUEUE_DESC queueDesc; D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc; @@ -782,7 +782,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) ID3D12DescriptorHeap *rootDescriptorHeaps[2]; // See if we need debug interfaces - createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); + createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, false); #ifdef SDL_PLATFORM_GDK CreateEventExFunc = CreateEventExW; @@ -1473,7 +1473,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); - data->viewportDirty = SDL_TRUE; + data->viewportDirty = true; #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); @@ -1497,11 +1497,11 @@ static void D3D12_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal; if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { - data->pixelSizeChanged = SDL_TRUE; + data->pixelSizeChanged = true; } } -static SDL_bool D3D12_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool D3D12_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -1514,9 +1514,9 @@ static SDL_bool D3D12_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode bl !GetBlendEquation(colorOperation) || !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) || !GetBlendEquation(alphaOperation)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static SIZE_T D3D12_GetAvailableSRVIndex(SDL_Renderer *renderer) @@ -1634,7 +1634,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL #if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - textureData->yuv = SDL_TRUE; + textureData->yuv = true; textureDesc.Width = (textureDesc.Width + 1) / 2; textureDesc.Height = (textureDesc.Height + 1) / 2; @@ -1688,7 +1688,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL texture->format == SDL_PIXELFORMAT_P010) { int bits_per_pixel; - textureData->nv12 = SDL_TRUE; + textureData->nv12 = true; switch (texture->format) { case SDL_PIXELFORMAT_P010: @@ -2297,7 +2297,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); int i; SDL_FColor color = cmd->data.draw.color; - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); if (!verts) { return -1; @@ -2329,7 +2329,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int i; int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); D3D12_TextureData *textureData = texture ? (D3D12_TextureData *)texture->internal : NULL; float u_scale = textureData ? (float)texture->w / textureData->w : 0.0f; float v_scale = textureData ? (float)texture->h / textureData->h : 0.0f; @@ -2421,7 +2421,7 @@ static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer, rendererData->currentVertexBuffer++; if (rendererData->currentVertexBuffer >= SDL_D3D12_NUM_VERTEX_BUFFERS) { rendererData->currentVertexBuffer = 0; - rendererData->issueBatch = SDL_TRUE; + rendererData->issueBatch = true; } return S_OK; @@ -2513,7 +2513,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer) // SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); ID3D12GraphicsCommandList_RSSetViewports(data->commandList, 1, &d3dviewport); - data->viewportDirty = SDL_FALSE; + data->viewportDirty = false; return 0; } @@ -2590,7 +2590,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c const Float4X4 *newmatrix = matrix ? matrix : &rendererData->identity; D3D12_CPU_DESCRIPTOR_HANDLE renderTargetView = D3D12_GetCurrentRenderTargetView(renderer); const SDL_BlendMode blendMode = cmd->data.draw.blend; - SDL_bool updateSubresource = SDL_FALSE; + bool updateSubresource = false; int i; D3D12_CPU_DESCRIPTOR_HANDLE firstShaderResource; DXGI_FORMAT rtvFormat = rendererData->renderTargetFormat; @@ -2640,7 +2640,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c ID3D12GraphicsCommandList2_SetGraphicsRootSignature(rendererData->commandList, rendererData->rootSignatures[D3D12_GetRootSignatureType(currentPipelineState->shader)]); // When we change these we will need to re-upload the constant buffer and reset any descriptors - updateSubresource = SDL_TRUE; + updateSubresource = true; rendererData->currentSampler.ptr = 0; rendererData->currentShaderResource.ptr = 0; rendererData->currentPipelineState = currentPipelineState; @@ -2654,7 +2654,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c if (rendererData->viewportDirty) { if (D3D12_UpdateViewport(renderer) == 0) { // vertexShaderConstantsData.projectionAndView has changed - updateSubresource = SDL_TRUE; + updateSubresource = true; } } @@ -2665,7 +2665,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c return -1; } ID3D12GraphicsCommandList2_RSSetScissorRects(rendererData->commandList, 1, &scissorRect); - rendererData->cliprectDirty = SDL_FALSE; + rendererData->cliprectDirty = false; } if (numShaderResources > 0) { @@ -2702,7 +2702,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c rendererData->currentSampler = *sampler; } - if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { + if (updateSubresource == true || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)); ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstants(rendererData->commandList, 0, @@ -2716,7 +2716,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c shader_constants = &solid_constants; } - if (updateSubresource == SDL_TRUE || + if (updateSubresource == true || SDL_memcmp(shader_constants, ¤tPipelineState->shader_constants, sizeof(*shader_constants)) != 0) { ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstants(rendererData->commandList, 1, @@ -2816,8 +2816,8 @@ static void D3D12_InvalidateCachedState(SDL_Renderer *renderer) data->currentRenderTargetView.ptr = 0; data->currentShaderResource.ptr = 0; data->currentSampler.ptr = 0; - data->cliprectDirty = SDL_TRUE; - data->viewportDirty = SDL_TRUE; + data->cliprectDirty = true; + data->viewportDirty = true; } static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -2827,12 +2827,12 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (rendererData->pixelSizeChanged) { D3D12_UpdateForWindowSizeChange(renderer); - rendererData->pixelSizeChanged = SDL_FALSE; + rendererData->pixelSizeChanged = false; } if (rendererData->currentViewportRotation != viewportRotation) { rendererData->currentViewportRotation = viewportRotation; - rendererData->viewportDirty = SDL_TRUE; + rendererData->viewportDirty = true; } if (D3D12_UpdateVertexBuffer(renderer, vertices, vertsize) < 0) { @@ -2851,8 +2851,8 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Rect *viewport = &rendererData->currentViewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = SDL_TRUE; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->viewportDirty = true; + rendererData->cliprectDirty = true; } break; } @@ -2863,7 +2863,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Rect viewport_cliprect; if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } if (!rendererData->currentCliprectEnabled) { /* If the clip rect is disabled, then the scissor rect should be the whole viewport, @@ -2876,7 +2876,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, } if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } break; } @@ -2884,7 +2884,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, case SDL_RENDERCMD_CLEAR: { D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor = D3D12_GetCurrentRenderTargetView(renderer); - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); SDL_FColor color = cmd->data.color.color; if (convert_color) { SDL_ConvertToLinear(&color); diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp index 9c667be6bb..0b79e36bfd 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp @@ -36,7 +36,7 @@ static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; extern "C" HRESULT -D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug) +D3D12_XBOX_CreateDevice(ID3D12Device **device, bool createDebug) { HRESULT result; D3D12XBOX_CREATE_DEVICE_PARAMETERS params; diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.h b/src/render/direct3d12/SDL_render_d3d12_xbox.h index 5c5ec44a69..e2959c04b6 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.h +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.h @@ -30,7 +30,7 @@ extern "C" { #endif -extern HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug); +extern HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, bool createDebug); extern HRESULT D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource); extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken); extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget); diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index 9573b108d4..41fae98271 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -171,16 +171,16 @@ typedef struct METAL_ShaderPipelines @implementation SDL3METAL_TextureData @end -static SDL_bool IsMetalAvailable() +static bool IsMetalAvailable() { #if (defined(SDL_PLATFORM_MACOS) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100)) // this checks a weak symbol. if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower. SDL_SetError("Metal framework not available on this system"); - return SDL_FALSE; + return false; } #endif - return SDL_TRUE; + return true; } static const MTLBlendOperation invalidBlendOperation = (MTLBlendOperation)0xFFFFFFFF; @@ -446,7 +446,7 @@ static inline id ChoosePipelineState(SDL3METAL_RenderDat return MakePipelineState(data, cache, [NSString stringWithFormat:@" (blend=custom 0x%x)", blendmode], blendmode); } -static SDL_bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLoadAction load, MTLClearColor *clear_color, id vertex_buffer) +static bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLoadAction load, MTLClearColor *clear_color, id vertex_buffer) { SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal; @@ -475,7 +475,7 @@ static SDL_bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLo /* mtltexture can be nil here if macOS refused to give us a drawable, which apparently can happen for minimized windows, etc. */ if (mtltexture == nil) { - return SDL_FALSE; + return false; } if (load == MTLLoadActionClear) { @@ -510,7 +510,7 @@ static SDL_bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLo [data.mtlcmdbuffer enqueue]; } - return SDL_TRUE; + return true; } static void METAL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) @@ -531,7 +531,7 @@ static int METAL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h) } } -static SDL_bool METAL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool METAL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -546,9 +546,9 @@ static SDL_bool METAL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode bl GetBlendFactor(dstColorFactor) == invalidBlendFactor || GetBlendFactor(dstAlphaFactor) == invalidBlendFactor || GetBlendOperation(alphaOperation) == invalidBlendOperation) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } size_t GetBT601ConversionMatrix(SDL_Colorspace colorspace) @@ -1153,7 +1153,7 @@ static int METAL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd) static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { SDL_FColor color = cmd->data.draw.color; - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); const size_t vertlen = (2 * sizeof(float) + 4 * sizeof(float)) * count; float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); @@ -1180,7 +1180,7 @@ static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { SDL_FColor color = cmd->data.draw.color; - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); size_t vertlen; float *verts; @@ -1238,7 +1238,7 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int num_vertices, const void *indices, int num_indices, int size_indices, float scale_x, float scale_y) { - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); int count = indices ? num_indices : num_vertices; const size_t vertlen = (2 * sizeof(float) + 4 * sizeof(float) + (texture ? 2 : 0) * sizeof(float)) * count; float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); @@ -1324,13 +1324,13 @@ typedef struct __unsafe_unretained id vertex_buffer; size_t constants_offset; SDL_Texture *texture; - SDL_bool cliprect_dirty; - SDL_bool cliprect_enabled; + bool cliprect_dirty; + bool cliprect_enabled; SDL_Rect cliprect; - SDL_bool viewport_dirty; + bool viewport_dirty; SDL_Rect viewport; size_t projection_offset; - SDL_bool shader_constants_dirty; + bool shader_constants_dirty; PixelShaderConstants shader_constants; } METAL_DrawStateCache; @@ -1390,7 +1390,7 @@ static void SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand } } -static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_MetalFragmentFunction shader, PixelShaderConstants *shader_constants, const size_t constants_offset, id mtlbufvertex, METAL_DrawStateCache *statecache) +static bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_MetalFragmentFunction shader, PixelShaderConstants *shader_constants, const size_t constants_offset, id mtlbufvertex, METAL_DrawStateCache *statecache) { SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal; const SDL_BlendMode blend = cmd->data.draw.blend; @@ -1399,7 +1399,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm PixelShaderConstants solid_constants; if (!METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, statecache->vertex_buffer)) { - return SDL_FALSE; + return false; } if (statecache->viewport_dirty) { @@ -1412,7 +1412,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm viewport.zfar = 1.0; [data.mtlcmdencoder setViewport:viewport]; [data.mtlcmdencoder setVertexBuffer:mtlbufvertex offset:statecache->projection_offset atIndex:2]; // projection - statecache->viewport_dirty = SDL_FALSE; + statecache->viewport_dirty = false; } if (statecache->cliprect_dirty) { @@ -1445,7 +1445,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm [data.mtlcmdencoder setScissorRect:mtlrect]; } - statecache->cliprect_dirty = SDL_FALSE; + statecache->cliprect_dirty = false; } newpipeline = ChoosePipelineState(data, data.activepipelines, shader, blend); @@ -1467,7 +1467,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm [data.mtlcmdencoder setFragmentBuffer:mtlbufconstants offset:0 atIndex:0]; SDL_memcpy(&statecache->shader_constants, shader_constants, sizeof(*shader_constants)); - statecache->shader_constants_dirty = SDL_FALSE; + statecache->shader_constants_dirty = false; } if (constants_offset != statecache->constants_offset) { @@ -1478,10 +1478,10 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm } [data.mtlcmdencoder setVertexBufferOffset:first atIndex:0]; // position/texcoords - return SDL_TRUE; + return true; } -static SDL_bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t constants_offset, +static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const size_t constants_offset, id mtlbufvertex, METAL_DrawStateCache *statecache) { SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal; @@ -1492,7 +1492,7 @@ static SDL_bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cm SetupShaderConstants(renderer, cmd, texture, &constants); if (!SetDrawState(renderer, cmd, texturedata.fragmentFunction, &constants, constants_offset, mtlbufvertex, statecache)) { - return SDL_FALSE; + return false; } if (texture != statecache->texture) { @@ -1532,7 +1532,7 @@ static SDL_bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cm #endif statecache->texture = texture; } - return SDL_TRUE; + return true; } static void METAL_InvalidateCachedState(SDL_Renderer *renderer) @@ -1552,9 +1552,9 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, statecache.vertex_buffer = nil; statecache.constants_offset = CONSTANTS_OFFSET_INVALID; statecache.texture = NULL; - statecache.shader_constants_dirty = SDL_TRUE; - statecache.cliprect_dirty = SDL_TRUE; - statecache.viewport_dirty = SDL_TRUE; + statecache.shader_constants_dirty = true; + statecache.cliprect_dirty = true; + statecache.viewport_dirty = true; statecache.projection_offset = 0; // !!! FIXME: have a ring of pre-made MTLBuffers we cycle through? How expensive is creation? @@ -1584,8 +1584,8 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, { SDL_memcpy(&statecache.viewport, &cmd->data.viewport.rect, sizeof(statecache.viewport)); statecache.projection_offset = cmd->data.viewport.first; - statecache.viewport_dirty = SDL_TRUE; - statecache.cliprect_dirty = SDL_TRUE; + statecache.viewport_dirty = true; + statecache.cliprect_dirty = true; break; } @@ -1593,7 +1593,7 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, { SDL_memcpy(&statecache.cliprect, &cmd->data.cliprect.rect, sizeof(statecache.cliprect)); statecache.cliprect_enabled = cmd->data.cliprect.enabled; - statecache.cliprect_dirty = SDL_TRUE; + statecache.cliprect_dirty = true; break; } @@ -1620,12 +1620,12 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, statecache.pipeline = nil; statecache.constants_offset = CONSTANTS_OFFSET_INVALID; statecache.texture = NULL; - statecache.shader_constants_dirty = SDL_TRUE; - statecache.cliprect_dirty = SDL_TRUE; - statecache.viewport_dirty = SDL_TRUE; + statecache.shader_constants_dirty = true; + statecache.cliprect_dirty = true; + statecache.viewport_dirty = true; { - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); SDL_FColor color = cmd->data.color.color; if (convert_color) { SDL_ConvertToLinear(&color); @@ -1758,7 +1758,7 @@ static int METAL_RenderPresent(SDL_Renderer *renderer) { @autoreleasepool { SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal; - SDL_bool ready = SDL_TRUE; + bool ready = true; // If we don't have a command buffer, we can't present, so activate to get one. if (data.mtlcmdencoder == nil) { @@ -1919,7 +1919,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ id mtlbufconstantstaging, mtlbufquadindicesstaging, mtlbufconstants, mtlbufquadindices; id cmdbuffer; id blitcmd; - SDL_bool scRGB_supported = SDL_FALSE; + bool scRGB_supported = false; // Note: matrices are column major. float identitytransform[16] = { @@ -1970,7 +1970,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ #ifndef SDL_PLATFORM_TVOS if (@available(macos 10.11, iOS 16.0, *)) { - scRGB_supported = SDL_TRUE; + scRGB_supported = true; } #endif if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) { @@ -1982,7 +1982,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ } #ifdef SDL_PLATFORM_MACOS - if (SDL_GetHintBoolean(SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE, true)) { NSArray> *devices = MTLCopyAllDevices(); for (id device in devices) { diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index d682b6b3dc..03fa8da010 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -60,7 +60,7 @@ struct GL_FBOList typedef struct { - SDL_bool viewport_dirty; + bool viewport_dirty; SDL_Rect viewport; SDL_Texture *texture; SDL_Texture *target; @@ -69,18 +69,18 @@ typedef struct SDL_BlendMode blend; GL_Shader shader; const float *shader_params; - SDL_bool cliprect_enabled_dirty; - SDL_bool cliprect_enabled; - SDL_bool cliprect_dirty; + bool cliprect_enabled_dirty; + bool cliprect_enabled; + bool cliprect_dirty; SDL_Rect cliprect; - SDL_bool texturing; - SDL_bool texturing_dirty; - SDL_bool vertex_array; - SDL_bool color_array; - SDL_bool texture_array; - SDL_bool color_dirty; + bool texturing; + bool texturing_dirty; + bool vertex_array; + bool color_array; + bool texture_array; + bool color_dirty; SDL_FColor color; - SDL_bool clear_color_dirty; + bool clear_color_dirty; SDL_FColor clear_color; } GL_DrawStateCache; @@ -88,8 +88,8 @@ typedef struct { SDL_GLContext context; - SDL_bool debug_enabled; - SDL_bool GL_ARB_debug_output_supported; + bool debug_enabled; + bool GL_ARB_debug_output_supported; int errors; char **error_messages; GLDEBUGPROCARB next_error_callback; @@ -97,9 +97,9 @@ typedef struct GLenum textype; - SDL_bool GL_ARB_texture_non_power_of_two_supported; - SDL_bool GL_ARB_texture_rectangle_supported; - SDL_bool GL_EXT_framebuffer_object_supported; + bool GL_ARB_texture_non_power_of_two_supported; + bool GL_ARB_texture_rectangle_supported; + bool GL_EXT_framebuffer_object_supported; GL_FBOList *framebuffers; // OpenGL functions @@ -108,7 +108,7 @@ typedef struct #undef SDL_PROC // Multitexture support - SDL_bool GL_ARB_multitexture_supported; + bool GL_ARB_multitexture_supported; PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; GLint num_texture_units; @@ -127,7 +127,7 @@ typedef struct typedef struct { GLuint texture; - SDL_bool texture_external; + bool texture_external; GLfloat texw; GLfloat texh; GLenum format; @@ -140,12 +140,12 @@ typedef struct #if SDL_HAVE_YUV // YUV texture support - SDL_bool yuv; - SDL_bool nv12; + bool yuv; + bool nv12; GLuint utexture; - SDL_bool utexture_external; + bool utexture_external; GLuint vtexture; - SDL_bool vtexture_external; + bool vtexture_external; #endif GL_FBOList *fbo; @@ -330,7 +330,7 @@ static void GL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) if (event->type == SDL_EVENT_WINDOW_RESIZED || event->type == SDL_EVENT_WINDOW_MOVED) { GL_RenderData *data = (GL_RenderData *)renderer->internal; - data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; } } @@ -380,7 +380,7 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation) } } -static SDL_bool GL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool GL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -395,15 +395,15 @@ static SDL_bool GL_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM || GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM || GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) { - return SDL_FALSE; + return false; } if (colorOperation != alphaOperation) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } -static SDL_bool convert_format(Uint32 pixel_format, GLint *internalFormat, GLenum *format, GLenum *type) +static bool convert_format(Uint32 pixel_format, GLint *internalFormat, GLenum *format, GLenum *type) { switch (pixel_format) { case SDL_PIXELFORMAT_ARGB8888: @@ -434,9 +434,9 @@ static SDL_bool convert_format(Uint32 pixel_format, GLint *internalFormat, GLenu break; #endif default: - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props) @@ -452,7 +452,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr GL_ActivateRenderer(renderer); renderdata->drawstate.texture = NULL; // we trash this state. - renderdata->drawstate.texturing_dirty = SDL_TRUE; // we trash this state. + renderdata->drawstate.texturing_dirty = true; // we trash this state. if (texture->access == SDL_TEXTUREACCESS_TARGET && !renderdata->GL_EXT_framebuffer_object_supported) { @@ -498,7 +498,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr data->texture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER, 0); if (data->texture) { - data->texture_external = SDL_TRUE; + data->texture_external = true; } else { GL_CheckError("", renderer); renderdata->glGenTextures(1, &data->texture); @@ -580,17 +580,17 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr #if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - data->yuv = SDL_TRUE; + data->yuv = true; data->utexture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER, 0); if (data->utexture) { - data->utexture_external = SDL_TRUE; + data->utexture_external = true; } else { renderdata->glGenTextures(1, &data->utexture); } data->vtexture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER, 0); if (data->vtexture) { - data->vtexture_external = SDL_TRUE; + data->vtexture_external = true; } else { renderdata->glGenTextures(1, &data->vtexture); } @@ -616,11 +616,11 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21) { - data->nv12 = SDL_TRUE; + data->nv12 = true; data->utexture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER, 0); if (data->utexture) { - data->utexture_external = SDL_TRUE; + data->utexture_external = true; } else { renderdata->glGenTextures(1, &data->utexture); } @@ -646,13 +646,13 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr if (data->yuv) { data->shader = SHADER_YUV; } else if (texture->format == SDL_PIXELFORMAT_NV12) { - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", false)) { data->shader = SHADER_NV12_RG; } else { data->shader = SHADER_NV12_RA; } } else { - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", false)) { data->shader = SHADER_NV21_RG; } else { data->shader = SHADER_NV21_RA; @@ -866,7 +866,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) return SDL_SetError("Render targets not supported by OpenGL"); } - data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; if (!texture) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -1012,12 +1012,12 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader shader, const float *shader_params) { const SDL_BlendMode blend = cmd->data.draw.blend; - SDL_bool vertex_array; - SDL_bool color_array; - SDL_bool texture_array; + bool vertex_array; + bool color_array; + bool texture_array; if (data->drawstate.viewport_dirty) { - const SDL_bool istarget = data->drawstate.target != NULL; + const bool istarget = data->drawstate.target != NULL; const SDL_Rect *viewport = &data->drawstate.viewport; data->glMatrixMode(GL_PROJECTION); data->glLoadIdentity(); @@ -1031,7 +1031,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const 0.0, 1.0); } data->glMatrixMode(GL_MODELVIEW); - data->drawstate.viewport_dirty = SDL_FALSE; + data->drawstate.viewport_dirty = false; } if (data->drawstate.cliprect_enabled_dirty) { @@ -1040,7 +1040,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const } else { data->glEnable(GL_SCISSOR_TEST); } - data->drawstate.cliprect_enabled_dirty = SDL_FALSE; + data->drawstate.cliprect_enabled_dirty = false; } if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) { @@ -1049,7 +1049,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const data->glScissor(viewport->x + rect->x, data->drawstate.target ? viewport->y + rect->y : data->drawstate.drawableh - viewport->y - rect->y - rect->h, rect->w, rect->h); - data->drawstate.cliprect_dirty = SDL_FALSE; + data->drawstate.cliprect_dirty = false; } if (blend != data->drawstate.blend) { @@ -1076,12 +1076,12 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const if (data->drawstate.texturing_dirty || ((cmd->data.draw.texture != NULL) != data->drawstate.texturing)) { if (!cmd->data.draw.texture) { data->glDisable(data->textype); - data->drawstate.texturing = SDL_FALSE; + data->drawstate.texturing = false; } else { data->glEnable(data->textype); - data->drawstate.texturing = SDL_TRUE; + data->drawstate.texturing = true; } - data->drawstate.texturing_dirty = SDL_FALSE; + data->drawstate.texturing_dirty = false; } vertex_array = cmd->command == SDL_RENDERCMD_DRAW_POINTS || cmd->command == SDL_RENDERCMD_DRAW_LINES || cmd->command == SDL_RENDERCMD_GEOMETRY; @@ -1195,20 +1195,20 @@ static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) static void GL_InvalidateCachedState(SDL_Renderer *renderer) { GL_DrawStateCache *cache = &((GL_RenderData *)renderer->internal)->drawstate; - cache->viewport_dirty = SDL_TRUE; + cache->viewport_dirty = true; cache->texture = NULL; cache->drawablew = 0; cache->drawableh = 0; cache->blend = SDL_BLENDMODE_INVALID; cache->shader = SHADER_INVALID; - cache->cliprect_enabled_dirty = SDL_TRUE; - cache->cliprect_dirty = SDL_TRUE; - cache->texturing_dirty = SDL_TRUE; - cache->vertex_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. - cache->color_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. - cache->texture_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. - cache->color_dirty = SDL_TRUE; - cache->clear_color_dirty = SDL_TRUE; + cache->cliprect_enabled_dirty = true; + cache->cliprect_dirty = true; + cache->texturing_dirty = true; + cache->vertex_array = false; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. + cache->color_array = false; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. + cache->texture_array = false; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. + cache->color_dirty = true; + cache->clear_color_dirty = true; } static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -1225,8 +1225,8 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo int w, h; SDL_GetWindowSizeInPixels(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = true; data->drawstate.drawablew = w; data->drawstate.drawableh = h; } @@ -1236,7 +1236,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo // On macOS on older systems, the OpenGL view change and resize events aren't // necessarily synchronized, so just always reset it. // Workaround for: https://discourse.libsdl.org/t/sdl-2-0-22-prerelease/35306/6 - data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; #endif while (cmd) { @@ -1257,7 +1257,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo data->drawstate.color.g = g; data->drawstate.color.b = b; data->drawstate.color.a = a; - data->drawstate.color_dirty = SDL_FALSE; + data->drawstate.color_dirty = false; } break; } @@ -1267,8 +1267,8 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_Rect *viewport = &data->drawstate.viewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; + data->drawstate.cliprect_dirty = true; } break; } @@ -1278,12 +1278,12 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo const SDL_Rect *rect = &cmd->data.cliprect.rect; if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + data->drawstate.cliprect_enabled_dirty = true; } if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = true; } break; } @@ -1304,7 +1304,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo data->drawstate.clear_color.g = g; data->drawstate.clear_color.b = b; data->drawstate.clear_color.a = a; - data->drawstate.clear_color_dirty = SDL_FALSE; + data->drawstate.clear_color_dirty = false; } if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { @@ -1445,15 +1445,15 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo relies on it being off. */ if (data->drawstate.vertex_array) { data->glDisableClientState(GL_VERTEX_ARRAY); - data->drawstate.vertex_array = SDL_FALSE; + data->drawstate.vertex_array = false; } if (data->drawstate.color_array) { data->glDisableClientState(GL_COLOR_ARRAY); - data->drawstate.color_array = SDL_FALSE; + data->drawstate.color_array = false; } if (data->drawstate.texture_array) { data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); - data->drawstate.texture_array = SDL_FALSE; + data->drawstate.texture_array = false; } return GL_CheckError("", renderer); @@ -1495,7 +1495,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect * // Flip the rows to be top-down if necessary if (!renderer->target) { - SDL_bool isstack; + bool isstack; int length = rect->w * SDL_BYTESPERPIXEL(format); Uint8 *src = (Uint8 *)surface->pixels + (rect->h - 1) * surface->pitch; Uint8 *dst = (Uint8 *)surface->pixels; @@ -1622,9 +1622,9 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro GLint value; SDL_WindowFlags window_flags; int profile_mask = 0, major = 0, minor = 0; - SDL_bool changed_window = SDL_FALSE; + bool changed_window = false; const char *hint; - SDL_bool non_power_of_two_supported = SDL_FALSE; + bool non_power_of_two_supported = false; SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); @@ -1636,7 +1636,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro if (!(window_flags & SDL_WINDOW_OPENGL) || profile_mask == SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { - changed_window = SDL_TRUE; + changed_window = true; SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); @@ -1715,12 +1715,12 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro // Check for debug output support if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { - data->debug_enabled = SDL_TRUE; + data->debug_enabled = true; } if (data->debug_enabled && SDL_GL_ExtensionSupported("GL_ARB_debug_output")) { PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB"); - data->GL_ARB_debug_output_supported = SDL_TRUE; + data->GL_ARB_debug_output_supported = true; data->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION_ARB, (GLvoid **)(char *)&data->next_error_callback); data->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM_ARB, &data->next_error_userparam); glDebugMessageCallbackARBFunc(GL_HandleDebugMessage, renderer); @@ -1731,7 +1731,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro hint = SDL_GetHint("GL_ARB_texture_non_power_of_two"); if (!hint || *hint != '0') { - SDL_bool isGL2 = SDL_FALSE; + bool isGL2 = false; const char *verstr = (const char *)data->glGetString(GL_VERSION); if (verstr) { char verbuf[16]; @@ -1741,23 +1741,23 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro if (ptr) { *ptr = '\0'; if (SDL_atoi(verbuf) >= 2) { - isGL2 = SDL_TRUE; + isGL2 = true; } } } if (isGL2 || SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two")) { - non_power_of_two_supported = SDL_TRUE; + non_power_of_two_supported = true; } } data->textype = GL_TEXTURE_2D; if (non_power_of_two_supported) { - data->GL_ARB_texture_non_power_of_two_supported = SDL_TRUE; + data->GL_ARB_texture_non_power_of_two_supported = true; data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value); } else if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { - data->GL_ARB_texture_rectangle_supported = SDL_TRUE; + data->GL_ARB_texture_rectangle_supported = true; data->textype = GL_TEXTURE_RECTANGLE_ARB; data->glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &value); SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value); @@ -1770,7 +1770,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB"); if (data->glActiveTextureARB) { - data->GL_ARB_multitexture_supported = SDL_TRUE; + data->GL_ARB_multitexture_supported = true; data->glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &data->num_texture_units); } } @@ -1804,7 +1804,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro renderer->rect_index_order[5] = 2; if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) { - data->GL_EXT_framebuffer_object_supported = SDL_TRUE; + data->GL_EXT_framebuffer_object_supported = true; data->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT"); data->glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index e705fabe7f..4ae0ae8457 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -55,7 +55,7 @@ struct GL_ShaderContext PFNGLUNIFORM3FARBPROC glUniform3fARB; PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; - SDL_bool GL_ARB_texture_rectangle_supported; + bool GL_ARB_texture_rectangle_supported; GL_ShaderData shaders[NUM_SHADERS]; const float *shader_params[NUM_SHADERS]; @@ -330,7 +330,7 @@ static const char *shader_source[NUM_SHADERS][2] = { /* *INDENT-ON* */ // clang-format on -static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) +static bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) { GLint status; const char *sources[2]; @@ -342,7 +342,7 @@ static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const c ctx->glCompileShaderARB(shader); ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); if (status == 0) { - SDL_bool isstack; + bool isstack; GLint length; char *info; @@ -357,13 +357,13 @@ static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const c #endif SDL_small_free(info, isstack); - return SDL_FALSE; + return false; } else { - return SDL_TRUE; + return true; } } -static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) +static bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) { const int num_tmus_bound = 4; const char *vert_defines = ""; @@ -372,7 +372,7 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader GLint location; if (index == SHADER_NONE) { - return SDL_TRUE; + return true; } ctx->glGetError(); @@ -394,13 +394,13 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader // Create the vertex shader data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) { - return SDL_FALSE; + return false; } // Create the fragment shader data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) { - return SDL_FALSE; + return false; } // ... and in the darkness bind them @@ -433,7 +433,7 @@ static void DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data) GL_ShaderContext *GL_CreateShaderContext(void) { GL_ShaderContext *ctx; - SDL_bool shaders_supported; + bool shaders_supported; int i; ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); @@ -444,11 +444,11 @@ GL_ShaderContext *GL_CreateShaderContext(void) if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") && (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) { - ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE; + ctx->GL_ARB_texture_rectangle_supported = true; } // Check for shader support - shaders_supported = SDL_FALSE; + shaders_supported = false; if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") && SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && @@ -483,7 +483,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) ctx->glUniform1fARB && ctx->glUniform3fARB && ctx->glUseProgramObjectARB) { - shaders_supported = SDL_TRUE; + shaders_supported = true; } } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index b957594421..80a02f72f8 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -62,7 +62,7 @@ struct GLES2_FBOList typedef struct GLES2_TextureData { GLuint texture; - SDL_bool texture_external; + bool texture_external; GLenum texture_type; GLenum pixel_format; GLenum pixel_type; @@ -70,8 +70,8 @@ typedef struct GLES2_TextureData int pitch; #if SDL_HAVE_YUV // YUV texture support - SDL_bool yuv; - SDL_bool nv12; + bool yuv; + bool nv12; GLuint texture_v; GLuint texture_v_external; GLuint texture_u; @@ -144,18 +144,18 @@ typedef enum typedef struct { SDL_Rect viewport; - SDL_bool viewport_dirty; + bool viewport_dirty; SDL_Texture *texture; SDL_Texture *target; SDL_BlendMode blend; - SDL_bool cliprect_enabled_dirty; - SDL_bool cliprect_enabled; - SDL_bool cliprect_dirty; + bool cliprect_enabled_dirty; + bool cliprect_enabled; + bool cliprect_dirty; SDL_Rect cliprect; - SDL_bool texturing; - SDL_bool texturing_dirty; + bool texturing; + bool texturing_dirty; SDL_FColor clear_color; - SDL_bool clear_color_dirty; + bool clear_color_dirty; int drawablew; int drawableh; GLES2_ProgramCacheEntry *program; @@ -167,9 +167,9 @@ typedef struct GLES2_RenderData { SDL_GLContext context; - SDL_bool debug_enabled; + bool debug_enabled; - SDL_bool GL_EXT_blend_minmax_supported; + bool GL_EXT_blend_minmax_supported; #define SDL_PROC(ret, func, params) ret (APIENTRY *func) params; #include "SDL_gles2funcs.h" @@ -373,7 +373,7 @@ static GLenum GetBlendEquation(SDL_BlendOperation operation) } } -static SDL_bool GLES2_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool GLES2_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal; @@ -390,17 +390,17 @@ static SDL_bool GLES2_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode bl GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM || GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM || GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) { - return SDL_FALSE; + return false; } if (colorOperation == SDL_BLENDOPERATION_MINIMUM && !data->GL_EXT_blend_minmax_supported) { - return SDL_FALSE; + return false; } if (colorOperation == SDL_BLENDOPERATION_MAXIMUM && !data->GL_EXT_blend_minmax_supported) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) @@ -636,7 +636,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, } break; case GLES2_IMAGESOURCE_TEXTURE_NV12: - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", false)) { ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_RG; } else { ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_RA; @@ -648,7 +648,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, } break; case GLES2_IMAGESOURCE_TEXTURE_NV21: - if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_RENDER_OPENGL_NV12_RG_SHADER", false)) { ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RG; } else { ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RA; @@ -740,7 +740,7 @@ static int GLES2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd) static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); + const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); int i; SDL_FColor color = cmd->data.draw.color; @@ -773,7 +773,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); + const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); int i; GLfloat prevx, prevy; SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); @@ -834,7 +834,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S float scale_x, float scale_y) { int i; - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); + const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); int count = indices ? num_indices : num_vertices; const float color_scale = cmd->data.draw.color_scale; @@ -949,7 +949,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co data->drawstate.projection[1][1] = (data->drawstate.target ? 2.0f : -2.0f) / viewport->h; data->drawstate.projection[3][1] = data->drawstate.target ? -1.0f : 1.0f; } - data->drawstate.viewport_dirty = SDL_FALSE; + data->drawstate.viewport_dirty = false; } if (data->drawstate.cliprect_enabled_dirty) { @@ -958,7 +958,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co } else { data->glEnable(GL_SCISSOR_TEST); } - data->drawstate.cliprect_enabled_dirty = SDL_FALSE; + data->drawstate.cliprect_enabled_dirty = false; } if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) { @@ -967,18 +967,18 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co data->glScissor(viewport->x + rect->x, data->drawstate.target ? viewport->y + rect->y : data->drawstate.drawableh - viewport->y - rect->y - rect->h, rect->w, rect->h); - data->drawstate.cliprect_dirty = SDL_FALSE; + data->drawstate.cliprect_dirty = false; } if (data->drawstate.texturing_dirty || ((texture != NULL) != data->drawstate.texturing)) { if (!texture) { data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); - data->drawstate.texturing = SDL_FALSE; + data->drawstate.texturing = false; } else { data->glEnableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); - data->drawstate.texturing = SDL_TRUE; + data->drawstate.texturing = true; } - data->drawstate.texturing_dirty = SDL_FALSE; + data->drawstate.texturing_dirty = false; } if (texture) { @@ -1217,13 +1217,13 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo static void GLES2_InvalidateCachedState(SDL_Renderer *renderer) { GLES2_DrawStateCache *cache = &((GLES2_RenderData *)renderer->internal)->drawstate; - cache->viewport_dirty = SDL_TRUE; + cache->viewport_dirty = true; cache->texture = NULL; cache->blend = SDL_BLENDMODE_INVALID; - cache->cliprect_enabled_dirty = SDL_TRUE; - cache->cliprect_dirty = SDL_TRUE; - cache->texturing_dirty = SDL_TRUE; - cache->clear_color_dirty = SDL_TRUE; + cache->cliprect_enabled_dirty = true; + cache->cliprect_dirty = true; + cache->texturing_dirty = true; + cache->clear_color_dirty = true; cache->drawablew = 0; cache->drawableh = 0; cache->program = NULL; @@ -1232,7 +1232,7 @@ static void GLES2_InvalidateCachedState(SDL_Renderer *renderer) static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal; - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); + const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); #if USE_VERTEX_BUFFER_OBJECTS const int vboidx = data->current_vertex_buffer; @@ -1248,8 +1248,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, int w, h; SDL_GetWindowSizeInPixels(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = true; data->drawstate.drawablew = w; data->drawstate.drawableh = h; } @@ -1285,8 +1285,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Rect *viewport = &data->drawstate.viewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; + data->drawstate.cliprect_dirty = true; } break; } @@ -1296,12 +1296,12 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_Rect *rect = &cmd->data.cliprect.rect; if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + data->drawstate.cliprect_enabled_dirty = true; } if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = true; } break; } @@ -1322,7 +1322,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, data->drawstate.clear_color.g = g; data->drawstate.clear_color.b = b; data->drawstate.clear_color.a = a; - data->drawstate.clear_color_dirty = SDL_FALSE; + data->drawstate.clear_color_dirty = false; } if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) { @@ -1575,7 +1575,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL if (data->yuv) { data->texture_v = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER, 0); if (data->texture_v) { - data->texture_v_external = SDL_TRUE; + data->texture_v_external = true; } else { renderdata->glGenTextures(1, &data->texture_v); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1591,7 +1591,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL data->texture_u = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER, 0); if (data->texture_u) { - data->texture_u_external = SDL_TRUE; + data->texture_u_external = true; } else { renderdata->glGenTextures(1, &data->texture_u); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1614,7 +1614,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL } else if (data->nv12) { data->texture_u = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER, 0); if (data->texture_u) { - data->texture_u_external = SDL_TRUE; + data->texture_u_external = true; } else { renderdata->glGenTextures(1, &data->texture_u); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1639,7 +1639,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL data->texture = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER, 0); if (data->texture) { - data->texture_external = SDL_TRUE; + data->texture_external = true; } else { renderdata->glGenTextures(1, &data->texture); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1938,7 +1938,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_TextureData *texturedata = NULL; GLenum status; - data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; if (!texture) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); @@ -2012,7 +2012,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec // Flip the rows to be top-down if necessary if (!renderer->target) { - SDL_bool isstack; + bool isstack; int length = rect->w * SDL_BYTESPERPIXEL(format); Uint8 *src = (Uint8 *)surface->pixels + (rect->h - 1) * surface->pitch; Uint8 *dst = (Uint8 *)surface->pixels; @@ -2077,7 +2077,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ GLint window_framebuffer; GLint value; int profile_mask = 0, major = 0, minor = 0; - SDL_bool changed_window = SDL_FALSE; + bool changed_window = false; if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask) < 0) { goto error; @@ -2096,7 +2096,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ if (!(window_flags & SDL_WINDOW_OPENGL) || profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major < RENDERER_CONTEXT_MAJOR) { - changed_window = SDL_TRUE; + changed_window = true; SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); @@ -2147,7 +2147,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ // Check for debug output support if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 && (value & SDL_GL_CONTEXT_DEBUG_FLAG)) { - data->debug_enabled = SDL_TRUE; + data->debug_enabled = true; } value = 0; @@ -2208,7 +2208,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_ renderer->rect_index_order[5] = 2; if (SDL_GL_ExtensionSupported("GL_EXT_blend_minmax")) { - data->GL_EXT_blend_minmax_supported = SDL_TRUE; + data->GL_EXT_blend_minmax_supported = true; } // Set up parameters for rendering diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 0ea1520e31..d1ed864105 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -68,7 +68,7 @@ typedef struct PSP_TextureData unsigned int bits; /**< Image bits per pixel. */ unsigned int format; /**< Image format - one of ::pgePixelFormat. */ unsigned int pitch; - SDL_bool swizzled; /**< Is image swizzled. */ + bool swizzled; /**< Is image swizzled. */ struct PSP_TextureData *prevhotw; /**< More recently used render target */ struct PSP_TextureData *nexthotw; /**< Less recently used render target */ } PSP_TextureData; @@ -91,17 +91,17 @@ typedef struct void *frontbuffer; /**< main screen buffer */ void *backbuffer; /**< buffer presented to display */ SDL_Texture *boundTarget; /**< currently bound rendertarget */ - SDL_bool initialized; /**< is driver initialized */ - SDL_bool displayListAvail; /**< is the display list already initialized for this frame */ + bool initialized; /**< is driver initialized */ + bool displayListAvail; /**< is the display list already initialized for this frame */ unsigned int psm; /**< format of the display buffers */ unsigned int bpp; /**< bits per pixel of the main display */ - SDL_bool vsync; /**< whether we do vsync */ + bool vsync; /**< whether we do vsync */ PSP_BlendState blendState; /**< current blend mode */ PSP_TextureData *most_recent_target; /**< start of render target LRU double linked list */ PSP_TextureData *least_recent_target; /**< end of the LRU list */ - SDL_bool vblank_not_reached; /**< whether vblank wasn't reached */ + bool vblank_not_reached; /**< whether vblank wasn't reached */ } PSP_RenderData; typedef struct @@ -188,7 +188,7 @@ static int TextureNextPow2(unsigned int w) static void psp_on_vblank(u32 sub, PSP_RenderData *data) { if (data) { - data->vblank_not_reached = SDL_FALSE; + data->vblank_not_reached = false; } } @@ -312,7 +312,7 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst) TextureStorageFree(psp_texture->data); psp_texture->data = data; - psp_texture->swizzled = SDL_TRUE; + psp_texture->swizzled = true; sceKernelDcacheWritebackRange(psp_texture->data, psp_texture->size); return 1; @@ -382,7 +382,7 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst) psp_texture->data = data; - psp_texture->swizzled = SDL_FALSE; + psp_texture->swizzled = false; sceKernelDcacheWritebackRange(psp_texture->data, psp_texture->size); return 1; @@ -407,7 +407,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture } } -static int TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_texture, SDL_bool target) +static int TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_texture, bool target) { // Assumes texture in sram and a large enough continuous block in vram void *tdata = vramalloc(psp_texture->size); @@ -455,7 +455,7 @@ static int TextureBindAsTarget(PSP_RenderData *data, PSP_TextureData *psp_textur if (TextureSpillTargetsForSpace(data, psp_texture->size) < 0) { return -1; } - if (TexturePromoteToVram(data, psp_texture, SDL_TRUE) < 0) { + if (TexturePromoteToVram(data, psp_texture, true) < 0) { return -1; } } @@ -490,7 +490,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P return -1; } - psp_texture->swizzled = SDL_FALSE; + psp_texture->swizzled = false; psp_texture->width = texture->w; psp_texture->height = texture->h; psp_texture->textureHeight = TextureNextPow2(texture->h); @@ -956,7 +956,7 @@ static void StartDrawing(SDL_Renderer *renderer) // Check if we need to start GU displaylist if (!data->displayListAvail) { sceGuStart(GU_DIRECT, DisplayList); - data->displayListAvail = SDL_TRUE; + data->displayListAvail = true; // ResetBlendState(&data->blendState); } @@ -1229,14 +1229,14 @@ static int PSP_RenderPresent(SDL_Renderer *renderer) return -1; } - data->displayListAvail = SDL_FALSE; + data->displayListAvail = false; sceGuFinish(); sceGuSync(0, 0); if ((data->vsync) && (data->vblank_not_reached)) { sceDisplayWaitVblankStart(); } - data->vblank_not_reached = SDL_TRUE; + data->vblank_not_reached = true; data->backbuffer = data->frontbuffer; data->frontbuffer = vabsptr(sceGuSwapBuffers()); @@ -1279,8 +1279,8 @@ static void PSP_DestroyRenderer(SDL_Renderer *renderer) vfree(data->backbuffer); vfree(data->frontbuffer); - data->initialized = SDL_FALSE; - data->displayListAvail = SDL_FALSE; + data->initialized = false; + data->displayListAvail = false; SDL_free(data); } } @@ -1341,7 +1341,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR8888); SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 512); - data->initialized = SDL_TRUE; + data->initialized = true; data->most_recent_target = NULL; data->least_recent_target = NULL; @@ -1394,7 +1394,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr sceGuDisplay(GU_TRUE); // Improve performance when VSYC is enabled and it is not reaching the 60 FPS - data->vblank_not_reached = SDL_TRUE; + data->vblank_not_reached = true; sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, data); sceKernelEnableSubIntr(PSP_VBLANK_INT, 0); diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index 77115b0b96..21ff8a3f7b 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -28,7 +28,7 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { const SDL_PixelFormatDetails *fmt = dst->internal->format; unsigned r, g, b, a, inva; @@ -151,7 +151,7 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2, static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { unsigned r, g, b, a, inva; @@ -273,7 +273,7 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { unsigned r, g, b, a, inva; @@ -395,7 +395,7 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { const SDL_PixelFormatDetails *fmt = dst->internal->format; unsigned r, g, b, a, inva; @@ -518,7 +518,7 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2, static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { const SDL_PixelFormatDetails *fmt = dst->internal->format; unsigned r, g, b, a, inva; @@ -641,7 +641,7 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2 static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { unsigned r, g, b, a, inva; @@ -763,7 +763,7 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, - SDL_bool draw_end) + bool draw_end) { unsigned r, g, b, a, inva; @@ -887,7 +887,7 @@ typedef void (*BlendLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a, - SDL_bool draw_end); + bool draw_end); static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fmt) { @@ -939,7 +939,7 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, return 0; } - func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE); + func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, true); return 0; } @@ -949,7 +949,7 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, int i; int x1, y1; int x2, y2; - SDL_bool draw_end; + bool draw_end; BlendLineFunc func; if (!SDL_SurfaceValid(dst)) { diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index d529bb73fe..4a97d1e2b3 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -27,7 +27,7 @@ #include "SDL_drawpoint.h" static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) + bool draw_end) { if (y1 == y2) { int length; @@ -54,7 +54,7 @@ static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint } static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) + bool draw_end) { if (y1 == y2) { HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end); @@ -83,7 +83,7 @@ static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint } static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color, - SDL_bool draw_end) + bool draw_end) { if (y1 == y2) { HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end); @@ -115,7 +115,7 @@ static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint typedef void (*DrawLineFunc)(SDL_Surface *dst, int x1, int y1, int x2, int y2, - Uint32 color, SDL_bool draw_end); + Uint32 color, bool draw_end); static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormatDetails *fmt) { @@ -152,7 +152,7 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) return 0; } - func(dst, x1, y1, x2, y2, color, SDL_TRUE); + func(dst, x1, y1, x2, y2, color, true); return 0; } @@ -162,7 +162,7 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, int i; int x1, y1; int x2, y2; - SDL_bool draw_end; + bool draw_end; DrawLineFunc func; if (!SDL_SurfaceValid(dst)) { diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index ddab8c2e88..b2a94ad4ba 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -41,7 +41,7 @@ typedef struct { const SDL_Rect *viewport; const SDL_Rect *cliprect; - SDL_bool surface_cliprect_dirty; + bool surface_cliprect_dirty; SDL_Color color; } SW_DrawStateCache; @@ -326,9 +326,9 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex int retval = 0; SDL_BlendMode blendmode; Uint8 alphaMod, rMod, gMod, bMod; - int applyModulation = SDL_FALSE; - int blitRequired = SDL_FALSE; - int isOpaque = SDL_FALSE; + int applyModulation = false; + int blitRequired = false; + int isOpaque = false; if (!SDL_SurfaceValid(surface)) { return -1; @@ -365,29 +365,29 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex // SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) { - blitRequired = SDL_TRUE; + blitRequired = true; } // If scaling and cropping is necessary, it has to be taken care of before the rotation. if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) { - blitRequired = SDL_TRUE; + blitRequired = true; } // srcrect is not selecting the whole src surface, so cropping is needed if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) { - blitRequired = SDL_TRUE; + blitRequired = true; } // The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes. if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) { - applyModulation = SDL_TRUE; + applyModulation = true; SDL_SetSurfaceAlphaMod(src_clone, alphaMod); SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod); } // Opaque surfaces are much easier to handle with the NONE blend mode. if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) { - isOpaque = SDL_TRUE; + isOpaque = true; } /* The NONE blend mode requires a mask for non-opaque surfaces. This mask will be used @@ -437,7 +437,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (!retval && mask) { // The mask needed for the NONE blend mode gets rotated with the same parameters. mask_rotated = SDLgfx_rotateSurface(mask, angle, - SDL_FALSE, 0, 0, + false, 0, 0, &rect_dest, cangle, sangle, center); if (!mask_rotated) { retval = -1; @@ -454,7 +454,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex * Other blend modes or opaque surfaces can be blitted directly. */ if (blendmode != SDL_BLENDMODE_NONE || isOpaque) { - if (applyModulation == SDL_FALSE) { + if (applyModulation == false) { // If the modulation wasn't already applied, make it happen now. SDL_SetSurfaceAlphaMod(src_rotated, alphaMod); SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod); @@ -629,9 +629,9 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache * const SDL_BlendMode blend = cmd->data.draw.blend; SDL_Texture *texture = cmd->data.draw.texture; SDL_Surface *surface = (SDL_Surface *)texture->internal; - const SDL_bool colormod = ((r & g & b) != 0xFF); - const SDL_bool alphamod = (a != 0xFF); - const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL)); + const bool colormod = ((r & g & b) != 0xFF); + const bool alphamod = (a != 0xFF); + const bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL)); if (colormod || alphamod || blending) { SDL_SetSurfaceRLE(surface, 0); @@ -661,7 +661,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) } else { SDL_SetSurfaceClipRect(surface, drawstate->viewport); } - drawstate->surface_cliprect_dirty = SDL_FALSE; + drawstate->surface_cliprect_dirty = false; } } @@ -682,7 +682,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo drawstate.viewport = NULL; drawstate.cliprect = NULL; - drawstate.surface_cliprect_dirty = SDL_TRUE; + drawstate.surface_cliprect_dirty = true; drawstate.color.r = 0; drawstate.color.g = 0; drawstate.color.b = 0; @@ -702,14 +702,14 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo case SDL_RENDERCMD_SETVIEWPORT: { drawstate.viewport = &cmd->data.viewport.rect; - drawstate.surface_cliprect_dirty = SDL_TRUE; + drawstate.surface_cliprect_dirty = true; break; } case SDL_RENDERCMD_SETCLIPRECT: { drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL; - drawstate.surface_cliprect_dirty = SDL_TRUE; + drawstate.surface_cliprect_dirty = true; break; } @@ -722,7 +722,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo // By definition the clear ignores the clip rect SDL_SetSurfaceClipRect(surface, NULL); SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a)); - drawstate.surface_cliprect_dirty = SDL_TRUE; + drawstate.surface_cliprect_dirty = true; break; } @@ -1120,7 +1120,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD return SDL_InvalidParamError("surface"); } - renderer->software = SDL_TRUE; + renderer->software = true; data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); if (!data) { @@ -1171,7 +1171,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro { // Set the vsync hint based on our flags, if it's not already set const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); - const SDL_bool no_hint_set = (!hint || !*hint); + const bool no_hint_set = (!hint || !*hint); if (no_hint_set) { if (SDL_GetBooleanProperty(create_props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 0)) { diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 85a25adadc..e8105dd797 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -492,7 +492,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in int is8bit, angle90; SDL_BlendMode blendmode; Uint32 colorkey = 0; - int colorKeyAvailable = SDL_FALSE; + int colorKeyAvailable = false; double sangleinv, cangleinv; // Sanity check @@ -502,7 +502,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (SDL_SurfaceHasColorKey(src)) { if (SDL_GetSurfaceColorKey(src, &colorkey) == 0) { - colorKeyAvailable = SDL_TRUE; + colorKeyAvailable = true; } } // This function requires a 32-bit surface or 8-bit surface with a colorkey @@ -538,9 +538,9 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in SDL_GetSurfaceBlendMode(src, &blendmode); - if (colorKeyAvailable == SDL_TRUE) { + if (colorKeyAvailable == true) { // If available, the colorkey will be used to discard the pixels that are outside of the rotated area. - SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey); + SDL_SetSurfaceColorKey(rz_dst, true, colorkey); SDL_FillSurfaceRect(rz_dst, NULL, colorkey); } else if (blendmode == SDL_BLENDMODE_NONE) { blendmode = SDL_BLENDMODE_BLEND; @@ -554,7 +554,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in * all pixels outside of the rotated area. This doesn't interfere with anything because * white pixels are already a no-op and the MOD blend mode does not interact with alpha. */ - SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey); + SDL_SetSurfaceColorKey(rz_dst, true, colorkey); } SDL_SetSurfaceBlendMode(rz_dst, blendmode); diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 8c945e9078..cded09f8e3 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -42,7 +42,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, - SDL_Color c0, SDL_Color c1, SDL_Color c2, SDL_bool is_uniform, SDL_TextureAddressMode texture_address_mode); + SDL_Color c0, SDL_Color c1, SDL_Color c2, bool is_uniform, SDL_TextureAddressMode texture_address_mode); #if 0 int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3]) @@ -241,7 +241,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin Sint64 w0_row, w1_row, w2_row; int bias_w0, bias_w1, bias_w2; - SDL_bool is_uniform; + bool is_uniform; SDL_Surface *tmp = NULL; @@ -494,9 +494,9 @@ int SDL_SW_BlitTriangle( Sint64 w0_row, w1_row, w2_row; int bias_w0, bias_w1, bias_w2; - SDL_bool is_uniform; + bool is_uniform; - SDL_bool has_modulation; + bool has_modulation; if (!SDL_SurfaceValid(src)) { return SDL_InvalidParamError("src"); @@ -573,7 +573,7 @@ int SDL_SW_BlitTriangle( // SDL_GetSurfaceColorMod(src, &r, &g, &b); has_modulation = c0.r != 255 || c0.g != 255 || c0.b != 255 || c0.a != 255; } else { - has_modulation = SDL_TRUE; + has_modulation = true; } { @@ -788,7 +788,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2, int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x, int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row, - SDL_Color c0, SDL_Color c1, SDL_Color c2, SDL_bool is_uniform, SDL_TextureAddressMode texture_address_mode) + SDL_Color c0, SDL_Color c1, SDL_Color c2, bool is_uniform, SDL_TextureAddressMode texture_address_mode) { SDL_Surface *src_surface = info->src_surface; const int flags = info->flags; diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index b112cfcba3..6cf8bca8d1 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -46,7 +46,7 @@ static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, S static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event); -static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); +static bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props); @@ -143,7 +143,7 @@ void StartDrawing(SDL_Renderer *renderer) data->drawstate.vertex_program = NULL; data->drawstate.fragment_program = NULL; data->drawstate.last_command = -1; - data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; // reset blend mode // data->currentBlendMode = SDL_BLENDMODE_BLEND; @@ -177,16 +177,16 @@ void StartDrawing(SDL_Renderer *renderer) // unset_clip_rectangle(data); - data->drawing = SDL_TRUE; + data->drawing = true; } static int VITA_GXM_SetVSync(SDL_Renderer *renderer, const int vsync) { VITA_GXM_RenderData *data = renderer->internal; if (vsync) { - data->displayData.wait_vblank = SDL_TRUE; + data->displayData.wait_vblank = true; } else { - data->displayData.wait_vblank = SDL_FALSE; + data->displayData.wait_vblank = false; } return 0; } @@ -246,7 +246,7 @@ static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, S SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21); SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 4096); - data->initialized = SDL_TRUE; + data->initialized = true; #ifdef DEBUG_RAZOR sceSysmoduleLoadModule(SCE_SYSMODULE_RAZOR_HUD); @@ -264,10 +264,10 @@ static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent * { } -static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { // only for custom modes. we build all modes on init, so no custom modes, sorry - return SDL_FALSE; + return false; } static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props) @@ -821,7 +821,7 @@ static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) sceGxmSetVertexStream(data->gxm_context, 0, data->clearVertices); sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 3); - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = true; return 0; } @@ -831,8 +831,8 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) const SDL_BlendMode blend = cmd->data.draw.blend; SceGxmFragmentProgram *fragment_program; SceGxmVertexProgram *vertex_program; - SDL_bool matrix_updated = SDL_FALSE; - SDL_bool program_updated = SDL_FALSE; + bool matrix_updated = false; + bool program_updated = false; if (data->drawstate.viewport_dirty) { const SDL_Rect *viewport = &data->drawstate.viewport; @@ -854,23 +854,23 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) (float)viewport->h, (float)0, 0.0f, 1.0f); - matrix_updated = SDL_TRUE; + matrix_updated = true; } - data->drawstate.viewport_dirty = SDL_FALSE; + data->drawstate.viewport_dirty = false; } if (data->drawstate.cliprect_enabled_dirty) { if (!data->drawstate.cliprect_enabled) { unset_clip_rectangle(data); } - data->drawstate.cliprect_enabled_dirty = SDL_FALSE; + data->drawstate.cliprect_enabled_dirty = false; } if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) { const SDL_Rect *rect = &data->drawstate.cliprect; set_clip_rectangle(data, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); - data->drawstate.cliprect_dirty = SDL_FALSE; + data->drawstate.cliprect_dirty = false; } VITA_GXM_SetBlendMode(data, blend); // do that first, to select appropriate shaders @@ -886,13 +886,13 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd) if (data->drawstate.vertex_program != vertex_program) { data->drawstate.vertex_program = vertex_program; sceGxmSetVertexProgram(data->gxm_context, vertex_program); - program_updated = SDL_TRUE; + program_updated = true; } if (data->drawstate.fragment_program != fragment_program) { data->drawstate.fragment_program = fragment_program; sceGxmSetFragmentProgram(data->gxm_context, fragment_program); - program_updated = SDL_TRUE; + program_updated = true; } if (program_updated || matrix_updated) { @@ -936,8 +936,8 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c int w, h; SDL_GetWindowSizeInPixels(renderer->window, &w, &h); if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { - data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = true; data->drawstate.drawablew = w; data->drawstate.drawableh = h; } @@ -951,8 +951,8 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c SDL_Rect *viewport = &data->drawstate.viewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - data->drawstate.viewport_dirty = SDL_TRUE; - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.viewport_dirty = true; + data->drawstate.cliprect_dirty = true; } break; } @@ -962,12 +962,12 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c const SDL_Rect *rect = &cmd->data.cliprect.rect; if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; - data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + data->drawstate.cliprect_enabled_dirty = true; } if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&data->drawstate.cliprect, rect); - data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = true; } break; } @@ -1048,7 +1048,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c } sceGxmEndScene(data->gxm_context, NULL, NULL); - data->drawing = SDL_FALSE; + data->drawing = false; return 0; } @@ -1102,7 +1102,7 @@ static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_ // Flip the rows to be top-down if necessary if (!renderer->target) { - SDL_bool isstack; + bool isstack; int length = rect->w * SDL_BYTESPERPIXEL(format); Uint8 *src = (Uint8 *)surface->pixels + (rect->h - 1) * surface->pitch; Uint8 *dst = (Uint8 *)surface->pixels; @@ -1198,8 +1198,8 @@ static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer) gxm_finish(renderer); - data->initialized = SDL_FALSE; - data->drawing = SDL_FALSE; + data->initialized = false; + data->drawing = false; SDL_free(data); } } diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 1e4b5a5afe..81475b6dd7 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -1158,7 +1158,7 @@ void gxm_minimal_term_for_common_dialog(void) void gxm_init_for_common_dialog(void) { for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) { - buffer_for_common_dialog[i].displayData.wait_vblank = SDL_TRUE; + buffer_for_common_dialog[i].displayData.wait_vblank = true; buffer_for_common_dialog[i].displayData.address = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, 4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT, diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h index a1d364b278..64e4808b2c 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_types.h +++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h @@ -83,7 +83,7 @@ typedef struct gxm_texture SceGxmColorSurface gxm_colorsurface; SceGxmDepthStencilSurface gxm_depthstencil; SceUID depth_UID; - SDL_bool cdram; + bool cdram; } gxm_texture; typedef struct fragment_programs @@ -104,7 +104,7 @@ typedef struct blend_fragment_programs typedef struct { SDL_Rect viewport; - SDL_bool viewport_dirty; + bool viewport_dirty; SDL_Texture *texture; SDL_Texture *target; SDL_FColor color; @@ -112,19 +112,19 @@ typedef struct SceGxmVertexProgram *vertex_program; int last_command; - SDL_bool cliprect_enabled_dirty; - SDL_bool cliprect_enabled; - SDL_bool cliprect_dirty; + bool cliprect_enabled_dirty; + bool cliprect_enabled; + bool cliprect_dirty; SDL_Rect cliprect; - SDL_bool texturing; + bool texturing; int drawablew; int drawableh; } gxm_drawstate_cache; typedef struct { - SDL_bool initialized; - SDL_bool drawing; + bool initialized; + bool drawing; unsigned int psm; unsigned int bpp; @@ -203,8 +203,8 @@ typedef struct unsigned int w; unsigned int h; float wscale; - SDL_bool yuv; - SDL_bool nv12; + bool yuv; + bool nv12; } VITA_GXM_TextureData; #endif // SDL_RENDER_VITA_GXM_TYPES_H diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c index a9723a6ddd..bf22e1ed1c 100644 --- a/src/render/vulkan/SDL_render_vulkan.c +++ b/src/render/vulkan/SDL_render_vulkan.c @@ -228,7 +228,7 @@ typedef struct // Vulkan image typedef struct { - SDL_bool allocatedImage; + bool allocatedImage; VkImage image; VkImageView imageView; VkDeviceMemory deviceMemory; @@ -283,9 +283,9 @@ typedef struct { PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; VkInstance instance; - SDL_bool instance_external; + bool instance_external; VkSurfaceKHR surface; - SDL_bool surface_external; + bool surface_external; VkPhysicalDevice physicalDevice; VkPhysicalDeviceProperties physicalDeviceProperties; VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties; @@ -293,7 +293,7 @@ typedef struct VkQueue graphicsQueue; VkQueue presentQueue; VkDevice device; - SDL_bool device_external; + bool device_external; uint32_t graphicsQueueFamilyIndex; uint32_t presentQueueFamilyIndex; VkSwapchainKHR swapchain; @@ -304,7 +304,7 @@ typedef struct VkFence *fences; VkSurfaceCapabilitiesKHR surfaceCapabilities; VkSurfaceFormatKHR *surfaceFormats; - SDL_bool recreateSwapchain; + bool recreateSwapchain; int vsync; VkFramebuffer *framebuffers; @@ -340,9 +340,9 @@ typedef struct VULKAN_PipelineState *pipelineStates; VULKAN_PipelineState *currentPipelineState; - SDL_bool supportsEXTSwapchainColorspace; - SDL_bool supportsKHRGetPhysicalDeviceProperties2; - SDL_bool supportsKHRSamplerYCbCrConversion; + bool supportsEXTSwapchainColorspace; + bool supportsKHRGetPhysicalDeviceProperties2; + bool supportsKHRSamplerYCbCrConversion; uint32_t surfaceFormatsAllocatedCount; uint32_t surfaceFormatsCount; uint32_t swapchainDesiredImageCount; @@ -367,16 +367,16 @@ typedef struct // Cached renderer properties VULKAN_TextureData *textureRenderTarget; - SDL_bool cliprectDirty; - SDL_bool currentCliprectEnabled; + bool cliprectDirty; + bool currentCliprectEnabled; SDL_Rect currentCliprect; SDL_Rect currentViewport; int currentViewportRotation; - SDL_bool viewportDirty; + bool viewportDirty; Float4X4 identity; VkComponentMapping identitySwizzle; int currentVertexBuffer; - SDL_bool issueBatch; + bool issueBatch; } VULKAN_RenderData; static SDL_PixelFormat VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat) @@ -460,7 +460,7 @@ static void VULKAN_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); static void VULKAN_DestroyBuffer(VULKAN_RenderData *rendererData, VULKAN_Buffer *vulkanBuffer); static void VULKAN_DestroyImage(VULKAN_RenderData *rendererData, VULKAN_Image *vulkanImage); static void VULKAN_ResetCommandList(VULKAN_RenderData *rendererData); -static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint32_t typeBits, VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags desiredFlags, uint32_t *memoryTypeIndexOut); +static bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint32_t typeBits, VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags desiredFlags, uint32_t *memoryTypeIndexOut); static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer); static VkDescriptorPool VULKAN_AllocateDescriptorPool(VULKAN_RenderData *rendererData); static VkResult VULKAN_CreateDescriptorSetAndPipelineLayout(VULKAN_RenderData *rendererData, VkSampler samplerYcbcr, VkDescriptorSetLayout *descriptorSetLayoutOut, VkPipelineLayout *pipelineLayoutOut); @@ -966,7 +966,7 @@ static void VULKAN_EnsureCommandBuffer(VULKAN_RenderData *rendererData) } } -static SDL_bool VULKAN_ActivateCommandBuffer(SDL_Renderer *renderer, VkAttachmentLoadOp loadOp, VkClearColorValue *clearColor, VULKAN_DrawStateCache *stateCache) +static bool VULKAN_ActivateCommandBuffer(SDL_Renderer *renderer, VkAttachmentLoadOp loadOp, VkClearColorValue *clearColor, VULKAN_DrawStateCache *stateCache) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; @@ -986,7 +986,7 @@ static SDL_bool VULKAN_ActivateCommandBuffer(SDL_Renderer *renderer, VkAttachmen vkCmdBindVertexBuffers(rendererData->currentCommandBuffer, 0, 1, &stateCache->vertexBuffer, &offset); } - return SDL_TRUE; + return true; } static void VULKAN_WaitForGPU(VULKAN_RenderData *rendererData) @@ -1009,8 +1009,8 @@ static void VULKAN_ResetCommandList(VULKAN_RenderData *rendererData) rendererData->currentPipelineState = NULL; rendererData->currentVertexBuffer = 0; - rendererData->issueBatch = SDL_FALSE; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->issueBatch = false; + rendererData->cliprectDirty = true; rendererData->currentDescriptorSetIndex = 0; rendererData->currentDescriptorPoolIndex = 0; rendererData->currentConstantBufferOffset = -1; @@ -1036,7 +1036,7 @@ static VkResult VULKAN_IssueBatch(VULKAN_RenderData *rendererData) } rendererData->currentPipelineState = VK_NULL_HANDLE; - rendererData->viewportDirty = SDL_TRUE; + rendererData->viewportDirty = true; vkEndCommandBuffer(rendererData->currentCommandBuffer); @@ -1278,10 +1278,10 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer, return &pipelineStates[rendererData->pipelineStateCount - 1]; } -static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint32_t typeBits, VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags desiredFlags, uint32_t *memoryTypeIndexOut) +static bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint32_t typeBits, VkMemoryPropertyFlags requiredFlags, VkMemoryPropertyFlags desiredFlags, uint32_t *memoryTypeIndexOut) { uint32_t memoryTypeIndex = 0; - SDL_bool foundExactMatch = SDL_FALSE; + bool foundExactMatch = false; // Desired flags must be a superset of required flags. desiredFlags |= requiredFlags; @@ -1289,7 +1289,7 @@ static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint for (memoryTypeIndex = 0; memoryTypeIndex < rendererData->physicalDeviceMemoryProperties.memoryTypeCount; memoryTypeIndex++) { if (typeBits & (1 << memoryTypeIndex)) { if (rendererData->physicalDeviceMemoryProperties.memoryTypes[memoryTypeIndex].propertyFlags == desiredFlags) { - foundExactMatch = SDL_TRUE; + foundExactMatch = true; break; } } @@ -1306,10 +1306,10 @@ static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint if (memoryTypeIndex >= rendererData->physicalDeviceMemoryProperties.memoryTypeCount) { SDL_SetError("[Vulkan] Unable to find memory type for allocation"); - return SDL_FALSE; + return false; } *memoryTypeIndexOut = memoryTypeIndex; - return SDL_TRUE; + return true; } static VkResult VULKAN_CreateVertexBuffer(VULKAN_RenderData *rendererData, size_t vbidx, size_t size) @@ -1434,7 +1434,7 @@ static VkResult VULKAN_FindPhysicalDevice(VULKAN_RenderData *rendererData) uint32_t queueFamiliesCount = 0; uint32_t queueFamilyIndex; uint32_t deviceExtensionCount = 0; - SDL_bool hasSwapchainExtension = SDL_FALSE; + bool hasSwapchainExtension = false; uint32_t i; VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; @@ -1525,7 +1525,7 @@ static VkResult VULKAN_FindPhysicalDevice(VULKAN_RenderData *rendererData) } for (i = 0; i < deviceExtensionCount; i++) { if (SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { - hasSwapchainExtension = SDL_TRUE; + hasSwapchainExtension = true; break; } } @@ -1589,14 +1589,14 @@ static VkSemaphore VULKAN_CreateSemaphore(VULKAN_RenderData *rendererData) return semaphore; } -static SDL_bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, int extensionsToCheck, const char* const* extNames) +static bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, int extensionsToCheck, const char* const* extNames) { uint32_t extensionCount; - SDL_bool foundExtensions = SDL_TRUE; + bool foundExtensions = true; VkResult result = vkEnumerateDeviceExtensionProperties(rendererData->physicalDevice, NULL, &extensionCount, NULL); if (result != VK_SUCCESS ) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateDeviceExtensionProperties(): %s.\n", SDL_Vulkan_GetResultString(result)); - return SDL_FALSE; + return false; } if (extensionCount > 0 ) { VkExtensionProperties *extensionProperties = (VkExtensionProperties *)SDL_calloc(sizeof(VkExtensionProperties), extensionCount); @@ -1604,13 +1604,13 @@ static SDL_bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, in if (result != VK_SUCCESS ) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateDeviceExtensionProperties): %s.\n", SDL_Vulkan_GetResultString(result)); SDL_free(extensionProperties); - return SDL_FALSE; + return false; } for (int ext = 0; ext < extensionsToCheck && foundExtensions; ext++) { - SDL_bool foundExtension = SDL_FALSE; + bool foundExtension = false; for (uint32_t i = 0; i < extensionCount; i++) { if (SDL_strcmp(extensionProperties[i].extensionName, extNames[ext]) == 0) { - foundExtension = SDL_TRUE; + foundExtension = true; break; } } @@ -1623,13 +1623,13 @@ static SDL_bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, in return foundExtensions; } -static SDL_bool VULKAN_InstanceExtensionFound(VULKAN_RenderData *rendererData, const char *extName) +static bool VULKAN_InstanceExtensionFound(VULKAN_RenderData *rendererData, const char *extName) { uint32_t extensionCount; VkResult result = vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, NULL); if (result != VK_SUCCESS ) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateInstanceExtensionProperties( NULL, ... ): %s.\n", SDL_Vulkan_GetResultString(result)); - return SDL_FALSE; + return false; } if (extensionCount > 0 ) { VkExtensionProperties *extensionProperties = (VkExtensionProperties *)SDL_calloc(extensionCount, sizeof(VkExtensionProperties)); @@ -1637,25 +1637,25 @@ static SDL_bool VULKAN_InstanceExtensionFound(VULKAN_RenderData *rendererData, c if (result != VK_SUCCESS ) { SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateInstanceExtensionProperties( NULL, ... ): %s.\n", SDL_Vulkan_GetResultString(result)); SDL_free(extensionProperties); - return SDL_FALSE; + return false; } for (uint32_t i = 0; i< extensionCount; i++) { if (SDL_strcmp(extensionProperties[i].extensionName, extName) == 0) { SDL_free(extensionProperties); - return SDL_TRUE; + return true; } } SDL_free(extensionProperties); } - return SDL_FALSE; + return false; } -static SDL_bool VULKAN_ValidationLayersFound(void) +static bool VULKAN_ValidationLayersFound(void) { uint32_t instanceLayerCount = 0; uint32_t i; - SDL_bool foundValidation = SDL_FALSE; + bool foundValidation = false; vkEnumerateInstanceLayerProperties(&instanceLayerCount, NULL); if (instanceLayerCount > 0) { @@ -1663,7 +1663,7 @@ static SDL_bool VULKAN_ValidationLayersFound(void) vkEnumerateInstanceLayerProperties(&instanceLayerCount, instanceLayers); for (i = 0; i < instanceLayerCount; i++) { if (!SDL_strcmp(SDL_VULKAN_VALIDATION_LAYER_NAME, instanceLayers[i].layerName)) { - foundValidation = SDL_TRUE; + foundValidation = true; break; } } @@ -1691,7 +1691,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert SDL_VideoDevice *device = SDL_GetVideoDevice(); VkResult result = VK_SUCCESS; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; - SDL_bool createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_VULKAN_DEBUG, SDL_FALSE); + bool createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_VULKAN_DEBUG, false); const char *validationLayerName[] = { SDL_VULKAN_VALIDATION_LAYER_NAME }; if (SDL_Vulkan_LoadLibrary(NULL) < 0) { @@ -1727,7 +1727,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert // Create VkInstance rendererData->instance = (VkInstance)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER, NULL); if (rendererData->instance) { - rendererData->instance_external = SDL_TRUE; + rendererData->instance_external = true; } else { VkInstanceCreateInfo instanceCreateInfo = { 0 }; VkApplicationInfo appInfo = { 0 }; @@ -1771,7 +1771,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert // Create Vulkan surface rendererData->surface = (VkSurfaceKHR)SDL_GetNumberProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER, 0); if (rendererData->surface) { - rendererData->surface_external = SDL_TRUE; + rendererData->surface_external = true; } else { if (!device->Vulkan_CreateSurface || (device->Vulkan_CreateSurface(device, renderer->window, rendererData->instance, NULL, &rendererData->surface) < 0)) { VULKAN_DestroyAll(renderer); @@ -1801,13 +1801,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert if (rendererData->supportsKHRGetPhysicalDeviceProperties2 && VULKAN_DeviceExtensionsFound(rendererData, 4, &deviceExtensionNames[1])) { - rendererData->supportsKHRSamplerYCbCrConversion = SDL_TRUE; + rendererData->supportsKHRSamplerYCbCrConversion = true; } // Create Vulkan device rendererData->device = (VkDevice)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER, NULL); if (rendererData->device) { - rendererData->device_external = SDL_TRUE; + rendererData->device_external = true; } else { VkPhysicalDeviceSamplerYcbcrConversionFeatures deviceSamplerYcbcrConversionFeatures = { 0 }; VkDeviceQueueCreateInfo deviceQueueCreateInfo[2] = { { 0 }, { 0 } }; @@ -2452,7 +2452,7 @@ static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer rendererData->recreateSwapchain = VK_TRUE; } - rendererData->viewportDirty = SDL_TRUE; + rendererData->viewportDirty = true; return result; } @@ -2472,11 +2472,11 @@ static void VULKAN_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *ev VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { - rendererData->recreateSwapchain = SDL_TRUE; + rendererData->recreateSwapchain = true; } } -static SDL_bool VULKAN_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) +static bool VULKAN_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) { SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); @@ -2491,9 +2491,9 @@ static SDL_bool VULKAN_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode b GetBlendFactor(dstColorFactor) == VK_BLEND_FACTOR_MAX_ENUM || GetBlendFactor(dstAlphaFactor) == VK_BLEND_FACTOR_MAX_ENUM || GetBlendOp(alphaOperation) == VK_BLEND_OP_MAX_ENUM) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props) @@ -3074,7 +3074,7 @@ static int VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd { VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); int i; - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); if (!verts) { return -1; @@ -3103,7 +3103,7 @@ static int VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, int i; int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); VULKAN_TextureData *textureData = texture ? (VULKAN_TextureData *)texture->internal : NULL; float u_scale = textureData ? (float)texture->w / textureData->width : 0.0f; float v_scale = textureData ? (float)texture->h / textureData->height : 0.0f; @@ -3151,7 +3151,7 @@ static int VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, return 0; } -static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, +static bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, const void *vertexData, size_t dataSizeInBytes, VULKAN_DrawStateCache *stateCache) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; @@ -3165,7 +3165,7 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, if (rendererData->issueBatch) { if (VULKAN_IssueBatch(rendererData) != VK_SUCCESS) { SDL_SetError("Failed to issue intermediate batch"); - return SDL_FALSE; + return false; } } // If the existing vertex buffer isn't big enough, we need to recreate a big enough one @@ -3183,10 +3183,10 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer, rendererData->currentVertexBuffer++; if (rendererData->currentVertexBuffer >= SDL_VULKAN_NUM_VERTEX_BUFFERS) { rendererData->currentVertexBuffer = 0; - rendererData->issueBatch = SDL_TRUE; + rendererData->issueBatch = true; } - return SDL_TRUE; + return true; } static int VULKAN_UpdateViewport(SDL_Renderer *renderer) @@ -3229,7 +3229,7 @@ static int VULKAN_UpdateViewport(SDL_Renderer *renderer) vkViewport.maxDepth = 1.0f; vkCmdSetViewport(rendererData->currentCommandBuffer, 0, 1, &vkViewport); - rendererData->viewportDirty = SDL_FALSE; + rendererData->viewportDirty = false; return 0; } @@ -3252,7 +3252,7 @@ static int VULKAN_UpdateClipRect(SDL_Renderer *renderer) } vkCmdSetScissor(rendererData->currentCommandBuffer, 0, 1, &scissor); - rendererData->cliprectDirty = SDL_FALSE; + rendererData->cliprectDirty = false; return 0; } @@ -3479,7 +3479,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK return descriptorSet; } -static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, VULKAN_Shader shader, VkPipelineLayout pipelineLayout, VkDescriptorSetLayout descriptorSetLayout, +static bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, VULKAN_Shader shader, VkPipelineLayout pipelineLayout, VkDescriptorSetLayout descriptorSetLayout, const PixelShaderConstants *shader_constants, VkPrimitiveTopology topology, VkImageView imageView, VkSampler sampler, const Float4X4 *matrix, VULKAN_DrawStateCache *stateCache) { @@ -3487,7 +3487,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm const SDL_BlendMode blendMode = cmd->data.draw.blend; VkFormat format = rendererData->surfaceFormat.format; const Float4X4 *newmatrix = matrix ? matrix : &rendererData->identity; - SDL_bool updateConstants = SDL_FALSE; + bool updateConstants = false; PixelShaderConstants solid_constants; VkDescriptorSet descriptorSet; VkBuffer constantBuffer; @@ -3495,7 +3495,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm int i; if (!VULKAN_ActivateCommandBuffer(renderer, VK_ATTACHMENT_LOAD_OP_LOAD, NULL, stateCache)) { - return SDL_FALSE; + return false; } // See if we need to change the pipeline state @@ -3531,13 +3531,13 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm } vkCmdBindPipeline(rendererData->currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, rendererData->currentPipelineState->pipeline); - updateConstants = SDL_TRUE; + updateConstants = true; } if (rendererData->viewportDirty) { if (VULKAN_UpdateViewport(renderer) == 0) { // vertexShaderConstantsData.projectionAndView has changed - updateConstants = SDL_TRUE; + updateConstants = true; } } @@ -3545,7 +3545,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm VULKAN_UpdateClipRect(renderer); } - if (updateConstants == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { + if (updateConstants == true || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)); vkCmdPushConstants(rendererData->currentCommandBuffer, rendererData->currentPipelineState->pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(rendererData->vertexShaderConstantsData), @@ -3591,7 +3591,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm if (result != VK_SUCCESS) { SDL_SetError("[Vulkan] Could not allocate new memory for constant buffer" ); - return SDL_FALSE; + return false; } rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex]++; @@ -3617,18 +3617,18 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm // Allocate/update descriptor set with the bindings descriptorSet = VULKAN_AllocateDescriptorSet(renderer, shader, descriptorSetLayout, sampler, constantBuffer, constantBufferOffset, imageView); if (descriptorSet == VK_NULL_HANDLE) { - return SDL_FALSE; + return false; } // Bind the descriptor set with the sampler/UBO/image views vkCmdBindDescriptorSets(rendererData->currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, rendererData->currentPipelineState->pipelineLayout, 0, 1, &descriptorSet, 0, NULL); - return SDL_TRUE; + return true; } -static SDL_bool VULKAN_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix, VULKAN_DrawStateCache *stateCache) +static bool VULKAN_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix, VULKAN_DrawStateCache *stateCache) { SDL_Texture *texture = cmd->data.draw.texture; VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; @@ -3670,11 +3670,11 @@ static SDL_bool VULKAN_SetCopyState(SDL_Renderer *renderer, const SDL_RenderComm } if (textureData->mainImage.imageLayout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) { - SDL_bool stoppedRenderPass = SDL_FALSE; + bool stoppedRenderPass = false; if (rendererData->currentRenderPass != VK_NULL_HANDLE) { vkCmdEndRenderPass(rendererData->currentCommandBuffer); rendererData->currentRenderPass = VK_NULL_HANDLE; - stoppedRenderPass = SDL_TRUE; + stoppedRenderPass = true; } VULKAN_RecordPipelineImageBarrier(rendererData, @@ -3704,7 +3704,7 @@ static void VULKAN_InvalidateCachedState(SDL_Renderer *renderer) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal; rendererData->currentPipelineState = NULL; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) @@ -3717,7 +3717,7 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd if (VULKAN_UpdateForWindowSizeChange(renderer) != VK_SUCCESS) { return -1; } - rendererData->recreateSwapchain = SDL_FALSE; + rendererData->recreateSwapchain = false; } if (!VULKAN_UpdateVertexBuffer(renderer, vertices, vertsize, &stateCache)) { @@ -3736,8 +3736,8 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd SDL_Rect *viewport = &rendererData->currentViewport; if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = SDL_TRUE; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->viewportDirty = true; + rendererData->cliprectDirty = true; } break; } @@ -3747,18 +3747,18 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd const SDL_Rect *rect = &cmd->data.cliprect.rect; if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = SDL_TRUE; + rendererData->cliprectDirty = true; } break; } case SDL_RENDERCMD_CLEAR: { - SDL_bool convert_color = SDL_RenderingLinearSpace(renderer); + bool convert_color = SDL_RenderingLinearSpace(renderer); SDL_FColor color = cmd->data.color.color; if (convert_color) { SDL_ConvertToLinear(&color); @@ -3981,7 +3981,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer) if (rendererData->currentCommandBuffer) { rendererData->currentPipelineState = VK_NULL_HANDLE; - rendererData->viewportDirty = SDL_TRUE; + rendererData->viewportDirty = true; VULKAN_RecordPipelineImageBarrier(rendererData, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, @@ -4081,7 +4081,7 @@ static int VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync) } if (vsync != rendererData->vsync) { rendererData->vsync = vsync; - rendererData->recreateSwapchain = SDL_TRUE; + rendererData->recreateSwapchain = true; } return 0; } diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 167fae1566..80bbb4aa7e 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -54,7 +54,7 @@ static SDL_Mutex *SDL_sensor_lock = NULL; // This needs to support recursive locks static SDL_AtomicInt SDL_sensor_lock_pending; static int SDL_sensors_locked; -static SDL_bool SDL_sensors_initialized; +static bool SDL_sensors_initialized; static SDL_Sensor *SDL_sensors SDL_GUARDED_BY(SDL_sensor_lock) = NULL; #define CHECK_SENSOR_MAGIC(sensor, retval) \ @@ -64,7 +64,7 @@ static SDL_Sensor *SDL_sensors SDL_GUARDED_BY(SDL_sensor_lock) = NULL; return retval; \ } -SDL_bool SDL_SensorsInitialized(void) +bool SDL_SensorsInitialized(void) { return SDL_sensors_initialized; } @@ -80,14 +80,14 @@ void SDL_LockSensors(void) void SDL_UnlockSensors(void) { - SDL_bool last_unlock = SDL_FALSE; + bool last_unlock = false; --SDL_sensors_locked; if (!SDL_sensors_initialized) { // NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks if (!SDL_sensors_locked && SDL_AtomicGet(&SDL_sensor_lock_pending) == 0) { - last_unlock = SDL_TRUE; + last_unlock = true; } } @@ -110,7 +110,7 @@ void SDL_UnlockSensors(void) } } -SDL_bool SDL_SensorsLocked(void) +bool SDL_SensorsLocked(void) { return (SDL_sensors_locked > 0); } @@ -135,7 +135,7 @@ int SDL_InitSensors(void) SDL_LockSensors(); - SDL_sensors_initialized = SDL_TRUE; + SDL_sensors_initialized = true; status = -1; for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) { @@ -153,16 +153,16 @@ int SDL_InitSensors(void) return status; } -SDL_bool SDL_SensorsOpened(void) +bool SDL_SensorsOpened(void) { - SDL_bool opened; + bool opened; SDL_LockSensors(); { if (SDL_sensors != NULL) { - opened = SDL_TRUE; + opened = true; } else { - opened = SDL_FALSE; + opened = false; } } SDL_UnlockSensors(); @@ -214,7 +214,7 @@ SDL_SensorID *SDL_GetSensors(int *count) * Get the driver and device index for a sensor instance ID * This should be called while the sensor lock is held, to prevent another thread from updating the list */ -static SDL_bool SDL_GetDriverAndSensorIndex(SDL_SensorID instance_id, SDL_SensorDriver **driver, int *driver_index) +static bool SDL_GetDriverAndSensorIndex(SDL_SensorID instance_id, SDL_SensorDriver **driver, int *driver_index) { int i, num_sensors, device_index; @@ -226,13 +226,13 @@ static SDL_bool SDL_GetDriverAndSensorIndex(SDL_SensorID instance_id, SDL_Sensor if (sensor_id == instance_id) { *driver = SDL_sensor_drivers[i]; *driver_index = device_index; - return SDL_TRUE; + return true; } } } } SDL_SetError("Sensor %" SDL_PRIu32 " not found", instance_id); - return SDL_FALSE; + return false; } /* @@ -325,14 +325,14 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id) SDL_UnlockSensors(); return NULL; } - SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, SDL_TRUE); + SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, true); sensor->driver = driver; sensor->instance_id = instance_id; sensor->type = driver->GetDeviceType(device_index); sensor->non_portable_type = driver->GetDeviceNonPortableType(device_index); if (driver->Open(sensor, device_index) < 0) { - SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, SDL_FALSE); + SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, false); SDL_free(sensor); SDL_UnlockSensors(); return NULL; @@ -507,7 +507,7 @@ void SDL_CloseSensor(SDL_Sensor *sensor) sensor->driver->Close(sensor); sensor->hwdata = NULL; - SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, SDL_FALSE); + SDL_SetObjectValid(sensor, SDL_OBJECT_TYPE_SENSOR, false); sensorlist = SDL_sensors; sensorlistprev = NULL; @@ -551,7 +551,7 @@ void SDL_QuitSensors(void) SDL_QuitSubSystem(SDL_INIT_EVENTS); - SDL_sensors_initialized = SDL_FALSE; + SDL_sensors_initialized = false; SDL_UnlockSensors(); } diff --git a/src/sensor/SDL_sensor_c.h b/src/sensor/SDL_sensor_c.h index 09b99fba52..1adef0bcdc 100644 --- a/src/sensor/SDL_sensor_c.h +++ b/src/sensor/SDL_sensor_c.h @@ -36,10 +36,10 @@ extern int SDL_InitSensors(void); extern void SDL_QuitSensors(void); // Return whether the sensor system is currently initialized -extern SDL_bool SDL_SensorsInitialized(void); +extern bool SDL_SensorsInitialized(void); // Return whether the sensors are currently locked -extern SDL_bool SDL_SensorsLocked(void); +extern bool SDL_SensorsLocked(void); // Make sure we currently have the sensors locked extern void SDL_AssertSensorsLocked(void) SDL_ASSERT_CAPABILITY(SDL_sensor_lock); @@ -48,7 +48,7 @@ extern void SDL_LockSensors(void) SDL_ACQUIRE(SDL_sensor_lock); extern void SDL_UnlockSensors(void) SDL_RELEASE(SDL_sensor_lock); // Function to return whether there are any sensors opened by the application -extern SDL_bool SDL_SensorsOpened(void); +extern bool SDL_SensorsOpened(void); // Update an individual sensor, used by gamepad sensor fusion extern void SDL_UpdateSensor(SDL_Sensor *sensor); diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 786c42ef27..93f4732ff9 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -93,7 +93,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data) static void SDL_ANDROID_StopSensorThread(SDL_AndroidSensorThreadContext *ctx) { - SDL_AtomicSet(&ctx->running, SDL_FALSE); + SDL_AtomicSet(&ctx->running, false); if (ctx->thread) { int result; @@ -119,7 +119,7 @@ static int SDL_ANDROID_StartSensorThread(SDL_AndroidSensorThreadContext *ctx) return -1; } - SDL_AtomicSet(&ctx->running, SDL_TRUE); + SDL_AtomicSet(&ctx->running, true); ctx->thread = SDL_CreateThread(SDL_ANDROID_SensorThread, "Sensors", ctx); if (!ctx->thread) { SDL_ANDROID_StopSensorThread(ctx); diff --git a/src/sensor/n3ds/SDL_n3dssensor.c b/src/sensor/n3ds/SDL_n3dssensor.c index 96603fdbb0..77996afea3 100644 --- a/src/sensor/n3ds/SDL_n3dssensor.c +++ b/src/sensor/n3ds/SDL_n3dssensor.c @@ -42,7 +42,7 @@ static int InitN3DSServices(void); static void UpdateN3DSAccelerometer(SDL_Sensor *sensor); static void UpdateN3DSGyroscope(SDL_Sensor *sensor); -static SDL_bool IsDeviceIndexValid(int device_index) +static bool IsDeviceIndexValid(int device_index) { return device_index >= 0 && device_index < N3DS_SENSOR_COUNT; } diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index 2a855422c5..bab6dc8397 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -52,7 +52,7 @@ typedef struct } SDL_Windows_Sensor; -static SDL_bool SDL_windowscoinit; +static bool SDL_windowscoinit; static ISensorManager *SDL_sensor_manager; static int SDL_num_sensors; static SDL_Windows_Sensor *SDL_sensors; @@ -358,7 +358,7 @@ static int SDL_WINDOWS_SensorInit(void) ISensorCollection *sensor_collection = NULL; if (WIN_CoInitialize() == S_OK) { - SDL_windowscoinit = SDL_TRUE; + SDL_windowscoinit = true; } hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *)&SDL_sensor_manager); diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index d53bb3ead7..394b7f71c3 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -351,7 +351,7 @@ size_t SDL_iconv(SDL_iconv_t cd, { Uint8 *p = (Uint8 *)src; size_t left = 0; - SDL_bool overlong = SDL_FALSE; + bool overlong = false; if (p[0] >= 0xF0) { if ((p[0] & 0xF8) != 0xF0) { /* Skip illegal sequences @@ -360,7 +360,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } else { if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) { - overlong = SDL_TRUE; + overlong = true; } ch = (Uint32)(p[0] & 0x07); left = 3; @@ -373,7 +373,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } else { if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) { - overlong = SDL_TRUE; + overlong = true; } ch = (Uint32)(p[0] & 0x0F); left = 2; @@ -386,7 +386,7 @@ size_t SDL_iconv(SDL_iconv_t cd, ch = UNKNOWN_UNICODE; } else { if ((p[0] & 0xDE) == 0xC0) { - overlong = SDL_TRUE; + overlong = true; } ch = (Uint32)(p[0] & 0x1F); left = 1; diff --git a/src/stdlib/SDL_random.c b/src/stdlib/SDL_random.c index 6b7ed737ef..ac55fa7218 100644 --- a/src/stdlib/SDL_random.c +++ b/src/stdlib/SDL_random.c @@ -23,7 +23,7 @@ // This file contains portable random functions for SDL static Uint64 SDL_rand_state; -static SDL_bool SDL_rand_initialized = SDL_FALSE; +static bool SDL_rand_initialized = false; void SDL_srand(Uint64 seed) { @@ -31,7 +31,7 @@ void SDL_srand(Uint64 seed) seed = SDL_GetPerformanceCounter(); } SDL_rand_state = seed; - SDL_rand_initialized = SDL_TRUE; + SDL_rand_initialized = true; } Sint32 SDL_rand(Sint32 n) diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 43dd7696ba..2bf291face 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -156,7 +156,7 @@ int SDL_CaseFoldUnicode(const Uint32 from, Uint32 *to) #define UNICODE_STRCASECMP(bits, slen1, slen2, update_slen1, update_slen2) \ Uint32 folded1[3], folded2[3]; \ int head1 = 0, tail1 = 0, head2 = 0, tail2 = 0; \ - while (SDL_TRUE) { \ + while (true) { \ Uint32 cp1, cp2; \ if (head1 != tail1) { \ cp1 = folded1[tail1++]; \ @@ -331,10 +331,10 @@ static size_t SDL_ScanLong(const char *text, int count, int radix, long *valuep) { const char *textstart = text; long value = 0; - SDL_bool negative = SDL_FALSE; + bool negative = false; if (*text == '-') { - negative = SDL_TRUE; + negative = true; ++text; } if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { @@ -375,10 +375,10 @@ static size_t SDL_ScanLongW(const wchar_t *text, int count, int radix, long *val { const wchar_t *textstart = text; long value = 0; - SDL_bool negative = SDL_FALSE; + bool negative = false; if (*text == '-') { - negative = SDL_TRUE; + negative = true; ++text; } if (radix == 16 && SDL_wcsncmp(text, L"0x", 2) == 0) { @@ -489,10 +489,10 @@ static size_t SDL_ScanLongLong(const char *text, int count, int radix, Sint64 *v { const char *textstart = text; Sint64 value = 0; - SDL_bool negative = SDL_FALSE; + bool negative = false; if (*text == '-') { - negative = SDL_TRUE; + negative = true; ++text; } if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { @@ -573,10 +573,10 @@ static size_t SDL_ScanFloat(const char *text, double *valuep) const char *textstart = text; unsigned long lvalue = 0; double value = 0.0; - SDL_bool negative = SDL_FALSE; + bool negative = false; if (*text == '-') { - negative = SDL_TRUE; + negative = true; ++text; } text += SDL_ScanUnsignedLong(text, 0, 10, &lvalue); @@ -1369,13 +1369,13 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) return vsscanf(text, fmt, ap); } #else -static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len) +static bool CharacterMatchesSet(char c, const char *set, size_t set_len) { - SDL_bool invert = SDL_FALSE; - SDL_bool result = SDL_FALSE; + bool invert = false; + bool result = false; if (*set == '^') { - invert = SDL_TRUE; + invert = true; ++set; --set_len; } @@ -1384,13 +1384,13 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len) char low_char = SDL_min(set[0], set[2]); char high_char = SDL_max(set[0], set[2]); if (c >= low_char && c <= high_char) { - result = SDL_TRUE; + result = true; } set += 3; set_len -= 3; } else { if (c == *set) { - result = SDL_TRUE; + result = true; } ++set; --set_len; @@ -1420,7 +1420,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li continue; } if (*fmt == '%') { - SDL_bool done = SDL_FALSE; + bool done = false; long count = 0; int radix = 10; enum @@ -1432,7 +1432,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li DO_SIZE_T } inttype = DO_INT; size_t advance; - SDL_bool suppress = SDL_FALSE; + bool suppress = false; ++fmt; if (*fmt == '%') { @@ -1444,7 +1444,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li break; } if (*fmt == '*') { - suppress = SDL_TRUE; + suppress = true; ++fmt; } fmt += SDL_ScanLong(fmt, 0, 10, &count); @@ -1475,7 +1475,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li while (!done) { switch (*fmt) { case '*': - suppress = SDL_TRUE; + suppress = true; break; case 'h': if (inttype == DO_INT) { @@ -1561,7 +1561,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++retval; } } - done = SDL_TRUE; + done = true; break; case 'o': if (radix == 10) { @@ -1622,7 +1622,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++retval; } } - done = SDL_TRUE; + done = true; break; case 'p': { @@ -1635,7 +1635,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++retval; } } - done = SDL_TRUE; + done = true; break; case 'f': { @@ -1648,7 +1648,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li ++retval; } } - done = SDL_TRUE; + done = true; break; case 's': if (suppress) { @@ -1673,7 +1673,7 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li *valuep = '\0'; ++retval; } - done = SDL_TRUE; + done = true; break; case '[': { @@ -1693,10 +1693,10 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li } } } else { - SDL_bool had_match = SDL_FALSE; + bool had_match = false; char *valuep = va_arg(ap, char *); while (CharacterMatchesSet(*text, set, set_len)) { - had_match = SDL_TRUE; + had_match = true; *valuep++ = *text++; if (count) { if (--count == 0) { @@ -1711,10 +1711,10 @@ int SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_li } } } - done = SDL_TRUE; + done = true; break; default: - done = SDL_TRUE; + done = true; break; } ++fmt; @@ -1796,10 +1796,10 @@ typedef enum typedef struct { - SDL_bool left_justify; - SDL_bool force_sign; - SDL_bool force_type; // for now: used only by float printer, ignored otherwise. - SDL_bool pad_zeroes; + bool left_justify; + bool force_sign; + bool force_type; // for now: used only by float printer, ignored otherwise. + bool pad_zeroes; SDL_letter_case force_case; int width; int radix; @@ -1956,7 +1956,7 @@ static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInf return SDL_PrintString(text, maxlen, info, num); } -static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg, SDL_bool g) +static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg, bool g) { char num[327]; size_t length = 0; @@ -2090,8 +2090,8 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO } while (*fmt) { if (*fmt == '%') { - SDL_bool done = SDL_FALSE; - SDL_bool check_flag; + bool done = false; + bool check_flag; SDL_FormatInfo info; enum { @@ -2105,24 +2105,24 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO info.radix = 10; info.precision = -1; - check_flag = SDL_TRUE; + check_flag = true; while (check_flag) { ++fmt; switch (*fmt) { case '-': - info.left_justify = SDL_TRUE; + info.left_justify = true; break; case '+': - info.force_sign = SDL_TRUE; + info.force_sign = true; break; case '#': - info.force_type = SDL_TRUE; + info.force_type = true; break; case '0': - info.pad_zeroes = SDL_TRUE; + info.pad_zeroes = true; break; default: - check_flag = SDL_FALSE; + check_flag = false; break; } } @@ -2156,7 +2156,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO text[length] = '%'; } ++length; - done = SDL_TRUE; + done = true; break; case 'c': // char is promoted to int when passed through (...) @@ -2164,7 +2164,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO text[length] = (char)va_arg(ap, int); } ++length; - done = SDL_TRUE; + done = true; break; case 'h': // short is promoted to int when passed through (...) @@ -2186,7 +2186,7 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO case 'i': case 'd': if (info.precision >= 0) { - info.pad_zeroes = SDL_FALSE; + info.pad_zeroes = false; } switch (inttype) { case DO_INT: @@ -2206,12 +2206,12 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO va_arg(ap, size_t)); break; } - done = SDL_TRUE; + done = true; break; case 'p': info.force_case = SDL_CASE_LOWER; length += SDL_PrintPointer(TEXT_AND_LEN_ARGS, &info, va_arg(ap, void *)); - done = SDL_TRUE; + done = true; break; case 'x': info.force_case = SDL_CASE_LOWER; @@ -2230,9 +2230,9 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO } SDL_FALLTHROUGH; case 'u': - info.force_sign = SDL_FALSE; + info.force_sign = false; if (info.precision >= 0) { - info.pad_zeroes = SDL_FALSE; + info.pad_zeroes = false; } switch (inttype) { case DO_INT: @@ -2253,32 +2253,32 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FO va_arg(ap, size_t)); break; } - done = SDL_TRUE; + done = true; break; case 'f': - length += SDL_PrintFloat(TEXT_AND_LEN_ARGS, &info, va_arg(ap, double), SDL_FALSE); - done = SDL_TRUE; + length += SDL_PrintFloat(TEXT_AND_LEN_ARGS, &info, va_arg(ap, double), false); + done = true; break; case 'g': - length += SDL_PrintFloat(TEXT_AND_LEN_ARGS, &info, va_arg(ap, double), SDL_TRUE); - done = SDL_TRUE; + length += SDL_PrintFloat(TEXT_AND_LEN_ARGS, &info, va_arg(ap, double), true); + done = true; break; case 'S': - info.pad_zeroes = SDL_FALSE; + info.pad_zeroes = false; length += SDL_PrintStringW(TEXT_AND_LEN_ARGS, &info, va_arg(ap, wchar_t *)); - done = SDL_TRUE; + done = true; break; case 's': - info.pad_zeroes = SDL_FALSE; + info.pad_zeroes = false; if (inttype > DO_INT) { length += SDL_PrintStringW(TEXT_AND_LEN_ARGS, &info, va_arg(ap, wchar_t *)); } else { length += SDL_PrintString(TEXT_AND_LEN_ARGS, &info, va_arg(ap, char *)); } - done = SDL_TRUE; + done = true; break; default: - done = SDL_TRUE; + done = true; break; } ++fmt; diff --git a/src/storage/SDL_storage.c b/src/storage/SDL_storage.c index c3b0ecfc6b..efb4b02fd1 100644 --- a/src/storage/SDL_storage.c +++ b/src/storage/SDL_storage.c @@ -177,12 +177,12 @@ int SDL_CloseStorage(SDL_Storage *storage) SDL_bool SDL_StorageReady(SDL_Storage *storage) { - CHECK_STORAGE_MAGIC_RET(SDL_FALSE) + CHECK_STORAGE_MAGIC_RET(false) if (storage->iface.ready) { return storage->iface.ready(storage->userdata); } - return SDL_TRUE; + return true; } int SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length) diff --git a/src/storage/steam/SDL_steamstorage.c b/src/storage/steam/SDL_steamstorage.c index a0182c28b5..71377618f9 100644 --- a/src/storage/steam/SDL_steamstorage.c +++ b/src/storage/steam/SDL_steamstorage.c @@ -57,7 +57,7 @@ static int STEAM_CloseStorage(void *userdata) static SDL_bool STEAM_StorageReady(void *userdata) { - return SDL_TRUE; + return true; } static int STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info) diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 634b757d2c..21b1db6d28 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -272,7 +272,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data) #endif // Routine to get the thread-specific error variable -SDL_error *SDL_GetErrBuf(SDL_bool create) +SDL_error *SDL_GetErrBuf(bool create) { #ifdef SDL_THREADS_DISABLED return SDL_GetStaticErrBuf(); diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 54b1826ca8..331a370ee6 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -71,10 +71,10 @@ static void *RunThread(void *data) } #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) -static SDL_bool checked_setname = SDL_FALSE; +static bool checked_setname = false; static int (*ppthread_setname_np)(const char *) = NULL; #elif defined(SDL_PLATFORM_LINUX) && defined(HAVE_DLOPEN) -static SDL_bool checked_setname = SDL_FALSE; +static bool checked_setname = false; static int (*ppthread_setname_np)(pthread_t, const char *) = NULL; #endif int SDL_SYS_CreateThread(SDL_Thread *thread, @@ -92,7 +92,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, #elif defined(SDL_PLATFORM_LINUX) ppthread_setname_np = (int (*)(pthread_t, const char *))fn; #endif - checked_setname = SDL_TRUE; + checked_setname = true; } #endif @@ -186,7 +186,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) int pri_policy; pthread_t thread = pthread_self(); const char *policyhint = SDL_GetHint(SDL_HINT_THREAD_PRIORITY_POLICY); - const SDL_bool timecritical_realtime_hint = SDL_GetHintBoolean(SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL, SDL_FALSE); + const bool timecritical_realtime_hint = SDL_GetHintBoolean(SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL, false); if (pthread_getschedparam(thread, &policy, &sched) != 0) { return SDL_SetError("pthread_getschedparam() failed"); diff --git a/src/thread/pthread/SDL_systls.c b/src/thread/pthread/SDL_systls.c index 7f0c5b5ecc..114291fb89 100644 --- a/src/thread/pthread/SDL_systls.c +++ b/src/thread/pthread/SDL_systls.c @@ -27,7 +27,7 @@ #define INVALID_PTHREAD_KEY ((pthread_key_t)-1) static pthread_key_t thread_local_storage = INVALID_PTHREAD_KEY; -static SDL_bool generic_local_storage = SDL_FALSE; +static bool generic_local_storage = false; void SDL_SYS_InitTLSData(void) { @@ -35,7 +35,7 @@ void SDL_SYS_InitTLSData(void) if (pthread_key_create(&thread_local_storage, NULL) != 0) { thread_local_storage = INVALID_PTHREAD_KEY; SDL_Generic_InitTLSData(); - generic_local_storage = SDL_TRUE; + generic_local_storage = true; } } } @@ -68,7 +68,7 @@ void SDL_SYS_QuitTLSData(void) { if (generic_local_storage) { SDL_Generic_QuitTLSData(); - generic_local_storage = SDL_FALSE; + generic_local_storage = false; } else { if (thread_local_storage != INVALID_PTHREAD_KEY) { pthread_key_delete(thread_local_storage); diff --git a/src/thread/windows/SDL_sysrwlock_srw.c b/src/thread/windows/SDL_sysrwlock_srw.c index fecbc2f733..ea47ec37be 100644 --- a/src/thread/windows/SDL_sysrwlock_srw.c +++ b/src/thread/windows/SDL_sysrwlock_srw.c @@ -193,8 +193,8 @@ SDL_RWLock *SDL_CreateRWLock(void) { HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { - SDL_bool okay = SDL_TRUE; - #define LOOKUP_SRW_SYM(sym) if (okay) { if ((p##sym = (pfn##sym)GetProcAddress(kernel32, #sym)) == NULL) { okay = SDL_FALSE; } } + bool okay = true; + #define LOOKUP_SRW_SYM(sym) if (okay) { if ((p##sym = (pfn##sym)GetProcAddress(kernel32, #sym)) == NULL) { okay = false; } } LOOKUP_SRW_SYM(InitializeSRWLock); LOOKUP_SRW_SYM(ReleaseSRWLockShared); LOOKUP_SRW_SYM(AcquireSRWLockShared); diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index e50d7f9547..5e9c7766a7 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -330,7 +330,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) const SDL_sem_impl_t *impl = &SDL_sem_impl_kern; #if !SDL_WINAPI_FAMILY_PHONE - if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, false)) { #ifdef SDL_PLATFORM_WINRT // Link statically on this platform impl = &SDL_sem_impl_atom; diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 0d9f815480..45514c004b 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -40,7 +40,7 @@ #endif static DWORD thread_local_storage = TLS_OUT_OF_INDEXES; -static SDL_bool generic_local_storage = SDL_FALSE; +static bool generic_local_storage = false; void SDL_SYS_InitTLSData(void) { @@ -48,7 +48,7 @@ void SDL_SYS_InitTLSData(void) thread_local_storage = TlsAlloc(); if (thread_local_storage == TLS_OUT_OF_INDEXES) { SDL_Generic_InitTLSData(); - generic_local_storage = SDL_TRUE; + generic_local_storage = true; } } } @@ -81,7 +81,7 @@ void SDL_SYS_QuitTLSData(void) { if (generic_local_storage) { SDL_Generic_QuitTLSData(); - generic_local_storage = SDL_FALSE; + generic_local_storage = false; } else { if (thread_local_storage != TLS_OUT_OF_INDEXES) { TlsFree(thread_local_storage); diff --git a/src/time/SDL_time.c b/src/time/SDL_time.c index 71ba037315..9ac252b11d 100644 --- a/src/time/SDL_time.c +++ b/src/time/SDL_time.c @@ -125,36 +125,36 @@ int SDL_GetDayOfWeek(int year, int month, int day) return dayOfWeek; } -static SDL_bool SDL_DateTimeIsValid(const SDL_DateTime *dt) +static bool SDL_DateTimeIsValid(const SDL_DateTime *dt) { if (dt->month < 1 || dt->month > 12) { SDL_SetError("Malformed SDL_DateTime: month out of range [1-12], current: %i", dt->month); - return SDL_FALSE; + return false; } const int daysInMonth = SDL_GetDaysInMonth(dt->year, dt->month); if (dt->day < 1 || dt->day > daysInMonth) { SDL_SetError("Malformed SDL_DateTime: day of month out of range [1-%i], current: %i", daysInMonth, dt->month); - return SDL_FALSE; + return false; } if (dt->hour < 0 || dt->hour > 23) { SDL_SetError("Malformed SDL_DateTime: hour out of range [0-23], current: %i", dt->hour); - return SDL_FALSE; + return false; } if (dt->minute < 0 || dt->minute > 59) { SDL_SetError("Malformed SDL_DateTime: minute out of range [0-59], current: %i", dt->minute); - return SDL_FALSE; + return false; } if (dt->second < 0 || dt->second > 60) { SDL_SetError("Malformed SDL_DateTime: second out of range [0-60], current: %i", dt->second); - return SDL_FALSE; // 60 accounts for a possible leap second. + return false; // 60 accounts for a possible leap second. } if (dt->nanosecond < 0 || dt->nanosecond >= SDL_NS_PER_SECOND) { SDL_SetError("Malformed SDL_DateTime: nanosecond out of range [0-999999999], current: %i", dt->nanosecond); - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } int SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks) diff --git a/src/time/windows/SDL_systime.c b/src/time/windows/SDL_systime.c index cc2c06a8bd..e889ca5c23 100644 --- a/src/time/windows/SDL_systime.c +++ b/src/time/windows/SDL_systime.c @@ -89,7 +89,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) GetSystemTimePreciseAsFileTime(&ft); #else static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL; - static SDL_bool load_attempted = SDL_FALSE; + static bool load_attempted = false; // Only available in Win8/Server 2012 or higher. if (!pGetSystemTimePreciseAsFileTime && !load_attempted) { @@ -97,7 +97,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks) if (kernel32) { pGetSystemTimePreciseAsFileTime = (pfnGetSystemTimePreciseAsFileTime)GetProcAddress(kernel32, "GetSystemTimePreciseAsFileTime"); } - load_attempted = SDL_TRUE; + load_attempted = true; } if (pGetSystemTimePreciseAsFileTime) { diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 1ce123e49f..0423814d0c 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -353,7 +353,7 @@ int SDL_RemoveTimer(SDL_TimerID id) { SDL_TimerData *data = &SDL_timer_data; SDL_TimerMap *prev, *entry; - SDL_bool canceled = SDL_FALSE; + bool canceled = false; if (!id) { return SDL_InvalidParamError("id"); @@ -377,7 +377,7 @@ int SDL_RemoveTimer(SDL_TimerID id) if (entry) { if (!SDL_AtomicGet(&entry->timer->canceled)) { SDL_AtomicSet(&entry->timer->canceled, 1); - canceled = SDL_TRUE; + canceled = true; } SDL_free(entry); } diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 6af7f60760..b9c9ac2334 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -64,22 +64,22 @@ #if !defined(HAVE_CLOCK_GETTIME) && defined(SDL_PLATFORM_APPLE) mach_timebase_info_data_t mach_base_info; #endif -static SDL_bool checked_monotonic_time = SDL_FALSE; -static SDL_bool has_monotonic_time = SDL_FALSE; +static bool checked_monotonic_time = false; +static bool has_monotonic_time = false; static void CheckMonotonicTime(void) { #ifdef HAVE_CLOCK_GETTIME struct timespec value; if (clock_gettime(SDL_MONOTONIC_CLOCK, &value) == 0) { - has_monotonic_time = SDL_TRUE; + has_monotonic_time = true; } else #elif defined(SDL_PLATFORM_APPLE) if (mach_timebase_info(&mach_base_info) == 0) { - has_monotonic_time = SDL_TRUE; + has_monotonic_time = true; } #endif - checked_monotonic_time = SDL_TRUE; + checked_monotonic_time = true; } Uint64 SDL_GetPerformanceCounter(void) @@ -101,7 +101,7 @@ Uint64 SDL_GetPerformanceCounter(void) #elif defined(SDL_PLATFORM_APPLE) ticks = mach_absolute_time(); #else - SDL_assert(SDL_FALSE); + SDL_assert(false); ticks = 0; #endif } else { @@ -147,7 +147,7 @@ void SDL_SYS_DelayNS(Uint64 ns) #endif #ifdef SDL_PLATFORM_EMSCRIPTEN - if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { + if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, true)) { // pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent emscripten_sleep(ns / SDL_NS_PER_MS); return; diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 465148b69a..78864f370a 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1374,7 +1374,7 @@ int SDL_RLESurface(SDL_Surface *surface) // Clear any previous RLE conversion if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - SDL_UnRLESurface(surface, SDL_TRUE); + SDL_UnRLESurface(surface, true); } // We don't support RLE encoding of bitmaps @@ -1435,7 +1435,7 @@ int SDL_RLESurface(SDL_Surface *surface) * completely transparent pixels will be lost, and color and alpha depth * may have been reduced (when encoding for 16bpp targets). */ -static SDL_bool UnRLEAlpha(SDL_Surface *surface) +static bool UnRLEAlpha(SDL_Surface *surface) { Uint8 *srcbuf; Uint32 *dst; @@ -1457,12 +1457,12 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } if (SDL_size_mul_overflow(surface->h, surface->pitch, &size)) { - return SDL_FALSE; + return false; } surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); if (!surface->pixels) { - return SDL_FALSE; + return false; } surface->flags |= SDL_SURFACE_SIMD_ALIGNED; // fill background with transparent pixels @@ -1513,10 +1513,10 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } end_function: - return SDL_TRUE; + return true; } -void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode) +void SDL_UnRLESurface(SDL_Surface *surface, bool recode) { if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { surface->internal->flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL; diff --git a/src/video/SDL_RLEaccel_c.h b/src/video/SDL_RLEaccel_c.h index d9cd067ce6..7f4c8adfe9 100644 --- a/src/video/SDL_RLEaccel_c.h +++ b/src/video/SDL_RLEaccel_c.h @@ -27,6 +27,6 @@ // Useful functions and variables from SDL_RLEaccel.c extern int SDL_RLESurface(SDL_Surface *surface); -extern void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode); +extern void SDL_UnRLESurface(SDL_Surface *surface, bool recode); #endif // SDL_RLEaccel_c_h_ diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 41569324dd..a90f571c20 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -102,23 +102,23 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, #ifdef SDL_PLATFORM_MACOS #include -static SDL_bool SDL_UseAltivecPrefetch(void) +static bool SDL_UseAltivecPrefetch(void) { const char key[] = "hw.l3cachesize"; u_int64_t result = 0; size_t typeSize = sizeof(result); if (sysctlbyname(key, &result, &typeSize, NULL, 0) == 0 && result > 0) { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } #else -static SDL_bool SDL_UseAltivecPrefetch(void) +static bool SDL_UseAltivecPrefetch(void) { // Just guess G4 - return SDL_TRUE; + return true; } #endif // SDL_PLATFORM_MACOS @@ -192,7 +192,7 @@ int SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) #if SDL_HAVE_RLE // Clean everything out to start if (surface->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - SDL_UnRLESurface(surface, SDL_TRUE); + SDL_UnRLESurface(surface, true); } #endif diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index a41683ae9d..bc1b9bb894 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -52,7 +52,7 @@ static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint void SDL_BlitCopy(SDL_BlitInfo *info) { - SDL_bool overlap; + bool overlap; Uint8 *src, *dst; int w, h; int srcskip, dstskip; diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 7e4fa85b9d..da00528ae6 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -50,7 +50,7 @@ #define LCS_WINDOWS_COLOR_SPACE 0x57696E20 #endif -static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle8) +static bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle8) { /* | Sets the surface pixels from src. A bmp image is upside down. @@ -72,7 +72,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle // !!! FIXME: for all these reads, handle error vs eof? handle -2 if non-blocking? for (;;) { if (!SDL_ReadU8(src, &ch)) { - return SDL_TRUE; + return true; } /* | encoded mode starts with a run length, and then a byte @@ -81,7 +81,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle if (ch) { Uint8 pixel; if (!SDL_ReadU8(src, &pixel)) { - return SDL_TRUE; + return true; } if (isRle8) { // 256-color bitmap, compressed do { @@ -108,7 +108,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle | zero tag may be absolute mode or an escape */ if (!SDL_ReadU8(src, &ch)) { - return SDL_TRUE; + return true; } switch (ch) { case 0: // end of line @@ -116,14 +116,14 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle bits -= pitch; // go to previous break; case 1: // end of bitmap - return SDL_FALSE; // success! + return false; // success! case 2: // delta if (!SDL_ReadU8(src, &ch)) { - return SDL_TRUE; + return true; } ofs += ch; if (!SDL_ReadU8(src, &ch)) { - return SDL_TRUE; + return true; } bits -= (ch * pitch); break; @@ -133,7 +133,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle do { Uint8 pixel; if (!SDL_ReadU8(src, &pixel)) { - return SDL_TRUE; + return true; } COPY_PIXEL(pixel); } while (--ch); @@ -142,7 +142,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle for (;;) { Uint8 pixel; if (!SDL_ReadU8(src, &pixel)) { - return SDL_TRUE; + return true; } COPY_PIXEL(pixel >> 4); if (!--ch) { @@ -156,7 +156,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle } // pad at even boundary if (needsPad && !SDL_ReadU8(src, &ch)) { - return SDL_TRUE; + return true; } break; } @@ -167,7 +167,7 @@ static SDL_bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle static void CorrectAlphaChannel(SDL_Surface *surface) { // Check to see if there is any alpha channel data - SDL_bool hasAlpha = SDL_FALSE; + bool hasAlpha = false; #if SDL_BYTEORDER == SDL_BIG_ENDIAN int alphaChannelOffset = 0; #else @@ -178,7 +178,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface) while (alpha < end) { if (*alpha != 0) { - hasAlpha = SDL_TRUE; + hasAlpha = true; break; } alpha += 4; @@ -195,7 +195,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface) SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) { - SDL_bool was_error = SDL_TRUE; + bool was_error = true; Sint64 fp_offset = 0; int i, pad; SDL_Surface *surface; @@ -205,10 +205,10 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) Uint32 Amask = 0; Uint8 *bits; Uint8 *top, *end; - SDL_bool topDown; - SDL_bool haveRGBMasks = SDL_FALSE; - SDL_bool haveAlphaMask = SDL_FALSE; - SDL_bool correctAlpha = SDL_FALSE; + bool topDown; + bool haveRGBMasks = false; + bool haveAlphaMask = false; + bool correctAlpha = false; // The Win32 BMP file header (14 bytes) char magic[2]; @@ -302,7 +302,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) speaking, this is the bmiColors field in BITMAPINFO immediately following the legacy v1 info header, just past biSize. */ if (biCompression == BI_BITFIELDS) { - haveRGBMasks = SDL_TRUE; + haveRGBMasks = true; if (!SDL_ReadU32LE(src, &Rmask) || !SDL_ReadU32LE(src, &Gmask) || !SDL_ReadU32LE(src, &Bmask)) { @@ -311,7 +311,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) // ...v3 adds an alpha mask. if (biSize >= 56) { // BITMAPV3INFOHEADER; adds alpha mask - haveAlphaMask = SDL_TRUE; + haveAlphaMask = true; if (!SDL_ReadU32LE(src, &Amask)) { goto done; } @@ -351,10 +351,10 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) goto done; } if (biHeight < 0) { - topDown = SDL_TRUE; + topDown = true; biHeight = -biHeight; } else { - topDown = SDL_FALSE; + topDown = false; } // Check for read error @@ -405,7 +405,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) break; case 32: // We don't know if this has alpha channel or not - correctAlpha = SDL_TRUE; + correctAlpha = true; // SDL_PIXELFORMAT_RGBA8888 Amask = 0xFF000000; Rmask = 0x00FF0000; @@ -570,7 +570,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio) CorrectAlphaChannel(surface); } - was_error = SDL_FALSE; + was_error = false; done: if (was_error) { @@ -593,13 +593,13 @@ SDL_Surface *SDL_LoadBMP(const char *file) int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) { - SDL_bool was_error = SDL_TRUE; + bool was_error = true; Sint64 fp_offset, new_offset; int i, pad; SDL_Surface *intermediate_surface; Uint8 *bits; - SDL_bool save32bit = SDL_FALSE; - SDL_bool saveLegacyBMP = SDL_FALSE; + bool save32bit = false; + bool saveLegacyBMP = false; // The Win32 BMP file header (14 bytes) char magic[2] = { 'B', 'M' }; @@ -645,7 +645,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) if (SDL_BITSPERPIXEL(surface->format) >= 8 && (SDL_ISPIXELFORMAT_ALPHA(surface->format) || surface->internal->map.info.flags & SDL_COPY_COLORKEY)) { - save32bit = SDL_TRUE; + save32bit = true; } #endif // SAVE_32BIT_BMP @@ -693,7 +693,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) } if (save32bit) { - saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, SDL_FALSE); + saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, false); } if (SDL_LockSurface(intermediate_surface) == 0) { @@ -852,7 +852,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio) // Close it up.. SDL_UnlockSurface(intermediate_surface); - was_error = SDL_FALSE; + was_error = false; } done: @@ -861,7 +861,7 @@ done: } if (closeio && dst) { if (SDL_CloseIO(dst) < 0) { - was_error = SDL_TRUE; + was_error = true; } } if (was_error) { diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index e26c0a2011..bd7a5ee0ac 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -197,16 +197,16 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size) } } -SDL_bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type) +bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type) { size_t i; for (i = 0; i < _this->num_clipboard_mime_types; ++i) { if (SDL_strcmp(mime_type, _this->clipboard_mime_types[i]) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } SDL_bool SDL_HasClipboardData(const char *mime_type) @@ -215,12 +215,12 @@ SDL_bool SDL_HasClipboardData(const char *mime_type) if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard data"); - return SDL_FALSE; + return false; } if (!mime_type) { SDL_InvalidParamError("mime_type"); - return SDL_FALSE; + return false; } if (_this->HasClipboardData) { @@ -234,7 +234,7 @@ SDL_bool SDL_HasClipboardData(const char *mime_type) // Clipboard text -SDL_bool SDL_IsTextMimeType(const char *mime_type) +bool SDL_IsTextMimeType(const char *mime_type) { return (SDL_strncmp(mime_type, "text", 4) == 0); } @@ -318,16 +318,16 @@ SDL_bool SDL_HasClipboardText(void) if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard text"); - return SDL_FALSE; + return false; } text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types); for (i = 0; i < num_mime_types; ++i) { if (SDL_HasClipboardData(text_mime_types[i])) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } // Primary selection text @@ -382,16 +382,16 @@ SDL_bool SDL_HasPrimarySelectionText(void) if (!_this) { SDL_SetError("Video subsystem must be initialized to check primary selection text"); - return SDL_FALSE; + return false; } if (_this->HasPrimarySelectionText) { return _this->HasPrimarySelectionText(_this); } else { if (_this->primary_selection_text && _this->primary_selection_text[0] != '\0') { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } } diff --git a/src/video/SDL_clipboard_c.h b/src/video/SDL_clipboard_c.h index 5347fc8307..0d5e9dc8fb 100644 --- a/src/video/SDL_clipboard_c.h +++ b/src/video/SDL_clipboard_c.h @@ -27,14 +27,14 @@ // Return true if the mime type is valid clipboard text -extern SDL_bool SDL_IsTextMimeType(const char *mime_type); +extern bool SDL_IsTextMimeType(const char *mime_type); // Cancel the clipboard data callback, called internally for cleanup extern void SDL_CancelClipboardData(Uint32 sequence); // Call the clipboard callback for application data extern void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); -extern SDL_bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type); // General purpose clipboard text callback const void * SDLCALL SDL_ClipboardTextCallback(void *userdata, const char *mime_type, size_t *size); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index bd7373cfcc..360fde584e 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -176,7 +176,7 @@ int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint // EGL implementation of SDL OpenGL ES support -SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext) +bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext) { size_t ext_len; const char *ext_override; @@ -186,7 +186,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type // Invalid extensions can be rejected early if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); - return SDL_FALSE; + return false; } /* Extensions can be masked with a hint or environment variable. @@ -200,9 +200,9 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type if (ext_override) { int disable_ext = SDL_atoi(ext_override); if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) { - return SDL_FALSE; + return false; } else if (disable_ext & 0x02 && type == SDL_EGL_CLIENT_EXTENSION) { - return SDL_FALSE; + return false; } } @@ -220,7 +220,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type break; default: // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid extension type"); - return SDL_FALSE; + return false; } if (egl_extstr) { @@ -229,12 +229,12 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type while (*ext_start) { ext_start = SDL_strstr(ext_start, ext); if (!ext_start) { - return SDL_FALSE; + return false; } // Check if the match is not just a substring of one of the extensions if (ext_start == egl_extstr || *(ext_start - 1) == ' ') { if (ext_start[ext_len] == ' ' || ext_start[ext_len] == 0) { - return SDL_TRUE; + return true; } } // If the search stopped in the middle of an extension, skip to the end of it @@ -245,7 +245,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type } } - return SDL_FALSE; + return false; } SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc) @@ -253,7 +253,7 @@ SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const SDL_FunctionPointer retval = NULL; if (_this->egl_data) { const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); - const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); + const bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); // EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { @@ -305,7 +305,7 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p const char *d3dcompiler; #endif #ifdef SDL_VIDEO_DRIVER_RPI - SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK)); + bool vc4 = (0 == access("/sys/module/vc4/", F_OK)); #endif #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) @@ -551,7 +551,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp // Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay) && - SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK, SDL_TRUE)) { + SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK, true)) { _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); } if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { @@ -570,7 +570,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp // Get the EGL version with a valid egl_display, for EGL <= 1.4 SDL_EGL_GetVersion(_this); - _this->egl_data->is_offscreen = SDL_FALSE; + _this->egl_data->is_offscreen = false; return 0; } @@ -625,7 +625,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) } } else { int i; - SDL_bool found = SDL_FALSE; + bool found = false; EGLDisplay attempted_egl_display; // If no hint is provided lets look for the first device/display that will allow us to eglInit @@ -643,7 +643,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) // We did not fail, we'll pick this one! _this->egl_data->egl_display = attempted_egl_display; - found = SDL_TRUE; + found = true; break; } @@ -656,7 +656,7 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) // Get the EGL version with a valid egl_display, for EGL <= 1.4 SDL_EGL_GetVersion(_this); - _this->egl_data->is_offscreen = SDL_TRUE; + _this->egl_data->is_offscreen = true; return 0; } @@ -727,14 +727,14 @@ static void dumpconfig(SDL_VideoDevice *_this, EGLConfig config) #endif // DUMP_EGL_CONFIG -static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_config_caveat_none) +static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, bool set_config_caveat_none) { // 64 seems nice. EGLint attribs[64]; EGLint found_configs = 0, value; // 128 seems even nicer here EGLConfig configs[128]; - SDL_bool has_matching_format = SDL_FALSE; + bool has_matching_format = false; int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1; int truecolor_config_idx = -1; @@ -836,7 +836,7 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf configs[i], EGL_NATIVE_VISUAL_ID, &format); if (_this->egl_data->egl_required_visual_id == format) { - has_matching_format = SDL_TRUE; + has_matching_format = true; break; } } @@ -846,7 +846,7 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf // From those, we select the one that matches our requirements more closely via a makeshift algorithm for (i = 0; i < found_configs; i++) { - SDL_bool is_truecolor = SDL_FALSE; + bool is_truecolor = false; int bitdiff = 0; if (has_matching_format && _this->egl_data->egl_required_visual_id) { @@ -865,7 +865,7 @@ static int SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, SDL_bool set_conf if (value == 8) { _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_BLUE_SIZE, &value); if (value == 8) { - is_truecolor = SDL_TRUE; + is_truecolor = true; } } } @@ -934,13 +934,13 @@ int SDL_EGL_ChooseConfig(SDL_VideoDevice *_this) } // Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG - ret = SDL_EGL_PrivateChooseConfig(_this, SDL_TRUE); + ret = SDL_EGL_PrivateChooseConfig(_this, true); if (ret == 0) { return 0; } // Fallback with all configs - ret = SDL_EGL_PrivateChooseConfig(_this, SDL_FALSE); + ret = SDL_EGL_PrivateChooseConfig(_this, false); if (ret == 0) { SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config"); return 0; @@ -959,7 +959,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa EGLint profile_mask = _this->gl_config.profile_mask; EGLint major_version = _this->gl_config.major_version; EGLint minor_version = _this->gl_config.minor_version; - SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES); + bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES); if (!_this->egl_data) { SDL_SetError("EGL not initialized"); @@ -1102,7 +1102,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa /* On OpenGL ES, the GL_OES_surfaceless_context extension must be * present. */ if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) { - _this->gl_allow_no_surface = SDL_TRUE; + _this->gl_allow_no_surface = true; } #if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_DRIVER_VITA) } else { @@ -1112,7 +1112,7 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa GLint v = 0; glGetIntegervFunc(GL_MAJOR_VERSION, &v); if (v >= 3) { - _this->gl_allow_no_surface = SDL_TRUE; + _this->gl_allow_no_surface = true; } } #endif @@ -1258,9 +1258,9 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat #ifdef EGL_EXT_present_opaque if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) { - SDL_bool allow_transparent = SDL_FALSE; + bool allow_transparent = false; if (window && (window->flags & SDL_WINDOW_TRANSPARENT)) { - allow_transparent = SDL_TRUE; + allow_transparent = true; } attribs[attr++] = EGL_PRESENT_OPAQUE_EXT; attribs[attr++] = allow_transparent ? EGL_FALSE : EGL_TRUE; diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index 4817ed47ed..187cb49b85 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -71,7 +71,7 @@ typedef struct SDL_EGL_VideoData int egl_surfacetype; int egl_version_major, egl_version_minor; EGLint egl_required_visual_id; - SDL_bool is_offscreen; // whether EGL display was offscreen + bool is_offscreen; // whether EGL display was offscreen EGLenum apitype; // EGL_OPENGL_ES_API, EGL_OPENGL_API, etc PFNEGLGETDISPLAYPROC eglGetDisplay; @@ -114,7 +114,7 @@ typedef enum SDL_EGL_ExtensionType SDL_EGL_CLIENT_EXTENSION } SDL_EGL_ExtensionType; -extern SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext); +extern bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext); extern int SDL_EGL_GetAttribute(SDL_VideoDevice *_this, SDL_GLattr attrib, int *value); /* SDL_EGL_LoadLibrary can get a display for a specific platform (EGL_PLATFORM_*) diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 3534db4a57..0455dd2ad5 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -656,7 +656,7 @@ const SDL_PixelFormatDetails *SDL_GetPixelFormatDetails(SDL_PixelFormat format) SDL_LockMutex(SDL_format_details_lock); if (!SDL_format_details) { - SDL_format_details = SDL_CreateHashTable(NULL, 8, SDL_HashID, SDL_KeyMatchID, SDL_NukeFreeValue, SDL_FALSE); + SDL_format_details = SDL_CreateHashTable(NULL, 8, SDL_HashID, SDL_KeyMatchID, SDL_NukeFreeValue, false); } if (SDL_FindInHashTable(SDL_format_details, (const void *)(uintptr_t)format, (const void **)&details)) { @@ -1149,49 +1149,49 @@ Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Pa } // Tell whether palette is opaque, and if it has an alpha_channel -void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel) +void SDL_DetectPalette(const SDL_Palette *pal, bool *is_opaque, bool *has_alpha_channel) { int i; { - SDL_bool all_opaque = SDL_TRUE; + bool all_opaque = true; for (i = 0; i < pal->ncolors; i++) { Uint8 alpha_value = pal->colors[i].a; if (alpha_value != SDL_ALPHA_OPAQUE) { - all_opaque = SDL_FALSE; + all_opaque = false; break; } } if (all_opaque) { // Palette is opaque, with an alpha channel - *is_opaque = SDL_TRUE; - *has_alpha_channel = SDL_TRUE; + *is_opaque = true; + *has_alpha_channel = true; return; } } { - SDL_bool all_transparent = SDL_TRUE; + bool all_transparent = true; for (i = 0; i < pal->ncolors; i++) { Uint8 alpha_value = pal->colors[i].a; if (alpha_value != SDL_ALPHA_TRANSPARENT) { - all_transparent = SDL_FALSE; + all_transparent = false; break; } } if (all_transparent) { // Palette is opaque, without an alpha channel - *is_opaque = SDL_TRUE; - *has_alpha_channel = SDL_FALSE; + *is_opaque = true; + *has_alpha_channel = false; return; } } // Palette has alpha values - *is_opaque = SDL_FALSE; - *has_alpha_channel = SDL_TRUE; + *is_opaque = false; + *has_alpha_channel = true; } // Find the opaque pixel value corresponding to an RGB triple @@ -1470,7 +1470,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map = &src->internal->map; #if SDL_HAVE_RLE if (src->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - SDL_UnRLESurface(src, SDL_TRUE); + SDL_UnRLESurface(src, true); } #endif SDL_InvalidateMap(map); @@ -1509,7 +1509,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) } else { if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { // BitField --> Palette - map->info.palette_map = SDL_CreateHashTable(NULL, 32, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE); + map->info.palette_map = SDL_CreateHashTable(NULL, 32, SDL_HashID, SDL_KeyMatchID, NULL, false); } else { // BitField --> BitField if (srcfmt == dstfmt) { diff --git a/src/video/SDL_pixels_c.h b/src/video/SDL_pixels_c.h index db9885503a..05da3ee457 100644 --- a/src/video/SDL_pixels_c.h +++ b/src/video/SDL_pixels_c.h @@ -29,7 +29,7 @@ // Pixel format functions -extern int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch); +extern int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, bool minimalPitch); extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat pixel_format); extern void SDL_QuitPixelFormatDetails(void); @@ -51,7 +51,7 @@ extern int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst); extern void SDL_DitherPalette(SDL_Palette *palette); extern Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); extern Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Palette *pal); -extern void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel); +extern void SDL_DetectPalette(const SDL_Palette *pal, bool *is_opaque, bool *has_alpha_channel); extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, void *pixels, int pitch); #endif // SDL_pixels_c_h_ diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index d89da72053..b284baf27f 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -24,7 +24,7 @@ /* There's no float version of this at the moment, because it's not a public API and internally we only need the int version. */ -SDL_bool SDL_GetSpanEnclosingRect(int width, int height, +bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span) { int i; @@ -33,19 +33,19 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, if (width < 1) { SDL_InvalidParamError("width"); - return SDL_FALSE; + return false; } else if (height < 1) { SDL_InvalidParamError("height"); - return SDL_FALSE; + return false; } else if (!rects) { SDL_InvalidParamError("rects"); - return SDL_FALSE; + return false; } else if (!span) { SDL_InvalidParamError("span"); - return SDL_FALSE; + return false; } else if (numrects < 1) { SDL_InvalidParamError("numrects"); - return SDL_FALSE; + return false; } // Initialize to empty rect @@ -73,9 +73,9 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, span->y = span_y1; span->w = width; span->h = (span_y2 - span_y1); - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } // For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h diff --git a/src/video/SDL_rect_c.h b/src/video/SDL_rect_c.h index d441ba176f..e30014acb7 100644 --- a/src/video/SDL_rect_c.h +++ b/src/video/SDL_rect_c.h @@ -24,6 +24,6 @@ #include "SDL_internal.h" -extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span); +extern bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span); #endif // SDL_rect_c_h_ diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index edde16fb75..76b7bf741a 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -21,7 +21,7 @@ // This file is #included twice to support int and float versions with the same code. -static SDL_bool SDL_RECT_CAN_OVERFLOW(const RECTTYPE *rect) +static bool SDL_RECT_CAN_OVERFLOW(const RECTTYPE *rect) { if (rect->x <= (SCALARTYPE)(SDL_MIN_SINT32 / 2) || rect->x >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || @@ -29,9 +29,9 @@ static SDL_bool SDL_RECT_CAN_OVERFLOW(const RECTTYPE *rect) rect->y >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || rect->w >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || rect->h >= (SCALARTYPE)(SDL_MAX_SINT32 / 2)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) @@ -40,16 +40,16 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) if (!A) { SDL_InvalidParamError("A"); - return SDL_FALSE; + return false; } else if (!B) { SDL_InvalidParamError("B"); - return SDL_FALSE; + return false; } else if (SDL_RECT_CAN_OVERFLOW(A) || SDL_RECT_CAN_OVERFLOW(B)) { SDL_SetError("Potential rect math overflow"); - return SDL_FALSE; + return false; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { - return SDL_FALSE; // Special cases for empty rects + return false; // Special cases for empty rects } // Horizontal intersection @@ -64,7 +64,7 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) Amax = Bmax; } if ((Amax - ENCLOSEPOINTS_EPSILON) < Amin) { - return SDL_FALSE; + return false; } // Vertical intersection Amin = A->y; @@ -78,9 +78,9 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) Amax = Bmax; } if ((Amax - ENCLOSEPOINTS_EPSILON) < Amin) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) @@ -89,21 +89,21 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul if (!A) { SDL_InvalidParamError("A"); - return SDL_FALSE; + return false; } else if (!B) { SDL_InvalidParamError("B"); - return SDL_FALSE; + return false; } else if (SDL_RECT_CAN_OVERFLOW(A) || SDL_RECT_CAN_OVERFLOW(B)) { SDL_SetError("Potential rect math overflow"); - return SDL_FALSE; + return false; } else if (!result) { SDL_InvalidParamError("result"); - return SDL_FALSE; + return false; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { // Special cases for empty rects result->w = 0; result->h = 0; - return SDL_FALSE; + return false; } // Horizontal intersection @@ -147,8 +147,7 @@ int SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) return SDL_InvalidParamError("B"); } else if (SDL_RECT_CAN_OVERFLOW(A) || SDL_RECT_CAN_OVERFLOW(B)) { - SDL_SetError("Potential rect math overflow"); - return SDL_FALSE; + return SDL_SetError("Potential rect math overflow"); } else if (!result) { return SDL_InvalidParamError("result"); } else if (SDL_RECTEMPTY(A)) { // Special cases for empty Rects @@ -193,8 +192,7 @@ int SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) return 0; } -SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *clip, - RECTTYPE *result) +SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *clip, RECTTYPE *result) { SCALARTYPE minx = 0; SCALARTYPE miny = 0; @@ -205,14 +203,14 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c if (!points) { SDL_InvalidParamError("points"); - return SDL_FALSE; + return false; } else if (count < 1) { SDL_InvalidParamError("count"); - return SDL_FALSE; + return false; } if (clip) { - SDL_bool added = SDL_FALSE; + bool added = false; const SCALARTYPE clip_minx = clip->x; const SCALARTYPE clip_miny = clip->y; const SCALARTYPE clip_maxx = clip->x + clip->w - ENCLOSEPOINTS_EPSILON; @@ -220,7 +218,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c // Special case for empty rectangle if (SDL_RECTEMPTY(clip)) { - return SDL_FALSE; + return false; } for (i = 0; i < count; ++i) { @@ -234,13 +232,13 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c if (!added) { // Special case: if no result was requested, we are done if (!result) { - return SDL_TRUE; + return true; } // First point added minx = maxx = x; miny = maxy = y; - added = SDL_TRUE; + added = true; continue; } if (x < minx) { @@ -255,12 +253,12 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } } if (!added) { - return SDL_FALSE; + return false; } } else { // Special case: if no result was requested, we are done if (!result) { - return SDL_TRUE; + return true; } // No clipping, always add the first point @@ -290,7 +288,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c result->w = (maxx - minx) + ENCLOSEPOINTS_EPSILON; result->h = (maxy - miny) + ENCLOSEPOINTS_EPSILON; } - return SDL_TRUE; + return true; } // Use the Cohen-Sutherland algorithm for line clipping @@ -324,24 +322,24 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY if (!rect) { SDL_InvalidParamError("rect"); - return SDL_FALSE; + return false; } else if (SDL_RECT_CAN_OVERFLOW(rect)) { SDL_SetError("Potential rect math overflow"); - return SDL_FALSE; + return false; } else if (!X1) { SDL_InvalidParamError("X1"); - return SDL_FALSE; + return false; } else if (!Y1) { SDL_InvalidParamError("Y1"); - return SDL_FALSE; + return false; } else if (!X2) { SDL_InvalidParamError("X2"); - return SDL_FALSE; + return false; } else if (!Y2) { SDL_InvalidParamError("Y2"); - return SDL_FALSE; + return false; } else if (SDL_RECTEMPTY(rect)) { - return SDL_FALSE; // Special case for empty rect + return false; // Special case for empty rect } x1 = *X1; @@ -356,13 +354,13 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY // Check to see if entire line is inside rect if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 && y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) { - return SDL_TRUE; + return true; } // Check to see if entire line is to one side of rect if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) || (y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) { - return SDL_FALSE; + return false; } if (y1 == y2) { // Horizontal line, easy to clip @@ -376,7 +374,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY } else if (x2 > rectx2) { *X2 = rectx2; } - return SDL_TRUE; + return true; } if (x1 == x2) { // Vertical line, easy to clip @@ -390,7 +388,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY } else if (y2 > recty2) { *Y2 = recty2; } - return SDL_TRUE; + return true; } // More complicated Cohen-Sutherland algorithm @@ -398,7 +396,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY outcode2 = COMPUTEOUTCODE(rect, x2, y2); while (outcode1 || outcode2) { if (outcode1 & outcode2) { - return SDL_FALSE; + return false; } if (outcode1) { @@ -449,7 +447,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY *Y1 = y1; *X2 = x2; *Y2 = y2; - return SDL_TRUE; + return true; } #undef RECTTYPE diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 5e3a2b9c47..bbb5b6b4e1 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -39,7 +39,7 @@ SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32); // Public routines -SDL_bool SDL_SurfaceValid(SDL_Surface *surface) +bool SDL_SurfaceValid(SDL_Surface *surface) { return surface && surface->internal; } @@ -59,7 +59,7 @@ void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface) * * for FOURCC, use SDL_CalculateYUVSize() */ -static int SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size_t *size, size_t *pitch, SDL_bool minimal) +static int SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size_t *size, size_t *pitch, bool minimal) { if (SDL_BITSPERPIXEL(format) >= 8) { if (SDL_size_mul_overflow(width, SDL_BYTESPERPIXEL(format), pitch)) { @@ -89,7 +89,7 @@ static int SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size return 0; } -int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch) +int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, bool minimalPitch) { size_t p = 0, sz = 0; @@ -124,7 +124,7 @@ int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size return 0; } -static SDL_Surface *SDL_InitializeSurface(SDL_InternalSurface *mem, int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, SDL_PropertiesID props, void *pixels, int pitch, SDL_bool onstack) +static SDL_Surface *SDL_InitializeSurface(SDL_InternalSurface *mem, int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, SDL_PropertiesID props, void *pixels, int pitch, bool onstack) { SDL_Surface *surface = &mem->surface; @@ -199,7 +199,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format) return NULL; } - if (SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, SDL_FALSE /* not minimal pitch */) < 0) { + if (SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, false /* not minimal pitch */) < 0) { // Overflow... return NULL; } @@ -210,7 +210,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format) return NULL; } - surface = SDL_InitializeSurface(mem, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, NULL, (int)pitch, SDL_FALSE); + surface = SDL_InitializeSurface(mem, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, NULL, (int)pitch, false); if (surface) { if (surface->w && surface->h) { surface->flags &= ~SDL_SURFACE_PREALLOCATED; @@ -251,7 +251,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format } else { size_t minimalPitch; - if (SDL_CalculateSurfaceSize(format, width, height, NULL, &minimalPitch, SDL_TRUE /* minimal pitch */) < 0) { + if (SDL_CalculateSurfaceSize(format, width, height, NULL, &minimalPitch, true /* minimal pitch */) < 0) { // Overflow... return NULL; } @@ -268,7 +268,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format return NULL; } - return SDL_InitializeSurface(mem, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, pixels, pitch, SDL_FALSE); + return SDL_InitializeSurface(mem, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, pixels, pitch, false); } SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface) @@ -460,7 +460,7 @@ int SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image) SDL_bool SDL_SurfaceHasAlternateImages(SDL_Surface *surface) { if (!SDL_SurfaceValid(surface)) { - return SDL_FALSE; + return false; } return (surface->internal->num_images > 0); @@ -604,14 +604,14 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, SDL_bool enabled) SDL_bool SDL_SurfaceHasRLE(SDL_Surface *surface) { if (!SDL_SurfaceValid(surface)) { - return SDL_FALSE; + return false; } if (!(surface->internal->map.info.flags & SDL_COPY_RLE_DESIRED)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } int SDL_SetSurfaceColorKey(SDL_Surface *surface, SDL_bool enabled, Uint32 key) @@ -643,14 +643,14 @@ int SDL_SetSurfaceColorKey(SDL_Surface *surface, SDL_bool enabled, Uint32 key) SDL_bool SDL_SurfaceHasColorKey(SDL_Surface *surface) { if (!SDL_SurfaceValid(surface)) { - return SDL_FALSE; + return false; } if (!(surface->internal->map.info.flags & SDL_COPY_COLORKEY)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } int SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key) @@ -675,7 +675,7 @@ int SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key) /* This is a fairly slow function to switch from colorkey to alpha NB: it doesn't handle bpp 1 or 3, because they have no alpha channel */ -static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alpha) +static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, bool ignore_alpha) { int x, y, bpp; @@ -760,7 +760,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp SDL_UnlockSurface(surface); - SDL_SetSurfaceColorKey(surface, 0, 0); + SDL_SetSurfaceColorKey(surface, false, 0); SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); } @@ -946,7 +946,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) // Don't do anything if there's no surface to act on if (!SDL_SurfaceValid(surface)) { - return SDL_FALSE; + return false; } // Set up the full surface rectangle @@ -958,7 +958,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) // Set the clipping rectangle if (!rect) { surface->internal->clip_rect = full_rect; - return SDL_TRUE; + return true; } return SDL_GetRectIntersection(rect, &full_rect, &surface->internal->clip_rect); } @@ -1030,7 +1030,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, // clip the source rectangle to the source surface if (srcrect) { SDL_Rect tmp; - if (SDL_GetRectIntersection(srcrect, &r_src, &tmp) == SDL_FALSE) { + if (SDL_GetRectIntersection(srcrect, &r_src, &tmp) == false) { return 0; } @@ -1049,7 +1049,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, // clip the destination rectangle against the clip rectangle { SDL_Rect tmp; - if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &tmp) == SDL_FALSE) { + if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &tmp) == false) { return 0; } @@ -1397,7 +1397,7 @@ int SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface // clip the source rectangle to the source surface if (srcrect) { - if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == SDL_FALSE) { + if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == false) { return 0; } @@ -1406,7 +1406,7 @@ int SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface // clip the destination rectangle against the clip rectangle { - if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == SDL_FALSE) { + if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == false) { return 0; } @@ -1506,7 +1506,7 @@ int SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, flo // clip the source rectangle to the source surface if (srcrect) { - if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == SDL_FALSE) { + if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == false) { return 0; } @@ -1515,7 +1515,7 @@ int SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, flo // clip the destination rectangle against the clip rectangle { - if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == SDL_FALSE) { + if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &r_dst) == false) { return 0; } @@ -1733,7 +1733,7 @@ int SDL_LockSurface(SDL_Surface *surface) #if SDL_HAVE_RLE // Perform the lock if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - SDL_UnRLESurface(surface, SDL_TRUE); + SDL_UnRLESurface(surface, true); surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL; // save accel'd state } #endif @@ -1774,7 +1774,7 @@ void SDL_UnlockSurface(SDL_Surface *surface) static int SDL_FlipSurfaceHorizontal(SDL_Surface *surface) { - SDL_bool isstack; + bool isstack; Uint8 *row, *a, *b, *tmp; int i, j, bpp; @@ -1812,7 +1812,7 @@ static int SDL_FlipSurfaceHorizontal(SDL_Surface *surface) static int SDL_FlipSurfaceVertical(SDL_Surface *surface) { - SDL_bool isstack; + bool isstack; Uint8 *a, *b, *tmp; int i; @@ -1863,7 +1863,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm SDL_Color copy_color; SDL_Rect bounds; int ret; - SDL_bool palette_ck_transform = SDL_FALSE; + bool palette_ck_transform = false; Uint8 palette_ck_value = 0; Uint8 *palette_saved_alpha = NULL; int palette_saved_alpha_ncolors = 0; @@ -1950,14 +1950,14 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm * Destination format has alpha. * -> set alpha channel to be opaque */ if (surface->internal->palette && SDL_ISPIXELFORMAT_ALPHA(format)) { - SDL_bool set_opaque = SDL_FALSE; + bool set_opaque = false; - SDL_bool is_opaque, has_alpha_channel; + bool is_opaque, has_alpha_channel; SDL_DetectPalette(surface->internal->palette, &is_opaque, &has_alpha_channel); if (is_opaque) { if (!has_alpha_channel) { - set_opaque = SDL_TRUE; + set_opaque = true; } } @@ -1978,7 +1978,7 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm // Transform colorkey to alpha. for cases where source palette has duplicate values, and colorkey is one of them if (copy_flags & SDL_COPY_COLORKEY) { if (surface->internal->palette && !palette) { - palette_ck_transform = SDL_TRUE; + palette_ck_transform = true; palette_ck_value = surface->internal->palette->colors[surface->internal->map.info.colorkey].a; surface->internal->palette->colors[surface->internal->map.info.colorkey].a = SDL_ALPHA_TRANSPARENT; } @@ -2022,8 +2022,8 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm } if (copy_flags & SDL_COPY_COLORKEY) { - SDL_bool set_colorkey_by_color = SDL_FALSE; - SDL_bool convert_colorkey = SDL_TRUE; + bool set_colorkey_by_color = false; + bool convert_colorkey = true; if (surface->internal->palette) { if (palette && @@ -2031,20 +2031,20 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm (SDL_memcmp(surface->internal->palette->colors, palette->colors, surface->internal->palette->ncolors * sizeof(SDL_Color)) == 0)) { // The palette is identical, just set the same colorkey - SDL_SetSurfaceColorKey(convert, 1, surface->internal->map.info.colorkey); + SDL_SetSurfaceColorKey(convert, true, surface->internal->map.info.colorkey); } else if (!palette) { if (SDL_ISPIXELFORMAT_ALPHA(format)) { // No need to add the colorkey, transparency is in the alpha channel } else { // Only set the colorkey information - set_colorkey_by_color = SDL_TRUE; - convert_colorkey = SDL_FALSE; + set_colorkey_by_color = true; + convert_colorkey = false; } } else { - set_colorkey_by_color = SDL_TRUE; + set_colorkey_by_color = true; } } else { - set_colorkey_by_color = SDL_TRUE; + set_colorkey_by_color = true; } if (set_colorkey_by_color) { @@ -2081,11 +2081,11 @@ SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelForm SDL_DestroySurface(tmp2); // Set the converted colorkey on the new surface - SDL_SetSurfaceColorKey(convert, 1, converted_colorkey); + SDL_SetSurfaceColorKey(convert, true, converted_colorkey); // This is needed when converting for 3D texture upload if (convert_colorkey) { - SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE); + SDL_ConvertColorkeyToAlpha(convert, true); } } } @@ -2104,7 +2104,7 @@ end: SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND); } if (copy_flags & SDL_COPY_RLE_DESIRED) { - SDL_SetSurfaceRLE(convert, SDL_TRUE); + SDL_SetSurfaceRLE(convert, true); } // Copy alternate images @@ -2306,13 +2306,13 @@ int SDL_ConvertPixelsAndColorspace(int width, int height, return 0; } - src_surface = SDL_InitializeSurface(&src_data, width, height, src_format, src_colorspace, src_properties, nonconst_src, src_pitch, SDL_TRUE); + src_surface = SDL_InitializeSurface(&src_data, width, height, src_format, src_colorspace, src_properties, nonconst_src, src_pitch, true); if (!src_surface) { return -1; } SDL_SetSurfaceBlendMode(src_surface, SDL_BLENDMODE_NONE); - dst_surface = SDL_InitializeSurface(&dst_data, width, height, dst_format, dst_colorspace, dst_properties, dst, dst_pitch, SDL_TRUE); + dst_surface = SDL_InitializeSurface(&dst_data, width, height, dst_format, dst_colorspace, dst_properties, dst, dst_pitch, true); if (!dst_surface) { return -1; } @@ -2438,7 +2438,7 @@ static void SDL_PremultiplyAlpha_AXYZ128(int width, int height, const void *src, } } -static int SDL_PremultiplyAlphaPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch, SDL_bool linear) +static int SDL_PremultiplyAlphaPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch, bool linear) { SDL_Surface *convert = NULL; void *final_dst = dst; @@ -2968,7 +2968,7 @@ void SDL_DestroySurface(SDL_Surface *surface) } #if SDL_HAVE_RLE if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { - SDL_UnRLESurface(surface, SDL_FALSE); + SDL_UnRLESurface(surface, false); } #endif SDL_SetSurfacePalette(surface, NULL); diff --git a/src/video/SDL_surface_c.h b/src/video/SDL_surface_c.h index 3980095c61..3c4e4f9c07 100644 --- a/src/video/SDL_surface_c.h +++ b/src/video/SDL_surface_c.h @@ -74,7 +74,7 @@ typedef struct SDL_InternalSurface } SDL_InternalSurface; // Surface functions -extern SDL_bool SDL_SurfaceValid(SDL_Surface *surface); +extern bool SDL_SurfaceValid(SDL_Surface *surface); extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface); extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace); extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace); diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 05917319a9..ff17d2b7c5 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -55,8 +55,8 @@ struct SDL_Window SDL_WindowFlags flags; SDL_WindowFlags pending_flags; float display_scale; - SDL_bool external_graphics_context; - SDL_bool fullscreen_exclusive; // The window is currently fullscreen exclusive + bool external_graphics_context; + bool fullscreen_exclusive; // The window is currently fullscreen exclusive SDL_DisplayID last_fullscreen_exclusive_display; // The last fullscreen_exclusive display SDL_DisplayID last_displayID; @@ -79,11 +79,11 @@ struct SDL_Window /* Toggle for drivers to indicate that the current window state is tiled, * and sizes set non-programmatically shouldn't be cached. */ - SDL_bool tiled; + bool tiled; // Whether or not the initial position was defined - SDL_bool undefined_x; - SDL_bool undefined_y; + bool undefined_x; + bool undefined_y; SDL_DisplayMode requested_fullscreen_mode; SDL_DisplayMode current_fullscreen_mode; @@ -92,13 +92,13 @@ struct SDL_Window float opacity; SDL_Surface *surface; - SDL_bool surface_valid; + bool surface_valid; - SDL_bool is_repositioning; // Set during an SDL_SetWindowPosition() call. - SDL_bool is_hiding; - SDL_bool restore_on_show; // Child was hidden recursively by the parent, restore when shown. - SDL_bool is_destroying; - SDL_bool is_dropping; // drag/drop in progress, expecting SDL_SendDropComplete(). + bool is_repositioning; // Set during an SDL_SetWindowPosition() call. + bool is_hiding; + bool restore_on_show; // Child was hidden recursively by the parent, restore when shown. + bool is_destroying; + bool is_dropping; // drag/drop in progress, expecting SDL_SendDropComplete(). int safe_inset_left; int safe_inset_right; @@ -107,7 +107,7 @@ struct SDL_Window SDL_Rect safe_rect; SDL_PropertiesID text_input_props; - SDL_bool text_input_active; + bool text_input_active; SDL_Rect text_input_rect; int text_input_cursor; @@ -264,15 +264,15 @@ struct SDL_VideoDevice void (*MaximizeWindow)(SDL_VideoDevice *_this, SDL_Window *window); void (*MinimizeWindow)(SDL_VideoDevice *_this, SDL_Window *window); void (*RestoreWindow)(SDL_VideoDevice *_this, SDL_Window *window); - void (*SetWindowBordered)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); - void (*SetWindowResizable)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); - void (*SetWindowAlwaysOnTop)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top); + void (*SetWindowBordered)(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); + void (*SetWindowResizable)(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); + void (*SetWindowAlwaysOnTop)(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); int (*SetWindowFullscreen)(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); void *(*GetWindowICCProfile)(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); SDL_DisplayID (*GetDisplayForWindow)(SDL_VideoDevice *_this, SDL_Window *window); int (*SetWindowMouseRect)(SDL_VideoDevice *_this, SDL_Window *window); - int (*SetWindowMouseGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); - int (*SetWindowKeyboardGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); + int (*SetWindowMouseGrab)(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); + int (*SetWindowKeyboardGrab)(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); void (*DestroyWindow)(SDL_VideoDevice *_this, SDL_Window *window); int (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); int (*SetWindowFramebufferVSync)(SDL_VideoDevice *_this, SDL_Window *window, int vsync); @@ -282,7 +282,7 @@ struct SDL_VideoDevice void (*OnWindowEnter)(SDL_VideoDevice *_this, SDL_Window *window); int (*UpdateWindowShape)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); int (*FlashWindow)(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); - int (*SetWindowFocusable)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable); + int (*SetWindowFocusable)(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); int (*SyncWindow)(SDL_VideoDevice *_this, SDL_Window *window); /* * * */ @@ -310,7 +310,7 @@ struct SDL_VideoDevice char const* const* (*Vulkan_GetInstanceExtensions)(SDL_VideoDevice *_this, Uint32 *count); int (*Vulkan_CreateSurface)(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface); void (*Vulkan_DestroySurface)(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); - SDL_bool (*Vulkan_GetPresentationSupport)(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); + bool (*Vulkan_GetPresentationSupport)(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); /* * * */ /* @@ -338,33 +338,33 @@ struct SDL_VideoDevice int (*ClearComposition)(SDL_VideoDevice *_this, SDL_Window *window); // Screen keyboard - SDL_bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this); + bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this); void (*ShowScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void (*HideScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window); - SDL_bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window); // Clipboard const char **(*GetTextMimeTypes)(SDL_VideoDevice *_this, size_t *num_mime_types); int (*SetClipboardData)(SDL_VideoDevice *_this); void *(*GetClipboardData)(SDL_VideoDevice *_this, const char *mime_type, size_t *size); - SDL_bool (*HasClipboardData)(SDL_VideoDevice *_this, const char *mime_type); + bool (*HasClipboardData)(SDL_VideoDevice *_this, const char *mime_type); /* If you implement *ClipboardData, you don't need to implement *ClipboardText */ int (*SetClipboardText)(SDL_VideoDevice *_this, const char *text); char *(*GetClipboardText)(SDL_VideoDevice *_this); - SDL_bool (*HasClipboardText)(SDL_VideoDevice *_this); + bool (*HasClipboardText)(SDL_VideoDevice *_this); // These functions are only needed if the platform has a separate primary selection buffer int (*SetPrimarySelectionText)(SDL_VideoDevice *_this, const char *text); char *(*GetPrimarySelectionText)(SDL_VideoDevice *_this); - SDL_bool (*HasPrimarySelectionText)(SDL_VideoDevice *_this); + bool (*HasPrimarySelectionText)(SDL_VideoDevice *_this); // MessageBox int (*ShowMessageBox)(SDL_VideoDevice *_this, const SDL_MessageBoxData *messageboxdata, int *buttonID); // Hit-testing - int (*SetWindowHitTest)(SDL_Window *window, SDL_bool enabled); + int (*SetWindowHitTest)(SDL_Window *window, bool enabled); // Tell window that app enabled drag'n'drop events - void (*AcceptDragAndDrop)(SDL_Window *window, SDL_bool accept); + void (*AcceptDragAndDrop)(SDL_Window *window, bool accept); // Display the system-level window menu void (*ShowWindowSystemMenu)(SDL_Window *window, int x, int y); @@ -372,9 +372,9 @@ struct SDL_VideoDevice /* * * */ // Data common to all drivers SDL_ThreadID thread; - SDL_bool checked_texture_framebuffer; - SDL_bool is_dummy; - SDL_bool suspend_screensaver; + bool checked_texture_framebuffer; + bool is_dummy; + bool suspend_screensaver; SDL_Window *wakeup_window; SDL_Mutex *wakeup_lock; // Initialized only if WaitEventTimeout/SendWakeupEvent are supported int num_displays; @@ -389,7 +389,7 @@ struct SDL_VideoDevice char **clipboard_mime_types; size_t num_clipboard_mime_types; char *primary_selection_text; - SDL_bool setting_display_mode; + bool setting_display_mode; Uint32 device_caps; SDL_SystemTheme system_theme; @@ -447,7 +447,7 @@ struct SDL_VideoDevice /* Flag that stores whether it's allowed to call SDL_GL_MakeCurrent() * with a NULL window, but a non-NULL context. (Not allowed in most cases, * except on EGL under some circumstances.) */ - SDL_bool gl_allow_no_surface; + bool gl_allow_no_surface; /* * * */ // Data used by the Vulkan drivers @@ -512,13 +512,13 @@ extern VideoBootStrap NGAGE_bootstrap; extern VideoBootStrap QNX_bootstrap; // Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work -extern SDL_bool SDL_OnVideoThread(void); +extern bool SDL_OnVideoThread(void); extern SDL_VideoDevice *SDL_GetVideoDevice(void); extern void SDL_SetSystemTheme(SDL_SystemTheme theme); extern SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode); -extern SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event); -extern void SDL_DelVideoDisplay(SDL_DisplayID display, SDL_bool send_event); -extern SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, bool send_event); +extern void SDL_DelVideoDisplay(SDL_DisplayID display, bool send_event); +extern bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); extern void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display); extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); @@ -533,13 +533,13 @@ extern int SDL_GetDisplayIndex(SDL_DisplayID displayID); extern SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID display); extern SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window); extern int SDL_GetMessageBoxCount(void); -extern void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, SDL_bool send_event); +extern void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, bool send_event); extern void SDL_SetWindowSafeAreaInsets(SDL_Window *window, int left, int right, int top, int bottom); extern void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor); extern int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags); -extern SDL_bool SDL_HasWindows(void); +extern bool SDL_HasWindows(void); extern void SDL_RelativeToGlobalForWindow(SDL_Window *window, int rel_x, int rel_y, int *abs_x, int *abs_y); extern void SDL_GlobalToRelativeForWindow(SDL_Window *window, int abs_x, int abs_y, int *rel_x, int *rel_y); @@ -560,16 +560,16 @@ extern void SDL_OnWindowFocusGained(SDL_Window *window); extern void SDL_OnWindowFocusLost(SDL_Window *window); extern void SDL_OnWindowDisplayChanged(SDL_Window *window); extern void SDL_UpdateWindowGrab(SDL_Window *window); -extern int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SDL_bool commit); +extern int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit); extern SDL_Window *SDL_GetToplevelForKeyboardFocus(void); -extern SDL_bool SDL_ShouldAllowTopmost(void); +extern bool SDL_ShouldAllowTopmost(void); extern void SDL_ToggleDragAndDropSupport(void); extern SDL_TextInputType SDL_GetTextInputType(SDL_PropertiesID props); extern SDL_Capitalization SDL_GetTextInputCapitalization(SDL_PropertiesID props); -extern SDL_bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props); -extern SDL_bool SDL_GetTextInputMultiline(SDL_PropertiesID props); +extern bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props); +extern bool SDL_GetTextInputMultiline(SDL_PropertiesID props); #endif // SDL_sysvideo_h_ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 64e52f7297..93666fb0db 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -162,8 +162,8 @@ static VideoBootStrap *bootstrap[] = { #if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) // Support for macOS fullscreen spaces -extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window); -extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_bool blocking); +extern bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window); +extern bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking); #endif static void SDL_CheckWindowDisplayChanged(SDL_Window *window); @@ -171,45 +171,45 @@ static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window); static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window); // Convenience functions for reading driver flags -static SDL_bool SDL_ModeSwitchingEmulated(SDL_VideoDevice *_this) +static bool SDL_ModeSwitchingEmulated(SDL_VideoDevice *_this) { if (_this->device_caps & VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool SDL_SendsFullscreenDimensions(SDL_VideoDevice *_this) +static bool SDL_SendsFullscreenDimensions(SDL_VideoDevice *_this) { return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS); } -static SDL_bool IsFullscreenOnly(SDL_VideoDevice *_this) +static bool IsFullscreenOnly(SDL_VideoDevice *_this) { return !!(_this->device_caps & VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY); } -static SDL_bool SDL_SendsDisplayChanges(SDL_VideoDevice *_this) +static bool SDL_SendsDisplayChanges(SDL_VideoDevice *_this) { return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES); } -static SDL_bool SDL_DisableMouseWarpOnFullscreenTransitions(SDL_VideoDevice *_this) +static bool SDL_DisableMouseWarpOnFullscreenTransitions(SDL_VideoDevice *_this) { return !!(_this->device_caps & VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS); } -static SDL_bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this) +static bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this) { return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES); } // Hint to treat all window ops as synchronous -static SDL_bool syncHint; +static bool syncHint; static void SDL_SyncHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue) { - syncHint = SDL_GetStringBoolean(newValue, SDL_FALSE); + syncHint = SDL_GetStringBoolean(newValue, false); } static void SDL_SyncIfRequired(SDL_Window *window) @@ -292,7 +292,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S { SDL_PropertiesID props = SDL_GetWindowProperties(window); SDL_WindowTextureData *data = (SDL_WindowTextureData *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL); - const SDL_bool transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE; + const bool transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; int i; int w, h; const SDL_PixelFormat *texture_formats; @@ -529,10 +529,10 @@ int SDL_GetNumVideoDrivers(void) // Build a list of unique video drivers. for (int i = 0; bootstrap[i] != NULL; ++i) { - SDL_bool duplicate = SDL_FALSE; + bool duplicate = false; for (int j = 0; j < i; ++j) { if (SDL_strcmp(bootstrap[i]->name, bootstrap[j]->name) == 0) { - duplicate = SDL_TRUE; + duplicate = true; break; } } @@ -559,11 +559,11 @@ const char *SDL_GetVideoDriver(int index) int SDL_VideoInit(const char *driver_name) { SDL_VideoDevice *video; - SDL_bool init_events = SDL_FALSE; - SDL_bool init_keyboard = SDL_FALSE; - SDL_bool init_mouse = SDL_FALSE; - SDL_bool init_touch = SDL_FALSE; - SDL_bool init_pen = SDL_FALSE; + bool init_events = false; + bool init_keyboard = false; + bool init_mouse = false; + bool init_touch = false; + bool init_pen = false; int i = 0; // Check to make sure we don't overwrite '_this' @@ -577,23 +577,23 @@ int SDL_VideoInit(const char *driver_name) if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { goto pre_driver_error; } - init_events = SDL_TRUE; + init_events = true; if (SDL_InitKeyboard() < 0) { goto pre_driver_error; } - init_keyboard = SDL_TRUE; + init_keyboard = true; if (SDL_PreInitMouse() < 0) { goto pre_driver_error; } - init_mouse = SDL_TRUE; + init_mouse = true; if (SDL_InitTouch() < 0) { goto pre_driver_error; } - init_touch = SDL_TRUE; + init_touch = true; if (SDL_InitPen() < 0) { goto pre_driver_error; } - init_pen = SDL_TRUE; + init_pen = true; // Select the proper video driver video = NULL; @@ -667,7 +667,7 @@ int SDL_VideoInit(const char *driver_name) joystick, or passively watching a movie. Things that use SDL but function more like a normal desktop app should explicitly reenable the screensaver. */ - if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, false)) { SDL_DisableScreenSaver(); } @@ -710,7 +710,7 @@ SDL_VideoDevice *SDL_GetVideoDevice(void) return _this; } -SDL_bool SDL_OnVideoThread(void) +bool SDL_OnVideoThread(void) { return (_this && SDL_GetCurrentThreadID() == _this->thread); } @@ -780,10 +780,10 @@ SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode) if (desktop_mode) { SDL_memcpy(&display.desktop_mode, desktop_mode, sizeof(display.desktop_mode)); } - return SDL_AddVideoDisplay(&display, SDL_FALSE); + return SDL_AddVideoDisplay(&display, false); } -SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event) +SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, bool send_event) { SDL_VideoDisplay **displays, *new_display; SDL_DisplayID id; @@ -857,7 +857,7 @@ void SDL_OnDisplayMoved(SDL_VideoDisplay *display) SDL_UpdateDesktopBounds(); } -void SDL_DelVideoDisplay(SDL_DisplayID displayID, SDL_bool send_event) +void SDL_DelVideoDisplay(SDL_DisplayID displayID, bool send_event) { SDL_VideoDisplay *display; int display_index = SDL_GetDisplayIndex(displayID); @@ -1109,7 +1109,7 @@ float SDL_GetDisplayContentScale(SDL_DisplayID displayID) return display->content_scale; } -void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, SDL_bool send_event) +void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, bool send_event) { if (window->HDR.HDR_headroom != HDR->HDR_headroom || window->HDR.SDR_white_level != window->HDR.SDR_white_level) { SDL_PropertiesID window_props = SDL_GetWindowProperties(window); @@ -1127,22 +1127,22 @@ void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputPropertie void SDL_SetDisplayHDRProperties(SDL_VideoDisplay *display, const SDL_HDROutputProperties *HDR) { - SDL_bool changed = SDL_FALSE; + bool changed = false; if (HDR->SDR_white_level != display->HDR.SDR_white_level) { display->HDR.SDR_white_level = SDL_max(HDR->SDR_white_level, 1.0f); - changed = SDL_TRUE; + changed = true; } if (HDR->HDR_headroom != display->HDR.HDR_headroom) { display->HDR.HDR_headroom = SDL_max(HDR->HDR_headroom, 1.0f); - changed = SDL_TRUE; + changed = true; } SDL_copyp(&display->HDR, HDR); if (changed && !SDL_DriverSendsHDRChanges(_this)) { for (SDL_Window *w = display->device->windows; w; w = w->next) { if (SDL_GetDisplayForWindow(w) == display->id) { - SDL_SetWindowHDRProperties(w, &display->HDR, SDL_TRUE); + SDL_SetWindowHDRProperties(w, &display->HDR, true); } } } @@ -1201,7 +1201,7 @@ static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode * return mode; } -SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) +bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { SDL_DisplayMode *modes; SDL_DisplayMode new_mode; @@ -1217,7 +1217,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ nmodes = display->num_fullscreen_modes; for (i = 0; i < nmodes; ++i) { if (cmpmodes(&new_mode, &modes[i]) == 0) { - return SDL_FALSE; + return false; } } @@ -1225,7 +1225,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ if (nmodes == display->max_fullscreen_modes) { modes = (SDL_DisplayMode *)SDL_malloc((display->max_fullscreen_modes + 32) * sizeof(*modes)); if (!modes) { - return SDL_FALSE; + return false; } if (display->fullscreen_modes) { @@ -1249,7 +1249,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ SDL_qsort(display->fullscreen_modes, display->num_fullscreen_modes, sizeof(SDL_DisplayMode), cmpmodes); - return SDL_TRUE; + return true; } void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display) @@ -1370,7 +1370,7 @@ int SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, f return 0; } -static SDL_bool DisplayModeChanged(const SDL_DisplayMode *old, const SDL_DisplayMode *new) +static bool DisplayModeChanged(const SDL_DisplayMode *old, const SDL_DisplayMode *new) { return ((old->displayID && old->displayID != new->displayID) || (old->format && old->format != new->format) || @@ -1460,9 +1460,9 @@ int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mod if (_this->SetDisplayMode) { int result; - _this->setting_display_mode = SDL_TRUE; + _this->setting_display_mode = true; result = _this->SetDisplayMode(_this, display, mode); - _this->setting_display_mode = SDL_FALSE; + _this->setting_display_mode = false; if (result < 0) { return -1; } @@ -1758,17 +1758,17 @@ static void SDL_RestoreMousePosition(SDL_Window *window) SDL_Mouse *mouse = SDL_GetMouse(); if (window == SDL_GetMouseFocus()) { - const SDL_bool prev_warp_val = mouse->warp_emulation_prohibited; + const bool prev_warp_val = mouse->warp_emulation_prohibited; SDL_GetMouseState(&x, &y); // Disable the warp emulation so it isn't accidentally activated on a fullscreen transitions. - mouse->warp_emulation_prohibited = SDL_TRUE; + mouse->warp_emulation_prohibited = true; SDL_WarpMouseInWindow(window, x, y); mouse->warp_emulation_prohibited = prev_warp_val; } } -int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SDL_bool commit) +int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit) { SDL_VideoDisplay *display = NULL; SDL_DisplayMode *mode = NULL; @@ -1776,11 +1776,11 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD CHECK_WINDOW_MAGIC(window, -1); - window->fullscreen_exclusive = SDL_FALSE; + window->fullscreen_exclusive = false; // If we are in the process of hiding don't go back to fullscreen if (window->is_destroying || window->is_hiding) { - fullscreen = SDL_FALSE; + fullscreen = false; } // Get the correct display for this operation @@ -1806,7 +1806,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (fullscreen) { mode = (SDL_DisplayMode *)SDL_GetWindowFullscreenMode(window); if (mode) { - window->fullscreen_exclusive = SDL_TRUE; + window->fullscreen_exclusive = true; } else { // Make sure the current mode is zeroed for fullscreen desktop. SDL_zero(window->current_fullscreen_mode); @@ -1819,7 +1819,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD */ if (SDL_strcmp(_this->name, "cocoa") == 0) { // don't do this for X11, etc if (window->is_destroying && !window->last_fullscreen_exclusive_display) { - window->fullscreen_exclusive = SDL_FALSE; + window->fullscreen_exclusive = false; if (display) { display->fullscreen_window = NULL; } @@ -1828,7 +1828,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (commit) { // If we're switching between a fullscreen Space and exclusive fullscreen, we need to get back to normal first. if (fullscreen && Cocoa_IsWindowInFullscreenSpace(window) && !window->last_fullscreen_exclusive_display && window->fullscreen_exclusive) { - if (!Cocoa_SetWindowFullscreenSpace(window, SDL_FALSE, SDL_TRUE)) { + if (!Cocoa_SetWindowFullscreenSpace(window, false, true)) { goto error; } } else if (fullscreen && window->last_fullscreen_exclusive_display && !window->fullscreen_exclusive) { @@ -1837,7 +1837,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (last_display->fullscreen_window == window) { SDL_SetDisplayModeForDisplay(last_display, NULL); if (_this->SetWindowFullscreen) { - _this->SetWindowFullscreen(_this, window, last_display, SDL_FALSE); + _this->SetWindowFullscreen(_this, window, last_display, false); } last_display->fullscreen_window = NULL; } @@ -1893,7 +1893,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (fullscreen) { int mode_w = 0, mode_h = 0; - SDL_bool resized = SDL_FALSE; + bool resized = false; // Hide any other fullscreen window on this display if (display->fullscreen_window && @@ -1909,7 +1909,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD if (_this->SetWindowFullscreen) { ret = _this->SetWindowFullscreen(_this, window, display, fullscreen); } else { - resized = SDL_TRUE; + resized = true; } if (ret == 0) { @@ -1942,7 +1942,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } if (window->w != mode_w || window->h != mode_h) { - resized = SDL_TRUE; + resized = true; } if (resized) { @@ -1958,7 +1958,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD } } } else { - SDL_bool resized = SDL_FALSE; + bool resized = false; // Restore the desktop mode if (display) { @@ -1972,7 +1972,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, SD ret = _this->SetWindowFullscreen(_this, window, full_screen_display, SDL_FULLSCREEN_OP_LEAVE); } } else { - resized = SDL_TRUE; + resized = true; } if (ret == 0) { @@ -2038,7 +2038,7 @@ int SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode) */ SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) { - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, SDL_TRUE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); SDL_SyncIfRequired(window); } @@ -2085,12 +2085,12 @@ SDL_PixelFormat SDL_GetWindowPixelFormat(SDL_Window *window) #define CREATE_FLAGS \ (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED | SDL_WINDOW_METAL | SDL_WINDOW_TRANSPARENT | SDL_WINDOW_NOT_FOCUSABLE) -static SDL_INLINE SDL_bool IsAcceptingDragAndDrop(void) +static SDL_INLINE bool IsAcceptingDragAndDrop(void) { if (SDL_EventEnabled(SDL_EVENT_DROP_FILE) || SDL_EventEnabled(SDL_EVENT_DROP_TEXT)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } // prepare a newly-created window @@ -2105,7 +2105,7 @@ static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window) void SDL_ToggleDragAndDropSupport(void) { if (_this && _this->AcceptDragAndDrop) { - const SDL_bool enable = IsAcceptingDragAndDrop(); + const bool enable = IsAcceptingDragAndDrop(); SDL_Window *window; for (window = _this->windows; window; window = window->next) { _this->AcceptDragAndDrop(window, enable); @@ -2168,10 +2168,10 @@ static void ApplyWindowFlags(SDL_Window *window, SDL_WindowFlags flags) } if (flags & SDL_WINDOW_MOUSE_GRABBED) { - SDL_SetWindowMouseGrab(window, SDL_TRUE); + SDL_SetWindowMouseGrab(window, true); } if (flags & SDL_WINDOW_KEYBOARD_GRABBED) { - SDL_SetWindowKeyboardGrab(window, SDL_TRUE); + SDL_SetWindowKeyboardGrab(window, true); } } } @@ -2207,26 +2207,26 @@ static int SDL_DllNotSupported(const char *name) static struct { const char *property_name; SDL_WindowFlags flag; - SDL_bool invert_value; + bool invert_value; } SDL_WindowFlagProperties[] = { - { SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN, SDL_WINDOW_ALWAYS_ON_TOP, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, SDL_WINDOW_BORDERLESS, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN, SDL_WINDOW_NOT_FOCUSABLE, SDL_TRUE }, - { SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, SDL_WINDOW_FULLSCREEN, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN, SDL_WINDOW_HIDDEN, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, SDL_WINDOW_HIGH_PIXEL_DENSITY, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN, SDL_WINDOW_MAXIMIZED, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN, SDL_WINDOW_POPUP_MENU, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN, SDL_WINDOW_METAL, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN, SDL_WINDOW_MINIMIZED, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN, SDL_WINDOW_MODAL, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN, SDL_WINDOW_MOUSE_GRABBED, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, SDL_WINDOW_OPENGL, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, SDL_WINDOW_RESIZABLE, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN, SDL_WINDOW_TRANSPARENT, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN, SDL_WINDOW_TOOLTIP, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN, SDL_WINDOW_UTILITY, SDL_FALSE }, - { SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN, SDL_WINDOW_VULKAN, SDL_FALSE } + { SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN, SDL_WINDOW_ALWAYS_ON_TOP, false }, + { SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, SDL_WINDOW_BORDERLESS, false }, + { SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN, SDL_WINDOW_NOT_FOCUSABLE, true }, + { SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, SDL_WINDOW_FULLSCREEN, false }, + { SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN, SDL_WINDOW_HIDDEN, false }, + { SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, SDL_WINDOW_HIGH_PIXEL_DENSITY, false }, + { SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN, SDL_WINDOW_MAXIMIZED, false }, + { SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN, SDL_WINDOW_POPUP_MENU, false }, + { SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN, SDL_WINDOW_METAL, false }, + { SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN, SDL_WINDOW_MINIMIZED, false }, + { SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN, SDL_WINDOW_MODAL, false }, + { SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN, SDL_WINDOW_MOUSE_GRABBED, false }, + { SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, SDL_WINDOW_OPENGL, false }, + { SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, SDL_WINDOW_RESIZABLE, false }, + { SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN, SDL_WINDOW_TRANSPARENT, false }, + { SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN, SDL_WINDOW_TOOLTIP, false }, + { SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN, SDL_WINDOW_UTILITY, false }, + { SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN, SDL_WINDOW_VULKAN, false } }; static SDL_WindowFlags SDL_GetWindowFlagProperties(SDL_PropertiesID props) @@ -2236,11 +2236,11 @@ static SDL_WindowFlags SDL_GetWindowFlagProperties(SDL_PropertiesID props) for (i = 0; i < SDL_arraysize(SDL_WindowFlagProperties); ++i) { if (SDL_WindowFlagProperties[i].invert_value) { - if (!SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, SDL_TRUE)) { + if (!SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, true)) { flags |= SDL_WindowFlagProperties[i].flag; } } else { - if (SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, SDL_FALSE)) { + if (SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, false)) { flags |= SDL_WindowFlagProperties[i].flag; } } @@ -2259,9 +2259,9 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) SDL_Window *parent = (SDL_Window *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, NULL); SDL_WindowFlags flags = SDL_GetWindowFlagProperties(props); SDL_WindowFlags type_flags, graphics_flags; - SDL_bool undefined_x = SDL_FALSE; - SDL_bool undefined_y = SDL_FALSE; - SDL_bool external_graphics_context = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, SDL_FALSE); + bool undefined_x = false; + bool undefined_y = false; + bool external_graphics_context = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, false); if (!_this) { // Initialize the video system if needed @@ -2338,13 +2338,13 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) } if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISUNDEFINED(x)) { if (SDL_WINDOWPOS_ISUNDEFINED(x)) { - undefined_x = SDL_TRUE; + undefined_x = true; } x = bounds.x + (bounds.w - w) / 2; } if (SDL_WINDOWPOS_ISCENTERED(y) || SDL_WINDOWPOS_ISUNDEFINED(y)) { if (SDL_WINDOWPOS_ISUNDEFINED(y)) { - undefined_y = SDL_TRUE; + undefined_y = true; } y = bounds.y + (bounds.h - h) / 2; } @@ -2393,7 +2393,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) if (!window) { return NULL; } - SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, SDL_TRUE); + SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, true); window->id = SDL_GetNextObjectID(); window->floating.x = window->windowed.x = window->x = x; window->floating.y = window->windowed.y = window->y = y; @@ -2403,7 +2403,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) window->undefined_y = undefined_y; SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); - SDL_SetWindowHDRProperties(window, &display->HDR, SDL_FALSE); + SDL_SetWindowHDRProperties(window, &display->HDR, false); if (flags & SDL_WINDOW_FULLSCREEN || IsFullscreenOnly(_this)) { SDL_Rect bounds; @@ -2421,7 +2421,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) window->display_scale = 1.0f; window->opacity = 1.0f; window->next = _this->windows; - window->is_destroying = SDL_FALSE; + window->is_destroying = false; window->last_displayID = SDL_GetDisplayForWindow(window); window->external_graphics_context = external_graphics_context; @@ -2516,12 +2516,12 @@ SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) { - SDL_bool loaded_opengl = SDL_FALSE; - SDL_bool need_gl_unload = SDL_FALSE; - SDL_bool need_gl_load = SDL_FALSE; - SDL_bool loaded_vulkan = SDL_FALSE; - SDL_bool need_vulkan_unload = SDL_FALSE; - SDL_bool need_vulkan_load = SDL_FALSE; + bool loaded_opengl = false; + bool need_gl_unload = false; + bool need_gl_load = false; + bool loaded_vulkan = false; + bool need_vulkan_unload = false; + bool need_vulkan_load = false; SDL_WindowFlags graphics_flags; SDL_Window *parent = window->parent; @@ -2555,7 +2555,7 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) // Restore video mode, etc. if (!(window->flags & SDL_WINDOW_EXTERNAL)) { - const SDL_bool restore_on_show = window->restore_on_show; + const bool restore_on_show = window->restore_on_show; SDL_HideWindow(window); window->restore_on_show = restore_on_show; } @@ -2565,24 +2565,24 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { if (flags & SDL_WINDOW_OPENGL) { - need_gl_load = SDL_TRUE; + need_gl_load = true; } else { - need_gl_unload = SDL_TRUE; + need_gl_unload = true; } } else if (window->flags & SDL_WINDOW_OPENGL) { - need_gl_unload = SDL_TRUE; - need_gl_load = SDL_TRUE; + need_gl_unload = true; + need_gl_load = true; } if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) { if (flags & SDL_WINDOW_VULKAN) { - need_vulkan_load = SDL_TRUE; + need_vulkan_load = true; } else { - need_vulkan_unload = SDL_TRUE; + need_vulkan_unload = true; } } else if (window->flags & SDL_WINDOW_VULKAN) { - need_vulkan_unload = SDL_TRUE; - need_vulkan_load = SDL_TRUE; + need_vulkan_unload = true; + need_vulkan_load = true; } if (need_gl_unload) { @@ -2601,18 +2601,18 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) if (SDL_GL_LoadLibrary(NULL) < 0) { return -1; } - loaded_opengl = SDL_TRUE; + loaded_opengl = true; } if (need_vulkan_load) { if (SDL_Vulkan_LoadLibrary(NULL) < 0) { return -1; } - loaded_vulkan = SDL_TRUE; + loaded_vulkan = true; } window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); - window->is_destroying = SDL_FALSE; + window->is_destroying = false; if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_EXTERNAL)) { /* Reset the window size to the original floating value, so the @@ -2665,7 +2665,7 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) } if (window->hit_test) { - _this->SetWindowHitTest(window, SDL_TRUE); + _this->SetWindowHitTest(window, true); } SDL_FinishWindowCreation(window, flags); @@ -2673,7 +2673,7 @@ int SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) return 0; } -SDL_bool SDL_HasWindows(void) +bool SDL_HasWindows(void) { return _this && _this->windows; } @@ -2821,13 +2821,13 @@ int SDL_SetWindowPosition(SDL_Window *window, int x, int y) window->floating.x = x; window->floating.y = y; - window->undefined_x = SDL_FALSE; - window->undefined_y = SDL_FALSE; + window->undefined_x = false; + window->undefined_y = false; if (_this->SetWindowPosition) { - window->is_repositioning = SDL_TRUE; + window->is_repositioning = true; const int ret = _this->SetWindowPosition(_this, window); - window->is_repositioning = SDL_FALSE; + window->is_repositioning = false; if (!ret) { SDL_SyncIfRequired(window); } @@ -2884,8 +2884,8 @@ int SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (bordered != SDL_FALSE); // normalize the flag. - const SDL_bool have = !(window->flags & SDL_WINDOW_BORDERLESS); + const bool want = (bordered != false); // normalize the flag. + const bool have = !(window->flags & SDL_WINDOW_BORDERLESS); if ((want != have) && (_this->SetWindowBordered)) { if (want) { window->flags &= ~SDL_WINDOW_BORDERLESS; @@ -2903,8 +2903,8 @@ int SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (resizable != SDL_FALSE); // normalize the flag. - const SDL_bool have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0); + const bool want = (resizable != false); // normalize the flag. + const bool have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0); if ((want != have) && (_this->SetWindowResizable)) { if (want) { window->flags |= SDL_WINDOW_RESIZABLE; @@ -2923,8 +2923,8 @@ int SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top) CHECK_WINDOW_MAGIC(window, -1); CHECK_WINDOW_NOT_POPUP(window, -1); - const SDL_bool want = (on_top != SDL_FALSE); // normalize the flag. - const SDL_bool have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); + const bool want = (on_top != false); // normalize the flag. + const bool have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); if ((want != have) && (_this->SetWindowAlwaysOnTop)) { if (want) { window->flags |= SDL_WINDOW_ALWAYS_ON_TOP; @@ -3179,7 +3179,7 @@ int SDL_ShowWindow(SDL_Window *window) // If the parent is hidden, set the flag to restore this when the parent is shown if (window->parent && (window->parent->flags & SDL_WINDOW_HIDDEN)) { - window->restore_on_show = SDL_TRUE; + window->restore_on_show = true; return 0; } @@ -3197,7 +3197,7 @@ int SDL_ShowWindow(SDL_Window *window) break; } SDL_ShowWindow(child); - child->restore_on_show = SDL_FALSE; + child->restore_on_show = false; } return 0; } @@ -3208,7 +3208,7 @@ int SDL_HideWindow(SDL_Window *window) CHECK_WINDOW_MAGIC(window, -1); if (window->flags & SDL_WINDOW_HIDDEN) { - window->restore_on_show = SDL_FALSE; + window->restore_on_show = false; return 0; } @@ -3218,20 +3218,20 @@ int SDL_HideWindow(SDL_Window *window) break; } SDL_HideWindow(child); - child->restore_on_show = SDL_TRUE; + child->restore_on_show = true; } // Store the flags for restoration later. window->pending_flags = window->flags; - window->is_hiding = SDL_TRUE; + window->is_hiding = true; if (_this->HideWindow) { _this->HideWindow(_this, window); } else { SDL_SetMouseFocus(NULL); SDL_SetKeyboardFocus(NULL); } - window->is_hiding = SDL_FALSE; + window->is_hiding = false; SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); return 0; } @@ -3331,7 +3331,7 @@ int SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); } - ret = SDL_UpdateFullscreenMode(window, fullscreen ? SDL_FULLSCREEN_OP_ENTER : SDL_FULLSCREEN_OP_LEAVE, SDL_TRUE); + ret = SDL_UpdateFullscreenMode(window, fullscreen ? SDL_FULLSCREEN_OP_ENTER : SDL_FULLSCREEN_OP_LEAVE, true); if (!fullscreen || ret != 0) { // Clear the current fullscreen mode. @@ -3356,23 +3356,23 @@ int SDL_SyncWindow(SDL_Window *window) return 0; } -static SDL_bool ShouldAttemptTextureFramebuffer(void) +static bool ShouldAttemptTextureFramebuffer(void) { const char *hint; - SDL_bool attempt_texture_framebuffer = SDL_TRUE; + bool attempt_texture_framebuffer = true; // The dummy driver never has GPU support, of course. if (_this->is_dummy) { - return SDL_FALSE; + return false; } // See if there's a hint override hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); if (hint && *hint) { if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0 || SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) == 0) { - attempt_texture_framebuffer = SDL_FALSE; + attempt_texture_framebuffer = false; } else { - attempt_texture_framebuffer = SDL_TRUE; + attempt_texture_framebuffer = true; } } else { // Check for platform specific defaults @@ -3381,17 +3381,17 @@ static SDL_bool ShouldAttemptTextureFramebuffer(void) if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { // if either of these exist, we're on WSL. - attempt_texture_framebuffer = SDL_FALSE; + attempt_texture_framebuffer = false; } } #endif #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) // GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) if (_this->CreateWindowFramebuffer && (SDL_strcmp(_this->name, "windows") == 0)) { - attempt_texture_framebuffer = SDL_FALSE; + attempt_texture_framebuffer = false; } #endif #ifdef SDL_PLATFORM_EMSCRIPTEN - attempt_texture_framebuffer = SDL_FALSE; + attempt_texture_framebuffer = false; #endif } return attempt_texture_framebuffer; @@ -3402,7 +3402,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) SDL_PixelFormat format = SDL_PIXELFORMAT_UNKNOWN; void *pixels = NULL; int pitch = 0; - SDL_bool created_framebuffer = SDL_FALSE; + bool created_framebuffer = false; int w, h; SDL_GetWindowSizeInPixels(window, &w, &h); @@ -3427,11 +3427,11 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) _this->GetWindowFramebufferVSync = SDL_GetWindowTextureVSync; _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; - created_framebuffer = SDL_TRUE; + created_framebuffer = true; } } - _this->checked_texture_framebuffer = SDL_TRUE; // don't check this again. + _this->checked_texture_framebuffer = true; // don't check this again. } if (!created_framebuffer) { @@ -3455,9 +3455,9 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) SDL_bool SDL_WindowHasSurface(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); - return window->surface ? SDL_TRUE : SDL_FALSE; + return window->surface ? true : false; } SDL_Surface *SDL_GetWindowSurface(SDL_Window *window) @@ -3473,7 +3473,7 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window) window->surface = SDL_CreateWindowFramebuffer(window); if (window->surface) { - window->surface_valid = SDL_TRUE; + window->surface_valid = true; window->surface->internal->flags |= SDL_INTERNAL_SURFACE_DONTFREE; } } @@ -3535,7 +3535,7 @@ int SDL_DestroyWindowSurface(SDL_Window *window) window->surface->internal->flags &= ~SDL_INTERNAL_SURFACE_DONTFREE; SDL_DestroySurface(window->surface); window->surface = NULL; - window->surface_valid = SDL_FALSE; + window->surface_valid = false; } if (_this->checked_texture_framebuffer) { // never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. @@ -3614,8 +3614,8 @@ int SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable) { CHECK_WINDOW_MAGIC(window, -1); - const SDL_bool want = (focusable != SDL_FALSE); // normalize the flag. - const SDL_bool have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE); + const bool want = (focusable != false); // normalize the flag. + const bool have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE); if ((want != have) && (_this->SetWindowFocusable)) { if (want) { window->flags &= ~SDL_WINDOW_NOT_FOCUSABLE; @@ -3630,23 +3630,23 @@ int SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable) void SDL_UpdateWindowGrab(SDL_Window *window) { - SDL_bool keyboard_grabbed, mouse_grabbed; + bool keyboard_grabbed, mouse_grabbed; if (window->flags & SDL_WINDOW_INPUT_FOCUS) { if (SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) { - mouse_grabbed = SDL_TRUE; + mouse_grabbed = true; } else { - mouse_grabbed = SDL_FALSE; + mouse_grabbed = false; } if (window->flags & SDL_WINDOW_KEYBOARD_GRABBED) { - keyboard_grabbed = SDL_TRUE; + keyboard_grabbed = true; } else { - keyboard_grabbed = SDL_FALSE; + keyboard_grabbed = false; } } else { - mouse_grabbed = SDL_FALSE; - keyboard_grabbed = SDL_FALSE; + mouse_grabbed = false; + keyboard_grabbed = false; } if (mouse_grabbed || keyboard_grabbed) { @@ -3654,10 +3654,10 @@ void SDL_UpdateWindowGrab(SDL_Window *window) // stealing a grab from another window! _this->grabbed_window->flags &= ~(SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED); if (_this->SetWindowMouseGrab) { - _this->SetWindowMouseGrab(_this, _this->grabbed_window, SDL_FALSE); + _this->SetWindowMouseGrab(_this, _this->grabbed_window, false); } if (_this->SetWindowKeyboardGrab) { - _this->SetWindowKeyboardGrab(_this, _this->grabbed_window, SDL_FALSE); + _this->SetWindowKeyboardGrab(_this, _this->grabbed_window, false); } } _this->grabbed_window = window; @@ -3743,13 +3743,13 @@ int SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed) SDL_bool SDL_GetWindowKeyboardGrab(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); return window == _this->grabbed_window && (_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED); } SDL_bool SDL_GetWindowMouseGrab(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); return window == _this->grabbed_window && (_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED); } @@ -3816,12 +3816,12 @@ int SDL_SetWindowRelativeMouseMode(SDL_Window *window, SDL_bool enabled) SDL_bool SDL_GetWindowRelativeMouseMode(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); if (window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE) { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } @@ -3853,7 +3853,7 @@ void SDL_OnWindowHidden(SDL_Window *window) window->pending_flags |= (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)); // The window is already hidden at this point, so just change the mode back if necessary. - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_FALSE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); } void SDL_OnWindowDisplayChanged(SDL_Window *window) @@ -3862,10 +3862,10 @@ void SDL_OnWindowDisplayChanged(SDL_Window *window) SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window); if (window->requested_fullscreen_mode.w != 0 || window->requested_fullscreen_mode.h != 0) { - SDL_bool include_high_density_modes = SDL_FALSE; + bool include_high_density_modes = false; if (window->requested_fullscreen_mode.pixel_density > 1.0f) { - include_high_density_modes = SDL_TRUE; + include_high_density_modes = true; } SDL_GetClosestFullscreenDisplayMode(displayID, window->requested_fullscreen_mode.w, window->requested_fullscreen_mode.h, window->requested_fullscreen_mode.refresh_rate, include_high_density_modes, &window->current_fullscreen_mode); } else { @@ -3873,7 +3873,7 @@ void SDL_OnWindowDisplayChanged(SDL_Window *window) } if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) { - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, SDL_TRUE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); } } @@ -3911,7 +3911,7 @@ void SDL_CheckWindowPixelSizeChanged(SDL_Window *window) void SDL_OnWindowPixelSizeChanged(SDL_Window *window) { - window->surface_valid = SDL_FALSE; + window->surface_valid = false; } static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window) @@ -3959,7 +3959,7 @@ int SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect) void SDL_OnWindowMinimized(SDL_Window *window) { if (window->flags & SDL_WINDOW_FULLSCREEN) { - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_FALSE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); } } @@ -3978,7 +3978,7 @@ void SDL_OnWindowRestored(SDL_Window *window) // SDL_RaiseWindow(window); if (window->flags & SDL_WINDOW_FULLSCREEN) { - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, SDL_FALSE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, false); } } @@ -4000,34 +4000,34 @@ void SDL_OnWindowFocusGained(SDL_Window *window) if (mouse && mouse->relative_mode) { SDL_SetMouseFocus(window); if (mouse->relative_mode_warp) { - SDL_PerformWarpMouseInWindow(window, (float)window->w / 2.0f, (float)window->h / 2.0f, SDL_TRUE); + SDL_PerformWarpMouseInWindow(window, (float)window->w / 2.0f, (float)window->h / 2.0f, true); } } SDL_UpdateWindowGrab(window); } -static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) +static bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) { const char *hint; if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) { - return SDL_FALSE; + return false; } #if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) if (SDL_strcmp(_this->name, "cocoa") == 0) { // don't do this for X11, etc if (Cocoa_IsWindowInFullscreenSpace(window)) { - return SDL_FALSE; + return false; } } #endif #ifdef SDL_PLATFORM_ANDROID { - extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void); + extern bool Android_JNI_ShouldMinimizeOnFocusLoss(void); if (!Android_JNI_ShouldMinimizeOnFocusLoss()) { - return SDL_FALSE; + return false; } } #endif @@ -4036,12 +4036,12 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { if (window->fullscreen_exclusive && !SDL_ModeSwitchingEmulated(_this)) { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } - return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, false); } void SDL_OnWindowFocusLost(SDL_Window *window) @@ -4071,7 +4071,7 @@ void SDL_DestroyWindow(SDL_Window *window) { CHECK_WINDOW_MAGIC(window,); - window->is_destroying = SDL_TRUE; + window->is_destroying = true; // Destroy any child windows of this window while (window->first_child) { @@ -4086,7 +4086,7 @@ void SDL_DestroyWindow(SDL_Window *window) } // Restore video mode, etc. - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_TRUE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, true); if (!(window->flags & SDL_WINDOW_EXTERNAL)) { SDL_HideWindow(window); } @@ -4114,7 +4114,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_SetKeyboardFocus(NULL); } if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { - SDL_UpdateMouseCapture(SDL_TRUE); + SDL_UpdateMouseCapture(true); } if (SDL_GetMouseFocus() == window) { SDL_SetMouseFocus(NULL); @@ -4154,7 +4154,7 @@ void SDL_DestroyWindow(SDL_Window *window) } // Now invalidate magic - SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, SDL_FALSE); + SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, false); // Free memory associated with the window SDL_free(window->title); @@ -4179,7 +4179,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_bool SDL_ScreenSaverEnabled(void) { if (!_this) { - return SDL_TRUE; + return true; } return !_this->suspend_screensaver; } @@ -4192,7 +4192,7 @@ int SDL_EnableScreenSaver(void) if (!_this->suspend_screensaver) { return 0; } - _this->suspend_screensaver = SDL_FALSE; + _this->suspend_screensaver = false; if (_this->SuspendScreenSaver) { return _this->SuspendScreenSaver(_this); } @@ -4208,7 +4208,7 @@ int SDL_DisableScreenSaver(void) if (_this->suspend_screensaver) { return 0; } - _this->suspend_screensaver = SDL_TRUE; + _this->suspend_screensaver = true; if (_this->SuspendScreenSaver) { return _this->SuspendScreenSaver(_this); } @@ -4241,7 +4241,7 @@ void SDL_VideoQuit(void) for (i = _this->num_displays; i--; ) { SDL_VideoDisplay *display = _this->displays[i]; - SDL_DelVideoDisplay(display->id, SDL_FALSE); + SDL_DelVideoDisplay(display->id, false); } SDL_assert(_this->num_displays == 0); @@ -4353,7 +4353,7 @@ typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGPROC) (GLenum name); typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); #endif -static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) +static SDL_INLINE bool isAtLeastGL3(const char *verstr) { return verstr && (SDL_atoi(verstr) >= 3); } @@ -4370,19 +4370,19 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { - return SDL_FALSE; + return false; } // See if there's a hint or environment variable override start = SDL_GetHint(extension); if (start && *start == '0') { - return SDL_FALSE; + return false; } // Lookup the available extensions glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); if (!glGetStringFunc) { - return SDL_FALSE; + return false; } if (isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { @@ -4394,7 +4394,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) glGetStringiFunc = (PFNGLGETSTRINGIPROC)SDL_GL_GetProcAddress("glGetStringi"); glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { - return SDL_FALSE; + return false; } #ifndef GL_NUM_EXTENSIONS @@ -4404,18 +4404,18 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) for (i = 0; i < num_exts; i++) { const char *thisext = (const char *)glGetStringiFunc(GL_EXTENSIONS, i); if (SDL_strcmp(thisext, extension) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } // Try the old way with glGetString(GL_EXTENSIONS) ... extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); if (!extensions) { - return SDL_FALSE; + return false; } /* * It takes a bit of care to be fool-proof about parsing the OpenGL @@ -4433,15 +4433,15 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) terminator = where + SDL_strlen(extension); if (where == extensions || *(where - 1) == ' ') { if (*terminator == ' ' || *terminator == '\0') { - return SDL_TRUE; + return true; } } start = terminator; } - return SDL_FALSE; + return false; #else - return SDL_FALSE; + return false; #endif } @@ -5235,32 +5235,32 @@ SDL_Capitalization SDL_GetTextInputCapitalization(SDL_PropertiesID props) } } -SDL_bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props) +bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props) { - return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN, SDL_TRUE); + return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN, true); } -SDL_bool SDL_GetTextInputMultiline(SDL_PropertiesID props) +bool SDL_GetTextInputMultiline(SDL_PropertiesID props) { if (SDL_HasProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN)) { - return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN, SDL_FALSE); + return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN, false); } - if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) { - return SDL_FALSE; + if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) { + return false; } else { - return SDL_TRUE; + return true; } } -static SDL_bool AutoShowingScreenKeyboard(void) +static bool AutoShowingScreenKeyboard(void) { const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD); if (((!hint || SDL_strcasecmp(hint, "auto") == 0) && !SDL_HasKeyboard()) || - SDL_GetStringBoolean(hint, SDL_FALSE)) { - return SDL_TRUE; + SDL_GetStringBoolean(hint, false)) { + return true; } else { - return SDL_FALSE; + return false; } } @@ -5302,14 +5302,14 @@ int SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props) return -1; } } - window->text_input_active = SDL_TRUE; + window->text_input_active = true; } return 0; } SDL_bool SDL_TextInputActive(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); return window->text_input_active; } @@ -5323,7 +5323,7 @@ int SDL_StopTextInput(SDL_Window *window) if (_this->StopTextInput) { _this->StopTextInput(_this, window); } - window->text_input_active = SDL_FALSE; + window->text_input_active = false; } // Hide the on-screen keyboard, if desired @@ -5385,17 +5385,17 @@ SDL_bool SDL_HasScreenKeyboardSupport(void) if (_this && _this->HasScreenKeyboardSupport) { return _this->HasScreenKeyboardSupport(_this); } - return SDL_FALSE; + return false; } SDL_bool SDL_ScreenKeyboardShown(SDL_Window *window) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); if (_this->IsScreenKeyboardShown) { return _this->IsScreenKeyboardShown(_this, window); } - return SDL_FALSE; + return false; } int SDL_GetMessageBoxCount(void) @@ -5438,7 +5438,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) { int dummybutton; int retval = -1; - SDL_bool show_cursor_prev; + bool show_cursor_prev; SDL_Window *current_window; SDL_MessageBoxData mbdata; @@ -5451,8 +5451,8 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) (void)SDL_AtomicIncRef(&SDL_messagebox_count); current_window = SDL_GetKeyboardFocus(); - SDL_UpdateMouseCapture(SDL_FALSE); - SDL_SetRelativeMouseMode(SDL_FALSE); + SDL_UpdateMouseCapture(false); + SDL_SetRelativeMouseMode(false); show_cursor_prev = SDL_CursorVisible(); SDL_ShowCursor(); SDL_ResetKeyboard(); @@ -5525,7 +5525,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) SDL_HideCursor(); } SDL_UpdateRelativeMouseMode(); - SDL_UpdateMouseCapture(SDL_FALSE); + SDL_UpdateMouseCapture(false); return retval; } @@ -5569,9 +5569,9 @@ int SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const #endif } -SDL_bool SDL_ShouldAllowTopmost(void) +bool SDL_ShouldAllowTopmost(void) { - return SDL_GetHintBoolean(SDL_HINT_WINDOW_ALLOW_TOPMOST, SDL_TRUE); + return SDL_GetHintBoolean(SDL_HINT_WINDOW_ALLOW_TOPMOST, true); } int SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y) @@ -5747,7 +5747,7 @@ int SDL_Vulkan_CreateSurface(SDL_Window *window, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, false); if (!(window->flags & SDL_WINDOW_VULKAN)) { return SDL_SetError(NOT_A_VULKAN_WINDOW); @@ -5779,17 +5779,17 @@ SDL_bool SDL_Vulkan_GetPresentationSupport(VkInstance instance, { if (!_this) { SDL_UninitializedVideo(); - return SDL_FALSE; + return false; } if (!instance) { SDL_InvalidParamError("instance"); - return SDL_FALSE; + return false; } if (!physicalDevice) { SDL_InvalidParamError("physicalDevice"); - return SDL_FALSE; + return false; } if (_this->Vulkan_GetPresentationSupport) { @@ -5800,7 +5800,7 @@ SDL_bool SDL_Vulkan_GetPresentationSupport(VkInstance instance, * WSI function to query it; in other words it's not necessary to check * as it is always supported. */ - return SDL_TRUE; + return true; } SDL_MetalView SDL_Metal_CreateView(SDL_Window *window) diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index fa815135c3..8bcb948a41 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -27,7 +27,7 @@ #if SDL_HAVE_YUV -static SDL_bool IsPlanar2x2Format(SDL_PixelFormat format); +static bool IsPlanar2x2Format(SDL_PixelFormat format); #endif /* @@ -41,7 +41,7 @@ int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, siz #if SDL_HAVE_YUV int sz_plane = 0, sz_plane_chroma = 0, sz_plane_packed = 0; - if (IsPlanar2x2Format(format) == SDL_TRUE) { + if (IsPlanar2x2Format(format) == true) { { /* sz_plane == w * h; */ size_t s1; @@ -187,12 +187,12 @@ static int GetYUVConversionType(SDL_Colorspace colorspace, YCbCrType *yuv_type) return SDL_SetError("Unsupported YUV colorspace"); } -static SDL_bool IsPlanar2x2Format(SDL_PixelFormat format) +static bool IsPlanar2x2Format(SDL_PixelFormat format) { return format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV || format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21 || format == SDL_PIXELFORMAT_P010; } -static SDL_bool IsPacked4Format(Uint32 format) +static bool IsPacked4Format(Uint32 format) { return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU; } @@ -303,7 +303,7 @@ static int GetYUVPlanes(int width, int height, SDL_PixelFormat format, const voi } #ifdef SDL_SSE2_INTRINSICS -static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse( +static bool SDL_TARGETING("sse2") yuv_rgb_sse( SDL_PixelFormat src_format, SDL_PixelFormat dst_format, Uint32 width, Uint32 height, const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, @@ -311,7 +311,7 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse( YCbCrType yuv_type) { if (!SDL_HasSSE2()) { - return SDL_FALSE; + return false; } if (src_format == SDL_PIXELFORMAT_YV12 || @@ -320,26 +320,26 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuv420_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuv420_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuv420_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuv420_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuv420_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuv420_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } @@ -352,26 +352,26 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuv422_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuv422_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuv422_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuv422_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuv422_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuv422_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } @@ -383,46 +383,46 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuvnv12_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuvnv12_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuvnv12_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuvnv12_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuvnv12_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuvnv12_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } } - return SDL_FALSE; + return false; } #else -static SDL_bool yuv_rgb_sse( +static bool yuv_rgb_sse( SDL_PixelFormat src_format, SDL_PixelFormat dst_format, Uint32 width, Uint32 height, const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, Uint8 *rgb, Uint32 rgb_stride, YCbCrType yuv_type) { - return SDL_FALSE; + return false; } #endif #ifdef SDL_LSX_INTRINSICS -static SDL_bool yuv_rgb_lsx( +static bool yuv_rgb_lsx( SDL_PixelFormat src_format, SDL_PixelFormat dst_format, Uint32 width, Uint32 height, const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, @@ -430,7 +430,7 @@ static SDL_bool yuv_rgb_lsx( YCbCrType yuv_type) { if (!SDL_HasLSX()) { - return SDL_FALSE; + return false; } if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) { @@ -438,42 +438,42 @@ static SDL_bool yuv_rgb_lsx( switch (dst_format) { case SDL_PIXELFORMAT_RGB24: yuv420_rgb24_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuv420_rgba_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuv420_bgra_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuv420_argb_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuv420_abgr_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } } - return SDL_FALSE; + return false; } #else -static SDL_bool yuv_rgb_lsx( +static bool yuv_rgb_lsx( SDL_PixelFormat src_format, SDL_PixelFormat dst_format, Uint32 width, Uint32 height, const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, Uint8 *rgb, Uint32 rgb_stride, YCbCrType yuv_type) { - return SDL_FALSE; + return false; } #endif -static SDL_bool yuv_rgb_std( +static bool yuv_rgb_std( SDL_PixelFormat src_format, SDL_PixelFormat dst_format, Uint32 width, Uint32 height, const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, @@ -486,26 +486,26 @@ static SDL_bool yuv_rgb_std( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuv420_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuv420_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuv420_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuv420_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuv420_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } @@ -518,26 +518,26 @@ static SDL_bool yuv_rgb_std( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuv422_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuv422_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuv422_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuv422_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuv422_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuv422_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } @@ -549,26 +549,26 @@ static SDL_bool yuv_rgb_std( switch (dst_format) { case SDL_PIXELFORMAT_RGB565: yuvnv12_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGB24: yuvnv12_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_RGBX8888: case SDL_PIXELFORMAT_RGBA8888: yuvnv12_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_BGRX8888: case SDL_PIXELFORMAT_BGRA8888: yuvnv12_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XRGB8888: case SDL_PIXELFORMAT_ARGB8888: yuvnv12_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; case SDL_PIXELFORMAT_XBGR8888: case SDL_PIXELFORMAT_ABGR8888: yuvnv12_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } @@ -578,12 +578,12 @@ static SDL_bool yuv_rgb_std( switch (dst_format) { case SDL_PIXELFORMAT_XBGR2101010: yuvp010_xbgr2101010_std(width, height, (const uint16_t *)y, (const uint16_t *)u, (const uint16_t *)v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); - return SDL_TRUE; + return true; default: break; } } - return SDL_FALSE; + return false; } int SDL_ConvertPixels_YUV_to_RGB(int width, int height, @@ -1330,7 +1330,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src } #ifdef SDL_SSE2_INTRINSICS -static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { int x, y; const int UVwidth = (width + 1) / 2; @@ -1396,7 +1396,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int w return 0; } -static int SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { int x, y; const int UVwidth = (width + 1) / 2; @@ -1508,7 +1508,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_SwapNV_SSE2(int width, int he } #endif -static int SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { int x, y; const int UVwidth = (width + 1) / 2; @@ -1562,7 +1562,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const return 0; } -static int SDL_ConvertPixels_SplitNV_to_UVPlanes_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_SplitNV_to_UVPlanes_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { int x, y; const int UVwidth = (width + 1) / 2; @@ -1646,7 +1646,7 @@ static int SDL_ConvertPixels_SwapNV_std(int width, int height, const void *src, return 0; } -static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { #ifdef SDL_SSE2_INTRINSICS if (SDL_HasSSE2()) { @@ -1656,7 +1656,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const voi return SDL_ConvertPixels_PackUVPlanes_to_NV_std(width, height, src, src_pitch, dst, dst_pitch, reverseUV); } -static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV) +static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) { #ifdef SDL_SSE2_INTRINSICS if (SDL_HasSSE2()) { @@ -1698,9 +1698,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, case SDL_PIXELFORMAT_IYUV: return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch); case SDL_PIXELFORMAT_NV12: - return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE); + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, true); case SDL_PIXELFORMAT_NV21: - return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE); + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, false); default: break; } @@ -1710,9 +1710,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, case SDL_PIXELFORMAT_YV12: return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch); case SDL_PIXELFORMAT_NV12: - return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE); + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, false); case SDL_PIXELFORMAT_NV21: - return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE); + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, true); default: break; } @@ -1720,9 +1720,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, case SDL_PIXELFORMAT_NV12: switch (dst_format) { case SDL_PIXELFORMAT_YV12: - return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE); + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, true); case SDL_PIXELFORMAT_IYUV: - return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE); + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, false); case SDL_PIXELFORMAT_NV21: return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch); default: @@ -1732,9 +1732,9 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, case SDL_PIXELFORMAT_NV21: switch (dst_format) { case SDL_PIXELFORMAT_YV12: - return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE); + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, false); case SDL_PIXELFORMAT_IYUV: - return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE); + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, true); case SDL_PIXELFORMAT_NV12: return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch); default: diff --git a/src/video/android/SDL_androidclipboard.c b/src/video/android/SDL_androidclipboard.c index ef792d8573..bc01f435d7 100644 --- a/src/video/android/SDL_androidclipboard.c +++ b/src/video/android/SDL_androidclipboard.c @@ -36,7 +36,7 @@ char *Android_GetClipboardText(SDL_VideoDevice *_this) return Android_JNI_GetClipboardText(); } -SDL_bool Android_HasClipboardText(SDL_VideoDevice *_this) +bool Android_HasClipboardText(SDL_VideoDevice *_this) { return Android_JNI_HasClipboardText(); } diff --git a/src/video/android/SDL_androidclipboard.h b/src/video/android/SDL_androidclipboard.h index 56c96ec608..0355a2838b 100644 --- a/src/video/android/SDL_androidclipboard.h +++ b/src/video/android/SDL_androidclipboard.h @@ -25,6 +25,6 @@ extern int Android_SetClipboardText(SDL_VideoDevice *_this, const char *text); extern char *Android_GetClipboardText(SDL_VideoDevice *_this); -extern SDL_bool Android_HasClipboardText(SDL_VideoDevice *_this); +extern bool Android_HasClipboardText(SDL_VideoDevice *_this); #endif // SDL_androidclipboard_h_ diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 331523c1f5..cacf5df66a 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -47,7 +47,7 @@ static void android_egl_context_restore(SDL_Window *window) event.common.timestamp = 0; SDL_PushEvent(&event); } - data->backup_done = SDL_FALSE; + data->backup_done = false; if (data->has_swap_interval) { SDL_GL_SetSwapInterval(data->swap_interval); @@ -72,7 +72,7 @@ static void android_egl_context_backup(SDL_Window *window) // We need to do this so the EGLSurface can be freed SDL_GL_MakeCurrent(window, NULL); - data->backup_done = SDL_TRUE; + data->backup_done = true; } } #endif @@ -80,19 +80,19 @@ static void android_egl_context_backup(SDL_Window *window) /* * Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume */ -static SDL_bool Android_EventsInitialized; -static SDL_bool Android_BlockOnPause = SDL_TRUE; -static SDL_bool Android_Paused; -static SDL_bool Android_PausedAudio; -static SDL_bool Android_Destroyed; +static bool Android_EventsInitialized; +static bool Android_BlockOnPause = true; +static bool Android_Paused; +static bool Android_PausedAudio; +static bool Android_Destroyed; void Android_InitEvents(void) { if (!Android_EventsInitialized) { - Android_BlockOnPause = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE, SDL_TRUE); - Android_Paused = SDL_FALSE; - Android_Destroyed = SDL_FALSE; - Android_EventsInitialized = SDL_TRUE; + Android_BlockOnPause = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE, true); + Android_Paused = false; + Android_Destroyed = false; + Android_EventsInitialized = true; } } @@ -100,7 +100,7 @@ static void Android_PauseAudio(void) { OPENSLES_PauseDevices(); AAUDIO_PauseDevices(); - Android_PausedAudio = SDL_TRUE; + Android_PausedAudio = true; } static void Android_ResumeAudio(void) @@ -108,7 +108,7 @@ static void Android_ResumeAudio(void) if (Android_PausedAudio) { OPENSLES_ResumeDevices(); AAUDIO_ResumeDevices(); - Android_PausedAudio = SDL_FALSE; + Android_PausedAudio = false; } } @@ -135,12 +135,12 @@ static void Android_OnPause(void) Android_PauseAudio(); } - Android_Paused = SDL_TRUE; + Android_Paused = true; } static void Android_OnResume(void) { - Android_Paused = SDL_FALSE; + Android_Paused = false; SDL_OnApplicationWillEnterForeground(); @@ -180,7 +180,7 @@ static void Android_OnDestroy(void) SDL_SendQuit(); SDL_SendAppEvent(SDL_EVENT_TERMINATING); - Android_Destroyed = SDL_TRUE; + Android_Destroyed = true; } static void Android_HandleLifecycleEvent(SDL_AndroidLifecycleEvent event) @@ -206,7 +206,7 @@ static void Android_HandleLifecycleEvent(SDL_AndroidLifecycleEvent event) } } -static Sint64 GetLifecycleEventTimeout(SDL_bool paused, Sint64 timeoutNS) +static Sint64 GetLifecycleEventTimeout(bool paused, Sint64 timeoutNS) { if (Android_Paused) { if (Android_BlockOnPause) { @@ -221,7 +221,7 @@ static Sint64 GetLifecycleEventTimeout(SDL_bool paused, Sint64 timeoutNS) void Android_PumpEvents(Sint64 timeoutNS) { SDL_AndroidLifecycleEvent event; - SDL_bool paused = Android_Paused; + bool paused = Android_Paused; while (!Android_Destroyed && Android_WaitLifecycleEvent(&event, GetLifecycleEventTimeout(paused, timeoutNS))) { @@ -237,7 +237,7 @@ void Android_PumpEvents(Sint64 timeoutNS) break; case SDL_ANDROID_LIFECYCLE_RESUME: // Finish handling events at the resume state timeout - paused = SDL_FALSE; + paused = false; break; default: break; @@ -262,7 +262,7 @@ int Android_WaitActiveAndLockActivity(void) void Android_QuitEvents(void) { - Android_EventsInitialized = SDL_FALSE; + Android_EventsInitialized = false; } #endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index cf41060fd9..37a8999b75 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -353,7 +353,7 @@ static SDL_Scancode Android_Keycodes[] = { SDL_SCANCODE_PASTE, // AKEYCODE_PASTE }; -static SDL_bool SDL_screen_keyboard_shown; +static bool SDL_screen_keyboard_shown; static SDL_Scancode TranslateKeycode(int keycode) { @@ -378,9 +378,9 @@ int Android_OnKeyUp(int keycode) return SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), SDL_RELEASED); } -SDL_bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -444,13 +444,13 @@ void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_ } } Android_JNI_ShowScreenKeyboard(input_type, &window->text_input_rect); - SDL_screen_keyboard_shown = SDL_TRUE; + SDL_screen_keyboard_shown = true; } void Android_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { Android_JNI_HideScreenKeyboard(); - SDL_screen_keyboard_shown = SDL_FALSE; + SDL_screen_keyboard_shown = false; } void Android_RestoreScreenKeyboardOnResume(SDL_VideoDevice *_this, SDL_Window *window) @@ -460,7 +460,7 @@ void Android_RestoreScreenKeyboardOnResume(SDL_VideoDevice *_this, SDL_Window *w } } -SDL_bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { return Android_JNI_IsScreenKeyboardShown(); } diff --git a/src/video/android/SDL_androidkeyboard.h b/src/video/android/SDL_androidkeyboard.h index c7b70090b8..e0cafa18c8 100644 --- a/src/video/android/SDL_androidkeyboard.h +++ b/src/video/android/SDL_androidkeyboard.h @@ -25,8 +25,8 @@ extern int Android_OnKeyDown(int keycode); extern int Android_OnKeyUp(int keycode); -extern SDL_bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this); extern void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); extern void Android_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); extern void Android_RestoreScreenKeyboardOnResume(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index f049b99119..813ce61764 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -155,7 +155,7 @@ static int Android_ShowCursor(SDL_Cursor *cursor) } } -static int Android_SetRelativeMouseMode(SDL_bool enabled) +static int Android_SetRelativeMouseMode(bool enabled) { if (!Android_JNI_SupportsRelativeMouse()) { return SDL_Unsupported(); @@ -206,7 +206,7 @@ static Uint8 TranslateButton(int state) } } -void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, SDL_bool relative) +void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, bool relative) { int changes; Uint8 button; diff --git a/src/video/android/SDL_androidmouse.h b/src/video/android/SDL_androidmouse.h index ee4021761d..37cf180462 100644 --- a/src/video/android/SDL_androidmouse.h +++ b/src/video/android/SDL_androidmouse.h @@ -25,7 +25,7 @@ #include "SDL_androidvideo.h" extern void Android_InitMouse(void); -extern void Android_OnMouse(SDL_Window *window, int button, int action, float x, float y, SDL_bool relative); +extern void Android_OnMouse(SDL_Window *window, int button, int action, float x, float y, bool relative); extern void Android_QuitMouse(void); #endif // SDL_androidmouse_h_ diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 14d73c5237..75b0c04181 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -72,7 +72,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin switch (action) { case ACTION_DOWN: case ACTION_POINTER_DOWN: - SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_TRUE, x, y, p); + SDL_SendTouch(0, touchDeviceId, fingerId, window, true, x, y, p); break; case ACTION_MOVE: @@ -81,7 +81,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin case ACTION_UP: case ACTION_POINTER_UP: - SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_FALSE, x, y, p); + SDL_SendTouch(0, touchDeviceId, fingerId, window, false, x, y, p); break; default: diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index b069dc41b2..5e5a615db7 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -162,8 +162,8 @@ int Android_VideoInit(SDL_VideoDevice *_this) SDL_VideoDisplay *display; SDL_DisplayMode mode; - videodata->isPaused = SDL_FALSE; - videodata->isPausing = SDL_FALSE; + videodata->isPaused = false; + videodata->isPausing = false; SDL_zero(mode); mode.format = Android_ScreenFormat; @@ -271,7 +271,7 @@ void Android_SendResize(SDL_Window *window) } } -void Android_SetDarkMode(SDL_bool enabled) +void Android_SetDarkMode(bool enabled) { SDL_VideoDevice *device = SDL_GetVideoDevice(); diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h index 4a2d9964e7..baead920ae 100644 --- a/src/video/android/SDL_androidvideo.h +++ b/src/video/android/SDL_androidvideo.h @@ -29,7 +29,7 @@ extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float density, float rate); extern void Android_SetFormat(int format_wanted, int format_got); extern void Android_SendResize(SDL_Window *window); -extern void Android_SetDarkMode(SDL_bool enabled); +extern void Android_SetDarkMode(bool enabled); // Private display data diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index c57303dc52..c8e2685096 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -40,8 +40,8 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 i, extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasAndroidSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasAndroidSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { return SDL_SetError("Vulkan already loaded"); @@ -81,9 +81,9 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasAndroidSurfaceExtension = SDL_TRUE; + hasAndroidSurfaceExtension = true; } } SDL_free(extensions); diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index c74c3b92f5..5842c59c65 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -165,7 +165,7 @@ void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) Android_JNI_MinizeWindow(); } -void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) +void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) { // Set orientation Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index 2de1fd25c7..dfa12a00e5 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -30,7 +30,7 @@ extern int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_ extern void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); extern int Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); extern void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); +extern void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); extern void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_Window *Android_Window; @@ -43,7 +43,7 @@ struct SDL_WindowData int has_swap_interval; // Save/Restore the swap interval / vsync int swap_interval; #endif - SDL_bool backup_done; + bool backup_done; ANativeWindow *native_window; }; diff --git a/src/video/cocoa/SDL_cocoaclipboard.h b/src/video/cocoa/SDL_cocoaclipboard.h index c263a04ef0..ff6f0b1f66 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.h +++ b/src/video/cocoa/SDL_cocoaclipboard.h @@ -28,10 +28,10 @@ extern int Cocoa_SetClipboardText(SDL_VideoDevice *_this, const char *text); extern char *Cocoa_GetClipboardText(SDL_VideoDevice *_this); -extern SDL_bool Cocoa_HasClipboardText(SDL_VideoDevice *_this); +extern bool Cocoa_HasClipboardText(SDL_VideoDevice *_this); extern void Cocoa_CheckClipboardUpdate(SDL_CocoaVideoData *data); extern int Cocoa_SetClipboardData(SDL_VideoDevice *_this); extern void *Cocoa_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); -extern SDL_bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); #endif // SDL_cocoaclipboard_h_ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index a262d4eb2b..b080a0ca37 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -156,16 +156,16 @@ void *Cocoa_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size } } -SDL_bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) { - SDL_bool result = SDL_FALSE; + bool result = false; @autoreleasepool { NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; CFStringRef mimeType = CFStringCreateWithCString(NULL, mime_type, kCFStringEncodingUTF8); CFStringRef utiType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL); CFRelease(mimeType); if ([pasteboard canReadItemWithDataConformingToTypes: @[(__bridge NSString *)utiType]]) { - result = SDL_TRUE; + result = true; } CFRelease(utiType); } diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 711b09de1b..1a71a7a8e9 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -62,7 +62,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win) SDL_SendQuit(); } -static SDL_bool s_bShouldHandleEventsInSDLApplication = SDL_FALSE; +static bool s_bShouldHandleEventsInSDLApplication = false; static void Cocoa_DispatchEvent(NSEvent *theEvent) { @@ -142,7 +142,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) self = [super init]; if (self) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - SDL_bool registerActivationHandlers = SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", SDL_TRUE); + bool registerActivationHandlers = SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true); seenFirstActivate = NO; @@ -310,7 +310,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) - (void)applicationDidFinishLaunching:(NSNotification *)notification { - if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", SDL_TRUE)) + if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true)) return; /* The menu bar of SDL apps which don't have the typical .app bundle @@ -318,7 +318,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) * de-focused and re-focused), if this call is in Cocoa_RegisterApp instead * of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051 */ - if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) { // Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { [i activateWithOptions:NSApplicationActivateIgnoringOtherApps]; @@ -504,9 +504,9 @@ void Cocoa_RegisterApp(void) [SDL3Application sharedApplication]; SDL_assert(NSApp != nil); - s_bShouldHandleEventsInSDLApplication = SDL_TRUE; + s_bShouldHandleEventsInSDLApplication = true; - if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) { [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; } diff --git a/src/video/cocoa/SDL_cocoakeyboard.h b/src/video/cocoa/SDL_cocoakeyboard.h index 6c57eae3a6..39407fd82c 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.h +++ b/src/video/cocoa/SDL_cocoakeyboard.h @@ -31,6 +31,6 @@ extern int Cocoa_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_ extern int Cocoa_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); extern int Cocoa_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); -extern int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); #endif // SDL_cocoakeyboard_h_ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index b942d68407..b0a331cd6e 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -274,7 +274,7 @@ static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned } } -static void UpdateKeymap(SDL_CocoaVideoData *data, SDL_bool send_event) +static void UpdateKeymap(SDL_CocoaVideoData *data, bool send_event) { TISInputSourceRef key_layout; UCKeyboardLayout *keyLayoutPtr = NULL; @@ -367,7 +367,7 @@ void Cocoa_InitKeyboard(SDL_VideoDevice *_this) { SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; - UpdateKeymap(data, SDL_FALSE); + UpdateKeymap(data, false); // Set our own names for the platform-dependent but layout-independent keys // This key is NumLock on the MacBook keyboard. :) @@ -378,7 +378,7 @@ void Cocoa_InitKeyboard(SDL_VideoDevice *_this) SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command"); data.modifierFlags = (unsigned int)[NSEvent modifierFlags]; - SDL_ToggleModState(SDL_KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) ? true : false); } int Cocoa_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -458,7 +458,7 @@ void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) case NSEventTypeKeyDown: if (![event isARepeat]) { // See if we need to rebuild the keyboard layout - UpdateKeymap(data, SDL_TRUE); + UpdateKeymap(data, true); } #ifdef DEBUG_SCANCODES @@ -509,7 +509,7 @@ typedef enum extern CGSConnection _CGSDefaultConnection(void); extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection connection, CGSGlobalHotKeyOperatingMode mode); -int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { #ifdef SDL_MAC_NO_SANDBOX CGSSetGlobalHotKeyOperatingMode(_CGSDefaultConnection(), grabbed ? CGSGlobalHotKeyDisable : CGSGlobalHotKeyEnable); diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index ad28f64d88..99ff9fd0ad 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -30,7 +30,7 @@ #if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) -static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) +static SDL_bool SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) { /* Update the drawable size when SDL receives a size changed event for * the window that contains the metal view. It would be nice to use @@ -47,7 +47,7 @@ static int SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) } } } - return 0; + return false; } @implementation SDL3_cocoametalview diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index 6291509b15..19f1b8dfa4 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -112,21 +112,21 @@ static float GetDisplayModeRefreshRate(CGDisplayModeRef vidmode, CVDisplayLinkRe return refreshRate; } -static SDL_bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) +static bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) { uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); // Filter out modes which have flags that we don't want. if (ioflags & (kDisplayModeNeverShowFlag | kDisplayModeNotGraphicsQualityFlag)) { - return SDL_FALSE; + return false; } // Filter out modes which don't have flags that we want. if (!(ioflags & kDisplayModeValidFlag) || !(ioflags & kDisplayModeSafeFlag)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) @@ -153,7 +153,7 @@ static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) return pixelformat; } -static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, SDL_bool vidmodeCurrent, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) +static bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, bool vidmodeCurrent, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) { SDL_DisplayModeData *data; bool usableForGUI = CGDisplayModeIsUsableForDesktopGUI(vidmode); @@ -168,13 +168,13 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, CFMutableArrayRef modes; if (format == SDL_PIXELFORMAT_UNKNOWN) { - return SDL_FALSE; + return false; } /* Don't fail the current mode based on flags because this could prevent Cocoa_InitModes from * succeeding if the current mode lacks certain flags (esp kDisplayModeSafeFlag). */ if (!vidmodeCurrent && !HasValidDisplayModeFlags(vidmode)) { - return SDL_FALSE; + return false; } modes = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); @@ -221,7 +221,7 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, */ if (interlaced && ((otherioflags & kDisplayModeInterlacedFlag) == 0) && width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && refreshrate == otherrefresh && format == otherformat && usableForGUI == otherGUI) { CFRelease(modes); - return SDL_FALSE; + return false; } /* Ignore this mode if it's not usable for desktop UI and its @@ -229,7 +229,7 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, */ if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && !usableForGUI && otherGUI && refreshrate == otherrefresh && format == otherformat) { CFRelease(modes); - return SDL_FALSE; + return false; } /* If multiple modes have the exact same properties, they'll all @@ -263,7 +263,7 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); if (!data) { CFRelease(modes); - return SDL_FALSE; + return false; } data->modes = modes; mode->format = format; @@ -272,7 +272,7 @@ static SDL_bool GetDisplayMode(SDL_VideoDevice *_this, CGDisplayModeRef vidmode, mode->pixel_density = (float)pixelW / width; mode->refresh_rate = refreshrate; mode->internal = data; - return SDL_TRUE; + return true; } static char *Cocoa_GetDisplayName(CGDirectDisplayID displayID) @@ -315,7 +315,7 @@ void Cocoa_InitModes(SDL_VideoDevice *_this) CGDisplayErr result; CGDirectDisplayID *displays; CGDisplayCount numDisplays; - SDL_bool isstack; + bool isstack; int pass, i; result = CGGetOnlineDisplayList(0, NULL, &numDisplays); @@ -372,7 +372,7 @@ void Cocoa_InitModes(SDL_VideoDevice *_this) SDL_zero(display); // this returns a strdup'ed string display.name = Cocoa_GetDisplayName(displays[i]); - if (!GetDisplayMode(_this, moderef, SDL_TRUE, NULL, link, &mode)) { + if (!GetDisplayMode(_this, moderef, true, NULL, link, &mode)) { CVDisplayLinkRelease(link); CGDisplayModeRelease(moderef); SDL_free(display.name); @@ -387,7 +387,7 @@ void Cocoa_InitModes(SDL_VideoDevice *_this) display.desktop_mode = mode; display.internal = displaydata; - SDL_AddVideoDisplay(&display, SDL_FALSE); + SDL_AddVideoDisplay(&display, false); SDL_free(display.name); } } @@ -486,7 +486,7 @@ int Cocoa_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) CGDisplayModeRef moderef = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i); SDL_DisplayMode mode; - if (GetDisplayMode(_this, moderef, SDL_FALSE, modes, link, &mode)) { + if (GetDisplayMode(_this, moderef, false, modes, link, &mode)) { if (!SDL_AddFullscreenDisplayMode(display, &mode)) { CFRelease(mode.internal->modes); SDL_free(mode.internal); @@ -526,7 +526,7 @@ int Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_ CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; CGError result = kCGErrorSuccess; - b_inModeTransition = SDL_TRUE; + b_inModeTransition = true; // Fade to black to hide resolution-switching flicker if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) { @@ -547,7 +547,7 @@ int Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_ CGReleaseDisplayFadeReservation(fade_token); } - b_inModeTransition = SDL_FALSE; + b_inModeTransition = false; if (result != kCGErrorSuccess) { CG_SetError("CGDisplaySwitchToMode()", result); diff --git a/src/video/cocoa/SDL_cocoamouse.h b/src/video/cocoa/SDL_cocoamouse.h index f8ce338f04..b99d75b214 100644 --- a/src/video/cocoa/SDL_cocoamouse.h +++ b/src/video/cocoa/SDL_cocoamouse.h @@ -34,7 +34,7 @@ extern void Cocoa_QuitMouse(SDL_VideoDevice *_this); typedef struct { // Whether we've seen a cursor warp since the last move event. - SDL_bool seenWarp; + bool seenWarp; // What location our last cursor warp was to. CGFloat lastWarpX; CGFloat lastWarpY; diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 0267c8df19..c09b55d0ae 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -302,7 +302,7 @@ static int Cocoa_WarpMouseGlobal(float x, float y) SDL_SetMouseFocus(win); if (win) { SDL_assert(win == mouse->focus); - SDL_SendMouseMotion(0, win, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x - win->x, y - win->y); + SDL_SendMouseMotion(0, win, SDL_GLOBAL_MOUSE_ID, false, x - win->x, y - win->y); } } @@ -314,7 +314,7 @@ static int Cocoa_WarpMouse(SDL_Window *window, float x, float y) return Cocoa_WarpMouseGlobal(window->x + x, window->y + y); } -static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) +static int Cocoa_SetRelativeMouseMode(bool enabled) { CGError result; @@ -449,7 +449,7 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) NSPoint location; CGFloat lastMoveX, lastMoveY; float deltaX, deltaY; - SDL_bool seenWarp; + bool seenWarp; switch ([event type]) { case NSEventTypeMouseMoved: case NSEventTypeLeftMouseDragged: @@ -516,7 +516,7 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) DLog("Motion was (%g, %g), offset to (%g, %g)", [event deltaX], [event deltaY], deltaX, deltaY); } - SDL_SendMouseMotion(Cocoa_GetEventTimestamp([event timestamp]), mouse->focus, mouseID, SDL_TRUE, deltaX, deltaY); + SDL_SendMouseMotion(Cocoa_GetEventTimestamp([event timestamp]), mouse->focus, mouseID, true, deltaX, deltaY); } void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) @@ -559,7 +559,7 @@ void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) SDL_MouseData *data = (SDL_MouseData *)SDL_GetMouse()->internal; data->lastWarpX = x; data->lastWarpY = y; - data->seenWarp = SDL_TRUE; + data->seenWarp = true; DLog("(%g, %g)", x, y); } diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index ed065c1508..0775f7aae2 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -52,11 +52,11 @@ #define _Nullable #endif -static SDL_bool SDL_opengl_async_dispatch = SDL_FALSE; +static bool SDL_opengl_async_dispatch = false; static void SDLCALL SDL_OpenGLAsyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { - SDL_opengl_async_dispatch = SDL_GetStringBoolean(hint, SDL_FALSE); + SDL_opengl_async_dispatch = SDL_GetStringBoolean(hint, false); } static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) diff --git a/src/video/cocoa/SDL_cocoapen.h b/src/video/cocoa/SDL_cocoapen.h index 8e3259ec46..a91531e1f2 100644 --- a/src/video/cocoa/SDL_cocoapen.h +++ b/src/video/cocoa/SDL_cocoapen.h @@ -26,7 +26,7 @@ #include "SDL_cocoavideo.h" extern int Cocoa_InitPen(SDL_VideoDevice *_this); -extern SDL_bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event); // return SDL_FALSE if we didn't handle this event. +extern bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event); // return false if we didn't handle this event. extern void Cocoa_QuitPen(SDL_VideoDevice *_this); #endif // SDL_cocoapen_h_ diff --git a/src/video/cocoa/SDL_cocoapen.m b/src/video/cocoa/SDL_cocoapen.m index db5d28faa6..5d068fad15 100644 --- a/src/video/cocoa/SDL_cocoapen.m +++ b/src/video/cocoa/SDL_cocoapen.m @@ -37,7 +37,7 @@ typedef struct Cocoa_PenHandle NSUInteger deviceid; NSUInteger toolid; SDL_PenID pen; - SDL_bool is_eraser; + bool is_eraser; } Cocoa_PenHandle; typedef struct FindPenByDeviceAndToolIDData @@ -47,18 +47,18 @@ typedef struct FindPenByDeviceAndToolIDData void *handle; } FindPenByDeviceAndToolIDData; -static SDL_bool FindPenByDeviceAndToolID(void *handle, void *userdata) +static bool FindPenByDeviceAndToolID(void *handle, void *userdata) { const Cocoa_PenHandle *cocoa_handle = (const Cocoa_PenHandle *) handle; FindPenByDeviceAndToolIDData *data = (FindPenByDeviceAndToolIDData *) userdata; if (cocoa_handle->deviceid != data->deviceid) { - return SDL_FALSE; + return false; } else if (cocoa_handle->toolid != data->toolid) { - return SDL_FALSE; + return false; } data->handle = handle; - return SDL_TRUE; + return true; } static Cocoa_PenHandle *Cocoa_FindPenByDeviceID(NSUInteger deviceid, NSUInteger toolid) @@ -78,8 +78,8 @@ static void Cocoa_HandlePenProximityEvent(SDL_CocoaWindowData *_data, NSEvent *e if (event.enteringProximity) { // new pen coming! const NSPointingDeviceType devtype = [event pointingDeviceType]; - const SDL_bool is_eraser = (devtype == NSPointingDeviceTypeEraser); - const SDL_bool is_pen = (devtype == NSPointingDeviceTypePen); + const bool is_eraser = (devtype == NSPointingDeviceTypeEraser); + const bool is_pen = (devtype == NSPointingDeviceTypePen); if (!is_eraser && !is_pen) { return; // we ignore other things, which hopefully is right. } @@ -125,7 +125,7 @@ static void Cocoa_HandlePenPointEvent(SDL_CocoaWindowData *_data, NSEvent *event const NSEventButtonMask buttons = [event buttonMask]; const NSPoint tilt = [event tilt]; const NSPoint point = [event locationInWindow]; - const SDL_bool is_touching = (buttons & NSEventButtonMaskPenTip) != 0; + const bool is_touching = (buttons & NSEventButtonMaskPenTip) != 0; SDL_Window *window = _data.window; SDL_SendPenTouch(timestamp, pen, window, is_touching, handle->is_eraser ? 1 : 0); @@ -139,7 +139,7 @@ static void Cocoa_HandlePenPointEvent(SDL_CocoaWindowData *_data, NSEvent *event SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_TANGENTIAL_PRESSURE, event.tangentialPressure); } -SDL_bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event) +bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event) { NSEventType type = [event type]; @@ -150,7 +150,7 @@ SDL_bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event) } else if (subtype == NSEventSubtypeTabletProximity) { type = NSEventTypeTabletProximity; } else { - return SDL_FALSE; // not a tablet event. + return false; // not a tablet event. } } @@ -159,10 +159,10 @@ SDL_bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event) } else if (type == NSEventTypeTabletProximity) { Cocoa_HandlePenProximityEvent(_data, event); } else { - return SDL_FALSE; // not a tablet event. + return false; // not a tablet event. } - return SDL_TRUE; + return true; } static void Cocoa_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdata) diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index f210551b9c..5a50d13a08 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -139,7 +139,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void) #endif #ifdef SDL_VIDEO_OPENGL_EGL #ifdef SDL_VIDEO_OPENGL_CGL - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { #endif device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; @@ -207,11 +207,11 @@ int Cocoa_VideoInit(SDL_VideoDevice *_this) // Assume we have a mouse and keyboard // We could use GCMouse and GCKeyboard if we needed to, as is done in SDL_uikitevents.m - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); - data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE); - data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, SDL_FALSE); + data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, true); + data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, false); data.swaplock = SDL_CreateMutex(); if (!data.swaplock) { @@ -273,7 +273,7 @@ NSImage *Cocoa_CreateImage(SDL_Surface *surface) } // Premultiply the alpha channel - SDL_PremultiplySurfaceAlpha(converted, SDL_FALSE); + SDL_PremultiplySurfaceAlpha(converted, false); NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:converted->w diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m index eaa2b24887..04dd93d2c6 100644 --- a/src/video/cocoa/SDL_cocoavulkan.m +++ b/src/video/cocoa/SDL_cocoavulkan.m @@ -50,9 +50,9 @@ int Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasMetalSurfaceExtension = SDL_FALSE; - SDL_bool hasMacOSSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasMetalSurfaceExtension = false; + bool hasMacOSSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { @@ -128,11 +128,11 @@ int Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (Uint32 i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_EXT_METAL_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasMetalSurfaceExtension = SDL_TRUE; + hasMetalSurfaceExtension = true; } else if (SDL_strcmp(VK_MVK_MACOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasMacOSSurfaceExtension = SDL_TRUE; + hasMacOSSurfaceExtension = true; } } SDL_free(extensions); diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 54cf362989..c77427e1b3 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -144,16 +144,16 @@ typedef enum @property(nonatomic) SDL3Cocoa_WindowListener *listener; @property(nonatomic) NSModalSession modal_session; @property(nonatomic) SDL_CocoaVideoData *videodata; -@property(nonatomic) SDL_bool send_floating_size; -@property(nonatomic) SDL_bool send_floating_position; -@property(nonatomic) SDL_bool border_toggled; +@property(nonatomic) bool send_floating_size; +@property(nonatomic) bool send_floating_position; +@property(nonatomic) bool border_toggled; @property(nonatomic) BOOL checking_zoom; #ifdef SDL_VIDEO_OPENGL_EGL @property(nonatomic) EGLSurface egl_surface; #endif @end -extern SDL_bool b_inModeTransition; +extern bool b_inModeTransition; extern int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); extern void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); @@ -170,19 +170,19 @@ extern void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Cocoa_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); -extern void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); -extern void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top); +extern void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); extern int Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); extern void *Cocoa_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); extern SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); -extern int Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); extern void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept); extern int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); -extern int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable); +extern int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); extern int Cocoa_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window); extern int Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 61a7adcf32..668907e2ef 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -340,7 +340,7 @@ @end -SDL_bool b_inModeTransition; +bool b_inModeTransition; static CGFloat SqDistanceToRect(const NSPoint *point, const NSRect *rect) { @@ -443,7 +443,7 @@ static void ScheduleContextUpdates(SDL_CocoaWindowData *data) // !!! FIXME: this should use a hint callback. static int GetHintCtrlClickEmulateRightClick(void) { - return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, false); } static NSUInteger GetWindowWindowedStyle(SDL_Window *window) @@ -482,7 +482,7 @@ static NSUInteger GetWindowStyle(SDL_Window *window) return style; } -static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style) +static bool SetWindowStyle(SDL_Window *window, NSUInteger style) { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; NSWindow *nswindow = data.nswindow; @@ -499,28 +499,28 @@ static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style) [data.sdlContentView setNextResponder:data.listener]; } - return SDL_TRUE; + return true; } -static SDL_bool ShouldAdjustCoordinatesForGrab(SDL_Window *window) +static bool ShouldAdjustCoordinatesForGrab(SDL_Window *window) { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; if (!data || [data.listener isMovingOrFocusClickPending]) { - return SDL_FALSE; + return false; } if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { - return SDL_FALSE; + return false; } if ((window->flags & SDL_WINDOW_MOUSE_GRABBED) || (window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } -static SDL_bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, CGPoint *adjusted) +static bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, CGPoint *adjusted) { if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { SDL_Rect window_rect; @@ -539,9 +539,9 @@ static SDL_bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, C if (x < left || x > right || y < top || y > bottom) { adjusted->x = SDL_clamp(x, left, right); adjusted->y = SDL_clamp(y, top, bottom); - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } } @@ -553,10 +553,10 @@ static SDL_bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, C if (x < left || x > right || y < top || y > bottom) { adjusted->x = SDL_clamp(x, left, right); adjusted->y = SDL_clamp(y, top, bottom); - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void Cocoa_UpdateClipCursor(SDL_Window *window) @@ -656,12 +656,12 @@ static void Cocoa_WaitForMiniaturizable(SDL_Window *window) } } -static SDL_bool Cocoa_IsZoomed(SDL_Window *window) +static bool Cocoa_IsZoomed(SDL_Window *window) { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; data.checking_zoom = YES; - const SDL_bool ret = [data.nswindow isZoomed]; + const bool ret = [data.nswindow isZoomed]; data.checking_zoom = NO; return ret; @@ -971,7 +971,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); } - mouse->SetRelativeMouseMode(SDL_TRUE); + mouse->SetRelativeMouseMode(true); } else { Cocoa_UpdateClipCursor(_data.window); } @@ -1159,7 +1159,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) } if ([self windowOperationIsPending:PENDING_OPERATION_ENTER_FULLSCREEN]) { - SDL_UpdateFullscreenMode(_data.window, SDL_TRUE, SDL_TRUE); + SDL_UpdateFullscreenMode(_data.window, true, true); } } @@ -1181,7 +1181,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) y = (window->h - point.y); if (x >= 0.0f && x < (float)window->w && y >= 0.0f && y < (float)window->h) { - SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); } } @@ -1194,7 +1194,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) { const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock; _data.videodata.modifierFlags = (_data.videodata.modifierFlags & ~NSEventModifierFlagCapsLock) | newflags; - SDL_ToggleModState(SDL_KMOD_CAPS, newflags ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_CAPS, newflags ? true : false); } } @@ -1302,7 +1302,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) * UpdateFullscreenMode(). */ if (!_data.in_blocking_transition) { - SDL_UpdateFullscreenMode(window, SDL_TRUE, SDL_FALSE); + SDL_UpdateFullscreenMode(window, true, false); } SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); @@ -1328,7 +1328,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; SetWindowStyle(window, flags); - _data.border_toggled = SDL_FALSE; + _data.border_toggled = false; } isFullscreenSpace = NO; @@ -1373,7 +1373,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) */ SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); if (!_data.in_blocking_transition) { - SDL_UpdateFullscreenMode(window, SDL_FALSE, SDL_FALSE); + SDL_UpdateFullscreenMode(window, false, false); } if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { @@ -1428,7 +1428,7 @@ static NSCursor *Cocoa_GetDesiredCursor(void) [self windowDidMove:aNotification]; [self windowDidResize:aNotification]; - _data.was_zoomed = SDL_FALSE; + _data.was_zoomed = false; // FIXME: Why does the window get hidden? if (!(window->flags & SDL_WINDOW_HIDDEN)) { @@ -1463,8 +1463,8 @@ static NSCursor *Cocoa_GetDesiredCursor(void) /* Also note that SDL_SendKeyboardKey expects all capslock events to be keypresses; it won't toggle the mod state if you send a keyrelease. */ - const SDL_bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? SDL_TRUE : SDL_FALSE; - const SDL_bool sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? SDL_TRUE : SDL_FALSE; + const bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? true : false; + const bool sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? true : false; if (osenabled ^ sdlenabled) { SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, SDL_SCANCODE_CAPSLOCK, SDL_PRESSED); SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, SDL_SCANCODE_CAPSLOCK, SDL_RELEASED); @@ -1736,7 +1736,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ } } - SDL_SendMouseMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, SDL_FALSE, x, y); + SDL_SendMouseMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, false, x, y); } - (void)mouseDragged:(NSEvent *)theEvent @@ -1814,7 +1814,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ * events from being generated from touch events. */ SDL_Window *window = NULL; - SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, SDL_FALSE, 0, 0, 0); + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, false, 0, 0, 0); } SDL_free(fingers); } @@ -1884,11 +1884,11 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ switch (phase) { case NSTouchPhaseBegan: - SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_TRUE, x, y, 1.0f); + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, true, x, y, 1.0f); break; case NSTouchPhaseEnded: case NSTouchPhaseCancelled: - SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_FALSE, x, y, 1.0f); + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, false, x, y, 1.0f); break; case NSTouchPhaseMoved: SDL_SendTouchMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, x, y, 1.0f); @@ -1997,9 +1997,9 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { if (SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH)) { - return SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); + return SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); } else { - return SDL_GetHintBoolean("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH", SDL_FALSE); + return SDL_GetHintBoolean("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH", false); } } @@ -2371,7 +2371,7 @@ int Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) ScheduleContextUpdates(windata); } else { - windata.send_floating_position = SDL_TRUE; + windata.send_floating_position = true; } } return 0; @@ -2408,10 +2408,10 @@ void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) [nswindow setFrame:[nswindow frameRectForContentRect:rect] display:YES]; ScheduleContextUpdates(windata); } else if (windata.was_zoomed) { - windata.send_floating_size = SDL_TRUE; + windata.send_floating_size = true; } } else { - windata.send_floating_size = SDL_TRUE; + windata.send_floating_size = true; } } } @@ -2464,7 +2464,7 @@ void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) @autoreleasepool { SDL_CocoaWindowData *windowData = ((__bridge SDL_CocoaWindowData *)window->internal); NSWindow *nswindow = windowData.nswindow; - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); if (![nswindow isMiniaturized]) { [windowData.listener pauseVisibleObservation]; @@ -2535,7 +2535,7 @@ void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) @autoreleasepool { SDL_CocoaWindowData *windowData = ((__bridge SDL_CocoaWindowData *)window->internal); NSWindow *nswindow = windowData.nswindow; - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, SDL_TRUE); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing a minimized or hidden window, so check for that before showing it. @@ -2590,7 +2590,7 @@ void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) [data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; if ([data.listener isInFullscreenSpace] || (window->flags & SDL_WINDOW_FULLSCREEN)) { [data.listener addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; - SDL_UpdateFullscreenMode(window, SDL_FALSE, SDL_TRUE); + SDL_UpdateFullscreenMode(window, false, true); } else if ([data.listener isInFullscreenSpaceTransition]) { [data.listener addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; } else { @@ -2633,7 +2633,7 @@ void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) ConvertNSRect(&rect); if (data.send_floating_position) { - data.send_floating_position = SDL_FALSE; + data.send_floating_position = false; [nswindow setFrameOrigin:rect.origin]; ScheduleContextUpdates(data); } @@ -2642,7 +2642,7 @@ void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered) +void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) { @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; @@ -2655,12 +2655,12 @@ void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_boo } } } else { - data.border_toggled = SDL_TRUE; + data.border_toggled = true; } } } -void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) +void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) { @autoreleasepool { /* Don't set this if we're in or transitioning to/from a space! @@ -2685,7 +2685,7 @@ void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bo } } -void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top) +void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) { @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; @@ -2902,7 +2902,7 @@ int Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -int Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; @@ -2979,23 +2979,23 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) +bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) { @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; if ([data.listener isInFullscreenSpace]) { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } } -SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_bool blocking) +bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking) { @autoreleasepool { - SDL_bool succeeded = SDL_FALSE; + bool succeeded = false; SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; data.in_blocking_transition = blocking; @@ -3028,7 +3028,7 @@ SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_ } // Return TRUE to prevent non-space fullscreen logic from running - succeeded = SDL_TRUE; + succeeded = true; } data.in_blocking_transition = NO; @@ -3036,7 +3036,7 @@ SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_ } } -int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled) { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; @@ -3044,7 +3044,7 @@ int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) return 0; } -void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) +void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept) { @autoreleasepool { SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; @@ -3103,7 +3103,7 @@ int Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOpera } } -int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable) +int Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) { return 0; // just succeed, the real work is done elsewhere. } @@ -3127,7 +3127,7 @@ int Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) */ Uint64 timeout = SDL_GetTicksNS() + SDL_MS_TO_NS(2000); SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; - while (SDL_TRUE) { + while (true) { SDL_PumpEvents(); if (SDL_GetTicksNS() >= timeout) { diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index c0818b64f1..38d6c0a955 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -61,7 +61,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window } // Send the data to the display - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES, false)) { char file[128]; (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index dc36a6cf3f..52551268f1 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -68,15 +68,15 @@ static void DUMMY_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) // DUMMY driver bootstrap functions -static SDL_bool DUMMY_Available(const char *enable_hint) +static bool DUMMY_Available(const char *enable_hint) { const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); if (hint) { if (SDL_strcmp(hint, enable_hint) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void DUMMY_DeleteDevice(SDL_VideoDevice *device) @@ -97,7 +97,7 @@ static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint) if (!device) { return NULL; } - device->is_dummy = SDL_TRUE; + device->is_dummy = true; // Set the function pointers device->VideoInit = DUMMY_VideoInit; diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index 80a4f1cd2b..3f3b3afe61 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -270,7 +270,7 @@ static EM_BOOL Emscripten_HandlePointerLockChange(int eventType, const Emscripte static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { SDL_WindowData *window_data = userData; - const SDL_bool isPointerLocked = window_data->has_pointer_lock; + const bool isPointerLocked = window_data->has_pointer_lock; float mx, my; // rescale (in case canvas is being scaled) @@ -298,7 +298,7 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse Uint8 sdl_button_state; SDL_EventType sdl_event_type; double css_w, css_h; - SDL_bool prevent_default = SDL_FALSE; // needed for iframe implementation in Chrome-based browsers. + bool prevent_default = false; // needed for iframe implementation in Chrome-based browsers. switch (mouseEvent->button) { case 0: @@ -341,7 +341,7 @@ static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseE { SDL_WindowData *window_data = userData; - const SDL_bool isPointerLocked = window_data->has_pointer_lock; + const bool isPointerLocked = window_data->has_pointer_lock; if (!isPointerLocked) { // rescale (in case canvas is being scaled) @@ -431,7 +431,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent } if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) { - SDL_SendTouch(0, deviceId, id, window_data->window, SDL_TRUE, x, y, 1.0f); + SDL_SendTouch(0, deviceId, id, window_data->window, true, x, y, 1.0f); // disable browser scrolling/pinch-to-zoom if app handles touch events if (!preventDefault && SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) { @@ -440,7 +440,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) { SDL_SendTouchMotion(0, deviceId, id, window_data->window, x, y, 1.0f); } else { - SDL_SendTouch(0, deviceId, id, window_data->window, SDL_FALSE, x, y, 1.0f); + SDL_SendTouch(0, deviceId, id, window_data->window, false, x, y, 1.0f); // block browser's simulated mousedown/mouseup on touchscreen devices preventDefault = 1; @@ -458,8 +458,8 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent SDL_WindowData *window_data = (SDL_WindowData *)userData; SDL_Scancode scancode = Emscripten_MapScanCode(keyEvent->code); SDL_Keycode keycode = SDLK_UNKNOWN; - SDL_bool prevent_default = SDL_FALSE; - SDL_bool is_nav_key = SDL_FALSE; + bool prevent_default = false; + bool is_nav_key = false; if (scancode == SDL_SCANCODE_UNKNOWN) { if (SDL_strcmp(keyEvent->key, "Sleep") == 0) { @@ -527,11 +527,11 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent (scancode == SDL_SCANCODE_DOWN) || ((scancode >= SDL_SCANCODE_F1) && (scancode <= SDL_SCANCODE_F15)) || keyEvent->ctrlKey) { - is_nav_key = SDL_TRUE; + is_nav_key = true; } if ((eventType == EMSCRIPTEN_EVENT_KEYDOWN) && SDL_TextInputActive(window_data->window) && !is_nav_key) { - prevent_default = SDL_FALSE; + prevent_default = false; } return prevent_default; @@ -562,7 +562,7 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); } - SDL_UpdateFullscreenMode(window_data->window, fullscreenChangeEvent->isFullscreen, SDL_FALSE); + SDL_UpdateFullscreenMode(window_data->window, fullscreenChangeEvent->isFullscreen, false); return 0; } @@ -570,13 +570,13 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) { SDL_WindowData *window_data = userData; - SDL_bool force = SDL_FALSE; + bool force = false; // update pixel ratio if (window_data->window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { if (window_data->pixel_ratio != emscripten_get_device_pixel_ratio()) { window_data->pixel_ratio = emscripten_get_device_pixel_ratio(); - force = SDL_TRUE; + force = true; } } @@ -668,7 +668,7 @@ static void Emscripten_UpdatePointerFromEvent(SDL_WindowData *window_data, const const double xscale = window_data->window->w / client_w; const double yscale = window_data->window->h / client_h; - const SDL_bool isPointerLocked = window_data->has_pointer_lock; + const bool isPointerLocked = window_data->has_pointer_lock; float mx, my; if (isPointerLocked) { mx = (float)(event->movementX * xscale); diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 3d821ae56f..d2d3fb0217 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -142,7 +142,7 @@ int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo }, surface->w, surface->h, surface->pixels, data->canvas_id); /* *INDENT-ON* */ // clang-format on - if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { + if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, true)) { // give back control to browser for screen refresh emscripten_sleep(0); } diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index 3ef88bae0e..eff5b07935 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -41,7 +41,7 @@ #endif #endif -static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL_bool is_custom) +static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, bool is_custom) { SDL_CursorData *curdata; SDL_Cursor *cursor = SDL_calloc(1, sizeof(SDL_Cursor)); @@ -62,7 +62,7 @@ static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL static SDL_Cursor *Emscripten_CreateDefaultCursor(void) { - return Emscripten_CreateCursorFromString("default", SDL_FALSE); + return Emscripten_CreateCursorFromString("default", false); } EM_JS_DEPS(sdlmouse, "$stringToUTF8,$UTF8ToString"); @@ -113,14 +113,14 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int SDL_DestroySurface(conv_surf); - return Emscripten_CreateCursorFromString(cursor_url, SDL_TRUE); + return Emscripten_CreateCursorFromString(cursor_url, true); } static SDL_Cursor *Emscripten_CreateSystemCursor(SDL_SystemCursor id) { const char *cursor_name = SDL_GetCSSCursorName(id, NULL); - return Emscripten_CreateCursorFromString(cursor_name, SDL_FALSE); + return Emscripten_CreateCursorFromString(cursor_name, false); } static void Emscripten_FreeCursor(SDL_Cursor *cursor) @@ -169,7 +169,7 @@ static int Emscripten_ShowCursor(SDL_Cursor *cursor) return 0; } -static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) +static int Emscripten_SetRelativeMouseMode(bool enabled) { SDL_Window *window; SDL_WindowData *window_data; diff --git a/src/video/emscripten/SDL_emscriptenmouse.h b/src/video/emscripten/SDL_emscriptenmouse.h index b155a9801e..fa50b24394 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.h +++ b/src/video/emscripten/SDL_emscriptenmouse.h @@ -25,7 +25,7 @@ struct SDL_CursorData { const char *system_cursor; - SDL_bool is_custom; + bool is_custom; }; extern void Emscripten_InitMouse(void); diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c index b9afb8a97c..e3be1b475c 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.c +++ b/src/video/emscripten/SDL_emscriptenopengles.c @@ -131,7 +131,7 @@ int Emscripten_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) int Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) { - if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { + if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, true)) { // give back control to browser for screen refresh emscripten_sleep(0); } diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 607b765621..c07d370ebf 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -137,8 +137,8 @@ int Emscripten_VideoInit(SDL_VideoDevice *_this) Emscripten_InitMouse(); // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); // We're done! return 0; @@ -301,7 +301,7 @@ static int Emscripten_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *wi if (fullscreen) { EmscriptenFullscreenStrategy strategy; - SDL_bool is_fullscreen_desktop = !window->fullscreen_exclusive; + bool is_fullscreen_desktop = !window->fullscreen_exclusive; SDL_zero(strategy); strategy.scaleMode = is_fullscreen_desktop ? EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH : EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT; diff --git a/src/video/emscripten/SDL_emscriptenvideo.h b/src/video/emscripten/SDL_emscriptenvideo.h index f5797e3c60..4dd63cb267 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.h +++ b/src/video/emscripten/SDL_emscriptenvideo.h @@ -39,12 +39,12 @@ struct SDL_WindowData float pixel_ratio; - SDL_bool external_size; + bool external_size; Uint32 fullscreen_mode_flags; - SDL_bool fullscreen_resize; + bool fullscreen_resize; - SDL_bool has_pointer_lock; + bool has_pointer_lock; }; #endif // SDL_emscriptenvideo_h_ diff --git a/src/video/gdk/SDL_gdktextinput.cpp b/src/video/gdk/SDL_gdktextinput.cpp index b7c9aaabaa..c7e1739982 100644 --- a/src/video/gdk/SDL_gdktextinput.cpp +++ b/src/video/gdk/SDL_gdktextinput.cpp @@ -48,7 +48,7 @@ static XTaskQueueHandle g_TextTaskQueue = NULL; static XAsyncBlock *g_TextBlock = NULL; // Creation parameters -static SDL_bool g_DidRegisterHints = SDL_FALSE; +static bool g_DidRegisterHints = false; static char *g_TitleText = NULL; static char *g_DescriptionText = NULL; static char *g_DefaultText = NULL; @@ -153,7 +153,7 @@ static void CALLBACK GDK_InternalTextEntryCallback(XAsyncBlock *asyncBlock) void GDK_EnsureHints(void) { - if (g_DidRegisterHints == SDL_FALSE) { + if (g_DidRegisterHints == false) { SDL_AddHintCallback( SDL_HINT_GDK_TEXTINPUT_TITLE, GDK_InternalHintCallback, @@ -174,7 +174,7 @@ void GDK_EnsureHints(void) SDL_HINT_GDK_TEXTINPUT_MAX_LENGTH, GDK_InternalHintCallback, &g_MaxTextLength); - g_DidRegisterHints = SDL_TRUE; + g_DidRegisterHints = true; } } @@ -220,10 +220,10 @@ int GDK_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -SDL_bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { // Currently always true for this input method - return SDL_TRUE; + return true; } void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -310,7 +310,7 @@ void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) } } -SDL_bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { return (g_TextBlock != NULL); } diff --git a/src/video/gdk/SDL_gdktextinput.h b/src/video/gdk/SDL_gdktextinput.h index 4b343da973..37a7ba18f1 100644 --- a/src/video/gdk/SDL_gdktextinput.h +++ b/src/video/gdk/SDL_gdktextinput.h @@ -37,10 +37,10 @@ int GDK_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); int GDK_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); int GDK_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window); -SDL_bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -SDL_bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); #ifdef __cplusplus } diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index 356f650855..bee65da48e 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -75,8 +75,8 @@ char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) { return result; } -SDL_bool HAIKU_HasClipboardText(SDL_VideoDevice *_this) { - SDL_bool result = SDL_FALSE; +bool HAIKU_HasClipboardText(SDL_VideoDevice *_this) { + bool result = false; char *text = HAIKU_GetClipboardText(_this); if (text) { result = (text[0] != '\0'); diff --git a/src/video/haiku/SDL_bclipboard.h b/src/video/haiku/SDL_bclipboard.h index ce36bf3c36..aba0e0da98 100644 --- a/src/video/haiku/SDL_bclipboard.h +++ b/src/video/haiku/SDL_bclipboard.h @@ -26,6 +26,6 @@ extern int HAIKU_SetClipboardText(SDL_VideoDevice *_this, const char *text); extern char *HAIKU_GetClipboardText(SDL_VideoDevice *_this); -extern SDL_bool HAIKU_HasClipboardText(SDL_VideoDevice *_this); +extern bool HAIKU_HasClipboardText(SDL_VideoDevice *_this); #endif diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 8cb772c50a..b22b637ee6 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -228,7 +228,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) return 0; } -static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) +static int HAIKU_SetRelativeMouseMode(bool enabled) { SDL_Window *window = SDL_GetMouseFocus(); if (!window) { @@ -279,8 +279,8 @@ int HAIKU_VideoInit(SDL_VideoDevice *_this) HAIKU_MouseInit(_this); // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); #ifdef SDL_VIDEO_OPENGL // testgl application doesn't load library, just tries to load symbols diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index 2f5e0bb8f5..2ec0e2ed9f 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -107,15 +107,15 @@ void HAIKU_SetWindowSize(SDL_VideoDevice *_this, SDL_Window * window) { _ToBeWin(window)->PostMessage(&msg); } -void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window * window, SDL_bool bordered) { +void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window * window, bool bordered) { BMessage msg(BWIN_SET_BORDERED); - msg.AddBool("window-border", bordered != SDL_FALSE); + msg.AddBool("window-border", bordered != false); _ToBeWin(window)->PostMessage(&msg); } -void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window * window, SDL_bool resizable) { +void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window * window, bool resizable) { BMessage msg(BWIN_SET_RESIZABLE); - msg.AddBool("window-resizable", resizable != SDL_FALSE); + msg.AddBool("window-resizable", resizable != false); _ToBeWin(window)->PostMessage(&msg); } @@ -166,7 +166,7 @@ void HAIKU_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window * window) { _ToBeWin(window)->PostMessage(&msg); } -int HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window * window, SDL_bool grabbed) { +int HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window * window, bool grabbed) { // TODO: Implement this! return SDL_Unsupported(); } diff --git a/src/video/haiku/SDL_bwindow.h b/src/video/haiku/SDL_bwindow.h index fed409ee1e..82815322aa 100644 --- a/src/video/haiku/SDL_bwindow.h +++ b/src/video/haiku/SDL_bwindow.h @@ -35,10 +35,10 @@ extern void HAIKU_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void HAIKU_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void HAIKU_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void HAIKU_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); -extern void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); +extern void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); extern int HAIKU_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); -extern int HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); extern void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); #endif diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index f186ec7a7e..0ce28d35d1 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -267,7 +267,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ straight-alpha pixels, so we always have to convert. */ SDL_PremultiplyAlpha(surface->w, surface->h, surface->format, surface->pixels, surface->pitch, - SDL_PIXELFORMAT_ARGB8888, curdata->buffer, surface->w * 4, SDL_TRUE); + SDL_PIXELFORMAT_ARGB8888, curdata->buffer, surface->w * 4, true); cursor->internal = curdata; @@ -351,7 +351,7 @@ static int KMSDRM_WarpMouseGlobal(float x, float y) SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); // Update internal mouse position. - SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, false, x, y); // And now update the cursor graphic position on screen. if (dispdata->cursor_bo) { @@ -396,7 +396,7 @@ void KMSDRM_InitMouse(SDL_VideoDevice *_this, SDL_VideoDisplay *display) we don't want several cursors to be created for the same display. */ if (!dispdata->default_cursor_init) { SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor()); - dispdata->default_cursor_init = SDL_TRUE; + dispdata->default_cursor_init = true; } } diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 73ef66e9b4..d46f9b21c8 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -180,7 +180,7 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) fb_info->fb_id, flip_flags, &windata->waiting_for_flip); if (ret == 0) { - windata->waiting_for_flip = SDL_TRUE; + windata->waiting_for_flip = true; } else { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret); } diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index b9558641a2..0a64b6cadf 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -52,9 +52,9 @@ #include #ifdef SDL_PLATFORM_OPENBSD -static SDL_bool moderndri = SDL_FALSE; +static bool moderndri = false; #else -static SDL_bool moderndri = SDL_TRUE; +static bool moderndri = true; #endif static char kmsdrm_dri_path[16]; @@ -133,15 +133,15 @@ static int get_driindex(void) if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) { - SDL_bool access_denied = SDL_FALSE; + bool access_denied = false; if (SDL_GetHintBoolean( SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER, - SDL_TRUE)) { + true)) { /* Skip this device if we can't obtain * DRM master */ KMSDRM_drmSetMaster(drm_fd); if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) { - access_denied = SDL_TRUE; + access_denied = true; } } @@ -200,7 +200,7 @@ static int KMSDRM_Available(void) if (!(uname(&nameofsystem) < 0)) { releaseversion = SDL_atof(nameofsystem.release); if (releaseversion >= 6.9) { - moderndri = SDL_TRUE; + moderndri = true; } } #endif @@ -412,10 +412,10 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo) static void KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) { - *((SDL_bool *)data) = SDL_FALSE; + *((bool *)data) = false; } -SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) +bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) { SDL_VideoData *viddata = _this->internal; @@ -464,14 +464,14 @@ SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) } else { // There was another error. Don't pull again or we could get into a busy loop. SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error"); - return SDL_FALSE; // Return number 1. + return false; // Return number 1. } } if (pfd.revents & (POLLHUP | POLLERR)) { // An event arrived on the FD in time, but it's an error. SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error"); - return SDL_FALSE; // Return number 2. + return false; // Return number 2. } if (pfd.revents & POLLIN) { @@ -495,7 +495,7 @@ SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) to polling. */ } - return SDL_TRUE; + return true; } /* Given w, h and refresh rate, returns the closest DRM video mode @@ -511,7 +511,7 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display, SDL_DisplayMode closest; drmModeModeInfo *drm_mode; - if (SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f, SDL_FALSE, &closest) == 0) { + if (SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f, false, &closest) == 0) { const SDL_DisplayModeData *modedata = closest.internal; drm_mode = &connector->modes[modedata->mode_index]; return drm_mode; @@ -580,7 +580,7 @@ static uint32_t KMSDRM_CrtcGetPropId(uint32_t drm_fd, return prop_id; } -static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) +static bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) { drmModeObjectPropertiesPtr drm_props; @@ -589,7 +589,7 @@ static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vr DRM_MODE_OBJECT_CRTC); if (!drm_props) { - return SDL_FALSE; + return false; } *vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, @@ -598,15 +598,15 @@ static SDL_bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vr KMSDRM_drmModeFreeObjectProperties(drm_props); - return SDL_TRUE; + return true; } -static SDL_bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, +static bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, uint32_t output_id, char const *name) { uint32_t i; - SDL_bool found = SDL_FALSE; + bool found = false; uint64_t prop_value = 0; drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(drm_fd, @@ -614,7 +614,7 @@ static SDL_bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, DRM_MODE_OBJECT_CONNECTOR); if (!props) { - return SDL_FALSE; + return false; } for (i = 0; !found && i < props->count_props; ++i) { @@ -626,19 +626,19 @@ static SDL_bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, if (SDL_strcasecmp(drm_prop->name, name) == 0) { prop_value = props->prop_values[i]; - found = SDL_TRUE; + found = true; } KMSDRM_drmModeFreeProperty(drm_prop); } if (found) { - return prop_value ? SDL_TRUE : SDL_FALSE; + return prop_value ? true : false; } - return SDL_FALSE; + return false; } -static void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) +static void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, bool enabled) { uint32_t vrr_prop_id; if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) { @@ -652,15 +652,15 @@ static void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enable enabled); } -static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) +static bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) { uint32_t object_prop_id, vrr_prop_id; drmModeObjectPropertiesPtr props; - SDL_bool object_prop_value; + bool object_prop_value; int i; if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) { - return SDL_FALSE; + return false; } props = KMSDRM_drmModeObjectGetProperties(drm_fd, @@ -668,7 +668,7 @@ static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) DRM_MODE_OBJECT_CRTC); if (!props) { - return SDL_FALSE; + return false; } for (i = 0; i < props->count_props; ++i) { @@ -679,7 +679,7 @@ static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) } object_prop_id = drm_prop->prop_id; - object_prop_value = props->prop_values[i] ? SDL_TRUE : SDL_FALSE; + object_prop_value = props->prop_values[i] ? true : false; KMSDRM_drmModeFreeProperty(drm_prop); @@ -687,10 +687,10 @@ static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) return object_prop_value; } } - return SDL_FALSE; + return false; } -static SDL_bool KMSDRM_OrientationPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *orientation_prop_id) +static bool KMSDRM_OrientationPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *orientation_prop_id) { drmModeObjectPropertiesPtr drm_props; @@ -699,7 +699,7 @@ static SDL_bool KMSDRM_OrientationPropId(uint32_t drm_fd, uint32_t crtc_id, uint DRM_MODE_OBJECT_CONNECTOR); if (!drm_props) { - return SDL_FALSE; + return false; } *orientation_prop_id = KMSDRM_CrtcGetPropId(drm_fd, @@ -708,7 +708,7 @@ static SDL_bool KMSDRM_OrientationPropId(uint32_t drm_fd, uint32_t crtc_id, uint KMSDRM_drmModeFreeObjectProperties(drm_props); - return SDL_TRUE; + return true; } static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id) @@ -716,7 +716,7 @@ static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id) uint32_t orientation_prop_id; drmModeObjectPropertiesPtr props; int i; - SDL_bool done = SDL_FALSE; + bool done = false; int orientation = 0; if (!KMSDRM_OrientationPropId(drm_fd, crtc_id, &orientation_prop_id)) { @@ -750,7 +750,7 @@ static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id) } } - done = SDL_TRUE; + done = true; } KMSDRM_drmModeFreeProperty(drm_prop); @@ -795,7 +795,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto if the display used by the window already has a default cursor or not. If we don't, new default cursors would stack up on mouse->cursors and SDL would have to hide and delete them at quit, not to mention the memory leak... */ - dispdata->default_cursor_init = SDL_FALSE; + dispdata->default_cursor_init = false; // Try to find the connector's current encoder for (i = 0; i < resources->count_encoders; i++) { @@ -932,7 +932,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto // try to enable vrr if (KMSDRM_ConnectorCheckVrrCapable(viddata->drm_fd, connector->connector_id, "VRR_CAPABLE")) { SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Enabling VRR"); - KMSDRM_CrtcSetVrr(viddata->drm_fd, crtc->crtc_id, SDL_TRUE); + KMSDRM_CrtcSetVrr(viddata->drm_fd, crtc->crtc_id, true); } /*****************************************/ @@ -958,7 +958,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto display.desktop_mode.internal = modedata; // Add the display to the list of SDL displays. - display_id = SDL_AddVideoDisplay(&display, SDL_FALSE); + display_id = SDL_AddVideoDisplay(&display, false); if (!display_id) { ret = -1; goto cleanup; @@ -1058,7 +1058,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) if (ret) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not determine async page flip capability."); } - viddata->async_pageflip_support = async_pageflip ? SDL_TRUE : SDL_FALSE; + viddata->async_pageflip_support = async_pageflip ? true : false; /***********************************/ // Block for Vulkan compatibility. @@ -1107,7 +1107,7 @@ static int KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) ret = SDL_SetError("Couldn't create gbm device."); } - viddata->gbm_init = SDL_TRUE; + viddata->gbm_init = true; return ret; } @@ -1130,7 +1130,7 @@ static void KMSDRM_GBMDeinit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) viddata->drm_fd = -1; } - viddata->gbm_init = SDL_FALSE; + viddata->gbm_init = false; } static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) @@ -1224,7 +1224,7 @@ static void KMSDRM_DirtySurfaces(SDL_Window *window) /* Can't recreate EGL surfaces right now, need to wait until SwapWindow so the correct thread-local surface and context state are available */ - windata->egl_surface_dirty = SDL_TRUE; + windata->egl_surface_dirty = true; /* The app may be waiting for the resize event after calling SetWindowSize or SetWindowFullscreen, send a fake event for now since the actual @@ -1295,7 +1295,7 @@ int KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window) SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, dispdata->mode.hdisplay, dispdata->mode.vdisplay); - windata->egl_surface_dirty = SDL_FALSE; + windata->egl_surface_dirty = false; cleanup: @@ -1349,8 +1349,8 @@ int KMSDRM_VideoInit(SDL_VideoDevice *_this) SDL_VideoData *viddata = _this->internal; SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()"); - viddata->video_init = SDL_FALSE; - viddata->gbm_init = SDL_FALSE; + viddata->video_init = false; + viddata->gbm_init = false; /* Get KMSDRM resources info and store what we need. Getting and storing this info isn't a problem for VK compatibility. @@ -1367,7 +1367,7 @@ int KMSDRM_VideoInit(SDL_VideoDevice *_this) SDL_WSCONS_Init(); #endif - viddata->video_init = SDL_TRUE; + viddata->video_init = true; return ret; } @@ -1392,7 +1392,7 @@ void KMSDRM_VideoQuit(SDL_VideoDevice *_this) viddata->windows = NULL; viddata->max_windows = 0; viddata->num_windows = 0; - viddata->video_init = SDL_FALSE; + viddata->video_init = false; } // Read modes from the connector modes, and store them in display->display_modes. @@ -1460,7 +1460,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *windata = window->internal; SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); SDL_VideoData *viddata; - SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? + bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? unsigned int i, j; if (!windata) { @@ -1501,7 +1501,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) // If we were in Vulkan mode, get out of it. if (viddata->vulkan_mode) { - viddata->vulkan_mode = SDL_FALSE; + viddata->vulkan_mode = false; } } @@ -1539,8 +1539,8 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_VideoData *viddata = _this->internal; SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_DisplayData *dispdata = display->internal; - SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? - SDL_bool vulkan_mode = viddata->vulkan_mode; // Do we have any Vulkan windows? + bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? + bool vulkan_mode = viddata->vulkan_mode; // Do we have any Vulkan windows? NativeDisplayType egl_display; drmModeModeInfo *mode; int ret = 0; @@ -1561,9 +1561,9 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti SDL_SetPointerProperty(props, SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER, viddata->gbm_dev); // Do we want a double buffering scheme to get low video lag? - windata->double_buffer = SDL_FALSE; - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { - windata->double_buffer = SDL_TRUE; + windata->double_buffer = false; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { + windata->double_buffer = true; } if (!is_vulkan && !vulkan_mode) { // NON-Vulkan block. diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index 75fd0b8b16..86de178c44 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -80,9 +80,9 @@ struct SDL_VideoData struct gbm_device *gbm_dev; - SDL_bool video_init; // Has VideoInit succeeded? - SDL_bool vulkan_mode; // Are we in Vulkan mode? One VK window is enough to be. - SDL_bool async_pageflip_support; // Does the hardware support async. pageflips? + bool video_init; // Has VideoInit succeeded? + bool vulkan_mode; // Are we in Vulkan mode? One VK window is enough to be. + bool async_pageflip_support; // Does the hardware support async. pageflips? SDL_Window **windows; int max_windows; @@ -90,7 +90,7 @@ struct SDL_VideoData /* Even if we have several displays, we only have to open 1 FD and create 1 gbm device. */ - SDL_bool gbm_init; + bool gbm_init; }; @@ -108,7 +108,7 @@ struct SDL_DisplayData drmModeModeInfo fullscreen_mode; drmModeCrtc *saved_crtc; // CRTC to restore on quit - SDL_bool saved_vrr; + bool saved_vrr; /* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's internal struct, because setting/unsetting up these is done on window creation/destruction, @@ -118,7 +118,7 @@ struct SDL_DisplayData int cursor_bo_drm_fd; uint64_t cursor_w, cursor_h; - SDL_bool default_cursor_init; + bool default_cursor_init; }; struct SDL_WindowData @@ -132,11 +132,11 @@ struct SDL_WindowData struct gbm_bo *bo; struct gbm_bo *next_bo; - SDL_bool waiting_for_flip; - SDL_bool double_buffer; + bool waiting_for_flip; + bool double_buffer; EGLSurface egl_surface; - SDL_bool egl_surface_dirty; + bool egl_surface_dirty; }; typedef struct KMSDRM_FBInfo @@ -149,7 +149,7 @@ typedef struct KMSDRM_FBInfo int KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window); KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo); KMSDRM_FBInfo *KMSDRM_FBFromBO2(SDL_VideoDevice *_this, struct gbm_bo *bo, int w, int h); -SDL_bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata); +bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata); /****************************************************************************/ // SDL_VideoDevice functions declaration diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 926418edec..b55619174f 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -46,8 +46,8 @@ int KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 i, extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasDisplayExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasDisplayExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { @@ -98,9 +98,9 @@ int KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasDisplayExtension = SDL_TRUE; + hasDisplayExtension = true; } } @@ -190,10 +190,10 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, VkDisplayPlaneAlphaFlagBitsKHR alpha_mode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; VkResult result; - SDL_bool ret = -1; - SDL_bool valid_gpu = SDL_FALSE; - SDL_bool mode_found = SDL_FALSE; - SDL_bool plane_supports_display = SDL_FALSE; + bool ret = -1; + bool valid_gpu = false; + bool mode_found = false; + bool plane_supports_display = false; // Get the display index from the display being used by the window. int display_index = SDL_GetDisplayIndex(SDL_GetDisplayForWindow(window)); @@ -292,7 +292,7 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, if (device_props->apiVersion >= 1 && (device_props->deviceType == 1 || device_props->deviceType == 2)) { gpu = physical_devices[i]; - valid_gpu = SDL_TRUE; + valid_gpu = true; break; } } @@ -346,7 +346,7 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, if (mode_props[i].parameters.visibleRegion.width == window->w && mode_props[i].parameters.visibleRegion.height == window->h) { display_mode_props = mode_props[i]; - mode_found = SDL_TRUE; + mode_found = true; break; } } @@ -426,10 +426,10 @@ int KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, /* Iterate the list of displays supported by this plane in order to find out if the chosen display is among them. */ - plane_supports_display = SDL_FALSE; + plane_supports_display = false; for (j = 0; j < supported_displays_count; j++) { if (supported_displays[j] == display) { - plane_supports_display = SDL_TRUE; + plane_supports_display = true; break; } } diff --git a/src/video/n3ds/SDL_n3dsswkb.c b/src/video/n3ds/SDL_n3dsswkb.c index d8c7e142d6..b4814640bb 100644 --- a/src/video/n3ds/SDL_n3dsswkb.c +++ b/src/video/n3ds/SDL_n3dsswkb.c @@ -45,9 +45,9 @@ void N3DS_SwkbQuit(void) return; } -SDL_bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } int N3DS_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) diff --git a/src/video/n3ds/SDL_n3dsswkb.h b/src/video/n3ds/SDL_n3dsswkb.h index d47c4dc4f5..ba9560d207 100644 --- a/src/video/n3ds/SDL_n3dsswkb.h +++ b/src/video/n3ds/SDL_n3dsswkb.h @@ -28,7 +28,7 @@ void N3DS_SwkbInit(); void N3DS_SwkbPoll(); void N3DS_SwkbQuit(); -SDL_bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this); int N3DS_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); int N3DS_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/src/video/n3ds/SDL_n3dstouch.c b/src/video/n3ds/SDL_n3dstouch.c index 10bb0a6f4d..7379ea15ea 100644 --- a/src/video/n3ds/SDL_n3dstouch.c +++ b/src/video/n3ds/SDL_n3dstouch.c @@ -58,8 +58,8 @@ void N3DS_PollTouch(SDL_VideoDevice *_this) touchPosition touch; SDL_Window *window; SDL_VideoDisplay *display; - static SDL_bool was_pressed = SDL_FALSE; - SDL_bool pressed; + static bool was_pressed = false; + bool pressed; hidTouchRead(&touch); pressed = (touch.px != 0 || touch.py != 0); diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c index bf5dfae83d..8c1c7ea962 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -167,7 +167,7 @@ static int AddN3DSDisplay(gfxScreen_t screen) display.desktop_mode = mode; display.internal = display_driver_data; - return SDL_AddVideoDisplay(&display, SDL_FALSE); + return SDL_AddVideoDisplay(&display, false); } static void N3DS_VideoQuit(SDL_VideoDevice *_this) diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index dfea274183..0de27480dd 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -62,7 +62,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi } // Send the data to the display - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES, false)) { char file[128]; (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index d04d287ea2..5bb36f6f41 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -51,15 +51,15 @@ static void OFFSCREEN_DeleteDevice(SDL_VideoDevice *device) SDL_free(device); } -static SDL_bool OFFSCREEN_Available(const char *enable_hint) +static bool OFFSCREEN_Available(const char *enable_hint) { const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); if (hint) { if (SDL_strcmp(hint, enable_hint) == 0) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) diff --git a/src/video/offscreen/SDL_offscreenvulkan.c b/src/video/offscreen/SDL_offscreenvulkan.c index 044af7cebf..4222647549 100644 --- a/src/video/offscreen/SDL_offscreenvulkan.c +++ b/src/video/offscreen/SDL_offscreenvulkan.c @@ -60,8 +60,8 @@ int OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasHeadlessSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasHeadlessSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; Uint32 i; const char **paths; @@ -134,9 +134,9 @@ int OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasHeadlessSurfaceExtension = SDL_TRUE; + hasHeadlessSurfaceExtension = true; } } SDL_free(extensions); @@ -175,7 +175,7 @@ char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this #if (HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD == 0) VkExtensionProperties *enumerateExtensions = NULL; Uint32 enumerateExtensionCount = 0; - SDL_bool hasHeadlessSurfaceExtension = SDL_FALSE; + bool hasHeadlessSurfaceExtension = false; Uint32 i; #endif @@ -194,12 +194,12 @@ char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this &enumerateExtensionCount); for (i = 0; i < enumerateExtensionCount; i++) { if (SDL_strcmp(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, enumerateExtensions[i].extensionName) == 0) { - hasHeadlessSurfaceExtension = SDL_TRUE; + hasHeadlessSurfaceExtension = true; } } SDL_free(enumerateExtensions); } - if ( hasHeadlessSurfaceExtension == SDL_TRUE ) { + if ( hasHeadlessSurfaceExtension == true ) { *count = SDL_arraysize(returnExtensions); } else { *count = SDL_arraysize(returnExtensions) - 1; // assumes VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME is last diff --git a/src/video/psp/SDL_pspgl.c b/src/video/psp/SDL_pspgl.c index 8e3c8d16c3..482bce6693 100644 --- a/src/video/psp/SDL_pspgl.c +++ b/src/video/psp/SDL_pspgl.c @@ -83,7 +83,7 @@ SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) // EGL init taken from glutCreateWindow() in PSPGL's glut.c. EGLCHK(display = eglGetDisplay(0)); EGLCHK(eglInitialize(display, NULL, NULL)); - wdata->uses_gles = SDL_TRUE; + wdata->uses_gles = true; window->flags |= SDL_WINDOW_FULLSCREEN; // Setup the config based on SDL's current values. @@ -170,7 +170,7 @@ int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) SDL_VideoData *phdata = _this->internal; EGLBoolean status; - if (phdata->egl_initialized != SDL_TRUE) { + if (phdata->egl_initialized != true) { return SDL_SetError("PSP: GLES initialization failed, no OpenGL ES support"); } diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index 5be0f5e5e5..5c25401e0c 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -39,7 +39,7 @@ #include /* unused -static SDL_bool PSP_initialized = SDL_FALSE; +static bool PSP_initialized = false; */ static void PSP_Destroy(SDL_VideoDevice *device) @@ -77,7 +77,7 @@ static SDL_VideoDevice *PSP_Create(void) device->internal = phdata; - phdata->egl_initialized = SDL_TRUE; + phdata->egl_initialized = true; // Setup amount of available displays device->num_displays = 0; @@ -244,9 +244,9 @@ void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { } -SDL_bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -349,9 +349,9 @@ void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prop void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { } -SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { - return SDL_FALSE; + return false; } #endif // SDL_VIDEO_DRIVER_PSP diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index 3219f000ec..314ffe3856 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -29,14 +29,14 @@ struct SDL_VideoData { - SDL_bool egl_initialized; // OpenGL ES device initialization status + bool egl_initialized; // OpenGL ES device initialization status uint32_t egl_refcount; // OpenGL ES reference count }; struct SDL_WindowData { - SDL_bool uses_gles; // if true window must support OpenGL ES + bool uses_gles; // if true window must support OpenGL ES }; @@ -73,9 +73,9 @@ int PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); int PSP_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); // PSP on screen keyboard -SDL_bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -SDL_bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); #endif // SDL_pspvideo_h_ diff --git a/src/video/qnx/SDL_qnxvideo.c b/src/video/qnx/SDL_qnxvideo.c index 8ec8522592..5831a96202 100644 --- a/src/video/qnx/SDL_qnxvideo.c +++ b/src/video/qnx/SDL_qnxvideo.c @@ -48,13 +48,13 @@ static int videoInit(SDL_VideoDevice *_this) SDL_zero(display); - if (SDL_AddVideoDisplay(&display, SDL_FALSE) < 0) { + if (SDL_AddVideoDisplay(&display, false) < 0) { return -1; } // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); return 0; } diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 7448acb6ef..6cccafadc5 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -276,7 +276,7 @@ static int RPI_WarpMouseGlobal(float x, float y) } // Update internal mouse position. - SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, false, x, y); return RPI_WarpMouseGlobalGraphically(x, y); } diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 9450ba796b..30473d7c41 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -183,7 +183,7 @@ static void AddDispManXDisplay(const int display_id) display.internal = data; - SDL_AddVideoDisplay(&display, SDL_FALSE); + SDL_AddVideoDisplay(&display, false); } int RPI_VideoInit(SDL_VideoDevice *_this) @@ -296,11 +296,11 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } // Start generating vsync callbacks if necessary - wdata->double_buffer = SDL_FALSE; - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { + wdata->double_buffer = false; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { wdata->vsync_cond = SDL_CreateCondition(); wdata->vsync_cond_mutex = SDL_CreateMutex(); - wdata->double_buffer = SDL_TRUE; + wdata->double_buffer = true; vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata); } diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h index 267fa970e6..af922cb1b3 100644 --- a/src/video/raspberry/SDL_rpivideo.h +++ b/src/video/raspberry/SDL_rpivideo.h @@ -48,7 +48,7 @@ struct SDL_WindowData // Vsync callback cond and mutex SDL_Condition *vsync_cond; SDL_Mutex *vsync_cond_mutex; - SDL_bool double_buffer; + bool double_buffer; }; #define SDL_RPI_VIDEOLAYER 10000 // High enough so to occlude everything diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index fd74a97ff8..5042a8c31b 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -126,7 +126,7 @@ void RISCOS_PollMouse(SDL_VideoDevice *_this) buttons = regs.r[2]; if (mouse->x != x || mouse->y != y) { - SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, (float)x, (float)y); + SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y); } if (internal->last_mouse_buttons != buttons) { @@ -148,9 +148,9 @@ int RISCOS_InitEvents(SDL_VideoDevice *_this) } status = (_kernel_osbyte(202, 0, 255) & 0xFF); - SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? SDL_FALSE : SDL_TRUE); - SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? SDL_FALSE : SDL_TRUE); - SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? false : true); + SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? false : true); + SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? true : false); _kernel_swi(OS_Mouse, ®s, ®s); internal->last_mouse_buttons = regs.r[2]; diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index 08a21ff76a..1bb0506614 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -105,7 +105,7 @@ static int read_mode_variable(int *block, int var) return regs.r[2]; } -static SDL_bool read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool extended) +static bool read_mode_block(int *block, SDL_DisplayMode *mode, bool extended) { int xres, yres, ncolour, modeflags, log2bpp, rate; @@ -124,7 +124,7 @@ static SDL_bool read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool exte log2bpp = block[5]; rate = block[6]; } else { - return SDL_FALSE; + return false; } if (extended) { @@ -141,7 +141,7 @@ static SDL_bool read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool exte mode->format = RISCOS_ModeToPixelFormat(ncolour, modeflags, log2bpp); mode->refresh_rate = (float)rate; - return SDL_TRUE; + return true; } static void *convert_mode_block(const int *block) @@ -213,7 +213,7 @@ int RISCOS_InitModes(SDL_VideoDevice *_this) } current_mode = (int *)regs.r[1]; - if (!read_mode_block(current_mode, &mode, SDL_TRUE)) { + if (!read_mode_block(current_mode, &mode, true)) { return SDL_SetError("Unsupported mode block format %d", current_mode[0]); } @@ -259,7 +259,7 @@ int RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) } for (pos = block; pos < (void *)regs.r[6]; pos += *((int *)pos)) { - if (!read_mode_block(pos + 4, &mode, SDL_FALSE)) { + if (!read_mode_block(pos + 4, &mode, false)) { continue; } diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 993a684742..f81cbd19cc 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -110,8 +110,8 @@ static int RISCOS_VideoInit(SDL_VideoDevice *_this) } // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); if (RISCOS_InitModes(_this) < 0) { return -1; diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index ba71b27bae..8599cd3b9e 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -404,9 +404,9 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) [self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0]; // run the user's application, passing argc and argv - SDL_SetiOSEventPump(SDL_TRUE); + SDL_SetiOSEventPump(true); exit_status = forward_main(forward_argc, forward_argv); - SDL_SetiOSEventPump(SDL_FALSE); + SDL_SetiOSEventPump(false); if (launchWindow) { launchWindow.hidden = YES; diff --git a/src/video/uikit/SDL_uikitclipboard.h b/src/video/uikit/SDL_uikitclipboard.h index 9d508a9095..aac728f17c 100644 --- a/src/video/uikit/SDL_uikitclipboard.h +++ b/src/video/uikit/SDL_uikitclipboard.h @@ -25,7 +25,7 @@ extern int UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text); extern char *UIKit_GetClipboardText(SDL_VideoDevice *_this); -extern SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this); +extern bool UIKit_HasClipboardText(SDL_VideoDevice *_this); extern void UIKit_InitClipboard(SDL_VideoDevice *_this); extern void UIKit_QuitClipboard(SDL_VideoDevice *_this); diff --git a/src/video/uikit/SDL_uikitclipboard.m b/src/video/uikit/SDL_uikitclipboard.m index 3ccc6a2e5a..836d3ee735 100644 --- a/src/video/uikit/SDL_uikitclipboard.m +++ b/src/video/uikit/SDL_uikitclipboard.m @@ -57,15 +57,15 @@ char *UIKit_GetClipboardText(SDL_VideoDevice *_this) #endif } -SDL_bool UIKit_HasClipboardText(SDL_VideoDevice *_this) +bool UIKit_HasClipboardText(SDL_VideoDevice *_this) { @autoreleasepool { #ifndef SDL_PLATFORM_TVOS if ([UIPasteboard generalPasteboard].string != nil) { - return SDL_TRUE; + return true; } #endif - return SDL_FALSE; + return false; } } diff --git a/src/video/uikit/SDL_uikitevents.h b/src/video/uikit/SDL_uikitevents.h index 6bf2392474..b0c152a95d 100644 --- a/src/video/uikit/SDL_uikitevents.h +++ b/src/video/uikit/SDL_uikitevents.h @@ -34,7 +34,7 @@ extern void SDL_InitGCKeyboard(void); extern void SDL_QuitGCKeyboard(void); extern void SDL_InitGCMouse(void); -extern SDL_bool SDL_GCMouseRelativeMode(void); +extern bool SDL_GCMouseRelativeMode(void); extern void SDL_QuitGCMouse(void); #endif // SDL_uikitevents_h_ diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index efde5ef087..1be24d0f4a 100644 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -184,7 +184,7 @@ static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0 { SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)keyboard; - SDL_AddKeyboard(keyboardID, NULL, SDL_TRUE); + SDL_AddKeyboard(keyboardID, NULL, true); keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed) { SDL_SendKeyboardKey(0, keyboardID, 0, (SDL_Scancode)keyCode, pressed ? SDL_PRESSED : SDL_RELEASED); @@ -199,7 +199,7 @@ static void OnGCKeyboardDisconnected(GCKeyboard *keyboard) API_AVAILABLE(macos(1 { SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)keyboard; - SDL_RemoveKeyboard(keyboardID, SDL_TRUE); + SDL_RemoveKeyboard(keyboardID, true); keyboard.keyboardInput.keyChangedHandler = nil; } @@ -272,7 +272,7 @@ void SDL_QuitGCKeyboard(void) static id mouse_connect_observer = nil; static id mouse_disconnect_observer = nil; -static bool mouse_relative_mode = SDL_FALSE; +static bool mouse_relative_mode = false; static SDL_MouseWheelDirection mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; static void UpdateScrollDirection(void) @@ -309,7 +309,7 @@ static void UpdatePointerLock(void) } } -static int SetGCMouseRelativeMode(SDL_bool enabled) +static int SetGCMouseRelativeMode(bool enabled) { mouse_relative_mode = enabled; UpdatePointerLock(); @@ -325,7 +325,7 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14 { SDL_MouseID mouseID = (SDL_MouseID)(uintptr_t)mouse; - SDL_AddMouse(mouseID, NULL, SDL_TRUE); + SDL_AddMouse(mouseID, NULL, true); mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { OnGCMouseButtonChanged(mouseID, SDL_BUTTON_LEFT, pressed); @@ -391,7 +391,7 @@ static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios UpdatePointerLock(); - SDL_RemoveMouse(mouseID, SDL_TRUE); + SDL_RemoveMouse(mouseID, true); } void SDL_InitGCMouse(void) @@ -434,7 +434,7 @@ void SDL_InitGCMouse(void) } } -SDL_bool SDL_GCMouseRelativeMode(void) +bool SDL_GCMouseRelativeMode(void) { return mouse_relative_mode; } @@ -470,9 +470,9 @@ void SDL_InitGCMouse(void) { } -SDL_bool SDL_GCMouseRelativeMode(void) +bool SDL_GCMouseRelativeMode(void) { - return SDL_FALSE; + return false; } void SDL_QuitGCMouse(void) diff --git a/src/video/uikit/SDL_uikitmessagebox.h b/src/video/uikit/SDL_uikitmessagebox.h index 5f0bf9fced..a93e891958 100644 --- a/src/video/uikit/SDL_uikitmessagebox.h +++ b/src/video/uikit/SDL_uikitmessagebox.h @@ -22,7 +22,7 @@ #ifdef SDL_VIDEO_DRIVER_UIKIT -extern SDL_bool UIKit_ShowingMessageBox(void); +extern bool UIKit_ShowingMessageBox(void); extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 72da5bf53c..0c930242e9 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -27,9 +27,9 @@ // Display a UIKit message box -static SDL_bool s_showingMessageBox = SDL_FALSE; +static bool s_showingMessageBox = false; -SDL_bool UIKit_ShowingMessageBox(void) +bool UIKit_ShowingMessageBox(void) { return s_showingMessageBox; } @@ -41,11 +41,11 @@ static void UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messagebox @autoreleasepool { // Run the main event loop until the alert has finished // Note that this needs to be done on the main thread - s_showingMessageBox = SDL_TRUE; + s_showingMessageBox = true; while ((*clickedindex) == messageboxdata->numbuttons) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } - s_showingMessageBox = SDL_FALSE; + s_showingMessageBox = false; } } diff --git a/src/video/uikit/SDL_uikitmodes.h b/src/video/uikit/SDL_uikitmodes.h index f09547d4fe..cbb98d5912 100644 --- a/src/video/uikit/SDL_uikitmodes.h +++ b/src/video/uikit/SDL_uikitmodes.h @@ -42,13 +42,13 @@ @end #ifndef SDL_PLATFORM_VISIONOS -extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); +extern bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); #endif extern int UIKit_InitModes(SDL_VideoDevice *_this); #ifndef SDL_PLATFORM_VISIONOS -extern int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event); -extern void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event); +extern int UIKit_AddDisplay(UIScreen *uiscreen, bool send_event); +extern void UIKit_DelDisplay(UIScreen *uiscreen, bool send_event); #endif extern int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); extern int UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 31965cc0fc..57b8dcac8d 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -86,13 +86,13 @@ + (void)screenConnected:(NSNotification *)notification { UIScreen *uiscreen = [notification object]; - UIKit_AddDisplay(uiscreen, SDL_TRUE); + UIKit_AddDisplay(uiscreen, true); } + (void)screenDisconnected:(NSNotification *)notification { UIScreen *uiscreen = [notification object]; - UIKit_DelDisplay(uiscreen, SDL_TRUE); + UIKit_DelDisplay(uiscreen, true); } @end @@ -164,7 +164,7 @@ static int UIKit_AddSingleDisplayMode(SDL_VideoDisplay *display, int w, int h, } static int UIKit_AddDisplayMode(SDL_VideoDisplay *display, int w, int h, - UIScreen *uiscreen, UIScreenMode *uiscreenmode, SDL_bool addRotation) + UIScreen *uiscreen, UIScreenMode *uiscreenmode, bool addRotation) { if (UIKit_AddSingleDisplayMode(display, w, h, uiscreen, uiscreenmode) < 0) { return -1; @@ -203,7 +203,7 @@ static CGSize GetUIScreenModeSize(UIScreen *uiscreen, UIScreenMode *mode) return size; } -int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) +int UIKit_AddDisplay(UIScreen *uiscreen, bool send_event) { UIScreenMode *uiscreenmode = uiscreen.currentMode; CGSize size = GetUIScreenModeSize(uiscreen, uiscreenmode); @@ -275,7 +275,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event) #endif #ifdef SDL_PLATFORM_VISIONOS -int UIKit_AddDisplay(SDL_bool send_event){ +int UIKit_AddDisplay(bool send_event){ CGSize size = CGSizeMake(SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); SDL_VideoDisplay display; SDL_DisplayMode mode; @@ -308,7 +308,7 @@ int UIKit_AddDisplay(SDL_bool send_event){ #ifndef SDL_PLATFORM_VISIONOS -void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event) +void UIKit_DelDisplay(UIScreen *uiscreen, bool send_event) { SDL_DisplayID *displays; int i; @@ -330,7 +330,7 @@ void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event) } } -SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) +bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) { #ifndef SDL_PLATFORM_TVOS if (uiscreen == [UIScreen mainScreen]) { @@ -347,10 +347,10 @@ int UIKit_InitModes(SDL_VideoDevice *_this) { @autoreleasepool { #ifdef SDL_PLATFORM_VISIONOS - UIKit_AddDisplay(SDL_FALSE); + UIKit_AddDisplay(false); #else for (UIScreen *uiscreen in [UIScreen screens]) { - if (UIKit_AddDisplay(uiscreen, SDL_FALSE) < 0) { + if (UIKit_AddDisplay(uiscreen, false) < 0) { return -1; } } @@ -374,12 +374,12 @@ int UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) @autoreleasepool { SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; - SDL_bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen); - SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]); + bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen); + bool addRotation = (data.uiscreen == [UIScreen mainScreen]); NSArray *availableModes = nil; #ifdef SDL_PLATFORM_TVOS - addRotation = SDL_FALSE; + addRotation = false; availableModes = @[ data.uiscreen.currentMode ]; #else availableModes = data.uiscreen.availableModes; diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index d82f231246..899fc193ad 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -45,7 +45,7 @@ int UIKit_SuspendScreenSaver(SDL_VideoDevice *_this); void UIKit_ForceUpdateHomeIndicator(void); -SDL_bool UIKit_IsSystemVersionAtLeast(double version); +bool UIKit_IsSystemVersionAtLeast(double version); SDL_SystemTheme UIKit_GetSystemTheme(void); diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index d58ef68f84..4d0ca3bd39 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -178,12 +178,12 @@ int UIKit_SuspendScreenSaver(SDL_VideoDevice *_this) UIApplication *app = [UIApplication sharedApplication]; // Prevent the display from dimming and going to sleep. - app.idleTimerDisabled = (_this->suspend_screensaver != SDL_FALSE); + app.idleTimerDisabled = (_this->suspend_screensaver != false); } return 0; } -SDL_bool UIKit_IsSystemVersionAtLeast(double version) +bool UIKit_IsSystemVersionAtLeast(double version) { return [[UIDevice currentDevice].systemVersion doubleValue] >= version; } @@ -302,7 +302,7 @@ void SDL_NSLog(const char *prefix, const char *text) * This doesn't really have anything to do with the interfaces of the SDL video * subsystem, but we need to stuff this into an Objective-C source code file. */ -SDL_bool SDL_IsIPad(void) +bool SDL_IsIPad(void) { return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); } diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index c32a2eb470..6e68cd2eac 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -163,7 +163,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; point.x -= origin.x; point.y -= origin.y; - SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, point.x, point.y); + SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, false, point.x, point.y); } return [UIPointerRegion regionWithRect:self.bounds identifier:nil]; } @@ -277,7 +277,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, - SDL_TRUE, locationInView.x, locationInView.y, pressure); + true, locationInView.x, locationInView.y, pressure); } } } @@ -333,7 +333,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick; CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, - SDL_FALSE, locationInView.x, locationInView.y, pressure); + false, locationInView.x, locationInView.y, pressure); } } } diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index 6433e7c33c..66ee9f404a 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -87,9 +87,9 @@ @end #ifdef SDL_IPHONE_KEYBOARD -SDL_bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void UIKit_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void UIKit_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -SDL_bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); int UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); #endif diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 97e7b290c3..2f2711073b 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -654,7 +654,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char { SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN); if (keyboardVisible && - SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) { + SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) { SDL_StopTextInput(window); } return YES; @@ -679,9 +679,9 @@ static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window *window) return data.viewcontroller; } -SDL_bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } void UIKit_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -701,14 +701,14 @@ void UIKit_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) } } -SDL_bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { @autoreleasepool { SDL_uikitviewcontroller *vc = GetWindowViewController(window); if (vc != nil) { return vc.keyboardVisible; } - return SDL_FALSE; + return false; } } diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m index d56cdf7153..f89a995000 100644 --- a/src/video/uikit/SDL_uikitvulkan.m +++ b/src/video/uikit/SDL_uikitvulkan.m @@ -48,9 +48,9 @@ int UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasMetalSurfaceExtension = SDL_FALSE; - SDL_bool hasIOSSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasMetalSurfaceExtension = false; + bool hasIOSSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { @@ -132,11 +132,11 @@ int UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) for (Uint32 i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_EXT_METAL_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasMetalSurfaceExtension = SDL_TRUE; + hasMetalSurfaceExtension = true; } else if (SDL_strcmp(VK_MVK_IOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasIOSSurfaceExtension = SDL_TRUE; + hasIOSSurfaceExtension = true; } } diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index 2f085f0691..dc34f76deb 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -31,7 +31,7 @@ extern void UIKit_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); +extern void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); extern int UIKit_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); extern void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window); extern void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 1e108d5e9a..057b43b29d 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -79,7 +79,7 @@ @end -static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) +static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow *uiwindow, bool created) { SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->internal; @@ -173,9 +173,9 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie const CGSize origsize = data.uiscreen.currentMode.size; if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { SDL_DisplayMode bestmode; - SDL_bool include_high_density_modes = SDL_FALSE; + bool include_high_density_modes = false; if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { - include_high_density_modes = SDL_TRUE; + include_high_density_modes = true; } if (SDL_GetClosestFullscreenDisplayMode(display->id, window->w, window->h, 0.0f, include_high_density_modes, &bestmode) == 0) { SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)bestmode.internal; @@ -212,7 +212,7 @@ int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie } #endif - if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) { + if (SetupWindowData(_this, window, uiwindow, true) < 0) { return -1; } } @@ -293,7 +293,7 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window) [viewcontroller.view layoutIfNeeded]; } -void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered) +void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) { @autoreleasepool { if (bordered) { diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index 72c77ba9e6..95bf465202 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -49,7 +49,7 @@ int VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, true)) { const char *override = SDL_GetHint(SDL_HINT_VITA_MODULE_PATH); if (override && *override) { diff --git a/src/video/vita/SDL_vitagles.c b/src/video/vita/SDL_vitagles.c index 51600a38fc..953a7a31f0 100644 --- a/src/video/vita/SDL_vitagles.c +++ b/src/video/vita/SDL_vitagles.c @@ -99,7 +99,7 @@ SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window EGLCHK(display = eglGetDisplay(0)); EGLCHK(eglInitialize(display, NULL, NULL)); - wdata->uses_gles = SDL_TRUE; + wdata->uses_gles = true; window->flags |= SDL_WINDOW_FULLSCREEN; EGLCHK(eglBindAPI(EGL_OPENGL_ES_API)); @@ -196,7 +196,7 @@ int VITA_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) SDL_VideoData *phdata = _this->internal; EGLBoolean status; - if (phdata->egl_initialized != SDL_TRUE) { + if (phdata->egl_initialized != true) { return SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support"); } diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index 0e69a96e98..bf2d46196e 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -38,7 +38,7 @@ int VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) const char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, true)) { const char *override = SDL_GetHint(SDL_HINT_VITA_MODULE_PATH); if (override && *override) { diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c index 4502192569..f0dc5dc845 100644 --- a/src/video/vita/SDL_vitakeyboard.c +++ b/src/video/vita/SDL_vitakeyboard.c @@ -45,7 +45,7 @@ void VITA_InitKeyboard(void) sceHidKeyboardEnumerate(&keyboard_hid_handle, 1); if (keyboard_hid_handle > 0) { - SDL_AddKeyboard((SDL_KeyboardID)keyboard_hid_handle, NULL, SDL_FALSE); + SDL_AddKeyboard((SDL_KeyboardID)keyboard_hid_handle, NULL, false); } } diff --git a/src/video/vita/SDL_vitamessagebox.c b/src/video/vita/SDL_vitamessagebox.c index 609155b2ba..c01d497289 100644 --- a/src/video/vita/SDL_vitamessagebox.c +++ b/src/video/vita/SDL_vitamessagebox.c @@ -41,7 +41,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) SceMsgDialogResult dialog_result; SceCommonDialogErrorCode init_result; - SDL_bool setup_minimal_gxm = SDL_FALSE; + bool setup_minimal_gxm = false; if (messageboxdata->numbuttons > 3) { return -1; @@ -78,7 +78,7 @@ int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED) { gxm_minimal_init_for_common_dialog(); init_result = sceMsgDialogInit(¶m); - setup_minimal_gxm = SDL_TRUE; + setup_minimal_gxm = true; } gxm_init_for_common_dialog(); diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c index 25fb610c2a..337ebd991d 100644 --- a/src/video/vita/SDL_vitamouse.c +++ b/src/video/vita/SDL_vitamouse.c @@ -39,7 +39,7 @@ void VITA_InitMouse(void) sceHidMouseEnumerate(&mouse_hid_handle, 1); if (mouse_hid_handle > 0) { - SDL_AddMouse((SDL_MouseID)mouse_hid_handle, NULL, SDL_FALSE); + SDL_AddMouse((SDL_MouseID)mouse_hid_handle, NULL, false); } } @@ -79,7 +79,7 @@ void VITA_PollMouse(void) prev_buttons = m_reports[i].buttons; if (m_reports[i].rel_x || m_reports[i].rel_y) { - SDL_SendMouseMotion(0, Vita_Window, mouseID, SDL_TRUE, (float)m_reports[i].rel_x, (float)m_reports[i].rel_y); + SDL_SendMouseMotion(0, Vita_Window, mouseID, true, (float)m_reports[i].rel_x, (float)m_reports[i].rel_y); } } } diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index 94dee65bbd..2f2183357f 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -41,13 +41,13 @@ struct float range; } force_info[SCE_TOUCH_PORT_MAX_NUM]; -static SDL_bool disableFrontPoll; -static SDL_bool disableBackPoll; +static bool disableFrontPoll; +static bool disableBackPoll; void VITA_InitTouch(void) { - disableFrontPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_FRONT_TOUCH, SDL_TRUE); - disableBackPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_BACK_TOUCH, SDL_TRUE); + disableFrontPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_FRONT_TOUCH, true); + disableBackPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_BACK_TOUCH, true); sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START); @@ -125,7 +125,7 @@ void VITA_PollTouch(void) // Skip if finger was already previously down if (!finger_down) { // Send an initial touch - SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_TRUE, x, y, force); + SDL_SendTouch(0, touch_id, finger_id, Vita_Window, true, x, y, force); } // Always send the motion @@ -151,7 +151,7 @@ void VITA_PollTouch(void) VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port); finger_id = (SDL_FingerID)(touch_old[port].report[i].id + 1); // Finger released from screen - SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_FALSE, x, y, force); + SDL_SendTouch(0, touch_id, finger_id, Vita_Window, false, x, y, force); } } } diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index de784f2a57..01b2a8fcd8 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -87,9 +87,9 @@ static SDL_VideoDevice *VITA_Create(void) return NULL; } device->gl_data = gldata; - phdata->egl_initialized = SDL_TRUE; + phdata->egl_initialized = true; #endif - phdata->ime_active = SDL_FALSE; + phdata->ime_active = false; device->internal = phdata; @@ -125,7 +125,7 @@ static SDL_VideoDevice *VITA_Create(void) #if defined(SDL_VIDEO_VITA_PIB) || defined(SDL_VIDEO_VITA_PVR) #ifdef SDL_VIDEO_VITA_PVR_OGL - if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, false)) { device->GL_LoadLibrary = VITA_GL_LoadLibrary; device->GL_CreateContext = VITA_GL_CreateContext; device->GL_GetProcAddress = VITA_GL_GetProcAddress; @@ -261,7 +261,7 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties win.windowSize = PSP2_WINDOW_960X544; } if (window->flags & SDL_WINDOW_OPENGL) { - SDL_bool use_opengl = SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, SDL_FALSE); + bool use_opengl = SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, false); if (use_opengl) { // Set version to 2.1 and PROFILE to ES temp_major = _this->gl_config.major_version; @@ -320,7 +320,7 @@ void VITA_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) void VITA_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) { } -int VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { return 0; } @@ -339,9 +339,9 @@ void VITA_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) Vita_Window = NULL; } -SDL_bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } #ifndef SCE_IME_LANGUAGE_ENGLISH_US @@ -406,7 +406,7 @@ void VITA_ImeEventHandler(void *arg, const SceImeEventData *e) break; case SCE_IME_EVENT_PRESS_CLOSE: sceImeClose(); - videodata->ime_active = SDL_FALSE; + videodata->ime_active = false; break; } } @@ -508,7 +508,7 @@ void VITA_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_Pro #endif - videodata->ime_active = SDL_TRUE; + videodata->ime_active = true; } void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) @@ -528,11 +528,11 @@ void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) break; } - videodata->ime_active = SDL_FALSE; + videodata->ime_active = false; #endif } -SDL_bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { #ifdef SDL_VIDEO_VITA_PVR SDL_VideoData *videodata = _this->internal; @@ -559,7 +559,7 @@ void VITA_PumpEvents(SDL_VideoDevice *_this) VITA_PollMouse(); #ifndef SDL_VIDEO_VITA_PVR - if (videodata->ime_active == SDL_TRUE) { + if (videodata->ime_active == true) { // update IME status. Terminate, if finished SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { @@ -582,7 +582,7 @@ void VITA_PumpEvents(SDL_VideoDevice *_this) sceImeDialogTerm(); - videodata->ime_active = SDL_FALSE; + videodata->ime_active = false; } } #endif diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h index a9956b3c0d..54f1bb844d 100644 --- a/src/video/vita/SDL_vitavideo.h +++ b/src/video/vita/SDL_vitavideo.h @@ -33,16 +33,16 @@ struct SDL_VideoData { - SDL_bool egl_initialized; // OpenGL device initialization status + bool egl_initialized; // OpenGL device initialization status uint32_t egl_refcount; // OpenGL reference count SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; - SDL_bool ime_active; + bool ime_active; }; struct SDL_WindowData { - SDL_bool uses_gles; + bool uses_gles; SceUID buffer_uid; void *buffer; #ifdef SDL_VIDEO_VITA_PVR @@ -72,7 +72,7 @@ void VITA_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); void VITA_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void VITA_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); void VITA_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -int VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +int VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); void VITA_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); #ifdef SDL_VIDEO_DRIVER_VITA @@ -96,10 +96,10 @@ int VITA_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); #endif // VITA on screen keyboard -SDL_bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this); void VITA_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -SDL_bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); void VITA_PumpEvents(SDL_VideoDevice *_this); diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index a4bb94f1ef..081f980afe 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -157,7 +157,7 @@ static int VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) display.name = VIVANTE_GetDisplayName(_this); display.desktop_mode = mode; display.internal = data; - if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) { + if (SDL_AddVideoDisplay(&display, false) == 0) { return -1; } return 0; diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index 8796580346..24dfe64ab6 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -38,8 +38,8 @@ int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 i, extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasDisplayExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasDisplayExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { return SDL_SetError("Vulkan already loaded"); @@ -88,9 +88,9 @@ int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasDisplayExtension = SDL_TRUE; + hasDisplayExtension = true; } } SDL_free(extensions); diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index 2604b08d79..2d92089477 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -72,11 +72,11 @@ void *Wayland_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, si return buffer; } -SDL_bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) { SDL_VideoData *video_data = _this->internal; SDL_WaylandDataDevice *data_device = NULL; - SDL_bool result = SDL_FALSE; + bool result = false; if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; @@ -153,16 +153,16 @@ char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this) return text; } -SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this) +bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this) { SDL_VideoData *video_data = _this->internal; SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; - SDL_bool result = SDL_FALSE; + bool result = false; if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; if (primary_selection_device->selection_source) { - result = SDL_TRUE; + result = true; } else { result = Wayland_primary_selection_offer_has_mime(primary_selection_device->selection_offer, TEXT_MIME); } diff --git a/src/video/wayland/SDL_waylandclipboard.h b/src/video/wayland/SDL_waylandclipboard.h index 3ebd072eae..d2a12ce31d 100644 --- a/src/video/wayland/SDL_waylandclipboard.h +++ b/src/video/wayland/SDL_waylandclipboard.h @@ -26,9 +26,9 @@ extern const char **Wayland_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types); extern int Wayland_SetClipboardData(SDL_VideoDevice *_this); extern void *Wayland_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length); -extern SDL_bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); extern int Wayland_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text); extern char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this); -extern SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this); +extern bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this); #endif // SDL_waylandclipboard_h_ diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index e062e5f710..c6a1a8bbd9 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -435,10 +435,10 @@ int Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *o return mime_data_list_add(&offer->mimes, mime_type, NULL, 0); } -SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, +bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, const char *mime_type) { - SDL_bool found = SDL_FALSE; + bool found = false; if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; @@ -446,10 +446,10 @@ SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, return found; } -SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, +bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, const char *mime_type) { - SDL_bool found = SDL_FALSE; + bool found = false; if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; diff --git a/src/video/wayland/SDL_waylanddatamanager.h b/src/video/wayland/SDL_waylanddatamanager.h index 34deec58d8..7686875701 100644 --- a/src/video/wayland/SDL_waylanddatamanager.h +++ b/src/video/wayland/SDL_waylanddatamanager.h @@ -85,7 +85,7 @@ typedef struct uint32_t drag_serial; SDL_WaylandDataOffer *drag_offer; SDL_WaylandDataOffer *selection_offer; - SDL_bool has_mime_file, has_mime_text; + bool has_mime_file, has_mime_text; SDL_Window *dnd_window; // Clipboard and Primary Selection @@ -133,9 +133,9 @@ extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, extern void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, const char *mime_type, size_t *length); -extern SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, +extern bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, const char *mime_type); -extern SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, +extern bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, const char *mime_type); extern int Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, const char *mime_type); diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index 117ec954e6..6a60e9d8f7 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -51,7 +51,7 @@ static waylanddynlib waylandlibs[] = { { NULL, NULL } }; -static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool required) +static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, bool required) { void *fn = NULL; waylanddynlib *dynlib; @@ -142,9 +142,9 @@ int SDL_WAYLAND_LoadSymbols(void) #include "SDL_waylandsym.h" #define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname; -#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, SDL_TRUE); -#define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, SDL_FALSE); -#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *)WAYLAND_GetSym(#iface, thismod, SDL_TRUE); +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, true); +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, false); +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *)WAYLAND_GetSym(#iface, thismod, true); #include "SDL_waylandsym.h" if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT && diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index c0a1abc2fc..a4806da4eb 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -144,17 +144,17 @@ static void touch_del(SDL_TouchID id, wl_fixed_t *fx, wl_fixed_t *fy, struct wl_ } } -static SDL_bool Wayland_SurfaceHasActiveTouches(struct wl_surface *surface) +static bool Wayland_SurfaceHasActiveTouches(struct wl_surface *surface) { struct SDL_WaylandTouchPoint *tp; wl_list_for_each (tp, &touch_points, link) { if (tp->surface == surface) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static Uint64 Wayland_GetEventTimestamp(Uint64 nsTimestamp) @@ -261,10 +261,10 @@ void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input) } } -// Returns SDL_TRUE if a key repeat event was due -static SDL_bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, Uint64 elapsed) +// Returns true if a key repeat event was due +static bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, Uint64 elapsed) { - SDL_bool ret = SDL_FALSE; + bool ret = false; while (elapsed >= repeat_info->next_repeat_ns) { if (repeat_info->scancode != SDL_SCANCODE_UNKNOWN) { const Uint64 timestamp = repeat_info->wl_press_time_ns + repeat_info->next_repeat_ns; @@ -274,7 +274,7 @@ static SDL_bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, U SDL_SendKeyboardText(repeat_info->text); } repeat_info->next_repeat_ns += SDL_NS_PER_SECOND / (Uint64)repeat_info->repeat_rate; - ret = SDL_TRUE; + ret = true; } return ret; } @@ -284,16 +284,16 @@ static void keyboard_repeat_clear(SDL_WaylandKeyboardRepeat *repeat_info) if (!repeat_info->is_initialized) { return; } - repeat_info->is_key_down = SDL_FALSE; + repeat_info->is_key_down = false; } static void keyboard_repeat_set(SDL_WaylandKeyboardRepeat *repeat_info, Uint32 keyboard_id, uint32_t key, Uint64 wl_press_time_ns, - uint32_t scancode, SDL_bool has_text, char text[8]) + uint32_t scancode, bool has_text, char text[8]) { if (!repeat_info->is_initialized || !repeat_info->repeat_rate) { return; } - repeat_info->is_key_down = SDL_TRUE; + repeat_info->is_key_down = true; repeat_info->keyboard_id = keyboard_id; repeat_info->key = key; repeat_info->wl_press_time_ns = wl_press_time_ns; @@ -323,12 +323,12 @@ static void keyboard_repeat_set_text(SDL_WaylandKeyboardRepeat *repeat_info, con } } -static SDL_bool keyboard_repeat_is_set(SDL_WaylandKeyboardRepeat *repeat_info) +static bool keyboard_repeat_is_set(SDL_WaylandKeyboardRepeat *repeat_info) { return repeat_info->is_initialized && repeat_info->is_key_down; } -static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t key) +static bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t key) { return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key; } @@ -377,7 +377,7 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) { SDL_VideoData *d = _this->internal; struct SDL_WaylandInput *input = d->input; - SDL_bool key_repeat_active = SDL_FALSE; + bool key_repeat_active = false; WAYLAND_wl_display_flush(d->display); @@ -405,7 +405,7 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) } else { timeoutNS = next_repeat_wait_time; } - key_repeat_active = SDL_TRUE; + key_repeat_active = true; } } @@ -523,7 +523,7 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer, if (input->pointer_focus) { float sx = (float)(wl_fixed_to_double(sx_w) * window_data->pointer_scale.x); float sy = (float)(wl_fixed_to_double(sy_w) * window_data->pointer_scale.y); - SDL_SendMouseMotion(Wayland_GetPointerTimestamp(input, time), window_data->sdlwindow, input->pointer_id, SDL_FALSE, sx, sy); + SDL_SendMouseMotion(Wayland_GetPointerTimestamp(input, time), window_data->sdlwindow, input->pointer_id, false, sx, sy); } if (window && window->hit_test) { @@ -611,7 +611,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, } } -static SDL_bool ProcessHitTest(SDL_WindowData *window_data, +static bool ProcessHitTest(SDL_WindowData *window_data, struct wl_seat *seat, wl_fixed_t sx_w, wl_fixed_t sy_w, uint32_t serial) @@ -653,7 +653,7 @@ static SDL_bool ProcessHitTest(SDL_WindowData *window_data, serial); } } - return SDL_TRUE; + return true; case SDL_HITTEST_RESIZE_TOPLEFT: case SDL_HITTEST_RESIZE_TOP: @@ -681,14 +681,14 @@ static SDL_bool ProcessHitTest(SDL_WindowData *window_data, directions[window_data->hit_test_result - SDL_HITTEST_RESIZE_TOPLEFT]); } } - return SDL_TRUE; + return true; default: - return SDL_FALSE; + return false; } } - return SDL_FALSE; + return false; } static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, @@ -697,7 +697,7 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_ SDL_WindowData *window = input->pointer_focus; enum wl_pointer_button_state state = state_w; uint32_t sdl_button; - SDL_bool ignore_click = SDL_FALSE; + bool ignore_click = false; if (window) { SDL_VideoData *viddata = window->waylandData; @@ -728,7 +728,7 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_ if (window->last_focus_event_time_ns) { if (state == WL_POINTER_BUTTON_STATE_PRESSED && (SDL_GetTicksNS() - window->last_focus_event_time_ns) < WAYLAND_FOCUS_CLICK_TIMEOUT_NS) { - ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); + ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); } window->last_focus_event_time_ns = 0; @@ -1025,7 +1025,7 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri SDL_SetMouseFocus(window_data->sdlwindow); SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, - (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_TRUE, x, y, 1.0f); + (SDL_FingerID)(id + 1), window_data->sdlwindow, true, x, y, 1.0f); } } @@ -1046,7 +1046,7 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height; SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, - (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_FALSE, x, y, 0.0f); + (SDL_FingerID)(id + 1), window_data->sdlwindow, false, x, y, 0.0f); /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window curently * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost. @@ -1200,10 +1200,10 @@ static void Wayland_UpdateKeymap(struct SDL_WaylandInput *input) } WAYLAND_xkb_state_unref(keymap.state); - SDL_SetKeymap(keymap.keymap, SDL_TRUE); + SDL_SetKeymap(keymap.keymap, true); } else { // Virtual keyboards use the default keymap. - SDL_SetKeymap(NULL, SDL_TRUE); + SDL_SetKeymap(NULL, true); } } @@ -1455,9 +1455,9 @@ static void Wayland_ReconcileModifiers(struct SDL_WaylandInput *input) SDL_SetModState(input->pressed_modifiers | input->locked_modifiers); } -static void Wayland_HandleModifierKeys(struct SDL_WaylandInput *input, SDL_Scancode scancode, SDL_bool pressed) +static void Wayland_HandleModifierKeys(struct SDL_WaylandInput *input, SDL_Scancode scancode, bool pressed) { - const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, SDL_FALSE); + const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false); SDL_Keymod mod; switch (keycode) { @@ -1528,7 +1528,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, #ifdef SDL_USE_IME if (!input->text_input) { - SDL_IME_SetFocus(SDL_TRUE); + SDL_IME_SetFocus(true); } #endif @@ -1536,7 +1536,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, wl_array_for_each (key, keys) { const SDL_Scancode scancode = Wayland_get_scancode_from_key(input, *key + 8); - const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, SDL_FALSE); + const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false); switch (keycode) { case SDLK_LSHIFT: @@ -1548,7 +1548,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, case SDLK_LGUI: case SDLK_RGUI: case SDLK_MODE: - Wayland_HandleModifierKeys(input, scancode, SDL_TRUE); + Wayland_HandleModifierKeys(input, scancode, true); SDL_SendKeyboardKeyIgnoreModifiers(0, input->keyboard_id, *key, scancode, SDL_PRESSED); break; default: @@ -1588,7 +1588,7 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, #ifdef SDL_USE_IME if (!input->text_input) { - SDL_IME_SetFocus(SDL_FALSE); + SDL_IME_SetFocus(false); } #endif @@ -1600,42 +1600,42 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, } } -static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, SDL_bool *handled_by_ime) +static bool keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, bool *handled_by_ime) { SDL_WindowData *window = input->keyboard_focus; const xkb_keysym_t *syms; xkb_keysym_t sym; if (!window || window->keyboard_device != input || !input->xkb.state) { - return SDL_FALSE; + return false; } // TODO: Can this happen? if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) { - return SDL_FALSE; + return false; } sym = syms[0]; #ifdef SDL_USE_IME if (SDL_IME_ProcessKeyEvent(sym, key + 8, state)) { if (handled_by_ime) { - *handled_by_ime = SDL_TRUE; + *handled_by_ime = true; } - return SDL_TRUE; + return true; } #endif if (state == SDL_RELEASED) { - return SDL_FALSE; + return false; } if (input->xkb.compose_state && WAYLAND_xkb_compose_state_feed(input->xkb.compose_state, sym) == XKB_COMPOSE_FEED_ACCEPTED) { switch (WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) { case XKB_COMPOSE_COMPOSING: if (handled_by_ime) { - *handled_by_ime = SDL_TRUE; + *handled_by_ime = true; } - return SDL_TRUE; + return true; case XKB_COMPOSE_CANCELLED: default: sym = XKB_KEY_NoSymbol; @@ -1659,8 +1659,8 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, enum wl_keyboard_key_state state = state_w; SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; char text[8]; - SDL_bool has_text = SDL_FALSE; - SDL_bool handled_by_ime = SDL_FALSE; + bool has_text = false; + bool handled_by_ime = false; const Uint64 timestamp_raw_ns = Wayland_GetKeyboardTimestampRaw(input, time); Wayland_UpdateImplicitGrabSerial(input, serial); @@ -1745,7 +1745,7 @@ static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keybo struct SDL_WaylandInput *input = data; input->keyboard_repeat.repeat_rate = SDL_clamp(rate, 0, 1000); input->keyboard_repeat.repeat_delay_ms = delay; - input->keyboard_repeat.is_initialized = SDL_TRUE; + input->keyboard_repeat.is_initialized = true; } static const struct wl_keyboard_listener keyboard_listener = { @@ -1773,7 +1773,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, wl_pointer_add_listener(input->pointer, &pointer_listener, input); input->pointer_id = SDL_GetNextObjectID(); - SDL_AddMouse(input->pointer_id, WAYLAND_DEFAULT_POINTER_NAME, SDL_TRUE); + SDL_AddMouse(input->pointer_id, WAYLAND_DEFAULT_POINTER_NAME, true); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) { if (input->cursor_shape) { wp_cursor_shape_device_v1_destroy(input->cursor_shape); @@ -1783,7 +1783,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, input->pointer = NULL; input->display->pointer = NULL; - SDL_RemoveMouse(input->pointer_id, SDL_TRUE); + SDL_RemoveMouse(input->pointer_id, true); input->pointer_id = 0; } @@ -1806,12 +1806,12 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, input); input->keyboard_id = SDL_GetNextObjectID(); - SDL_AddKeyboard(input->keyboard_id, WAYLAND_DEFAULT_KEYBOARD_NAME, SDL_TRUE); + SDL_AddKeyboard(input->keyboard_id, WAYLAND_DEFAULT_KEYBOARD_NAME, true); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) { wl_keyboard_destroy(input->keyboard); input->keyboard = NULL; - SDL_RemoveKeyboard(input->keyboard_id, SDL_TRUE); + SDL_RemoveKeyboard(input->keyboard_id, true); input->keyboard_id = 0; } @@ -2022,8 +2022,8 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; - data_device->has_mime_file = SDL_FALSE; - data_device->has_mime_text = SDL_FALSE; + data_device->has_mime_file = false; + data_device->has_mime_text = false; uint32_t dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; data_device->drag_serial = serial; @@ -2034,17 +2034,17 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ // TODO: SDL Support more mime types #ifdef SDL_USE_LIBDBUS if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { - data_device->has_mime_file = SDL_TRUE; + data_device->has_mime_file = true; wl_data_offer_accept(id, serial, FILE_PORTAL_MIME); } #endif if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_MIME)) { - data_device->has_mime_file = SDL_TRUE; + data_device->has_mime_file = true; wl_data_offer_accept(id, serial, FILE_MIME); } if (Wayland_data_offer_has_mime(data_device->drag_offer, TEXT_MIME)) { - data_device->has_mime_text = SDL_TRUE; + data_device->has_mime_text = true; wl_data_offer_accept(id, serial, TEXT_MIME); } @@ -2116,8 +2116,8 @@ static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_ ". In wl_data_device_listener . data_device_handle_leave on data_offer 0x%08x for serial %d\n", -1, -1); } - data_device->has_mime_file = SDL_FALSE; - data_device->has_mime_text = SDL_FALSE; + data_device->has_mime_file = false; + data_device->has_mime_text = false; } static void data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, @@ -2157,7 +2157,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d SDL_GetWindowID(data_device->dnd_window), data_device->drag_serial); // TODO: SDL Support more mime types size_t length; - SDL_bool drop_handled = SDL_FALSE; + bool drop_handled = false; #ifdef SDL_USE_LIBDBUS if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { void *buffer = Wayland_data_offer_receive(data_device->drag_offer, @@ -2175,7 +2175,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d } dbus->free_string_array(paths); SDL_SendDropComplete(data_device->dnd_window); - drop_handled = SDL_TRUE; + drop_handled = true; } } SDL_free(buffer); @@ -2205,7 +2205,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d } else { SDL_SendDropComplete(data_device->dnd_window); } - drop_handled = SDL_TRUE; + drop_handled = true; } else if (data_device->has_mime_text) { if (buffer) { char *saveptr = NULL; @@ -2225,7 +2225,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d */ SDL_SendDropComplete(data_device->dnd_window); } - drop_handled = SDL_TRUE; + drop_handled = true; } } @@ -2335,7 +2335,7 @@ static void text_input_preedit_string(void *data, int32_t cursor_end) { SDL_WaylandTextInput *text_input = data; - text_input->has_preedit = SDL_TRUE; + text_input->has_preedit = true; if (text) { int cursor_begin_utf8 = cursor_begin >= 0 ? (int)SDL_utf8strnlen(text, cursor_begin) : -1; int cursor_end_utf8 = cursor_end >= 0 ? (int)SDL_utf8strnlen(text, cursor_end) : -1; @@ -2378,7 +2378,7 @@ static void text_input_done(void *data, if (!text_input->has_preedit) { SDL_SendEditingText("", 0, 0); } - text_input->has_preedit = SDL_FALSE; + text_input->has_preedit = false; } static const struct zwp_text_input_v3_listener text_input_listener = { @@ -2485,7 +2485,7 @@ typedef struct SDL_WaylandPenTool // a stylus, etc, on a tablet. struct zwp_tablet_tool_v2 *wltool; float x; float y; - SDL_bool frame_motion_set; + bool frame_motion_set; float frame_axes[SDL_PEN_NUM_AXES]; Uint32 frame_axes_set; int frame_pen_down; @@ -2596,7 +2596,7 @@ static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *too const float sy = sy_f * windowdata->pointer_scale.y; sdltool->x = sx; sdltool->y = sy; - sdltool->frame_motion_set = SDL_TRUE; + sdltool->frame_motion_set = true; } } @@ -2721,7 +2721,7 @@ static void tablet_tool_handle_frame(void *data, struct zwp_tablet_tool_v2 *tool // reset for next frame. sdltool->frame_pen_down = -1; - sdltool->frame_motion_set = SDL_FALSE; + sdltool->frame_motion_set = false; sdltool->frame_axes_set = 0; } @@ -2984,7 +2984,7 @@ static void relative_pointer_handle_relative_motion(void *data, dy_unaccel = wl_fixed_to_double(dy_unaccel_w); if (input->pointer_focus && d->relative_mouse_mode) { - SDL_SendMouseMotion(Wayland_GetEventTimestamp(timestamp), window->sdlwindow, input->pointer_id, SDL_TRUE, (float)dx_unaccel, (float)dy_unaccel); + SDL_SendMouseMotion(Wayland_GetEventTimestamp(timestamp), window->sdlwindow, input->pointer_id, true, (float)dx_unaccel, (float)dy_unaccel); } } diff --git a/src/video/wayland/SDL_waylandevents_c.h b/src/video/wayland/SDL_waylandevents_c.h index 6e41895db0..36b2e377f1 100644 --- a/src/video/wayland/SDL_waylandevents_c.h +++ b/src/video/wayland/SDL_waylandevents_c.h @@ -52,9 +52,9 @@ typedef struct int32_t repeat_rate; // Repeat rate in range of [1, 1000] character(s) per second int32_t repeat_delay_ms; // Time to first repeat event in milliseconds Uint32 keyboard_id; // ID of the source keyboard. - SDL_bool is_initialized; + bool is_initialized; - SDL_bool is_key_down; + bool is_key_down; uint32_t key; Uint64 wl_press_time_ns; // Key press time as reported by the Wayland API Uint64 sdl_press_time_ns; // Key press time expressed in SDL ticks @@ -141,7 +141,7 @@ struct SDL_WaylandInput SDL_WaylandTabletInput *tablet_input; - SDL_bool keyboard_is_virtual; + bool keyboard_is_virtual; // Current SDL modifier flags SDL_Keymod pressed_modifiers; diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index 2065a4f169..797d83d62e 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -194,15 +194,15 @@ int Wayland_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -SDL_bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { /* In reality we just want to return true when the screen keyboard is the * _only_ way to get text input. So, in addition to checking for the text * input protocol, make sure we don't have any physical keyboards either. */ SDL_VideoData *internal = _this->internal; - SDL_bool haskeyboard = (internal->input != NULL) && (internal->input->keyboard != NULL); - SDL_bool hastextmanager = (internal->text_input_manager != NULL); + bool haskeyboard = (internal->input != NULL) && (internal->input->keyboard != NULL); + bool hastextmanager = (internal->text_input_manager != NULL); return !haskeyboard && hastextmanager; } diff --git a/src/video/wayland/SDL_waylandkeyboard.h b/src/video/wayland/SDL_waylandkeyboard.h index 6f4fd16537..c34ca0a509 100644 --- a/src/video/wayland/SDL_waylandkeyboard.h +++ b/src/video/wayland/SDL_waylandkeyboard.h @@ -27,7 +27,7 @@ typedef struct SDL_WaylandTextInput { struct zwp_text_input_v3 *text_input; SDL_Rect cursor_rect; - SDL_bool has_preedit; + bool has_preedit; } SDL_WaylandTextInput; extern int Wayland_InitKeyboard(SDL_VideoDevice *_this); @@ -35,6 +35,6 @@ extern void Wayland_QuitKeyboard(SDL_VideoDevice *_this); extern int Wayland_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); extern int Wayland_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); extern int Wayland_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this); #endif // SDL_waylandkeyboard_h_ diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index f80d5b5a0c..3780b2c97a 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -43,7 +43,7 @@ static SDL_Cursor *sys_cursors[SDL_HITTEST_RESIZE_LEFT + 1]; -static int Wayland_SetRelativeMouseMode(SDL_bool enabled); +static int Wayland_SetRelativeMouseMode(bool enabled); typedef struct { @@ -92,7 +92,7 @@ struct SDL_CursorData int hot_x, hot_y; - SDL_bool is_system_cursor; + bool is_system_cursor; }; static int dbus_cursor_size; @@ -140,28 +140,28 @@ static DBusMessage *Wayland_ReadDBusProperty(SDL_DBusContext *dbus, const char * return reply; } -static SDL_bool Wayland_ParseDBusReply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) +static bool Wayland_ParseDBusReply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) { DBusMessageIter iter[3]; dbus->message_iter_init(reply, &iter[0]); if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_VARIANT) { - return SDL_FALSE; + return false; } dbus->message_iter_recurse(&iter[0], &iter[1]); if (dbus->message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_VARIANT) { - return SDL_FALSE; + return false; } dbus->message_iter_recurse(&iter[1], &iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != type) { - return SDL_FALSE; + return false; } dbus->message_iter_get_basic(&iter[2], value); - return SDL_TRUE; + return true; } static DBusHandlerResult Wayland_DBusCursorMessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) @@ -250,7 +250,7 @@ static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) { DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - SDL_bool add_filter = SDL_FALSE; + bool add_filter = false; if (!dbus) { return; @@ -258,7 +258,7 @@ static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) if ((reply = Wayland_ReadDBusProperty(dbus, CURSOR_SIZE_KEY))) { if (Wayland_ParseDBusReply(dbus, reply, DBUS_TYPE_INT32, &dbus_cursor_size)) { - add_filter = SDL_TRUE; + add_filter = true; } dbus->message_unref(reply); } @@ -266,7 +266,7 @@ static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) if ((reply = Wayland_ReadDBusProperty(dbus, CURSOR_THEME_KEY))) { const char *temp = NULL; if (Wayland_ParseDBusReply(dbus, reply, DBUS_TYPE_STRING, &temp)) { - add_filter = SDL_TRUE; + add_filter = true; if (temp) { dbus_cursor_theme = SDL_strdup(temp); @@ -332,7 +332,7 @@ static void cursor_frame_done(void *data, struct wl_callback *cb, uint32_t time) wl_surface_commit(c->surface); } -static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData *cdata, float *scale) +static bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData *cdata, float *scale) { struct wl_cursor_theme *theme = NULL; struct wl_cursor *cursor; @@ -375,7 +375,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * SDL_WaylandCursorTheme *new_cursor_themes = SDL_realloc(vdata->cursor_themes, sizeof(SDL_WaylandCursorTheme) * (vdata->num_cursor_themes + 1)); if (!new_cursor_themes) { - return SDL_FALSE; + return false; } vdata->cursor_themes = new_cursor_themes; @@ -404,14 +404,14 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); } if (!cursor) { - return SDL_FALSE; + return false; } if (cdata->cursor_data.system.num_frames != cursor->image_count) { SDL_free(cdata->cursor_data.system.frames); cdata->cursor_data.system.frames = SDL_calloc(cursor->image_count, sizeof(Wayland_SystemCursorFrame)); if (!cdata->cursor_data.system.frames) { - return SDL_FALSE; + return false; } } @@ -425,7 +425,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, SDL_CursorData * } cdata->hot_x = cursor->images[0]->hotspot_x; cdata->hot_y = cursor->images[0]->hotspot_y; - return SDL_TRUE; + return true; } static Wayland_CachedCustomCursor *Wayland_GetCachedCustomCursor(SDL_Cursor *cursor) @@ -474,7 +474,7 @@ static Wayland_CachedCustomCursor *Wayland_GetCachedCustomCursor(SDL_Cursor *cur // Wayland requires premultiplied alpha for its surfaces. SDL_PremultiplyAlpha(surface->w, surface->h, surface->format, surface->pixels, surface->pitch, - SDL_PIXELFORMAT_ARGB8888, cache->shmBuffer.shm_data, surface->w * 4, SDL_TRUE); + SDL_PIXELFORMAT_ARGB8888, cache->shmBuffer.shm_data, surface->w * 4, true); cache->dst_width = data->cursor_data.custom.sdl_cursor_surface->w; cache->dst_height = data->cursor_data.custom.sdl_cursor_surface->h; @@ -539,7 +539,7 @@ static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) } cdata->cursor_data.system.id = id; - cdata->is_system_cursor = SDL_TRUE; + cdata->is_system_cursor = true; } return cursor; @@ -769,7 +769,7 @@ static int Wayland_WarpMouse(SDL_Window *window, float x, float y) struct SDL_WaylandInput *input = d->input; if (d->pointer_constraints) { - const SDL_bool toggle_lock = !wind->locked_pointer; + const bool toggle_lock = !wind->locked_pointer; /* The pointer confinement protocol allows setting a hint to warp the pointer, * but only when the pointer is locked. @@ -792,7 +792,7 @@ static int Wayland_WarpMouse(SDL_Window *window, float x, float y) /* NOTE: There is a pending warp event under discussion that should replace this when available. * https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/340 */ - SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); } else { return SDL_SetError("wayland: mouse warp failed; compositor lacks support for the required zwp_pointer_confinement_v1 protocol"); } @@ -816,7 +816,7 @@ static int Wayland_WarpMouseGlobal(float x, float y) return SDL_SetError("wayland: can't warp the mouse when a window does not have focus"); } -static int Wayland_SetRelativeMouseMode(SDL_bool enabled) +static int Wayland_SetRelativeMouseMode(bool enabled) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *data = vd->internal; diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 76af7b4fd6..43500d6b90 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -102,12 +102,12 @@ /* GNOME doesn't expose displays in any particular order, but we can find the * primary display and its logical coordinates via a DBus method. */ -static SDL_bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) +static bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) { #ifdef SDL_USE_LIBDBUS SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (dbus == NULL) { - return SDL_FALSE; + return false; } DBusMessage *reply = NULL; DBusMessageIter iter[3]; @@ -189,7 +189,7 @@ static SDL_bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) // We found the primary display: success. dbus->message_unref(reply); - return SDL_TRUE; + return true; } } while (dbus->message_iter_next(&iter[1])); } @@ -199,7 +199,7 @@ error: dbus->message_unref(reply); } #endif - return SDL_FALSE; + return false; } static void Wayland_FlushOutputOrder(SDL_VideoData *vid) @@ -210,7 +210,7 @@ static void Wayland_FlushOutputOrder(SDL_VideoData *vid) SDL_free(c); } - vid->output_order_finalized = SDL_FALSE; + vid->output_order_finalized = false; } /* The order of wl_output displays exposed by KDE doesn't correspond to any priority, but KDE does provide a protocol @@ -235,7 +235,7 @@ static void handle_kde_output_order_output(void *data, struct kde_output_order_v static void handle_kde_output_order_done(void *data, struct kde_output_order_v1 *kde_output_order_v1) { SDL_VideoData *vid = (SDL_VideoData *)data; - vid->output_order_finalized = SDL_TRUE; + vid->output_order_finalized = true; } static const struct kde_output_order_v1_listener kde_output_order_listener = { @@ -314,12 +314,12 @@ void SDL_WAYLAND_register_output(struct wl_output *output) wl_proxy_set_tag((struct wl_proxy *)output, &SDL_WAYLAND_output_tag); } -SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface) +bool SDL_WAYLAND_own_surface(struct wl_surface *surface) { return wl_proxy_get_tag((struct wl_proxy *)surface) == &SDL_WAYLAND_surface_tag; } -SDL_bool SDL_WAYLAND_own_output(struct wl_output *output) +bool SDL_WAYLAND_own_output(struct wl_output *output) { return wl_proxy_get_tag((struct wl_proxy *)output) == &SDL_WAYLAND_output_tag; } @@ -374,8 +374,8 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device) typedef struct { - SDL_bool has_fifo_v1; - SDL_bool has_commit_timing_v1; + bool has_fifo_v1; + bool has_commit_timing_v1; } SDL_WaylandPreferredData; static void wayland_preferred_check_handle_global(void *data, struct wl_registry *registry, uint32_t id, @@ -384,9 +384,9 @@ static void wayland_preferred_check_handle_global(void *data, struct wl_registry SDL_WaylandPreferredData *d = data; if (SDL_strcmp(interface, "wp_fifo_manager_v1") == 0) { - d->has_fifo_v1 = SDL_TRUE; + d->has_fifo_v1 = true; } else if (SDL_strcmp(interface, "wp_commit_timing_manager_v1") == 0) { - d->has_commit_timing_v1 = SDL_TRUE; + d->has_commit_timing_v1 = true; } } @@ -400,14 +400,14 @@ static const struct wl_registry_listener preferred_registry_listener = { wayland_preferred_check_remove_global }; -static SDL_bool Wayland_IsPreferred(struct wl_display *display) +static bool Wayland_IsPreferred(struct wl_display *display) { struct wl_registry *registry = wl_display_get_registry(display); SDL_WaylandPreferredData preferred_data = { 0 }; if (!registry) { SDL_SetError("Failed to get the Wayland registry"); - return SDL_FALSE; + return false; } wl_registry_add_listener(registry, &preferred_registry_listener, &preferred_data); @@ -419,14 +419,14 @@ static SDL_bool Wayland_IsPreferred(struct wl_display *display) return preferred_data.has_fifo_v1 && preferred_data.has_commit_timing_v1; } -static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocols) +static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols) { SDL_VideoDevice *device; SDL_VideoData *data; struct SDL_WaylandInput *input; struct wl_display *display = SDL_GetPointerProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, NULL); - SDL_bool display_is_external = !!display; + bool display_is_external = !!display; // Are we trying to connect to or are currently in a Wayland session? if (!SDL_getenv("WAYLAND_DISPLAY")) { @@ -480,11 +480,11 @@ static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocol input->sy_w = wl_fixed_from_int(0); input->xkb.current_group = XKB_GROUP_INVALID; - data->initializing = SDL_TRUE; + data->initializing = true; data->display = display; data->input = input; data->display_externally_owned = display_is_external; - data->scale_to_display_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, SDL_FALSE); + data->scale_to_display_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, false); WAYLAND_wl_list_init(&data->output_list); WAYLAND_wl_list_init(&data->output_order); WAYLAND_wl_list_init(&external_window_list); @@ -595,12 +595,12 @@ static SDL_VideoDevice *Wayland_CreateDevice(SDL_bool require_preferred_protocol static SDL_VideoDevice *Wayland_Preferred_CreateDevice(void) { - return Wayland_CreateDevice(SDL_TRUE); + return Wayland_CreateDevice(true); } static SDL_VideoDevice *Wayland_Fallback_CreateDevice(void) { - return Wayland_CreateDevice(SDL_FALSE); + return Wayland_CreateDevice(false); } VideoBootStrap Wayland_preferred_bootstrap = { @@ -622,7 +622,7 @@ static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 internal->x = x; internal->y = y; - internal->has_logical_position = SDL_TRUE; + internal->has_logical_position = true; } static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, @@ -632,7 +632,7 @@ static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xd internal->screen_width = width; internal->screen_height = height; - internal->has_logical_size = SDL_TRUE; + internal->has_logical_size = true; } static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) @@ -736,7 +736,7 @@ static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int na int i; SDL_DisplayMode mode; SDL_VideoDisplay *dpy = dispdata->display ? SDL_GetVideoDisplay(dispdata->display) : &dispdata->placeholder; - const SDL_bool rot_90 = native_width < native_height; // Reverse width/height for portrait displays. + const bool rot_90 = native_width < native_height; // Reverse width/height for portrait displays. for (i = 0; i < SDL_arraysize(mode_list); ++i) { SDL_zero(mode); @@ -847,7 +847,7 @@ static void display_handle_mode(void *data, static void display_handle_done(void *data, struct wl_output *output) { - const SDL_bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, SDL_TRUE); + const bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, true); SDL_DisplayData *internal = (SDL_DisplayData *)data; SDL_VideoData *video = internal->videodata; SDL_DisplayMode native_mode, desktop_mode; @@ -978,7 +978,7 @@ static void display_handle_done(void *data, // During initialization, the displays will be added after enumeration is complete. if (!video->initializing) { - internal->display = SDL_AddVideoDisplay(&internal->placeholder, SDL_TRUE); + internal->display = SDL_AddVideoDisplay(&internal->placeholder, true); SDL_free(internal->placeholder.name); SDL_zero(internal->placeholder); } @@ -1078,7 +1078,7 @@ static void Wayland_free_display(SDL_VideoDisplay *display) // Unlink this display. WAYLAND_wl_list_remove(&display_data->link); - SDL_DelVideoDisplay(display->id, SDL_FALSE); + SDL_DelVideoDisplay(display->id, false); } } @@ -1088,7 +1088,7 @@ static void Wayland_FinalizeDisplays(SDL_VideoData *vid) Wayland_SortOutputs(vid); wl_list_for_each (d, &vid->output_list, link) { - d->display = SDL_AddVideoDisplay(&d->placeholder, SDL_FALSE); + d->display = SDL_AddVideoDisplay(&d->placeholder, false); SDL_free(d->placeholder.name); SDL_zero(d->placeholder); } @@ -1220,44 +1220,44 @@ static const struct wl_registry_listener registry_listener = { }; #ifdef HAVE_LIBDECOR_H -static SDL_bool should_use_libdecor(SDL_VideoData *data, SDL_bool ignore_xdg) +static bool should_use_libdecor(SDL_VideoData *data, bool ignore_xdg) { if (!SDL_WAYLAND_HAVE_WAYLAND_LIBDECOR) { - return SDL_FALSE; + return false; } - if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, SDL_TRUE)) { - return SDL_FALSE; + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, true)) { + return false; } - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR, SDL_FALSE)) { - return SDL_TRUE; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR, false)) { + return true; } if (ignore_xdg) { - return SDL_TRUE; + return true; } if (data->decoration_manager) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } #endif -SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg) +bool Wayland_LoadLibdecor(SDL_VideoData *data, bool ignore_xdg) { #ifdef HAVE_LIBDECOR_H if (data->shell.libdecor != NULL) { - return SDL_TRUE; // Already loaded! + return true; // Already loaded! } if (should_use_libdecor(data, ignore_xdg)) { data->shell.libdecor = libdecor_new(data->display, &libdecor_interface); return data->shell.libdecor != NULL; } #endif - return SDL_FALSE; + return false; } int Wayland_VideoInit(SDL_VideoDevice *_this) @@ -1282,11 +1282,11 @@ int Wayland_VideoInit(SDL_VideoDevice *_this) // Require viewports for display scaling. if (data->scale_to_display_enabled && !data->viewporter) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "wayland: Display scaling requires the missing 'wp_viewporter' protocol: disabling"); - data->scale_to_display_enabled = SDL_FALSE; + data->scale_to_display_enabled = false; } // Now that we have all the protocols, load libdecor if applicable - Wayland_LoadLibdecor(data, SDL_FALSE); + Wayland_LoadLibdecor(data, false); // Second roundtrip to receive all output events. WAYLAND_wl_display_roundtrip(data->display); @@ -1305,7 +1305,7 @@ int Wayland_VideoInit(SDL_VideoDevice *_this) _this->HasPrimarySelectionText = Wayland_HasPrimarySelectionText; } - data->initializing = SDL_FALSE; + data->initializing = false; return 0; } @@ -1483,7 +1483,7 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this) } } -SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this) +bool Wayland_VideoReconnect(SDL_VideoDevice *_this) { #if 0 // TODO RECONNECT: Uncomment all when https://invent.kde.org/plasma/kwin/-/wikis/Restarting is completed SDL_VideoData *data = _this->internal; @@ -1499,7 +1499,7 @@ SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this) SDL_ResetKeyboard(); SDL_ResetMouse(); if (WAYLAND_wl_display_reconnect(data->display) < 0) { - return SDL_FALSE; + return false; } Wayland_VideoInit(_this); @@ -1524,9 +1524,9 @@ SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this) if (current_window && current_ctx) { SDL_GL_MakeCurrent (current_window, current_ctx); } - return SDL_TRUE; + return true; #else - return SDL_FALSE; + return false; #endif // 0 } diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h index e2865484d1..426b566619 100644 --- a/src/video/wayland/SDL_waylandvideo.h +++ b/src/video/wayland/SDL_waylandvideo.h @@ -48,7 +48,7 @@ typedef struct struct SDL_VideoData { - SDL_bool initializing; + bool initializing; struct wl_display *display; int display_disconnected; struct wl_registry *registry; @@ -90,12 +90,12 @@ struct SDL_VideoData struct wl_list output_list; struct wl_list output_order; - SDL_bool output_order_finalized; + bool output_order_finalized; int relative_mouse_mode; - SDL_bool display_externally_owned; + bool display_externally_owned; - SDL_bool scale_to_display_enabled; + bool scale_to_display_enabled; }; struct SDL_DisplayData @@ -110,7 +110,7 @@ struct SDL_DisplayData int x, y, screen_width, screen_height, refresh, transform; SDL_DisplayOrientation orientation; int physical_width, physical_height; - SDL_bool has_logical_position, has_logical_size; + bool has_logical_position, has_logical_size; SDL_DisplayID display; SDL_VideoDisplay placeholder; int wl_output_done_count; @@ -122,15 +122,15 @@ struct SDL_DisplayData extern void SDL_WAYLAND_register_surface(struct wl_surface *surface); extern void SDL_WAYLAND_register_output(struct wl_output *output); -extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface); -extern SDL_bool SDL_WAYLAND_own_output(struct wl_output *output); +extern bool SDL_WAYLAND_own_surface(struct wl_surface *surface); +extern bool SDL_WAYLAND_own_output(struct wl_output *output); extern SDL_WindowData *Wayland_GetWindowDataForOwnedSurface(struct wl_surface *surface); void Wayland_AddWindowDataToExternalList(SDL_WindowData *data); void Wayland_RemoveWindowDataFromExternalList(SDL_WindowData *data); -extern SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg); +extern bool Wayland_LoadLibdecor(SDL_VideoData *data, bool ignore_xdg); -extern SDL_bool Wayland_VideoReconnect(SDL_VideoDevice *_this); +extern bool Wayland_VideoReconnect(SDL_VideoDevice *_this); #endif // SDL_waylandvideo_h_ diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index d3f4b5778f..8f6407c485 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -45,8 +45,8 @@ int Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) { VkExtensionProperties *extensions = NULL; Uint32 i, extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasWaylandSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasWaylandSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { return SDL_SetError("Vulkan already loaded"); @@ -86,9 +86,9 @@ int Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasWaylandSurfaceExtension = SDL_TRUE; + hasWaylandSurfaceExtension = true; } } SDL_free(extensions); @@ -175,7 +175,7 @@ void Wayland_Vulkan_DestroySurface(SDL_VideoDevice *_this, } } -SDL_bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex) @@ -189,13 +189,13 @@ SDL_bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, if (!_this->vulkan_config.loader_handle) { SDL_SetError("Vulkan is not loaded"); - return SDL_FALSE; + return false; } if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR) { SDL_SetError(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); - return SDL_FALSE; + return false; } return vkGetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, diff --git a/src/video/wayland/SDL_waylandvulkan.h b/src/video/wayland/SDL_waylandvulkan.h index 6425cb266e..6c35d2c0a8 100644 --- a/src/video/wayland/SDL_waylandvulkan.h +++ b/src/video/wayland/SDL_waylandvulkan.h @@ -46,7 +46,7 @@ void Wayland_Vulkan_DestroySurface(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); -SDL_bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 6402982169..fc6c7bb0db 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -59,7 +59,7 @@ static int PixelToPoint(SDL_Window *window, int pixel) return (int)SDL_lroundf((float)pixel / window->internal->windowed_scale_factor); } -static SDL_bool FloatEqual(float a, float b) +static bool FloatEqual(float a, float b) { const float diff = SDL_fabsf(a - b); const float largest = SDL_max(SDL_fabsf(a), SDL_fabsf(b)); @@ -256,7 +256,7 @@ static void AdjustPopupOffset(SDL_Window *popup, int *x, int *y) #endif } -static void RepositionPopup(SDL_Window *window, SDL_bool use_current_position) +static void RepositionPopup(SDL_Window *window, bool use_current_position) { SDL_WindowData *wind = window->internal; @@ -281,7 +281,7 @@ static void RepositionPopup(SDL_Window *window, SDL_bool use_current_position) } } -static void SetSurfaceOpaqueRegion(SDL_WindowData *wind, SDL_bool is_opaque) +static void SetSurfaceOpaqueRegion(SDL_WindowData *wind, bool is_opaque) { SDL_VideoData *viddata = wind->waylandData; @@ -302,11 +302,11 @@ static void ConfigureWindowGeometry(SDL_Window *window) const int old_pixel_width = data->current.pixel_width; const int old_pixel_height = data->current.pixel_height; int window_width, window_height; - SDL_bool window_size_changed; + bool window_size_changed; // Set the drawable backbuffer size. GetBufferSize(window, &data->current.pixel_width, &data->current.pixel_height); - const SDL_bool buffer_size_changed = data->current.pixel_width != old_pixel_width || + const bool buffer_size_changed = data->current.pixel_width != old_pixel_width || data->current.pixel_height != old_pixel_height; if (data->egl_window && buffer_size_changed) { @@ -419,7 +419,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) // Ensure that child popup windows are still in bounds. for (SDL_Window *child = window->first_child; child; child = child->next_sibling) { - RepositionPopup(child, SDL_TRUE); + RepositionPopup(child, true); } } @@ -574,10 +574,10 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) return; // Can't do anything yet, wait for ShowWindow } - wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : SDL_FALSE; + wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false; ++wind->fullscreen_deadline_count; if (output) { - Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, SDL_TRUE); + Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true); wl_surface_commit(wind->surface); libdecor_frame_set_fullscreen(wind->shell_surface.libdecor.frame, output); @@ -591,10 +591,10 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) return; // Can't do anything yet, wait for ShowWindow } - wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : SDL_FALSE; + wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false; ++wind->fullscreen_deadline_count; if (output) { - Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, SDL_TRUE); + Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true); wl_surface_commit(wind->surface); xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.roleobj.toplevel, output); @@ -608,7 +608,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) wl_callback_add_listener(cb, &fullscreen_deadline_listener, (void *)((uintptr_t)window->id)); } -static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) +static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen) { SDL_WindowData *wind = window->internal; @@ -618,7 +618,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, SDL_FALSE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, false); /* Set the output for exclusive fullscreen windows when entering fullscreen from a * compositor event, or if the fullscreen paramaters were changed between the initial @@ -628,7 +628,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) if (window->fullscreen_exclusive && (!wind->fullscreen_exclusive || !wind->fullscreen_was_positioned)) { SDL_VideoDisplay *disp = SDL_GetVideoDisplay(window->current_fullscreen_mode.displayID); if (disp) { - wind->fullscreen_was_positioned = SDL_TRUE; + wind->fullscreen_was_positioned = true; SetFullscreen(window, disp->internal->output); } } @@ -637,8 +637,8 @@ static void UpdateWindowFullscreen(SDL_Window *window, SDL_bool fullscreen) // Don't change the fullscreen flags if the window is hidden or being hidden. if ((window->flags & SDL_WINDOW_FULLSCREEN) && !window->is_hiding && !(window->flags & SDL_WINDOW_HIDDEN)) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, SDL_FALSE); - wind->fullscreen_was_positioned = SDL_FALSE; + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); + wind->fullscreen_was_positioned = false; /* Send a move event, in case it was deferred while the fullscreen window was moving and * on multiple outputs. @@ -718,7 +718,7 @@ static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *x ConfigureWindowGeometry(window); xdg_surface_ack_configure(xdg, serial); - wind->shell_surface.xdg.initial_configure_seen = SDL_TRUE; + wind->shell_surface.xdg.initial_configure_seen = true; } static const struct xdg_surface_listener shell_surface_listener_xdg = { @@ -735,34 +735,34 @@ static void handle_configure_xdg_toplevel(void *data, SDL_Window *window = wind->sdlwindow; enum xdg_toplevel_state *state; - SDL_bool fullscreen = SDL_FALSE; - SDL_bool maximized = SDL_FALSE; - SDL_bool floating = SDL_TRUE; - SDL_bool tiled = SDL_FALSE; - SDL_bool active = SDL_FALSE; - SDL_bool suspended = SDL_FALSE; + bool fullscreen = false; + bool maximized = false; + bool floating = true; + bool tiled = false; + bool active = false; + bool suspended = false; wl_array_for_each (state, states) { switch (*state) { case XDG_TOPLEVEL_STATE_FULLSCREEN: - fullscreen = SDL_TRUE; - floating = SDL_FALSE; + fullscreen = true; + floating = false; break; case XDG_TOPLEVEL_STATE_MAXIMIZED: - maximized = SDL_TRUE; - floating = SDL_FALSE; + maximized = true; + floating = false; break; case XDG_TOPLEVEL_STATE_ACTIVATED: - active = SDL_TRUE; + active = true; break; case XDG_TOPLEVEL_STATE_TILED_LEFT: case XDG_TOPLEVEL_STATE_TILED_RIGHT: case XDG_TOPLEVEL_STATE_TILED_TOP: case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - tiled = SDL_TRUE; - floating = SDL_FALSE; + tiled = true; + floating = false; break; case XDG_TOPLEVEL_STATE_SUSPENDED: - suspended = SDL_TRUE; + suspended = true; break; default: break; @@ -801,7 +801,7 @@ static void handle_configure_xdg_toplevel(void *data, * that the size is up to the client, so use the cached window size here. */ if (floating) { - wind->pending_restored_size = SDL_FALSE; + wind->pending_restored_size = false; width = window->floating.w; height = window->floating.h; } else { @@ -1028,7 +1028,7 @@ static void handle_configure_zxdg_decoration(void *data, // borderless windows do request CSD, so we got what we wanted return; } - if (!Wayland_LoadLibdecor(internal->waylandData, SDL_TRUE)) { + if (!Wayland_LoadLibdecor(internal->waylandData, true)) { // libdecor isn't available, so no borders for you... oh well return; } @@ -1099,13 +1099,13 @@ static void decoration_frame_configure(struct libdecor_frame *frame, enum libdecor_window_state window_state; int width, height; - SDL_bool prev_fullscreen = wind->is_fullscreen; - SDL_bool active = SDL_FALSE; - SDL_bool fullscreen = SDL_FALSE; - SDL_bool maximized = SDL_FALSE; - SDL_bool tiled = SDL_FALSE; - SDL_bool suspended = SDL_FALSE; - SDL_bool floating; + bool prev_fullscreen = wind->is_fullscreen; + bool active = false; + bool fullscreen = false; + bool maximized = false; + bool tiled = false; + bool suspended = false; + bool floating; static const enum libdecor_window_state tiled_states = (LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT | LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM); @@ -1191,7 +1191,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, * used the cached window size here. */ if (floating) { - wind->pending_restored_size = SDL_FALSE; + wind->pending_restored_size = false; width = window->floating.w; height = window->floating.h; } else { @@ -1301,7 +1301,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame, if (!wind->shell_surface.libdecor.initial_configure_seen) { LibdecorGetMinContentSize(frame, &wind->system_limits.min_width, &wind->system_limits.min_height); - wind->shell_surface.libdecor.initial_configure_seen = SDL_TRUE; + wind->shell_surface.libdecor.initial_configure_seen = true; } if (wind->surface_status == WAYLAND_SURFACE_STATUS_WAITING_FOR_CONFIGURE) { wind->surface_status = WAYLAND_SURFACE_STATUS_WAITING_FOR_FRAME; @@ -1537,7 +1537,7 @@ static void frog_preferred_metadata_handler(void *data, struct frog_color_manage } HDR.SDR_white_level = 1.0f; - SDL_SetWindowHDRProperties(wind->sdlwindow, &HDR, SDL_TRUE); + SDL_SetWindowHDRProperties(wind->sdlwindow, &HDR, true); } static const struct frog_color_managed_surface_listener frog_surface_listener = { @@ -1558,7 +1558,7 @@ static void SetKeyboardFocus(SDL_Window *window) SDL_SetKeyboardFocus(window); } -int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int Wayland_SetWindowHitTest(SDL_Window *window, bool enabled) { return 0; // just succeed, the real work is done elsewhere. } @@ -1571,11 +1571,11 @@ int Wayland_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, struct xdg_toplevel *modal_toplevel = NULL; struct xdg_toplevel *parent_toplevel = NULL; - modal_data->modal_reparenting_required = SDL_FALSE; + modal_data->modal_reparenting_required = false; if (parent_data && parent_data->surface_status != WAYLAND_SURFACE_STATUS_SHOWN) { // Need to wait for the parent to become mapped, or it's the same as setting a null parent. - modal_data->modal_reparenting_required = SDL_TRUE; + modal_data->modal_reparenting_required = true; return 0; } @@ -1630,7 +1630,7 @@ static void show_hide_sync_handler(void *data, struct wl_callback *callback, uin if (window && window->internal) { SDL_WindowData *wind = window->internal; - wind->show_hide_sync_required = SDL_FALSE; + wind->show_hide_sync_required = false; } wl_callback_destroy(callback); @@ -1895,7 +1895,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) } } - data->show_hide_sync_required = SDL_TRUE; + data->show_hide_sync_required = true; struct wl_callback *cb = wl_display_sync(_this->internal->display); wl_callback_add_listener(cb, &show_hide_sync_listener, (void*)((uintptr_t)window->id)); @@ -2014,7 +2014,7 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, NULL); } - wind->show_hide_sync_required = SDL_TRUE; + wind->show_hide_sync_required = true; struct wl_callback *cb = wl_display_sync(_this->internal->display); wl_callback_add_listener(cb, &show_hide_sync_listener, (void*)((uintptr_t)window->id)); } @@ -2057,7 +2057,7 @@ static const struct xdg_activation_token_v1_listener activation_listener_xdg = { * * -flibit */ -static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_wind, SDL_bool set_serial) +static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_wind, bool set_serial) { struct SDL_WaylandInput * input = data->input; SDL_Window *focus = SDL_GetKeyboardFocus(); @@ -2094,7 +2094,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ void Wayland_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) { - Wayland_activate_window(_this->internal, window->internal, SDL_TRUE); + Wayland_activate_window(_this->internal, window->internal, true); } int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) @@ -2102,7 +2102,7 @@ int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOpe /* Not setting the serial will specify 'urgency' without switching focus as per * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9#note_854977 */ - Wayland_activate_window(_this->internal, window->internal, SDL_FALSE); + Wayland_activate_window(_this->internal, window->internal, false); return 0; } @@ -2126,9 +2126,9 @@ int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, return 0; } - wind->drop_fullscreen_requests = SDL_TRUE; + wind->drop_fullscreen_requests = true; FlushPendingEvents(window); - wind->drop_fullscreen_requests = SDL_FALSE; + wind->drop_fullscreen_requests = false; // Nothing to do if the window is not fullscreen, and this isn't an explicit enter request. if (!wind->is_fullscreen) { @@ -2154,7 +2154,7 @@ int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, * window geometry. */ if (wind->last_displayID != display->id) { - wind->fullscreen_was_positioned = SDL_TRUE; + wind->fullscreen_was_positioned = true; SetFullscreen(window, output); } else { ConfigureWindowGeometry(window); @@ -2188,7 +2188,7 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) } } -void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered) +void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) { SDL_WindowData *wind = window->internal; const SDL_VideoData *viddata = (const SDL_VideoData *)_this->internal; @@ -2208,7 +2208,7 @@ void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_b } } -void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) +void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) { #ifdef HAVE_LIBDECOR_H const SDL_WindowData *wind = window->internal; @@ -2311,7 +2311,7 @@ int Wayland_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) } } -int Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { SDL_VideoData *data = _this->internal; @@ -2324,7 +2324,7 @@ int Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_b return 0; } -int Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { SDL_VideoData *data = _this->internal; @@ -2341,9 +2341,9 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert SDL_VideoData *c = _this->internal; struct wl_surface *external_surface = (struct wl_surface *)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER, (struct wl_surface *)SDL_GetPointerProperty(create_props, "sdl2-compat.external_window", NULL)); - const SDL_bool custom_surface_role = (external_surface != NULL) || SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN, SDL_FALSE); - const SDL_bool create_egl_window = !!(window->flags & SDL_WINDOW_OPENGL) || - SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN, SDL_FALSE); + const bool custom_surface_role = (external_surface != NULL) || SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN, false); + const bool create_egl_window = !!(window->flags & SDL_WINDOW_OPENGL) || + SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN, false); data = SDL_calloc(1, sizeof(*data)); if (!data) { @@ -2508,8 +2508,8 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert data->surface_status = WAYLAND_SURFACE_STATUS_SHOWN; } - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { - data->double_buffer = SDL_TRUE; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { + data->double_buffer = true; } SDL_PropertiesID props = SDL_GetWindowProperties(window); @@ -2545,7 +2545,7 @@ int Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) return SDL_Unsupported(); } - RepositionPopup(window, SDL_FALSE); + RepositionPopup(window, false); return 0; } else if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR || wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) { const int x = window->floating.x; @@ -2611,7 +2611,7 @@ void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) ConfigureWindowGeometry(window); } else { - wind->pending_restored_size = SDL_TRUE; + wind->pending_restored_size = true; } // Always commit, as this may be in response to a min/max limit change. diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 6b70b89396..813eea335f 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -47,7 +47,7 @@ struct SDL_WindowData struct { struct libdecor_frame *frame; - SDL_bool initial_configure_seen; + bool initial_configure_seen; } libdecor; #endif struct @@ -62,7 +62,7 @@ struct SDL_WindowData struct xdg_positioner *positioner; } popup; } roleobj; - SDL_bool initial_configure_seen; + bool initial_configure_seen; } xdg; } shell_surface; enum @@ -159,18 +159,18 @@ struct SDL_WindowData int fullscreen_deadline_count; int maximized_deadline_count; Uint64 last_focus_event_time_ns; - SDL_bool floating; - SDL_bool suspended; - SDL_bool active; - SDL_bool is_fullscreen; - SDL_bool fullscreen_exclusive; - SDL_bool drop_fullscreen_requests; - SDL_bool fullscreen_was_positioned; - SDL_bool show_hide_sync_required; - SDL_bool scale_to_display; - SDL_bool modal_reparenting_required; - SDL_bool pending_restored_size; - SDL_bool double_buffer; + bool floating; + bool suspended; + bool active; + bool is_fullscreen; + bool fullscreen_exclusive; + bool drop_fullscreen_requests; + bool fullscreen_was_positioned; + bool show_hide_sync_required; + bool scale_to_display; + bool modal_reparenting_required; + bool pending_restored_size; + bool double_buffer; SDL_HitTestResult hit_test_result; @@ -186,11 +186,11 @@ extern int Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *windo extern void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int Wayland_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); -extern int Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); -extern int Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern int Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); extern void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); -extern void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); +extern void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); extern int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); extern int Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); extern void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); @@ -205,7 +205,7 @@ extern void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y); extern void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int Wayland_SuspendScreenSaver(SDL_VideoDevice *_this); -extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); +extern int Wayland_SetWindowHitTest(SDL_Window *window, bool enabled); extern int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); extern int Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 8c9b190d82..5cbbf346f2 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -311,22 +311,22 @@ void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t return data; } -SDL_bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) { if (SDL_IsTextMimeType(mime_type)) { if (IsClipboardFormatAvailable(TEXT_FORMAT)) { - return SDL_TRUE; + return true; } } else if (SDL_strcmp(mime_type, IMAGE_MIME_TYPE) == 0) { if (IsClipboardFormatAvailable(IMAGE_FORMAT)) { - return SDL_TRUE; + return true; } } else { if (SDL_HasInternalClipboardData(_this, mime_type)) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } void WIN_CheckClipboardUpdate(struct SDL_VideoData *data) diff --git a/src/video/windows/SDL_windowsclipboard.h b/src/video/windows/SDL_windowsclipboard.h index 2a70b2c418..a719cf3313 100644 --- a/src/video/windows/SDL_windowsclipboard.h +++ b/src/video/windows/SDL_windowsclipboard.h @@ -28,7 +28,7 @@ struct SDL_VideoData; extern int WIN_SetClipboardData(SDL_VideoDevice *_this); extern void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); -extern SDL_bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); extern void WIN_CheckClipboardUpdate(struct SDL_VideoData *data); #endif // SDL_windowsclipboard_h_ diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 055713f005..e4c53481ad 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -118,7 +118,7 @@ typedef Uint64 QWORD; // Needed for NEXTRAWINPUTBLOCK() #endif -static SDL_bool SDL_processing_messages; +static bool SDL_processing_messages; static DWORD message_tick; static Uint64 timestamp_offset; @@ -159,7 +159,7 @@ static Uint64 WIN_GetEventTimestamp(void) return timestamp; } -static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, Uint16 *rawcode, SDL_bool *virtual_key) +static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, Uint16 *rawcode, bool *virtual_key) { SDL_Scancode code; Uint8 index; @@ -204,13 +204,13 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, U } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -static SDL_bool WIN_ShouldIgnoreFocusClick(SDL_WindowData *data) +static bool WIN_ShouldIgnoreFocusClick(SDL_WindowData *data) { return !SDL_WINDOW_IS_POPUP(data->window) && - !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); + !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); } -static void WIN_CheckWParamMouseButton(Uint64 timestamp, SDL_bool bwParamMousePressed, Uint32 mouseFlags, SDL_bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) +static void WIN_CheckWParamMouseButton(Uint64 timestamp, bool bwParamMousePressed, Uint32 mouseFlags, bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) { if (bSwapButtons) { if (button == SDL_BUTTON_LEFT) { @@ -248,11 +248,11 @@ static void WIN_CheckWParamMouseButtons(Uint64 timestamp, WPARAM wParam, SDL_Win SDL_MouseButtonFlags mouseFlags = SDL_GetMouseState(NULL, NULL); // WM_LBUTTONDOWN and friends handle button swapping for us. No need to check SM_SWAPBUTTON here. - WIN_CheckWParamMouseButton(timestamp, (wParam & MK_LBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_LEFT, mouseID); - WIN_CheckWParamMouseButton(timestamp, (wParam & MK_MBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_MIDDLE, mouseID); - WIN_CheckWParamMouseButton(timestamp, (wParam & MK_RBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_RIGHT, mouseID); - WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON1), mouseFlags, SDL_FALSE, data, SDL_BUTTON_X1, mouseID); - WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON2), mouseFlags, SDL_FALSE, data, SDL_BUTTON_X2, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_LBUTTON), mouseFlags, false, data, SDL_BUTTON_LEFT, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_MBUTTON), mouseFlags, false, data, SDL_BUTTON_MIDDLE, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_RBUTTON), mouseFlags, false, data, SDL_BUTTON_RIGHT, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON1), mouseFlags, false, data, SDL_BUTTON_X1, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON2), mouseFlags, false, data, SDL_BUTTON_X2, mouseID); data->mouse_button_flags = wParam; } @@ -263,7 +263,7 @@ static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data) SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID; Uint32 mouseFlags; SHORT keyState; - SDL_bool swapButtons; + bool swapButtons; /* mouse buttons may have changed state here, we need to resync them, but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also @@ -273,33 +273,33 @@ static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data) keyState = GetAsyncKeyState(VK_LBUTTON); if (!(keyState & 0x8000)) { - WIN_CheckWParamMouseButton(timestamp, SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID); + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID); } keyState = GetAsyncKeyState(VK_RBUTTON); if (!(keyState & 0x8000)) { - WIN_CheckWParamMouseButton(timestamp, SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, mouseID); + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, mouseID); } keyState = GetAsyncKeyState(VK_MBUTTON); if (!(keyState & 0x8000)) { - WIN_CheckWParamMouseButton(timestamp, SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, mouseID); + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, mouseID); } keyState = GetAsyncKeyState(VK_XBUTTON1); if (!(keyState & 0x8000)) { - WIN_CheckWParamMouseButton(timestamp, SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_X1, mouseID); + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_X1, mouseID); } keyState = GetAsyncKeyState(VK_XBUTTON2); if (!(keyState & 0x8000)) { - WIN_CheckWParamMouseButton(timestamp, SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_X2, mouseID); + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_X2, mouseID); } data->mouse_button_flags = (WPARAM)-1; } -static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) +static void WIN_UpdateFocus(SDL_Window *window, bool expect_focus) { SDL_WindowData *data = window->internal; HWND hwnd = data->hwnd; - SDL_bool had_focus = (SDL_GetKeyboardFocus() == window); - SDL_bool has_focus = (GetForegroundWindow() == hwnd); + bool had_focus = (SDL_GetKeyboardFocus() == window); + bool has_focus = (GetForegroundWindow() == hwnd); if (had_focus == has_focus || has_focus != expect_focus) { return; @@ -308,7 +308,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) if (has_focus) { POINT cursorPos; - SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; if (GetAsyncKeyState(VK_LBUTTON)) { data->focus_click_pending |= !swapButtons ? SDL_BUTTON_LMASK : SDL_BUTTON_RMASK; } @@ -331,7 +331,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) if (!SDL_GetMouse()->relative_mode) { GetCursorPos(&cursorPos); ScreenToClient(hwnd, &cursorPos); - SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); } WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); @@ -342,15 +342,15 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) */ WIN_CheckClipboardUpdate(data->videodata); - SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? true : false); - WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); + WIN_UpdateWindowICCProfile(data->window, true); } else { RECT rect; - data->in_window_deactivation = SDL_TRUE; + data->in_window_deactivation = true; SDL_SetKeyboardFocus(NULL); // In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus @@ -364,25 +364,25 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) SDL_zero(data->cursor_clipped_rect); } - data->in_window_deactivation = SDL_FALSE; + data->in_window_deactivation = false; } } #endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -static SDL_bool ShouldGenerateWindowCloseOnAltF4(void) +static bool ShouldGenerateWindowCloseOnAltF4(void) { - return SDL_GetHintBoolean(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, SDL_TRUE); + return SDL_GetHintBoolean(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, true); } -static SDL_bool ShouldClearWindowOnEraseBackground(SDL_WindowData *data) +static bool ShouldClearWindowOnEraseBackground(SDL_WindowData *data) { switch (data->hint_erase_background_mode) { case SDL_ERASEBACKGROUNDMODE_NEVER: - return SDL_FALSE; + return false; case SDL_ERASEBACKGROUNDMODE_INITIAL: return !data->videodata->cleared; case SDL_ERASEBACKGROUNDMODE_ALWAYS: - return SDL_TRUE; + return true; default: // Unexpected value, fallback to default behaviour return !data->videodata->cleared; @@ -513,11 +513,11 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) return 1; } -static SDL_bool WIN_SwapButtons(HANDLE hDevice) +static bool WIN_SwapButtons(HANDLE hDevice) { if (hDevice == NULL) { // Touchpad, already has buttons swapped - return SDL_FALSE; + return false; } return GetSystemMetrics(SM_SWAPBUTTON) != 0; } @@ -543,7 +543,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) { if (rawmouse->lLastX || rawmouse->lLastY) { - SDL_SendMouseMotion(timestamp, window, mouseID, SDL_TRUE, (float)rawmouse->lLastX, (float)rawmouse->lLastY); + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)rawmouse->lLastX, (float)rawmouse->lLastY); } } else if (rawmouse->lLastX || rawmouse->lLastY) { /* This is absolute motion, either using a tablet or mouse over RDP @@ -556,9 +556,9 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL We handle this by creating a safe area within the application window, and when the mouse leaves that safe area, we warp back to the opposite side. Any single motion > 50% of the safe area is assumed to be a warp and ignored. */ - SDL_bool remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? SDL_TRUE : SDL_FALSE; - SDL_bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? SDL_TRUE : SDL_FALSE; - SDL_bool normalized_coordinates = !(rawmouse->usFlags & 0x40) ? SDL_TRUE : SDL_FALSE; + bool remote_desktop = GetSystemMetrics(SM_REMOTESESSION) ? true : false; + bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? true : false; + bool normalized_coordinates = !(rawmouse->usFlags & 0x40) ? true : false; int w = GetSystemMetrics(virtual_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); int h = GetSystemMetrics(virtual_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); int x = normalized_coordinates ? (int)(((float)rawmouse->lLastX / 65535.0f) * w) : (int)rawmouse->lLastX; @@ -600,7 +600,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL const int MAX_RELATIVE_MOTION = (h / 6); if (SDL_abs(relX) < MAX_RELATIVE_MOTION && SDL_abs(relY) < MAX_RELATIVE_MOTION) { - SDL_SendMouseMotion(timestamp, window, mouseID, SDL_TRUE, (float)relX, (float)relY); + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)relX, (float)relY); } } } @@ -610,7 +610,7 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL SDL_abs(relY) > MAXIMUM_TABLET_RELATIVE_MOTION) { // Ignore this motion, probably a pen lift and drop } else { - SDL_SendMouseMotion(timestamp, window, mouseID, SDL_TRUE, (float)relX, (float)relY); + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)relX, (float)relY); } } @@ -688,7 +688,7 @@ static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_VideoData *data, HA if (rawkeyboard->Flags & RI_KEY_E1) { // First key in a Ctrl+{key} sequence - data->pending_E1_key_sequence = SDL_TRUE; + data->pending_E1_key_sequence = true; return; } @@ -718,7 +718,7 @@ static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_VideoData *data, HA // Ctrl+ScrollLock == Break (no SDL scancode?) code = SDL_SCANCODE_UNKNOWN; } - data->pending_E1_key_sequence = SDL_FALSE; + data->pending_E1_key_sequence = false; } else { // The code is in the lower 7 bits, the high bit is set for the E0 prefix Uint8 index = (Uint8)rawkeyboard->MakeCode; @@ -832,14 +832,14 @@ static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) *list = new_list; } -static SDL_bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) +static bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) { for (int i = 0; i < count; ++i) { if (deviceID == list[i]) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -870,7 +870,7 @@ static void GetDeviceName(HDEVINFO devinfo, const char *instance, char *name, si } } -void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_check) +void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check) { PRAWINPUTDEVICELIST raw_devices = NULL; UINT raw_device_count = 0; @@ -882,7 +882,7 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c SDL_MouseID *old_mice = NULL; int new_mouse_count = 0; SDL_MouseID *new_mice = NULL; - SDL_bool send_event = !initial_check; + bool send_event = !initial_check; // Check to see if anything has changed static Uint64 s_last_device_change; @@ -1001,17 +1001,17 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c } #endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -// Return SDL_TRUE if spurious LCtrl is pressed +// Return true if spurious LCtrl is pressed // LCtrl is sent when RAltGR is pressed -static SDL_bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam) +static bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam) { if (wParam != VK_CONTROL) { - return SDL_FALSE; + return false; } // Is this an extended key (i.e. right key)? if (lParam & 0x01000000) { - return SDL_FALSE; + return false; } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -1025,13 +1025,13 @@ static SDL_bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam) next_msg.message == WM_SYSKEYDOWN) { if (next_msg.wParam == VK_MENU && (next_msg.lParam & 0x01000000) && next_msg.time == msg_time) { // Next message is a RALT down message, which means that this is NOT a proper LCTRL message! - return SDL_TRUE; + return true; } } } #endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) - return SDL_FALSE; + return false; } LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -1084,7 +1084,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_NCACTIVATE: { // Don't immediately clip the cursor in case we're clicking minimize/maximize buttons - data->skip_update_clipcursor = SDL_TRUE; + data->skip_update_clipcursor = true; /* Update the focus here, since it's possible to get WM_ACTIVATE and WM_SETFOCUS without actually being the foreground window, but this appears to get called in all cases where @@ -1108,14 +1108,14 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_SETFOCUS: { // Update the focus in case it's changing between top-level windows in the same application - WIN_UpdateFocus(data->window, SDL_TRUE); + WIN_UpdateFocus(data->window, true); } break; case WM_KILLFOCUS: case WM_ENTERIDLE: { // Update the focus in case it's changing between top-level windows in the same application - WIN_UpdateFocus(data->window, SDL_FALSE); + WIN_UpdateFocus(data->window, false); } break; case WM_POINTERUPDATE: @@ -1136,7 +1136,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara trackMouseEvent.hwndTrack = data->hwnd; if (TrackMouseEvent(&trackMouseEvent)) { - data->mouse_tracked = SDL_TRUE; + data->mouse_tracked = true; } } @@ -1144,7 +1144,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara // Only generate mouse events for real mouse if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH && lParam != data->last_pointer_update) { - SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam)); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, false, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam)); } } } break; @@ -1215,13 +1215,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara ScreenToClient(hwnd, &cursorPos); mouse = SDL_GetMouse(); if (!mouse->was_touch_mouse_events) { // we're not a touch handler causing a mouse leave? - SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); } else { // touch handling? - mouse->was_touch_mouse_events = SDL_FALSE; // not anymore + mouse->was_touch_mouse_events = false; // not anymore if (mouse->touch_mouse_events) { // convert touch to mouse events - SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, false, (float)cursorPos.x, (float)cursorPos.y); } else { // normal handling - SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); } } } @@ -1233,7 +1233,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } // Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked - data->mouse_tracked = SDL_FALSE; + data->mouse_tracked = false; returnCode = 0; break; @@ -1247,7 +1247,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } - SDL_bool virtual_key = SDL_FALSE; + bool virtual_key = false; Uint16 rawcode = 0; SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key); @@ -1275,7 +1275,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } - SDL_bool virtual_key = SDL_FALSE; + bool virtual_key = false; Uint16 rawcode = 0; SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); @@ -1337,7 +1337,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara #ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: { - WIN_UpdateKeymap(SDL_TRUE); + WIN_UpdateKeymap(true); } returnCode = 1; break; @@ -1345,12 +1345,12 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_NCLBUTTONDOWN: { - data->in_title_click = SDL_TRUE; + data->in_title_click = true; } break; case WM_CAPTURECHANGED: { - data->in_title_click = SDL_FALSE; + data->in_title_click = false; // The mouse may have been released during a modal loop WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); @@ -1461,7 +1461,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara windowpos->cy = fh; windowpos->flags &= ~(SWP_NOSIZE | SWP_NOMOVE); - data->floating_rect_pending = SDL_FALSE; + data->floating_rect_pending = false; } } break; @@ -1470,8 +1470,8 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SDL_Window *win; const SDL_DisplayID original_displayID = data->last_displayID; const WINDOWPOS *windowpos = (WINDOWPOS *)lParam; - const SDL_bool iconic = IsIconic(hwnd); - const SDL_bool zoomed = IsZoomed(hwnd); + const bool iconic = IsIconic(hwnd); + const bool zoomed = IsZoomed(hwnd); RECT rect; int x, y; int w, h; @@ -1531,7 +1531,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (data->last_displayID != original_displayID) { // Display changed, check ICC profile - WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); + WIN_UpdateWindowICCProfile(data->window, true); } // Update the position of any child windows @@ -1557,7 +1557,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara { if (wParam == (UINT_PTR)SDL_IterateMainCallbacks) { if (SDL_HasMainCallbacks()) { - SDL_IterateMainCallbacks(SDL_FALSE); + SDL_IterateMainCallbacks(false); } else { // Send an expose event so the application can redraw SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); @@ -1577,7 +1577,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara WPARAM edge = wParam; RECT* dragRect = (RECT*)lParam; RECT clientDragRect = *dragRect; - SDL_bool lock_aspect_ratio = (data->window->max_aspect == data->window->min_aspect) ? SDL_TRUE : SDL_FALSE; + bool lock_aspect_ratio = (data->window->max_aspect == data->window->min_aspect) ? true : false; RECT rc; LONG w, h; float new_aspect; @@ -1741,7 +1741,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (ShouldClearWindowOnEraseBackground(data)) { RECT client_rect; HBRUSH brush; - data->videodata->cleared = SDL_TRUE; + data->videodata->cleared = true; GetClientRect(hwnd, &client_rect); brush = CreateSolidBrush(0); FillRect(GetDC(hwnd), &client_rect, brush); @@ -1778,7 +1778,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_TOUCH: if (data->videodata->GetTouchInputInfo && data->videodata->CloseTouchInputHandle) { UINT i, num_inputs = LOWORD(wParam); - SDL_bool isstack; + bool isstack; PTOUCHINPUT inputs = SDL_small_alloc(TOUCHINPUT, num_inputs, &isstack); if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) { RECT rect; @@ -1826,13 +1826,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara // FIXME: Should we use the input->dwTime field for the tick source of the timestamp? if (input->dwFlags & TOUCHEVENTF_DOWN) { - SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_TRUE, x, y, 1.0f); + SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, true, x, y, 1.0f); } if (input->dwFlags & TOUCHEVENTF_MOVE) { SDL_SendTouchMotion(WIN_GetEventTimestamp(), touchId, fingerId, data->window, x, y, 1.0f); } if (input->dwFlags & TOUCHEVENTF_UP) { - SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_FALSE, x, y, 1.0f); + SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, false, x, y, 1.0f); } } } @@ -2064,7 +2064,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara suggestedRect->left, suggestedRect->top, w, h); #endif - data->expected_resize = SDL_TRUE; + data->expected_resize = true; SetWindowPos(hwnd, NULL, suggestedRect->left, @@ -2072,7 +2072,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara w, h, SWP_NOZORDER | SWP_NOACTIVATE); - data->expected_resize = SDL_FALSE; + data->expected_resize = false; return 0; } break; @@ -2113,7 +2113,7 @@ static void WIN_UpdateClipCursorForWindows(void) SDL_WindowData *data = window->internal; if (data) { if (data->skip_update_clipcursor) { - data->skip_update_clipcursor = SDL_FALSE; + data->skip_update_clipcursor = false; WIN_UpdateClipCursor(window); } else if (CLIPCURSOR_UPDATE_INTERVAL_MS > 0 && now >= (data->last_updated_clipcursor + CLIPCURSOR_UPDATE_INTERVAL_MS)) { WIN_UpdateClipCursor(window); @@ -2134,10 +2134,10 @@ static void WIN_UpdateMouseCapture(void) POINT cursorPos; if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) { - SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID; - SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, false, (float)cursorPos.x, (float)cursorPos.y); SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT); SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, @@ -2238,7 +2238,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) } if (g_WindowsEnableMessageLoop) { - SDL_processing_messages = SDL_TRUE; + SDL_processing_messages = true; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (g_WindowsMessageHook) { @@ -2279,7 +2279,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) } } - SDL_processing_messages = SDL_FALSE; + SDL_processing_messages = false; } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -2315,7 +2315,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) WIN_UpdateMouseCapture(); if (!_this->internal->gameinput_context) { - WIN_CheckKeyboardAndMouseHotplug(_this, SDL_FALSE); + WIN_CheckKeyboardAndMouseHotplug(_this, false); } WIN_UpdateIMECandidates(_this); diff --git a/src/video/windows/SDL_windowsevents.h b/src/video/windows/SDL_windowsevents.h index 9e57cb2fab..a48b8aaafd 100644 --- a/src/video/windows/SDL_windowsevents.h +++ b/src/video/windows/SDL_windowsevents.h @@ -31,7 +31,7 @@ extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lP extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); extern void WIN_PollRawInput(SDL_VideoDevice *_this); -extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_check); +extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check); extern void WIN_PumpEvents(SDL_VideoDevice *_this); extern void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); extern int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index d8331dea2c..fc75a803d7 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -27,7 +27,7 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) { SDL_WindowData *data = window->internal; - SDL_bool isstack; + bool isstack; size_t size; LPBITMAPINFO info; HBITMAP hbm; diff --git a/src/video/windows/SDL_windowsgameinput.c b/src/video/windows/SDL_windowsgameinput.c index 80f20b63cf..6be1587fb0 100644 --- a/src/video/windows/SDL_windowsgameinput.c +++ b/src/video/windows/SDL_windowsgameinput.c @@ -51,8 +51,8 @@ typedef struct GAMEINPUT_Device const GameInputDeviceInfo *info; char *name; Uint32 instance_id; // generated by SDL - SDL_bool registered; - SDL_bool delete_requested; + bool registered; + bool delete_requested; IGameInputReading *last_mouse_reading; IGameInputReading *last_keyboard_reading; } GAMEINPUT_Device; @@ -84,7 +84,7 @@ static int GAMEINPUT_InternalAddOrFind(WIN_GameInputData *data, IGameInputDevice device = data->devices[i]; if (device && device->pDevice == pDevice) { // we're already added - device->delete_requested = SDL_FALSE; + device->delete_requested = false; retval = 0; goto done; } @@ -142,10 +142,10 @@ static int GAMEINPUT_InternalRemoveByIndex(WIN_GameInputData *data, int idx) if (device) { if (device->registered) { if (device->info->supportedInput & GameInputKindMouse) { - SDL_RemoveMouse(device->instance_id, SDL_TRUE); + SDL_RemoveMouse(device->instance_id, true); } if (device->info->supportedInput & GameInputKindKeyboard) { - SDL_RemoveKeyboard(device->instance_id, SDL_TRUE); + SDL_RemoveKeyboard(device->instance_id, true); } if (device->last_mouse_reading) { IGameInputReading_Release(device->last_mouse_reading); @@ -206,7 +206,7 @@ static void CALLBACK GAMEINPUT_InternalDeviceCallback( device = data->devices[idx]; if (device && device->pDevice == pDevice) { // will be deleted on the next Detect call - device->delete_requested = SDL_TRUE; + device->delete_requested = true; break; } } @@ -309,7 +309,7 @@ static void GAMEINPUT_HandleMouseDelta(WIN_GameInputData *data, SDL_Window *wind delta.wheelY = (state.wheelY - last.wheelY); if (delta.positionX || delta.positionY) { - SDL_SendMouseMotion(timestamp, window, mouseID, SDL_TRUE, (float)delta.positionX, (float)delta.positionY); + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)delta.positionX, (float)delta.positionY); } if (delta.buttons) { for (int i = 0; i < MAX_GAMEINPUT_BUTTONS; ++i) { @@ -336,14 +336,14 @@ static SDL_Scancode GetScancodeFromKeyState(const GameInputKeyState *state) return windows_scancode_table[index]; } -static SDL_bool KeysHaveScancode(const GameInputKeyState *keys, uint32_t count, SDL_Scancode scancode) +static bool KeysHaveScancode(const GameInputKeyState *keys, uint32_t count, SDL_Scancode scancode) { for (uint32_t i = 0; i < count; ++i) { if (GetScancodeFromKeyState(&keys[i]) == scancode) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void GAMEINPUT_InitialKeyboardReading(WIN_GameInputData *data, SDL_Window *window, GAMEINPUT_Device *device, IGameInputReading *reading) @@ -450,12 +450,12 @@ void WIN_UpdateGameInput(SDL_VideoDevice *_this) if (!device->registered) { if (device->info->supportedInput & GameInputKindMouse) { - SDL_AddMouse(device->instance_id, device->name, SDL_TRUE); + SDL_AddMouse(device->instance_id, device->name, true); } if (device->info->supportedInput & GameInputKindKeyboard) { - SDL_AddKeyboard(device->instance_id, device->name, SDL_TRUE); + SDL_AddKeyboard(device->instance_id, device->name, true); } - device->registered = SDL_TRUE; + device->registered = true; } if (device->delete_requested) { @@ -530,8 +530,8 @@ void WIN_UpdateGameInput(SDL_VideoDevice *_this) int WIN_UpdateGameInputEnabled(SDL_VideoDevice *_this) { WIN_GameInputData *data = _this->internal->gameinput_context; - SDL_bool raw_mouse_enabled = _this->internal->raw_mouse_enabled; - SDL_bool raw_keyboard_enabled = _this->internal->raw_keyboard_enabled; + bool raw_mouse_enabled = _this->internal->raw_mouse_enabled; + bool raw_keyboard_enabled = _this->internal->raw_keyboard_enabled; SDL_LockMutex(data->lock); { diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index ab6232fe23..f98c438dc5 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -65,19 +65,19 @@ void WIN_InitKeyboard(SDL_VideoDevice *_this) data->ime_composition = (WCHAR *)SDL_calloc(data->ime_composition_length, sizeof(WCHAR)); #endif // !SDL_DISABLE_WINDOWS_IME - WIN_UpdateKeymap(SDL_FALSE); + WIN_UpdateKeymap(false); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows"); // Are system caps/num/scroll lock active? Set our state to match. - SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? true : false); } -void WIN_UpdateKeymap(SDL_bool send_event) +void WIN_UpdateKeymap(bool send_event) { SDL_Scancode scancode; SDL_Keymap *keymap; @@ -259,9 +259,9 @@ int WIN_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window) #ifdef SDL_DISABLE_WINDOWS_IME -SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) +bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) { - return SDL_FALSE; + return false; } void WIN_UpdateIMECandidates(SDL_VideoDevice *_this) @@ -323,17 +323,17 @@ static int IME_Init(SDL_VideoData *videodata, SDL_Window *window) const char *hint = SDL_GetHint(SDL_HINT_IME_IMPLEMENTED_UI); if (hint && SDL_strstr(hint, "composition")) { - videodata->ime_internal_composition = SDL_TRUE; + videodata->ime_internal_composition = true; } if (hint && SDL_strstr(hint, "candidates")) { - videodata->ime_internal_candidates = SDL_TRUE; + videodata->ime_internal_candidates = true; } videodata->ime_hwnd_main = hwnd; - videodata->ime_initialized = SDL_TRUE; + videodata->ime_initialized = true; videodata->ime_himm32 = SDL_LoadObject("imm32.dll"); if (!videodata->ime_himm32) { - videodata->ime_available = SDL_FALSE; + videodata->ime_available = false; SDL_ClearError(); return 0; } @@ -348,11 +348,11 @@ static int IME_Init(SDL_VideoData *videodata, SDL_Window *window) videodata->ime_himc = ImmGetContext(hwnd); ImmReleaseContext(hwnd, videodata->ime_himc); if (!videodata->ime_himc) { - videodata->ime_available = SDL_FALSE; + videodata->ime_available = false; IME_Disable(videodata, hwnd); return 0; } - videodata->ime_available = SDL_TRUE; + videodata->ime_available = true; IME_UpdateInputLocale(videodata); IME_SetupAPI(videodata); IME_UpdateInputLocale(videodata); @@ -374,7 +374,7 @@ static void IME_Enable(SDL_VideoData *videodata, HWND hwnd) ImmAssociateContext(videodata->ime_hwnd_current, videodata->ime_himc); } - videodata->ime_enabled = SDL_TRUE; + videodata->ime_enabled = true; IME_UpdateInputLocale(videodata); } @@ -389,7 +389,7 @@ static void IME_Disable(SDL_VideoData *videodata, HWND hwnd) ImmAssociateContext(videodata->ime_hwnd_current, (HIMC)0); } - videodata->ime_enabled = SDL_FALSE; + videodata->ime_enabled = false; } static void IME_Quit(SDL_VideoData *videodata) @@ -412,7 +412,7 @@ static void IME_Quit(SDL_VideoData *videodata) SDL_free(videodata->ime_candidates[i]); videodata->ime_candidates[i] = NULL; } - videodata->ime_initialized = SDL_FALSE; + videodata->ime_initialized = false; } static void IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) @@ -860,7 +860,7 @@ static void IME_SendEditingEvent(SDL_VideoData *videodata) SDL_SendEditingText(s, videodata->ime_cursor, 0); } if (*s) { - videodata->ime_needs_clear_composition = SDL_TRUE; + videodata->ime_needs_clear_composition = true; } SDL_free(s); } @@ -871,13 +871,13 @@ static void IME_SendClearComposition(SDL_VideoData *videodata) { if (videodata->ime_needs_clear_composition) { SDL_SendEditingText("", 0, 0); - videodata->ime_needs_clear_composition = SDL_FALSE; + videodata->ime_needs_clear_composition = false; } } static int IME_OpenCandidateList(SDL_VideoData *videodata) { - videodata->ime_candidates_open = SDL_TRUE; + videodata->ime_candidates_open = true; videodata->ime_candcount = 0; return 0; } @@ -904,7 +904,7 @@ static void IME_SendCandidateList(SDL_VideoData *videodata) static void IME_CloseCandidateList(SDL_VideoData *videodata) { - videodata->ime_candidates_open = SDL_FALSE; + videodata->ime_candidates_open = false; if (videodata->ime_candcount > 0) { for (int i = 0; i < videodata->ime_candcount; ++i) { @@ -913,7 +913,7 @@ static void IME_CloseCandidateList(SDL_VideoData *videodata) } videodata->ime_candcount = 0; - SDL_SendEditingTextCandidates(NULL, 0, -1, SDL_FALSE); + SDL_SendEditingTextCandidates(NULL, 0, -1, false); } } @@ -922,7 +922,7 @@ static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd) HIMC himc; DWORD size; LPCANDIDATELIST cand_list; - SDL_bool has_candidates = SDL_FALSE; + bool has_candidates = false; himc = ImmGetContext(hwnd); if (himc) { @@ -966,7 +966,7 @@ static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd) IME_AddCandidate(videodata, j, candidate); } - has_candidates = SDL_TRUE; + has_candidates = true; IME_SendCandidateList(videodata); } } @@ -981,9 +981,9 @@ static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd) } } -SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) +bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) { - SDL_bool trap = SDL_FALSE; + bool trap = false; HIMC himc = 0; if (msg == WM_IME_SETCONTEXT) { @@ -1003,18 +1003,18 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam } *lParam &= element_mask; - return SDL_FALSE; + return false; } if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled) { - return SDL_FALSE; + return false; } switch (msg) { case WM_KEYDOWN: if (wParam == VK_PROCESSKEY) { SDL_DebugIMELog("WM_KEYDOWN VK_PROCESSKEY\n"); - trap = SDL_TRUE; + trap = true; } else { SDL_DebugIMELog("WM_KEYDOWN normal\n"); } @@ -1026,13 +1026,13 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam case WM_IME_STARTCOMPOSITION: SDL_DebugIMELog("WM_IME_STARTCOMPOSITION\n"); if (videodata->ime_internal_composition) { - trap = SDL_TRUE; + trap = true; } break; case WM_IME_COMPOSITION: SDL_DebugIMELog("WM_IME_COMPOSITION %x\n", lParam); if (videodata->ime_internal_composition) { - trap = SDL_TRUE; + trap = true; himc = ImmGetContext(hwnd); if (*lParam & GCS_RESULTSTR) { SDL_DebugIMELog("GCS_RESULTSTR\n"); @@ -1052,7 +1052,7 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam case WM_IME_ENDCOMPOSITION: SDL_DebugIMELog("WM_IME_ENDCOMPOSITION\n"); if (videodata->ime_internal_composition) { - trap = SDL_TRUE; + trap = true; videodata->ime_composition[0] = 0; videodata->ime_readingstring[0] = 0; videodata->ime_cursor = 0; @@ -1082,15 +1082,15 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam case IMN_CHANGECANDIDATE: SDL_DebugIMELog("%s\n", wParam == IMN_OPENCANDIDATE ? "IMN_OPENCANDIDATE" : "IMN_CHANGECANDIDATE"); if (videodata->ime_internal_candidates) { - trap = SDL_TRUE; - videodata->ime_update_candidates = SDL_TRUE; + trap = true; + videodata->ime_update_candidates = true; } break; case IMN_CLOSECANDIDATE: SDL_DebugIMELog("IMN_CLOSECANDIDATE\n"); if (videodata->ime_internal_candidates) { - trap = SDL_TRUE; - videodata->ime_update_candidates = SDL_FALSE; + trap = true; + videodata->ime_update_candidates = false; IME_CloseCandidateList(videodata); } break; @@ -1106,7 +1106,7 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam case IMEID_CHS_VER41: case IMEID_CHS_VER42: if (*lParam == 1 || *lParam == 2) { - trap = SDL_TRUE; + trap = true; } break; @@ -1116,13 +1116,13 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam case IMEID_CHT_VER60: case IMEID_CHS_VER53: if (*lParam == 16 || *lParam == 17 || *lParam == 26 || *lParam == 27 || *lParam == 28) { - trap = SDL_TRUE; + trap = true; } break; } } break; default: - trap = SDL_TRUE; + trap = true; break; } break; @@ -1136,7 +1136,7 @@ void WIN_UpdateIMECandidates(SDL_VideoDevice *_this) if (videodata->ime_update_candidates) { IME_GetCandidateList(videodata, videodata->ime_hwnd_current); - videodata->ime_update_candidates = SDL_FALSE; + videodata->ime_update_candidates = false; } } diff --git a/src/video/windows/SDL_windowskeyboard.h b/src/video/windows/SDL_windowskeyboard.h index 15558fb18c..6b84e16247 100644 --- a/src/video/windows/SDL_windowskeyboard.h +++ b/src/video/windows/SDL_windowskeyboard.h @@ -24,7 +24,7 @@ #define SDL_windowskeyboard_h_ extern void WIN_InitKeyboard(SDL_VideoDevice *_this); -extern void WIN_UpdateKeymap(SDL_bool send_event); +extern void WIN_UpdateKeymap(bool send_event); extern void WIN_QuitKeyboard(SDL_VideoDevice *_this); extern void WIN_ResetDeadKeys(void); @@ -34,7 +34,7 @@ extern int WIN_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); extern int WIN_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); extern int WIN_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); +extern bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); extern void WIN_UpdateIMECandidates(SDL_VideoDevice *_this); #endif // SDL_windowskeyboard_h_ diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 22582b7a20..f259edb5d7 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -238,14 +238,14 @@ typedef struct WORD numbuttons; } WIN_DialogData; -static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, SDL_MessageBoxButtonFlags flags, size_t *i) +static bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, SDL_MessageBoxButtonFlags flags, size_t *i) { for (*i = 0; *i < (size_t)messageboxdata->numbuttons; ++*i) { if (messageboxdata->buttons[*i].flags & flags) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) @@ -316,7 +316,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return FALSE; } -static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) +static bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) { // Growing memory in 64 KiB steps. const size_t sizestep = 0x10000; @@ -332,7 +332,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) } } else if (SIZE_MAX - dialog->used < space) { SDL_OutOfMemory(); - return SDL_FALSE; + return false; } else if (SIZE_MAX - (dialog->used + space) < sizestep) { // Close to the maximum. size = dialog->used + space; @@ -345,46 +345,46 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) if (size > dialog->size) { void *data = SDL_realloc(dialog->data, size); if (!data) { - return SDL_FALSE; + return false; } dialog->data = data; dialog->size = size; dialog->lpDialog = (DLGTEMPLATEEX *)dialog->data; } - return SDL_TRUE; + return true; } -static SDL_bool AlignDialogData(WIN_DialogData *dialog, size_t size) +static bool AlignDialogData(WIN_DialogData *dialog, size_t size) { size_t padding = (dialog->used % size); if (!ExpandDialogSpace(dialog, padding)) { - return SDL_FALSE; + return false; } dialog->used += padding; - return SDL_TRUE; + return true; } -static SDL_bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t size) +static bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t size) { if (!ExpandDialogSpace(dialog, size)) { - return SDL_FALSE; + return false; } SDL_memcpy((Uint8 *)dialog->data + dialog->used, data, size); dialog->used += size; - return SDL_TRUE; + return true; } -static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) +static bool AddDialogString(WIN_DialogData *dialog, const char *string) { WCHAR *wstring; WCHAR *p; size_t count; - SDL_bool status; + bool status; if (!string) { string = ""; @@ -392,7 +392,7 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) wstring = WIN_UTF8ToStringW(string); if (!wstring) { - return SDL_FALSE; + return false; } // Find out how many characters we have, including null terminator @@ -417,7 +417,7 @@ static void Vec2ToDLU(short *x, short *y) *y = (short)MulDiv(*y, 8, s_BaseUnitsY); } -static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal) +static bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal) { DLGITEMTEMPLATEEX item; WORD marker = 0xFFFF; @@ -436,53 +436,53 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, Vec2ToDLU(&item.cx, &item.cy); if (!AlignDialogData(dialog, sizeof(DWORD))) { - return SDL_FALSE; + return false; } if (!AddDialogData(dialog, &item, sizeof(item))) { - return SDL_FALSE; + return false; } if (!AddDialogData(dialog, &marker, sizeof(marker))) { - return SDL_FALSE; + return false; } if (!AddDialogData(dialog, &type, sizeof(type))) { - return SDL_FALSE; + return false; } if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption)) { if (!AddDialogString(dialog, caption)) { - return SDL_FALSE; + return false; } } else { if (!AddDialogData(dialog, &marker, sizeof(marker))) { - return SDL_FALSE; + return false; } if (!AddDialogData(dialog, &ordinal, sizeof(ordinal))) { - return SDL_FALSE; + return false; } } if (!AddDialogData(dialog, &extraData, sizeof(extraData))) { - return SDL_FALSE; + return false; } if (type == DLGITEMTYPEBUTTON) { dialog->numbuttons++; } ++dialog->lpDialog->cDlgItems; - return SDL_TRUE; + return true; } -static SDL_bool AddDialogStaticText(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text) +static bool AddDialogStaticText(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text) { DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL | WS_GROUP; return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -1, text, 0); } -static SDL_bool AddDialogStaticIcon(WIN_DialogData *dialog, int x, int y, int w, int h, Uint16 ordinal) +static bool AddDialogStaticIcon(WIN_DialogData *dialog, int x, int y, int w, int h, Uint16 ordinal) { DWORD style = WS_VISIBLE | WS_CHILD | SS_ICON | WS_GROUP; return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -2, NULL, ordinal); } -static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, SDL_bool isDefault) +static bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, bool isDefault) { DWORD style = WS_VISIBLE | WS_CHILD | WS_TABSTOP; if (isDefault) { @@ -834,7 +834,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons; y = Size.cy - ButtonHeight - ButtonMargin; for (i = 0; i < messageboxdata->numbuttons; i++) { - SDL_bool isdefault = SDL_FALSE; + bool isdefault = false; const char *buttontext; const SDL_MessageBoxButtonData *sdlButton; @@ -850,7 +850,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { defbuttoncount++; if (defbuttoncount == 1) { - isdefault = SDL_TRUE; + isdefault = true; } } diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index bc1179447e..8ec9c26fa1 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -271,7 +271,7 @@ static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor) return dpi / (float)USER_DEFAULT_SCREEN_DPI; } -static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HMONITOR hMonitor, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *natural_orientation, SDL_DisplayOrientation *current_orientation) +static bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HMONITOR hMonitor, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *natural_orientation, SDL_DisplayOrientation *current_orientation) { SDL_DisplayModeData *data; DEVMODE devmode; @@ -279,12 +279,12 @@ static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HM devmode.dmSize = sizeof(devmode); devmode.dmDriverExtra = 0; if (!EnumDisplaySettingsW(deviceName, index, &devmode)) { - return SDL_FALSE; + return false; } data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); if (!data) { - return SDL_FALSE; + return false; } SDL_zerop(mode); @@ -306,7 +306,7 @@ static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HM *current_orientation = WIN_GetDisplayOrientation(&devmode); } - return SDL_TRUE; + return true; } static char *WIN_GetDisplayNameVista(SDL_VideoData *videodata, const WCHAR *deviceName) @@ -389,12 +389,12 @@ WIN_GetDisplayNameVista_failed: } #ifdef HAVE_DXGI1_6_H -static SDL_bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) +static bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) { typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL; void *hDXGIMod = NULL; - SDL_bool found = SDL_FALSE; + bool found = false; #ifdef SDL_PLATFORM_WINRT CreateDXGIFactoryFunc = CreateDXGIFactory1; @@ -420,7 +420,7 @@ static SDL_bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) if (SUCCEEDED(IDXGIOutput_QueryInterface(dxgiOutput, &SDL_IID_IDXGIOutput6, (void **)&dxgiOutput6))) { if (SUCCEEDED(IDXGIOutput6_GetDesc1(dxgiOutput6, desc))) { if (desc->Monitor == hMonitor) { - found = SDL_TRUE; + found = true; } } IDXGIOutput6_Release(dxgiOutput6); @@ -440,7 +440,7 @@ static SDL_bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) return found; } -static SDL_bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonitor, DISPLAYCONFIG_PATH_INFO *path_info) +static bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonitor, DISPLAYCONFIG_PATH_INFO *path_info) { LONG result; MONITORINFOEXW view_info; @@ -449,10 +449,10 @@ static SDL_bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonit UINT32 num_mode_info_array_elements = 0; DISPLAYCONFIG_PATH_INFO *path_infos = NULL, *new_path_infos; DISPLAYCONFIG_MODE_INFO *mode_infos = NULL, *new_mode_infos; - SDL_bool found = SDL_FALSE; + bool found = false; if (!videodata->GetDisplayConfigBufferSizes || !videodata->QueryDisplayConfig || !videodata->DisplayConfigGetDeviceInfo) { - return SDL_FALSE; + return false; } SDL_zero(view_info); @@ -465,7 +465,7 @@ static SDL_bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonit if (videodata->GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path_array_elements, &num_mode_info_array_elements) != ERROR_SUCCESS) { SDL_free(path_infos); SDL_free(mode_infos); - return SDL_FALSE; + return false; } new_path_infos = (DISPLAYCONFIG_PATH_INFO *)SDL_realloc(path_infos, num_path_array_elements * sizeof(*path_infos)); @@ -496,7 +496,7 @@ static SDL_bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonit if (videodata->DisplayConfigGetDeviceInfo(&device_name.header) == ERROR_SUCCESS) { if (SDL_wcscmp(view_info.szDevice, device_name.viewGdiDeviceName) == 0) { SDL_copyp(path_info, &path_infos[i]); - found = SDL_TRUE; + found = true; break; } } @@ -564,7 +564,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI #endif dxgi_output = WIN_GetDXGIOutput(_this, info->szDevice); - SDL_bool found = WIN_GetDisplayMode(_this, dxgi_output, hMonitor, info->szDevice, ENUM_CURRENT_SETTINGS, &mode, &natural_orientation, ¤t_orientation); + bool found = WIN_GetDisplayMode(_this, dxgi_output, hMonitor, info->szDevice, ENUM_CURRENT_SETTINGS, &mode, &natural_orientation, ¤t_orientation); WIN_ReleaseDXGIOutput(dxgi_output); if (!found) { return; @@ -576,8 +576,8 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI for (i = 0; i < _this->num_displays; ++i) { SDL_DisplayData *internal = _this->displays[i]->internal; if (SDL_wcscmp(internal->DeviceName, info->szDevice) == 0) { - SDL_bool moved = (index != i); - SDL_bool changed_bounds = SDL_FALSE; + bool moved = (index != i); + bool changed_bounds = false; if (internal->state != DisplayRemoved) { // We've already enumerated this display, don't move it @@ -609,7 +609,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI SDL_SetDesktopDisplayMode(existing_display, &mode); if (WIN_GetDisplayBounds(_this, existing_display, &bounds) == 0 && SDL_memcmp(&internal->bounds, &bounds, sizeof(bounds)) != 0) { - changed_bounds = SDL_TRUE; + changed_bounds = true; SDL_copyp(&internal->bounds, &bounds); } if (moved || changed_bounds) { @@ -656,7 +656,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI #ifdef HAVE_DXGI1_6_H WIN_GetHDRProperties(_this, hMonitor, &display.HDR); #endif - SDL_AddVideoDisplay(&display, SDL_FALSE); + SDL_AddVideoDisplay(&display, false); SDL_free(display.name); done: @@ -667,7 +667,7 @@ typedef struct _WIN_AddDisplaysData { SDL_VideoDevice *video_device; int display_index; - SDL_bool want_primary; + bool want_primary; } WIN_AddDisplaysData; static BOOL CALLBACK WIN_AddDisplaysCallback(HMONITOR hMonitor, @@ -682,7 +682,7 @@ static BOOL CALLBACK WIN_AddDisplaysCallback(HMONITOR hMonitor, info.cbSize = sizeof(info); if (GetMonitorInfoW(hMonitor, (LPMONITORINFO)&info) != 0) { - const SDL_bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY); + const bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY); if (is_primary == data->want_primary) { WIN_AddDisplay(data->video_device, hMonitor, &info, &data->display_index); @@ -699,10 +699,10 @@ static void WIN_AddDisplays(SDL_VideoDevice *_this) callback_data.video_device = _this; callback_data.display_index = 0; - callback_data.want_primary = SDL_TRUE; + callback_data.want_primary = true; EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data); - callback_data.want_primary = SDL_FALSE; + callback_data.want_primary = false; EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data); } @@ -904,7 +904,7 @@ void WIN_RefreshDisplays(SDL_VideoDevice *_this) SDL_VideoDisplay *display = _this->displays[i]; SDL_DisplayData *internal = display->internal; if (internal->state == DisplayRemoved) { - SDL_DelVideoDisplay(display->id, SDL_TRUE); + SDL_DelVideoDisplay(display->id, true); } } diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index cf1774fec6..f22194eebc 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -76,7 +76,7 @@ static SDL_Cursor *WIN_CreateDefaultCursor(void) return WIN_CreateCursorAndData(LoadCursor(NULL, IDC_ARROW)); } -static SDL_bool IsMonochromeSurface(SDL_Surface *surface) +static bool IsMonochromeSurface(SDL_Surface *surface) { int x, y; Uint8 r, g, b, a; @@ -89,17 +89,17 @@ static SDL_bool IsMonochromeSurface(SDL_Surface *surface) // Black or white pixel. if (!((r == 0x00 && g == 0x00 && b == 0x00) || (r == 0xff && g == 0xff && b == 0xff))) { - return SDL_FALSE; + return false; } // Transparent or opaque pixel. if (!(a == 0x00 || a == 0xff)) { - return SDL_FALSE; + return false; } } } - return SDL_TRUE; + return true; } static HBITMAP CreateColorBitmap(SDL_Surface *surface) @@ -134,10 +134,10 @@ static HBITMAP CreateColorBitmap(SDL_Surface *surface) * For info on the expected mask format see: * https://devblogs.microsoft.com/oldnewthing/20101018-00/?p=12513 */ -static HBITMAP CreateMaskBitmap(SDL_Surface *surface, SDL_bool is_monochrome) +static HBITMAP CreateMaskBitmap(SDL_Surface *surface, bool is_monochrome) { HBITMAP bitmap; - SDL_bool isstack; + bool isstack; void *pixels; int x, y; Uint8 r, g, b, a; @@ -191,7 +191,7 @@ static HCURSOR WIN_CreateHCursor(SDL_Surface *surface, int hot_x, int hot_y) { HCURSOR hcursor; ICONINFO ii; - SDL_bool is_monochrome = IsMonochromeSurface(surface); + bool is_monochrome = IsMonochromeSurface(surface); SDL_zero(ii); ii.fIcon = FALSE; @@ -464,7 +464,7 @@ static int WIN_WarpMouse(SDL_Window *window, float x, float y) WIN_SetCursorPos(pt.x, pt.y); // Send the exact mouse motion associated with this warp - SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, x, y); + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); return 0; } @@ -478,7 +478,7 @@ static int WIN_WarpMouseGlobal(float x, float y) return 0; } -static int WIN_SetRelativeMouseMode(SDL_bool enabled) +static int WIN_SetRelativeMouseMode(bool enabled) { return WIN_SetRawMouseEnabled(SDL_GetVideoDevice(), enabled); } @@ -507,7 +507,7 @@ static SDL_MouseButtonFlags WIN_GetGlobalMouseState(float *x, float *y) { SDL_MouseButtonFlags retval = 0; POINT pt = { 0, 0 }; - SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; GetCursorPos(&pt); *x = (float)pt.x; @@ -555,7 +555,7 @@ void WIN_QuitMouse(SDL_VideoDevice *_this) * https://superuser.com/questions/278362/windows-mouse-acceleration-curve-smoothmousexcurve-and-smoothmouseycurve * http://www.esreality.com/?a=post&id=1846538/ */ -static SDL_bool LoadFiveFixedPointFloats(const BYTE *bytes, float *values) +static bool LoadFiveFixedPointFloats(const BYTE *bytes, float *values) { int i; @@ -565,7 +565,7 @@ static SDL_bool LoadFiveFixedPointFloats(const BYTE *bytes, float *values) *values++ = value; bytes += 8; } - return SDL_TRUE; + return true; } static void WIN_SetEnhancedMouseScale(int mouse_speed) diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 616ecff675..5518716b14 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -369,7 +369,7 @@ static int WIN_GL_ChoosePixelFormat(SDL_VideoDevice *_this, HDC hdc, PIXELFORMAT return best; } -static SDL_bool HasExtension(const char *extension, const char *extensions) +static bool HasExtension(const char *extension, const char *extensions) { const char *start; const char *where, *terminator; @@ -377,11 +377,11 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { - return SDL_FALSE; + return false; } if (!extensions) { - return SDL_FALSE; + return false; } /* It takes a bit of care to be fool-proof about parsing the @@ -399,13 +399,13 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) terminator = where + SDL_strlen(extension); if (where == start || *(where - 1) == ' ') { if (*terminator == ' ' || *terminator == '\0') { - return SDL_TRUE; + return true; } } start = terminator; } - return SDL_FALSE; + return false; } void WIN_GL_InitExtensions(SDL_VideoDevice *_this) @@ -454,7 +454,7 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) } // Check for WGL_ARB_pixel_format - _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE; + _this->gl_data->HAS_WGL_ARB_pixel_format = false; if (HasExtension("WGL_ARB_pixel_format", extensions)) { /* *INDENT-OFF* */ // clang-format off _this->gl_data->wglChoosePixelFormatARB = @@ -467,12 +467,12 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) if ((_this->gl_data->wglChoosePixelFormatARB != NULL) && (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { - _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE; + _this->gl_data->HAS_WGL_ARB_pixel_format = true; } } // Check for WGL_EXT_swap_control - _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE; + _this->gl_data->HAS_WGL_EXT_swap_control_tear = false; if (HasExtension("WGL_EXT_swap_control", extensions)) { _this->gl_data->wglSwapIntervalEXT = (BOOL (WINAPI *)(int)) @@ -481,7 +481,7 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) (int (WINAPI *)(void)) WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT"); if (HasExtension("WGL_EXT_swap_control_tear", extensions)) { - _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE; + _this->gl_data->HAS_WGL_EXT_swap_control_tear = true; } } else { _this->gl_data->wglSwapIntervalEXT = NULL; @@ -497,17 +497,17 @@ void WIN_GL_InitExtensions(SDL_VideoDevice *_this) // Check for WGL_ARB_context_flush_control if (HasExtension("WGL_ARB_context_flush_control", extensions)) { - _this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE; + _this->gl_data->HAS_WGL_ARB_context_flush_control = true; } // Check for WGL_ARB_create_context_robustness if (HasExtension("WGL_ARB_create_context_robustness", extensions)) { - _this->gl_data->HAS_WGL_ARB_create_context_robustness = SDL_TRUE; + _this->gl_data->HAS_WGL_ARB_create_context_robustness = true; } // Check for WGL_ARB_create_context_no_error if (HasExtension("WGL_ARB_create_context_no_error", extensions)) { - _this->gl_data->HAS_WGL_ARB_create_context_no_error = SDL_TRUE; + _this->gl_data->HAS_WGL_ARB_create_context_no_error = true; } _this->gl_data->wglMakeCurrent(hdc, NULL); @@ -695,12 +695,12 @@ int WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) return retval; } -SDL_bool WIN_GL_UseEGL(SDL_VideoDevice *_this) +bool WIN_GL_UseEGL(SDL_VideoDevice *_this) { SDL_assert(_this->gl_data != NULL); SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); - return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); // No WGL extension for OpenGL ES 1.x profiles. + return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, false) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); // No WGL extension for OpenGL ES 1.x profiles. } SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index cb4816232b..0296296484 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -59,11 +59,11 @@ typedef struct tagPIXELFORMATDESCRIPTOR struct SDL_GLDriverData { - SDL_bool HAS_WGL_ARB_pixel_format; - SDL_bool HAS_WGL_EXT_swap_control_tear; - SDL_bool HAS_WGL_ARB_context_flush_control; - SDL_bool HAS_WGL_ARB_create_context_robustness; - SDL_bool HAS_WGL_ARB_create_context_no_error; + bool HAS_WGL_ARB_pixel_format; + bool HAS_WGL_EXT_swap_control_tear; + bool HAS_WGL_ARB_context_flush_control; + bool HAS_WGL_ARB_create_context_robustness; + bool HAS_WGL_ARB_create_context_no_error; /* Max version of OpenGL ES context that can be created if the implementation supports WGL_EXT_create_context_es2_profile. @@ -105,7 +105,7 @@ struct SDL_GLDriverData extern int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); extern void WIN_GL_UnloadLibrary(SDL_VideoDevice *_this); -extern SDL_bool WIN_GL_UseEGL(SDL_VideoDevice *_this); +extern bool WIN_GL_UseEGL(SDL_VideoDevice *_this); extern int WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); extern SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern int WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index 319a3ff666..846376403b 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -34,7 +34,7 @@ int WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) // If the profile requested is not GL ES, switch over to WIN_GL functions if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES && - !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { #ifdef SDL_VIDEO_OPENGL_WGL WIN_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GL_LoadLibrary; @@ -67,7 +67,7 @@ SDL_GLContext WIN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) #ifdef SDL_VIDEO_OPENGL_WGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES && - !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { // Switch to WGL based functions WIN_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GL_LoadLibrary; diff --git a/src/video/windows/SDL_windowsrawinput.c b/src/video/windows/SDL_windowsrawinput.c index ad7fc0756b..116a615c61 100644 --- a/src/video/windows/SDL_windowsrawinput.c +++ b/src/video/windows/SDL_windowsrawinput.c @@ -35,7 +35,7 @@ typedef struct { - SDL_bool done; + bool done; Uint32 flags; HANDLE ready_event; HANDLE done_event; @@ -43,7 +43,7 @@ typedef struct } RawInputThreadData; static RawInputThreadData thread_data = { - SDL_FALSE, + false, 0, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, @@ -113,7 +113,7 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param) static void CleanupRawInputThreadData(RawInputThreadData *data) { if (data->thread != INVALID_HANDLE_VALUE) { - data->done = SDL_TRUE; + data->done = true; SetEvent(data->done_event); WaitForSingleObject(data->thread, 3000); CloseHandle(data->thread); @@ -147,7 +147,7 @@ static int WIN_SetRawInputEnabled(SDL_VideoDevice *_this, Uint32 flags) goto done; } - thread_data.done = SDL_FALSE; + thread_data.done = false; thread_data.done_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (thread_data.done_event == INVALID_HANDLE_VALUE) { WIN_SetError("CreateEvent"); @@ -199,7 +199,7 @@ static int WIN_UpdateRawInputEnabled(SDL_VideoDevice *_this) return 0; } -int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, SDL_bool enabled) +int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled) { SDL_VideoData *data = _this->internal; data->raw_mouse_enabled = enabled; @@ -217,7 +217,7 @@ int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, SDL_bool enabled) return 0; } -int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled) +int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled) { SDL_VideoData *data = _this->internal; data->raw_keyboard_enabled = enabled; @@ -237,12 +237,12 @@ int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled) #else -int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, SDL_bool enabled) +int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled) { return SDL_Unsupported(); } -int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled) +int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled) { return SDL_Unsupported(); } diff --git a/src/video/windows/SDL_windowsrawinput.h b/src/video/windows/SDL_windowsrawinput.h index ddf6ed3d54..ddef47fbc5 100644 --- a/src/video/windows/SDL_windowsrawinput.h +++ b/src/video/windows/SDL_windowsrawinput.h @@ -23,7 +23,7 @@ #ifndef SDL_windowsrawinput_h_ #define SDL_windowsrawinput_h_ -extern int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, SDL_bool enabled); -extern int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, SDL_bool enabled); +extern int WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled); +extern int WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled); #endif // SDL_windowsrawinput_h_ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 4f38cc06e3..0eac38b50d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -47,30 +47,30 @@ static int WIN_VideoInit(SDL_VideoDevice *_this); static void WIN_VideoQuit(SDL_VideoDevice *_this); // Hints -SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE; -SDL_bool g_WindowsEnableMenuMnemonics = SDL_FALSE; -SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE; +bool g_WindowsEnableMessageLoop = true; +bool g_WindowsEnableMenuMnemonics = false; +bool g_WindowFrameUsableWhileCursorHidden = true; static void SDLCALL UpdateWindowsRawKeyboard(void *userdata, const char *name, const char *oldValue, const char *newValue) { SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; - SDL_bool enabled = SDL_GetStringBoolean(newValue, SDL_FALSE); + bool enabled = SDL_GetStringBoolean(newValue, false); WIN_SetRawKeyboardEnabled(_this, enabled); } static void SDLCALL UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue) { - g_WindowsEnableMessageLoop = SDL_GetStringBoolean(newValue, SDL_TRUE); + g_WindowsEnableMessageLoop = SDL_GetStringBoolean(newValue, true); } static void SDLCALL UpdateWindowsEnableMenuMnemonics(void *userdata, const char *name, const char *oldValue, const char *newValue) { - g_WindowsEnableMenuMnemonics = SDL_GetStringBoolean(newValue, SDL_FALSE); + g_WindowsEnableMenuMnemonics = SDL_GetStringBoolean(newValue, false); } static void SDLCALL UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue) { - g_WindowFrameUsableWhileCursorHidden = SDL_GetStringBoolean(newValue, SDL_TRUE); + g_WindowFrameUsableWhileCursorHidden = SDL_GetStringBoolean(newValue, true); } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -264,7 +264,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) #endif #ifdef SDL_VIDEO_OPENGL_EGL #ifdef SDL_VIDEO_OPENGL_WGL - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { #endif // Use EGL based functions device->GL_LoadLibrary = WIN_GLES_LoadLibrary; @@ -471,12 +471,12 @@ int WIN_VideoInit(SDL_VideoDevice *_this) hr = WIN_CoInitialize(); if (SUCCEEDED(hr)) { - data->coinitialized = SDL_TRUE; + data->coinitialized = true; #if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) hr = OleInitialize(NULL); if (SUCCEEDED(hr)) { - data->oleinitialized = SDL_TRUE; + data->oleinitialized = true; } else { SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "OleInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr); } @@ -491,7 +491,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) SDL_Log("DPI awareness: %s", WIN_GetDPIAwareness(_this)); #endif - if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_GAMEINPUT, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_GAMEINPUT, true)) { WIN_InitGameInput(_this); } @@ -516,7 +516,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) WIN_InitMouse(_this); WIN_InitDeviceNotification(); if (!_this->internal->gameinput_context) { - WIN_CheckKeyboardAndMouseHotplug(_this, SDL_TRUE); + WIN_CheckKeyboardAndMouseHotplug(_this, true); } #endif @@ -541,8 +541,8 @@ void WIN_VideoQuit(SDL_VideoDevice *_this) SDL_DelHintCallback(SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS, UpdateWindowsEnableMenuMnemonics, NULL); SDL_DelHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL); - WIN_SetRawMouseEnabled(_this, SDL_FALSE); - WIN_SetRawKeyboardEnabled(_this, SDL_FALSE); + WIN_SetRawMouseEnabled(_this, false); + WIN_SetRawKeyboardEnabled(_this, false); WIN_QuitGameInput(_this); #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -553,13 +553,13 @@ void WIN_VideoQuit(SDL_VideoDevice *_this) if (data->oleinitialized) { OleUninitialize(); - data->oleinitialized = SDL_FALSE; + data->oleinitialized = false; } #endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) if (data->coinitialized) { WIN_CoUninitialize(); - data->coinitialized = SDL_FALSE; + data->coinitialized = false; } } @@ -583,7 +583,7 @@ void WIN_VideoQuit(SDL_VideoDevice *_this) #endif #endif -SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) +bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); if (*pD3DDLL) { @@ -593,7 +593,7 @@ SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) /* *INDENT-ON* */ // clang-format on Direct3DCreate9_t Direct3DCreate9Func; - if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, false)) { Direct3DCreate9Ex_t Direct3DCreate9ExFunc; Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); @@ -605,7 +605,7 @@ SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void **)pDirect3D9Interface); IDirect3D9Ex_Release(pDirect3D9ExInterface); if (SUCCEEDED(hr)) { - return SDL_TRUE; + return true; } } } @@ -615,7 +615,7 @@ SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) if (Direct3DCreate9Func) { *pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION); if (*pDirect3D9Interface) { - return SDL_TRUE; + return true; } } @@ -623,7 +623,7 @@ SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) *pD3DDLL = NULL; } *pDirect3D9Interface = NULL; - return SDL_FALSE; + return false; } int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) @@ -747,7 +747,7 @@ SDL_SystemTheme WIN_GetSystemTheme(void) return theme; } -SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) +bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) { #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_VideoData *data = _this->internal; @@ -757,7 +757,7 @@ SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) return data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, data->GetThreadDpiAwarenessContext()); } #endif - return SDL_FALSE; + return false; } #endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index eb46c2cd77..869e8ad366 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -380,9 +380,9 @@ struct SDL_VideoData { int render; - SDL_bool coinitialized; + bool coinitialized; #if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) - SDL_bool oleinitialized; + bool oleinitialized; #endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) DWORD clipboard_count; @@ -425,7 +425,7 @@ struct SDL_VideoData IDXGIFactory *pDXGIFactory; #endif - SDL_bool cleared; + bool cleared; BYTE *rawinput; UINT rawinput_offset; @@ -433,22 +433,22 @@ struct SDL_VideoData UINT rawinput_count; Uint64 last_rawinput_poll; SDL_Point last_raw_mouse_position; - SDL_bool raw_mouse_enabled; - SDL_bool raw_keyboard_enabled; - SDL_bool pending_E1_key_sequence; + bool raw_mouse_enabled; + bool raw_keyboard_enabled; + bool pending_E1_key_sequence; Uint32 raw_input_enabled; WIN_GameInputData *gameinput_context; #ifndef SDL_DISABLE_WINDOWS_IME - SDL_bool ime_initialized; - SDL_bool ime_enabled; - SDL_bool ime_available; - SDL_bool ime_internal_composition; - SDL_bool ime_internal_candidates; + bool ime_initialized; + bool ime_enabled; + bool ime_available; + bool ime_internal_composition; + bool ime_internal_candidates; HWND ime_hwnd_main; HWND ime_hwnd_current; - SDL_bool ime_needs_clear_composition; + bool ime_needs_clear_composition; HIMC ime_himc; WCHAR *ime_composition; @@ -458,14 +458,14 @@ struct SDL_VideoData int ime_selected_start; int ime_selected_length; - SDL_bool ime_candidates_open; - SDL_bool ime_update_candidates; + bool ime_candidates_open; + bool ime_update_candidates; char *ime_candidates[MAX_CANDLIST]; int ime_candcount; DWORD ime_candref; DWORD ime_candsel; int ime_candlistindexbase; - SDL_bool ime_horizontal_candidates; + bool ime_horizontal_candidates; #endif #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -491,14 +491,14 @@ struct SDL_VideoData UINT _SDL_WAKEUP; }; -extern SDL_bool g_WindowsEnableMessageLoop; -extern SDL_bool g_WindowsEnableMenuMnemonics; -extern SDL_bool g_WindowFrameUsableWhileCursorHidden; +extern bool g_WindowsEnableMessageLoop; +extern bool g_WindowsEnableMenuMnemonics; +extern bool g_WindowFrameUsableWhileCursorHidden; typedef struct IDirect3D9 IDirect3D9; -extern SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface); +extern bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface); extern SDL_SystemTheme WIN_GetSystemTheme(void); -extern SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this); +extern bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this); #endif // SDL_windowsvideo_h_ diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index 79f275e9ae..7ab469aa97 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -40,8 +40,8 @@ int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; Uint32 i; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasWin32SurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasWin32SurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; if (_this->vulkan_config.loader_handle) { return SDL_SetError("Vulkan already loaded"); @@ -81,9 +81,9 @@ int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasWin32SurfaceExtension = SDL_TRUE; + hasWin32SurfaceExtension = true; } } SDL_free(extensions); @@ -166,7 +166,7 @@ void WIN_Vulkan_DestroySurface(SDL_VideoDevice *_this, } } -SDL_bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex) @@ -180,13 +180,13 @@ SDL_bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, if (!_this->vulkan_config.loader_handle) { SDL_SetError("Vulkan is not loaded"); - return SDL_FALSE; + return false; } if (!vkGetPhysicalDeviceWin32PresentationSupportKHR) { SDL_SetError(VK_KHR_WIN32_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); - return SDL_FALSE; + return false; } return vkGetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, diff --git a/src/video/windows/SDL_windowsvulkan.h b/src/video/windows/SDL_windowsvulkan.h index 79c9f4dbf5..cd28d75d35 100644 --- a/src/video/windows/SDL_windowsvulkan.h +++ b/src/video/windows/SDL_windowsvulkan.h @@ -46,7 +46,7 @@ void WIN_Vulkan_DestroySurface(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); -SDL_bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 99a0df623c..e515e97a39 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -138,7 +138,7 @@ static DWORD GetWindowStyle(SDL_Window *window) but still interacts with the window manager (e.g. task bar shows above it, it can be resized to fit within usable desktop area, etc.) */ - if (SDL_GetHintBoolean("SDL_BORDERLESS_WINDOWED_STYLE", SDL_TRUE)) { + if (SDL_GetHintBoolean("SDL_BORDERLESS_WINDOWED_STYLE", true)) { style |= STYLE_BORDERLESS_WINDOWED; } else { style |= STYLE_BORDERLESS; @@ -152,7 +152,7 @@ static DWORD GetWindowStyle(SDL_Window *window) see https://bugzilla.libsdl.org/show_bug.cgi?id=4466 */ if (!(window->flags & SDL_WINDOW_BORDERLESS) || - SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", SDL_FALSE)) { + SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", false)) { style |= STYLE_RESIZABLE; } } @@ -206,7 +206,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD break; default: // Should never be here - SDL_assert_release(SDL_FALSE); + SDL_assert_release(false); *width = 0; *height = 0; break; @@ -333,11 +333,11 @@ int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect WIN_AdjustWindowRect(window, &x, &y, &w, &h, rect_type); - data->expected_resize = SDL_TRUE; + data->expected_resize = true; if (SetWindowPos(hwnd, top, x, y, w, h, flags) == 0) { result = WIN_SetError("SetWindowPos()"); } - data->expected_resize = SDL_FALSE; + data->expected_resize = false; // Update any child windows for (child_window = window->first_child; child_window; child_window = child_window->next_sibling) { @@ -351,7 +351,7 @@ int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect static void SDLCALL WIN_MouseRelativeModeCenterChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_WindowData *data = (SDL_WindowData *)userdata; - data->mouse_relative_mode_center = SDL_GetStringBoolean(hint, SDL_TRUE); + data->mouse_relative_mode_center = SDL_GetStringBoolean(hint, true); } static SDL_WindowEraseBackgroundMode GetEraseBackgroundModeHint(void) @@ -400,12 +400,12 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd data->mouse_button_flags = (WPARAM)-1; data->last_pointer_update = (LPARAM)-1; data->videodata = videodata; - data->initializing = SDL_TRUE; + data->initializing = true; data->last_displayID = window->last_displayID; data->dwma_border_color = DWMWA_COLOR_DEFAULT; data->hint_erase_background_mode = GetEraseBackgroundModeHint(); - if (SDL_GetHintBoolean("SDL_WINDOW_RETAIN_CONTENT", SDL_FALSE)) { + if (SDL_GetHintBoolean("SDL_WINDOW_RETAIN_CONTENT", false)) { data->copybits_flag = 0; } else { data->copybits_flag = SWP_NOCOPYBITS; @@ -494,9 +494,9 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd int x, y; // Figure out what the window area will be WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_WINDOWRECT_FLOATING); - data->expected_resize = SDL_TRUE; + data->expected_resize = true; SetWindowPos(hwnd, NULL, x, y, w, h, data->copybits_flag | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - data->expected_resize = SDL_FALSE; + data->expected_resize = false; } else { window->w = w; window->h = h; @@ -518,7 +518,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd } } - WIN_UpdateWindowICCProfile(window, SDL_FALSE); + WIN_UpdateWindowICCProfile(window, false); #endif #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) @@ -532,9 +532,9 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd #endif if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { - WIN_SetWindowAlwaysOnTop(_this, window, SDL_TRUE); + WIN_SetWindowAlwaysOnTop(_this, window, true); } else { - WIN_SetWindowAlwaysOnTop(_this, window, SDL_FALSE); + WIN_SetWindowAlwaysOnTop(_this, window, false); } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) @@ -545,17 +545,17 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd #endif if (data->parent && !window->parent) { - data->destroy_parent_with_window = SDL_TRUE; + data->destroy_parent_with_window = true; } - data->initializing = SDL_FALSE; + data->initializing = false; #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (window->flags & SDL_WINDOW_EXTERNAL) { // Query the title from the existing window LPTSTR title; int titleLen; - SDL_bool isstack; + bool isstack; titleLen = GetWindowTextLength(hwnd); title = SDL_small_alloc(TCHAR, titleLen + 1, &isstack); @@ -591,7 +591,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (data->drop_target) { - WIN_AcceptDragAndDrop(window, SDL_FALSE); + WIN_AcceptDragAndDrop(window, false); } if (data->ICMFileName) { SDL_free(data->ICMFileName); @@ -782,7 +782,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI // The rest of this macro mess is for OpenGL or OpenGL ES windows #ifdef SDL_VIDEO_OPENGL_ES2 if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES || - SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) #ifdef SDL_VIDEO_OPENGL_WGL && (!_this->gl_data || WIN_GL_UseEGL(_this)) #endif // SDL_VIDEO_OPENGL_WGL @@ -832,7 +832,7 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i int icon_len, mask_len, row_len, y; BITMAPINFOHEADER *bmi; Uint8 *dst; - SDL_bool isstack; + bool isstack; int retval = 0; // Create temporary buffer for ICONIMAGE structure @@ -900,10 +900,10 @@ int WIN_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) window->internal->copybits_flag | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE, SDL_WINDOWRECT_FLOATING); } else { - window->internal->floating_rect_pending = SDL_TRUE; + window->internal->floating_rect_pending = true; } } else { - return SDL_UpdateFullscreenMode(window, SDL_TRUE, SDL_TRUE); + return SDL_UpdateFullscreenMode(window, true, true); } return 0; @@ -914,7 +914,7 @@ void WIN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED))) { WIN_SetWindowPositionInternal(window, window->internal->copybits_flag | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE, SDL_WINDOWRECT_FLOATING); } else { - window->internal->floating_rect_pending = SDL_TRUE; + window->internal->floating_rect_pending = true; } } @@ -1009,7 +1009,7 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) DWORD style; HWND hwnd; - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); if (window->parent) { // Update our position in case our parent moved while we were hidden @@ -1025,7 +1025,7 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) hwnd = window->internal->hwnd; style = GetWindowLong(hwnd, GWL_EXSTYLE); if (style & WS_EX_NOACTIVATE) { - bActivate = SDL_FALSE; + bActivate = false; } if (bActivate) { ShowWindow(hwnd, SW_SHOW); @@ -1079,8 +1079,8 @@ void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) * nearly impossible to programmatically move a window to the foreground, * for "security" reasons. Apparently, the following song-and-dance gets * around their objections. */ - SDL_bool bForce = SDL_GetHintBoolean(SDL_HINT_FORCE_RAISEWINDOW, SDL_FALSE); - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, SDL_TRUE); + bool bForce = SDL_GetHintBoolean(SDL_HINT_FORCE_RAISEWINDOW, false); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); HWND hCurWnd = NULL; DWORD dwMyID = 0u; @@ -1123,9 +1123,9 @@ void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { HWND hwnd = data->hwnd; - data->expected_resize = SDL_TRUE; + data->expected_resize = true; ShowWindow(hwnd, SW_MAXIMIZE); - data->expected_resize = SDL_FALSE; + data->expected_resize = false; /* Clamp the maximized window size to the max window size. * This is automatic if maximizing from the window controls. @@ -1137,12 +1137,12 @@ void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) window->windowed.h = window->max_h ? SDL_min(window->h, window->max_h) : window->windowed.h; WIN_AdjustWindowRect(window, &fx, &fy, &fw, &fh, SDL_WINDOWRECT_WINDOWED); - data->expected_resize = SDL_TRUE; + data->expected_resize = true; SetWindowPos(hwnd, HWND_TOP, fx, fy, fw, fh, data->copybits_flag | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - data->expected_resize = SDL_FALSE; + data->expected_resize = false; } } else { - data->windowed_mode_was_maximized = SDL_TRUE; + data->windowed_mode_was_maximized = true; } } @@ -1152,7 +1152,7 @@ void WIN_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) ShowWindow(hwnd, SW_MINIMIZE); } -void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered) +void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) { SDL_WindowData *data = window->internal; HWND hwnd = data->hwnd; @@ -1162,13 +1162,13 @@ void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool style &= ~STYLE_MASK; style |= GetWindowStyle(window); - data->in_border_change = SDL_TRUE; + data->in_border_change = true; SetWindowLong(hwnd, GWL_STYLE, style); WIN_SetWindowPositionInternal(window, data->copybits_flag | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); - data->in_border_change = SDL_FALSE; + data->in_border_change = false; } -void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) +void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) { SDL_WindowData *data = window->internal; HWND hwnd = data->hwnd; @@ -1181,7 +1181,7 @@ void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool SetWindowLong(hwnd, GWL_STYLE, style); } -void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top) +void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) { WIN_SetWindowPositionInternal(window, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); } @@ -1191,11 +1191,11 @@ void WIN_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->internal; if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { HWND hwnd = data->hwnd; - data->expected_resize = SDL_TRUE; + data->expected_resize = true; ShowWindow(hwnd, SW_RESTORE); - data->expected_resize = SDL_FALSE; + data->expected_resize = false; } else { - data->windowed_mode_was_maximized = SDL_FALSE; + data->windowed_mode_was_maximized = false; } } @@ -1251,7 +1251,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide HWND top; int x, y; int w, h; - SDL_bool enterMaximized = SDL_FALSE; + bool enterMaximized = false; #ifdef HIGHDPI_DEBUG SDL_Log("WIN_SetWindowFullscreen: %d", (int)fullscreen); @@ -1295,7 +1295,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide https://bugzilla.libsdl.org/show_bug.cgi?id=3215 */ if (style & WS_MAXIMIZE) { - data->windowed_mode_was_maximized = SDL_TRUE; + data->windowed_mode_was_maximized = true; style &= ~WS_MAXIMIZE; } @@ -1316,7 +1316,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide */ if (data->windowed_mode_was_maximized && !data->in_window_deactivation) { style |= WS_MAXIMIZE; - enterMaximized = SDL_TRUE; + enterMaximized = true; } menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); @@ -1324,10 +1324,10 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide &x, &y, &w, &h, data->windowed_mode_was_maximized ? SDL_WINDOWRECT_WINDOWED : SDL_WINDOWRECT_FLOATING); - data->windowed_mode_was_maximized = SDL_FALSE; + data->windowed_mode_was_maximized = false; } SetWindowLong(hwnd, GWL_STYLE, style); - data->expected_resize = SDL_TRUE; + data->expected_resize = true; if (!enterMaximized) { SetWindowPos(hwnd, top, x, y, w, h, data->copybits_flag | SWP_NOACTIVATE); @@ -1335,7 +1335,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide WIN_MaximizeWindow(_this, window); } - data->expected_resize = SDL_FALSE; + data->expected_resize = false; #ifdef HIGHDPI_DEBUG SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h); @@ -1346,7 +1346,7 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide } #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) -void WIN_UpdateWindowICCProfile(SDL_Window *window, SDL_bool send_event) +void WIN_UpdateWindowICCProfile(SDL_Window *window, bool send_event) { SDL_WindowData *data = window->internal; SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); @@ -1441,13 +1441,13 @@ int WIN_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -int WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { WIN_UpdateClipCursor(window); return 0; } -int WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { if (grabbed) { WIN_GrabKeyboard(window); @@ -1628,13 +1628,13 @@ void WIN_UpdateClipCursor(SDL_Window *window) } } } else { - SDL_bool unclip_cursor = SDL_FALSE; + bool unclip_cursor = false; // If the cursor is clipped to the screen, clear the clip state if (!videodevice || (clipped_rect.left == videodevice->desktop_bounds.x && clipped_rect.top == videodevice->desktop_bounds.y)) { - unclip_cursor = SDL_TRUE; + unclip_cursor = true; } else { POINT first, second; @@ -1644,7 +1644,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) second.y = clipped_rect.bottom - 1; if (PtInRect(&data->cursor_clipped_rect, first) && PtInRect(&data->cursor_clipped_rect, second)) { - unclip_cursor = SDL_TRUE; + unclip_cursor = true; } } if (unclip_cursor) { @@ -1655,7 +1655,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) data->last_updated_clipcursor = SDL_GetTicks(); } -int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int WIN_SetWindowHitTest(SDL_Window *window, bool enabled) { return 0; // just succeed, the real work is done elsewhere. } @@ -2126,7 +2126,7 @@ static void *vtDropTarget[] = { (void *)(SDLDropTarget_Drop) }; -void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) +void WIN_AcceptDragAndDrop(SDL_Window *window, bool accept) { SDL_WindowData *data = window->internal; if (data->videodata->oleinitialized) { @@ -2199,7 +2199,7 @@ void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y) SendMessage(data->hwnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y)); } -int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable) +int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) { SDL_WindowData *data = window->internal; HWND hwnd = data->hwnd; diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 14205950c8..d78537bcb1 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -72,22 +72,22 @@ struct SDL_WindowData WPARAM mouse_button_flags; LPARAM last_pointer_update; WCHAR high_surrogate; - SDL_bool initializing; - SDL_bool expected_resize; - SDL_bool in_border_change; - SDL_bool in_title_click; - SDL_bool floating_rect_pending; + bool initializing; + bool expected_resize; + bool in_border_change; + bool in_title_click; + bool floating_rect_pending; Uint8 focus_click_pending; - SDL_bool skip_update_clipcursor; + bool skip_update_clipcursor; Uint64 last_updated_clipcursor; - SDL_bool mouse_relative_mode_center; - SDL_bool windowed_mode_was_maximized; - SDL_bool in_window_deactivation; + bool mouse_relative_mode_center; + bool windowed_mode_was_maximized; + bool in_window_deactivation; RECT cursor_clipped_rect; UINT windowed_mode_corner_rounding; COLORREF dwma_border_color; - SDL_bool mouse_tracked; - SDL_bool destroy_parent_with_window; + bool mouse_tracked; + bool destroy_parent_with_window; SDL_DisplayID last_displayID; WCHAR *ICMFileName; SDL_Window *keyboard_focus; @@ -116,25 +116,25 @@ extern void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); -extern void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); -extern void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top); +extern void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); extern int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); -extern void WIN_UpdateWindowICCProfile(SDL_Window *window, SDL_bool send_event); +extern void WIN_UpdateWindowICCProfile(SDL_Window *window, bool send_event); extern void *WIN_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); extern int WIN_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); -extern int WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); -extern int WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern int WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); extern void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window); extern void WIN_UpdateClipCursor(SDL_Window *window); -extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int WIN_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void WIN_AcceptDragAndDrop(SDL_Window *window, bool accept); extern int WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); extern void WIN_UpdateDarkModeForHWND(HWND hwnd); extern int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect rect_type); extern void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y); -extern int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable); +extern int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); extern int WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_WindowRect rect_type); extern int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi); extern int WIN_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window); diff --git a/src/video/winrt/SDL_winrtevents_c.h b/src/video/winrt/SDL_winrtevents_c.h index 2c56a672c2..2219190e82 100644 --- a/src/video/winrt/SDL_winrtevents_c.h +++ b/src/video/winrt/SDL_winrtevents_c.h @@ -53,7 +53,7 @@ typedef enum extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window *window, Windows::Foundation::Point rawPosition, WINRT_CursorNormalizationType normalization); -extern SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed); +extern bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed); extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^ pointerPoint); @@ -68,10 +68,10 @@ extern void WINRT_ProcessCharacterReceivedEvent(SDL_Window *window, Windows::UI: #if NTDDI_VERSION >= NTDDI_WIN10 extern void WINTRT_InitialiseInputPaneEvents(SDL_VideoDevice *_this); -extern SDL_bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this); extern void WINRT_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); extern void WINRT_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); #endif // NTDDI_VERSION >= ... // XAML Thread Management diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp index 843c1a133d..2caff1cf34 100644 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/src/video/winrt/SDL_winrtkeyboard.cpp @@ -143,9 +143,9 @@ void WINTRT_InitialiseInputPaneEvents(SDL_VideoDevice *_this) } } -SDL_bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool WINRT_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { - return SDL_TRUE; + return true; } void WINRT_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) @@ -166,7 +166,7 @@ void WINRT_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) } } -SDL_bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { using namespace Windows::UI::ViewManagement; InputPane ^ inputPane = InputPane::GetForCurrentView(); @@ -178,7 +178,7 @@ SDL_bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) // This does not seem to work on latest UWP/Xbox. // Workaround: Listen to Showing/Hiding events if (WINRT_InputPaneVisible) { - return SDL_TRUE; + return true; } break; default: @@ -186,12 +186,12 @@ SDL_bool WINRT_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.visible?view=winrt-22621 Windows::Foundation::Rect rect = inputPane->OccludedRect; if (rect.Width > 0 && rect.Height > 0) { - return SDL_TRUE; + return true; } break; } } - return SDL_FALSE; + return false; } #endif // NTDDI_VERSION >= ... diff --git a/src/video/winrt/SDL_winrtmouse.cpp b/src/video/winrt/SDL_winrtmouse.cpp index 09b3ef444e..ce89a41357 100644 --- a/src/video/winrt/SDL_winrtmouse.cpp +++ b/src/video/winrt/SDL_winrtmouse.cpp @@ -43,7 +43,7 @@ extern "C" { #include "SDL_winrtvideo_cpp.h" #include "SDL_winrtmouse_c.h" -extern "C" SDL_bool WINRT_UsingRelativeMouseMode = SDL_FALSE; +extern "C" bool WINRT_UsingRelativeMouseMode = false; static SDL_Cursor *WINRT_CreateSystemCursor(SDL_SystemCursor id) { @@ -220,7 +220,7 @@ static int WINRT_ShowCursor(SDL_Cursor *cursor) return 0; } -static int WINRT_SetRelativeMouseMode(SDL_bool enabled) +static int WINRT_SetRelativeMouseMode(bool enabled) { WINRT_UsingRelativeMouseMode = enabled; return 0; diff --git a/src/video/winrt/SDL_winrtmouse_c.h b/src/video/winrt/SDL_winrtmouse_c.h index afa32dee94..bf41245b34 100644 --- a/src/video/winrt/SDL_winrtmouse_c.h +++ b/src/video/winrt/SDL_winrtmouse_c.h @@ -29,7 +29,7 @@ extern "C" { extern void WINRT_InitMouse(SDL_VideoDevice *_this); extern void WINRT_QuitMouse(SDL_VideoDevice *_this); -extern SDL_bool WINRT_UsingRelativeMouseMode; +extern bool WINRT_UsingRelativeMouseMode; #ifdef __cplusplus } diff --git a/src/video/winrt/SDL_winrtpointerinput.cpp b/src/video/winrt/SDL_winrtpointerinput.cpp index 1138bae766..efd5b0fc17 100644 --- a/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/src/video/winrt/SDL_winrtpointerinput.cpp @@ -111,44 +111,44 @@ WINRT_TransformCursorPosition(SDL_Window *window, return outputPosition; } -SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed) +bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt, Uint8 *button, Uint8 *pressed) { using namespace Windows::UI::Input; #if SDL_WINAPI_FAMILY_PHONE *button = SDL_BUTTON_LEFT; - return SDL_TRUE; + return true; #else switch (pt->Properties->PointerUpdateKind) { case PointerUpdateKind::LeftButtonPressed: case PointerUpdateKind::LeftButtonReleased: *button = SDL_BUTTON_LEFT; *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::LeftButtonPressed); - return SDL_TRUE; + return true; case PointerUpdateKind::RightButtonPressed: case PointerUpdateKind::RightButtonReleased: *button = SDL_BUTTON_RIGHT; *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::RightButtonPressed); - return SDL_TRUE; + return true; case PointerUpdateKind::MiddleButtonPressed: case PointerUpdateKind::MiddleButtonReleased: *button = SDL_BUTTON_MIDDLE; *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::MiddleButtonPressed); - return SDL_TRUE; + return true; case PointerUpdateKind::XButton1Pressed: case PointerUpdateKind::XButton1Released: *button = SDL_BUTTON_X1; *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton1Pressed); - return SDL_TRUE; + return true; case PointerUpdateKind::XButton2Pressed: case PointerUpdateKind::XButton2Released: *button = SDL_BUTTON_X2; *pressed = (pt->Properties->PointerUpdateKind == PointerUpdateKind::XButton2Pressed); - return SDL_TRUE; + return true; default: break; @@ -157,7 +157,7 @@ SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt *button = 0; *pressed = 0; - return SDL_FALSE; + return false; } // const char * @@ -229,7 +229,7 @@ void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::Po WINRT_TouchID, (SDL_FingerID)(pointerPoint->PointerId + 1), window, - SDL_TRUE, + true, normalizedPoint.X, normalizedPoint.Y, pointerPoint->Properties->Pressure); @@ -252,7 +252,7 @@ void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::Poin SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, pressed, button); } - SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, SDL_FALSE, windowPoint.X, windowPoint.Y); + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, false, windowPoint.X, windowPoint.Y); } else { SDL_SendTouchMotion(0, WINRT_TouchID, @@ -282,7 +282,7 @@ void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::P WINRT_TouchID, (SDL_FingerID)(pointerPoint->PointerId + 1), window, - SDL_FALSE, + false, normalizedPoint.X, normalizedPoint.Y, pointerPoint->Properties->Pressure); @@ -383,7 +383,7 @@ void WINRT_ProcessMouseMovedEvent(SDL_Window *window, Windows::Devices::Input::M // const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y); const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize); - SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, SDL_TRUE, mouseDeltaInSDLWindowCoords.X, mouseDeltaInSDLWindowCoords.Y); + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, true, mouseDeltaInSDLWindowCoords.X, mouseDeltaInSDLWindowCoords.Y); } #endif // SDL_VIDEO_DRIVER_WINRT diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 19b5dc1d82..aff8ae57e5 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -240,8 +240,8 @@ int WINRT_VideoInit(SDL_VideoDevice *_this) } // Assume we have a mouse and keyboard - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); return 0; } @@ -337,7 +337,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg } } - if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) { + if (SDL_AddVideoDisplay(&display, false) == 0) { goto done; } @@ -417,7 +417,7 @@ static int WINRT_AddDisplaysForAdapter(SDL_VideoDevice *_this, IDXGIFactory2 *dx mode.format = D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM); display.desktop_mode = mode; - bool error = (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0); + bool error = (SDL_AddVideoDisplay(&display, false) == 0); if (display.name) { SDL_free(display.name); } diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 06511200be..d115582bc7 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -68,7 +68,7 @@ static int SetSelectionData(SDL_VideoDevice *_this, Atom selection, SDL_Clipboar Display *display = videodata->display; Window window; SDLX11_ClipboardData *clipboard; - SDL_bool clipboard_owner = SDL_FALSE; + bool clipboard_owner = false; window = GetWindow(_this); if (window == None) { @@ -131,29 +131,29 @@ static void *AppendDataBuffer(void *original_buffer, const size_t old_len, const } } -static SDL_bool WaitForSelection(SDL_VideoDevice *_this, Atom selection_type, SDL_bool *flag) +static bool WaitForSelection(SDL_VideoDevice *_this, Atom selection_type, bool *flag) { Uint64 waitStart; Uint64 waitElapsed; waitStart = SDL_GetTicks(); - *flag = SDL_TRUE; + *flag = true; while (*flag) { SDL_PumpEvents(); waitElapsed = SDL_GetTicks() - waitStart; // Wait one second for a selection response. if (waitElapsed > 1000) { - *flag = SDL_FALSE; + *flag = false; SDL_SetError("Selection timeout"); /* We need to set the selection text so that next time we won't timeout, otherwise we will hang on every call to this function. */ SetSelectionData(_this, selection_type, SDL_ClipboardTextCallback, NULL, text_mime_types, SDL_arraysize(text_mime_types), 0); - return SDL_FALSE; + return false; } } - return SDL_TRUE; + return true; } static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, @@ -172,7 +172,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, SDLX11_ClipboardData *clipboard; void *data = NULL; unsigned char *src = NULL; - SDL_bool incr_success = SDL_FALSE; + bool incr_success = false; Atom XA_MIME = X11_XInternAtom(display, mime_type, False); Atom XA_INCR = X11_XInternAtom(display, "INCR", False); @@ -203,7 +203,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, X11_XConvertSelection(display, selection_type, XA_MIME, selection, owner, CurrentTime); - if (WaitForSelection(_this, selection_type, &videodata->selection_waiting) == SDL_FALSE) { + if (WaitForSelection(_this, selection_type, &videodata->selection_waiting) == false) { data = NULL; *length = 0; } @@ -219,7 +219,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, X11_XDeleteProperty(display, owner, selection); X11_XFlush(display); - if (WaitForSelection(_this, selection_type, &videodata->selection_incr_waiting) == SDL_FALSE) { + if (WaitForSelection(_this, selection_type, &videodata->selection_incr_waiting) == false) { break; } @@ -230,7 +230,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, } if (count == 0) { - incr_success = SDL_TRUE; + incr_success = true; break; } @@ -247,7 +247,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, } } - if (incr_success == SDL_FALSE) { + if (incr_success == false) { SDL_free(data); data = 0; *length = 0; @@ -287,7 +287,7 @@ void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t return GetSelectionData(_this, XA_CLIPBOARD, mime_type, length); } -SDL_bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) { size_t length; void *data; @@ -313,13 +313,13 @@ char *X11_GetPrimarySelectionText(SDL_VideoDevice *_this) return text; } -SDL_bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this) +bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this) { - SDL_bool result = SDL_FALSE; + bool result = false; char *text = X11_GetPrimarySelectionText(_this); if (text) { if (text[0] != '\0') { - result = SDL_TRUE; + result = true; } SDL_free(text); } diff --git a/src/video/x11/SDL_x11clipboard.h b/src/video/x11/SDL_x11clipboard.h index 1ca4d16033..b6c6fa42c9 100644 --- a/src/video/x11/SDL_x11clipboard.h +++ b/src/video/x11/SDL_x11clipboard.h @@ -36,10 +36,10 @@ typedef struct X11_ClipboardData { extern const char **X11_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types); extern int X11_SetClipboardData(SDL_VideoDevice *_this); extern void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length); -extern SDL_bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); extern int X11_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text); extern char *X11_GetPrimarySelectionText(SDL_VideoDevice *_this); -extern SDL_bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this); +extern bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this); extern void X11_QuitClipboard(SDL_VideoDevice *_this); #endif // SDL_x11clipboard_h_ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 182db6184a..8769a1c711 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -165,7 +165,7 @@ static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) struct KeyRepeatCheckData { XEvent *event; - SDL_bool found; + bool found; }; static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev, @@ -173,7 +173,7 @@ static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev, { struct KeyRepeatCheckData *d = (struct KeyRepeatCheckData *)arg; if (chkev->type == KeyPress && chkev->xkey.keycode == d->event->xkey.keycode && chkev->xkey.time - d->event->xkey.time < 2) { - d->found = SDL_TRUE; + d->found = true; } return False; } @@ -181,19 +181,19 @@ static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev, /* Check to see if this is a repeated key. (idea shamelessly lifted from GII -- thanks guys! :) */ -static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) +static bool X11_KeyRepeat(Display *display, XEvent *event) { XEvent dummyev; struct KeyRepeatCheckData d; d.event = event; - d.found = SDL_FALSE; + d.found = false; if (X11_XPending(display)) { X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, (XPointer)&d); } return d.found; } -static SDL_bool X11_IsWheelEvent(Display *display, int button, int *xticks, int *yticks) +static bool X11_IsWheelEvent(Display *display, int button, int *xticks, int *yticks) { /* according to the xlib docs, no specific mouse wheel events exist. However, the defacto standard is that the vertical wheel is X buttons @@ -203,20 +203,20 @@ static SDL_bool X11_IsWheelEvent(Display *display, int button, int *xticks, int switch (button) { case 4: *yticks = 1; - return SDL_TRUE; + return true; case 5: *yticks = -1; - return SDL_TRUE; + return true; case 6: *xticks = 1; - return SDL_TRUE; + return true; case 7: *xticks = -1; - return SDL_TRUE; + return true; default: break; } - return SDL_FALSE; + return false; } // An X11 event hook @@ -310,20 +310,20 @@ void X11_ReconcileKeyboardState(SDL_VideoDevice *_this) // Sync up the keyboard modifier state if (X11_XQueryPointer(display, DefaultRootWindow(display), &junk_window, &junk_window, &x, &y, &x, &y, &mask)) { - SDL_ToggleModState(SDL_KMOD_CAPS, (mask & LockMask) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_NUM, (mask & X11_GetNumLockModifierMask(_this)) ? SDL_TRUE : SDL_FALSE); - SDL_ToggleModState(SDL_KMOD_SCROLL, (mask & X11_GetScrollLockModifierMask(_this)) ? SDL_TRUE : SDL_FALSE); + SDL_ToggleModState(SDL_KMOD_CAPS, (mask & LockMask) ? true : false); + SDL_ToggleModState(SDL_KMOD_NUM, (mask & X11_GetNumLockModifierMask(_this)) ? true : false); + SDL_ToggleModState(SDL_KMOD_SCROLL, (mask & X11_GetScrollLockModifierMask(_this)) ? true : false); } keyboardState = SDL_GetKeyboardState(0); for (keycode = 0; keycode < SDL_arraysize(videodata->key_layout); ++keycode) { SDL_Scancode scancode = videodata->key_layout[keycode]; - SDL_bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0; - SDL_bool sdlKeyPressed = keyboardState[scancode] == SDL_PRESSED; + bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0; + bool sdlKeyPressed = keyboardState[scancode] == SDL_PRESSED; if (x11KeyPressed && !sdlKeyPressed) { // Only update modifier state for keys that are pressed in another application - switch (SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, SDL_FALSE)) { + switch (SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false)) { case SDLK_LCTRL: case SDLK_RCTRL: case SDLK_LSHIFT: @@ -357,7 +357,7 @@ static void X11_DispatchFocusIn(SDL_VideoDevice *_this, SDL_WindowData *data) } #endif #ifdef SDL_USE_IME - SDL_IME_SetFocus(SDL_TRUE); + SDL_IME_SetFocus(true); #endif if (data->flashing_window) { X11_FlashWindow(_this, data->window, SDL_FLASH_CANCEL); @@ -382,7 +382,7 @@ static void X11_DispatchFocusOut(SDL_VideoDevice *_this, SDL_WindowData *data) } #endif #ifdef SDL_USE_IME - SDL_IME_SetFocus(SDL_FALSE); + SDL_IME_SetFocus(false); #endif } @@ -429,7 +429,7 @@ static void DispatchWindowMove(SDL_VideoDevice *_this, const SDL_WindowData *dat static void ScheduleWindowMove(SDL_VideoDevice *_this, SDL_WindowData *data, const SDL_Point *point) { - data->pending_move = SDL_TRUE; + data->pending_move = true; data->pending_move_point = *point; } @@ -462,21 +462,21 @@ static void InitiateWindowResize(SDL_VideoDevice *_this, const SDL_WindowData *d X11_XSync(display, 0); } -SDL_bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, SDL_bool force_new_result) +bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, bool force_new_result) { SDL_Window *window = data->window; - if (!window->hit_test) return SDL_FALSE; + if (!window->hit_test) return false; const SDL_Point point = { (int)x, (int)y }; SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); if (!force_new_result && rc == data->hit_test_result) { - return SDL_TRUE; + return true; } X11_SetHitTestCursor(rc); data->hit_test_result = rc; - return SDL_TRUE; + return true; } -SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y) +bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y) { SDL_Window *window = data->window; @@ -499,7 +499,7 @@ SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, } else { ScheduleWindowMove(_this, data, &point); } - return SDL_TRUE; + return true; case SDL_HITTEST_RESIZE_TOPLEFT: case SDL_HITTEST_RESIZE_TOP: @@ -510,14 +510,14 @@ SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, case SDL_HITTEST_RESIZE_BOTTOMLEFT: case SDL_HITTEST_RESIZE_LEFT: InitiateWindowResize(_this, data, &point, directions[data->hit_test_result - SDL_HITTEST_RESIZE_TOPLEFT]); - return SDL_TRUE; + return true; default: - return SDL_FALSE; + return false; } } - return SDL_FALSE; + return false; } static void X11_UpdateUserTime(SDL_WindowData *data, const unsigned long latest) @@ -631,7 +631,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven SDL_Log("window CLIPBOARD: SelectionNotify (requestor = 0x%lx, target = 0x%lx)\n", xevent->xselection.requestor, xevent->xselection.target); #endif - videodata->selection_waiting = SDL_FALSE; + videodata->selection_waiting = false; } break; case SelectionClear: @@ -665,7 +665,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven char *name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); if (SDL_strncmp(name_of_atom, "SDL_SELECTION", sizeof("SDL_SELECTION") - 1) == 0 && xevent->xproperty.state == PropertyNewValue) { - videodata->selection_incr_waiting = SDL_FALSE; + videodata->selection_incr_waiting = false; } if (name_of_atom) { @@ -707,16 +707,16 @@ static Bool isReparentNotify(Display *display, XEvent *ev, XPointer arg) ev->xreparent.serial == unmap->serial; } -static SDL_bool IsHighLatin1(const char *string, int length) +static bool IsHighLatin1(const char *string, int length) { while (length-- > 0) { Uint8 ch = (Uint8)*string; if (ch >= 0x80) { - return SDL_TRUE; + return true; } ++string; } - return SDL_FALSE; + return false; } static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int bytes_buffer, KeySym *keysym_return, XComposeStatus *status_in_out) @@ -760,7 +760,7 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_ int text_length = 0; char text[64]; Status status = 0; - SDL_bool handled_by_ime = SDL_FALSE; + bool handled_by_ime = false; #ifdef DEBUG_XEVENTS SDL_Log("window 0x%lx %s (X11 keycode = 0x%X)\n", xevent->xany.window, (xevent->type == KeyPress ? "KeyPress" : "KeyRelease"), xevent->xkey.keycode); @@ -862,7 +862,7 @@ void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, S if (X11_IsWheelEvent(display, button, &xticks, &yticks)) { SDL_SendMouseWheel(0, window, mouseID, (float)-xticks, (float)yticks, SDL_MOUSEWHEEL_NORMAL); } else { - SDL_bool ignore_click = SDL_FALSE; + bool ignore_click = false; if (button == Button1) { if (X11_TriggerHitTestAction(_this, windowdata, x, y)) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); @@ -876,7 +876,7 @@ void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, S if (windowdata->last_focus_event_time) { const int X11_FOCUS_CLICK_TIMEOUT = 10; if (SDL_GetTicks() < (windowdata->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { - ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, SDL_FALSE); + ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); } windowdata->last_focus_event_time = 0; } @@ -1032,7 +1032,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (X11_XkbGetState(videodata->display, XkbUseCoreKbd, &state) == Success) { if (state.group != videodata->xkb_group) { // Only rebuild the keymap if the layout has changed. - X11_UpdateKeymap(_this, SDL_TRUE); + X11_UpdateKeymap(_this, true); } } } @@ -1050,7 +1050,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) X11_XRefreshKeyboardMapping(&xevent->xmapping); } - X11_UpdateKeymap(_this, SDL_TRUE); + X11_UpdateKeymap(_this, true); } else if (xevent->type == PropertyNotify && videodata && videodata->windowlist) { char *name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); @@ -1109,20 +1109,20 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) { // Only create the barriers if we have input focus SDL_WindowData *windowdata = data->window->internal; - if ((data->pointer_barrier_active == SDL_TRUE) && windowdata->window->flags & SDL_WINDOW_INPUT_FOCUS) { + if ((data->pointer_barrier_active == true) && windowdata->window->flags & SDL_WINDOW_INPUT_FOCUS) { X11_ConfineCursorWithFlags(_this, windowdata->window, &windowdata->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); } } #endif if (!mouse->relative_mode) { - SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); } // We ungrab in LeaveNotify, so we may need to grab again here SDL_UpdateWindowGrab(data->window); - X11_ProcessHitTest(_this, data, mouse->last_x, mouse->last_y, SDL_TRUE); + X11_ProcessHitTest(_this, data, mouse->last_x, mouse->last_y, true); } break; // Losing mouse coverage? case LeaveNotify: @@ -1140,7 +1140,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } #endif if (!SDL_GetMouse()->relative_mode) { - SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); } if (xevent->xcrossing.mode != NotifyGrab && @@ -1150,7 +1150,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) /* In order for interaction with the window decorations and menu to work properly on Mutter, we need to ungrab the keyboard when the the mouse leaves. */ if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowKeyboardGrab(_this, data->window, SDL_FALSE); + X11_SetWindowKeyboardGrab(_this, data->window, false); } SDL_SetMouseFocus(NULL); @@ -1221,7 +1221,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES // Disable confinement if it is activated. - if (data->pointer_barrier_active == SDL_TRUE) { + if (data->pointer_barrier_active == true) { X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); } #endif // SDL_VIDEO_DRIVER_X11_XFIXES @@ -1245,7 +1245,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES // Disable confinement if the window gets hidden. - if (data->pointer_barrier_active == SDL_TRUE) { + if (data->pointer_barrier_active == true) { X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); } #endif // SDL_VIDEO_DRIVER_X11_XFIXES @@ -1261,7 +1261,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES // Enable confinement if it was activated. - if (data->pointer_barrier_active == SDL_TRUE) { + if (data->pointer_barrier_active == true) { X11_ConfineCursorWithFlags(_this, data->window, &data->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); } #endif // SDL_VIDEO_DRIVER_X11_XFIXES @@ -1310,7 +1310,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) for (w = data->window->first_child; w; w = w->next_sibling) { // Don't update hidden child windows, their relative position doesn't change if (!(w->flags & SDL_WINDOW_HIDDEN)) { - X11_UpdateWindowPosition(w, SDL_TRUE); + X11_UpdateWindowPosition(w, true); } } } @@ -1336,7 +1336,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (xevent->xclient.message_type == videodata->XdndEnter) { - SDL_bool use_list = xevent->xclient.data.l[1] & 1; + bool use_list = xevent->xclient.data.l[1] & 1; data->xdnd_source = xevent->xclient.data.l[0]; xdnd_version = (xevent->xclient.data.l[1] >> 24); #ifdef DEBUG_XEVENTS @@ -1479,8 +1479,8 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_Log("window 0x%lx: X11 motion: %d,%d\n", xevent->xany.window, xevent->xmotion.x, xevent->xmotion.y); #endif - X11_ProcessHitTest(_this, data, (float)xevent->xmotion.x, (float)xevent->xmotion.y, SDL_FALSE); - SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)xevent->xmotion.x, (float)xevent->xmotion.y); + X11_ProcessHitTest(_this, data, (float)xevent->xmotion.x, (float)xevent->xmotion.y, false); + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xmotion.x, (float)xevent->xmotion.y); } } break; @@ -1617,7 +1617,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if (flags & SDL_WINDOW_FULLSCREEN) { if (!(flags & SDL_WINDOW_MINIMIZED)) { - const SDL_bool commit = SDL_memcmp(&data->window->current_fullscreen_mode, &data->requested_fullscreen_mode, sizeof(SDL_DisplayMode)) != 0; + const bool commit = SDL_memcmp(&data->window->current_fullscreen_mode, &data->requested_fullscreen_mode, sizeof(SDL_DisplayMode)) != 0; SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); if (commit) { @@ -1625,14 +1625,14 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) * becoming fullscreen. Switch to the application requested mode if necessary. */ SDL_copyp(&data->window->current_fullscreen_mode, &data->window->requested_fullscreen_mode); - SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_UPDATE, SDL_TRUE); + SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_UPDATE, true); } else { - SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_ENTER, SDL_FALSE); + SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_ENTER, false); } } } else { SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); - SDL_UpdateFullscreenMode(data->window, SDL_FALSE, SDL_FALSE); + SDL_UpdateFullscreenMode(data->window, false, false); SDL_zero(data->requested_fullscreen_mode); @@ -1641,8 +1641,8 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) // Toggle the borders if they were forced on while creating a borderless fullscreen window. if (data->fullscreen_borders_forced_on) { - data->toggle_borders = SDL_TRUE; - data->fullscreen_borders_forced_on = SDL_FALSE; + data->toggle_borders = true; + data->fullscreen_borders_forced_on = false; } } @@ -1653,8 +1653,8 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) * shut off to avoid bogus window sizes and positions, and * note that the old borders were non-zero for restoration. */ - data->disable_size_position_events = SDL_TRUE; - data->previous_borders_nonzero = SDL_TRUE; + data->disable_size_position_events = true; + data->previous_borders_nonzero = true; } else if (!(flags & SDL_WINDOW_FULLSCREEN) && data->previous_borders_nonzero && (!data->border_top && !data->border_left && !data->border_bottom && !data->border_right)) { @@ -1663,14 +1663,14 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) * off size events until the borders come back to avoid bogus * window sizes and positions. */ - data->disable_size_position_events = SDL_TRUE; - data->previous_borders_nonzero = SDL_FALSE; + data->disable_size_position_events = true; + data->previous_borders_nonzero = false; } else { - data->disable_size_position_events = SDL_FALSE; - data->previous_borders_nonzero = SDL_FALSE; + data->disable_size_position_events = false; + data->previous_borders_nonzero = false; if (!(data->window->flags & SDL_WINDOW_FULLSCREEN) && data->toggle_borders) { - data->toggle_borders = SDL_FALSE; + data->toggle_borders = false; X11_SetWindowBordered(_this, data->window, !(data->window->flags & SDL_WINDOW_BORDERLESS)); } } @@ -1706,7 +1706,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) if ((flags & SDL_WINDOW_INPUT_FOCUS)) { if (data->pending_move) { DispatchWindowMove(_this, data, &data->pending_move_point); - data->pending_move = SDL_FALSE; + data->pending_move = false; } } } @@ -1720,13 +1720,13 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) icon). Since it changes the XKLAVIER_STATE property, we notice and reinit our keymap here. This might not be the right approach, but it seems to work. */ - X11_UpdateKeymap(_this, SDL_TRUE); + X11_UpdateKeymap(_this, true); } else if (xevent->xproperty.atom == videodata->_NET_FRAME_EXTENTS) { if (data->disable_size_position_events) { /* Re-enable size events if they were turned off waiting for the borders to come back * when leaving fullscreen. */ - data->disable_size_position_events = SDL_FALSE; + data->disable_size_position_events = false; X11_GetBorderValues(data); if (data->border_top != 0 || data->border_left != 0 || data->border_right != 0 || data->border_bottom != 0) { // Adjust if the window size/position changed to accommodate the borders. @@ -1745,7 +1745,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } } if (!(data->window->flags & SDL_WINDOW_FULLSCREEN) && data->toggle_borders) { - data->toggle_borders = SDL_FALSE; + data->toggle_borders = false; X11_SetWindowBordered(_this, data->window, !(data->window->flags & SDL_WINDOW_BORDERLESS)); } } @@ -1840,13 +1840,13 @@ static Bool isAnyEvent(Display *display, XEvent *ev, XPointer arg) return True; } -static SDL_bool X11_PollEvent(Display *display, XEvent *event) +static bool X11_PollEvent(Display *display, XEvent *event) { if (!X11_XCheckIfEvent(display, event, isAnyEvent, NULL)) { - return SDL_FALSE; + return false; } - return SDL_TRUE; + return true; } void X11_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) @@ -1996,8 +1996,8 @@ void X11_PumpEvents(SDL_VideoDevice *_this) } if (data->xinput_hierarchy_changed) { - X11_Xinput2UpdateDevices(_this, SDL_FALSE); - data->xinput_hierarchy_changed = SDL_FALSE; + X11_Xinput2UpdateDevices(_this, false); + data->xinput_hierarchy_changed = false; } } diff --git a/src/video/x11/SDL_x11events.h b/src/video/x11/SDL_x11events.h index 7805f0a423..fa30688bba 100644 --- a/src/video/x11/SDL_x11events.h +++ b/src/video/x11/SDL_x11events.h @@ -33,7 +33,7 @@ extern void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdat extern void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button, const float x, const float y, const unsigned long time); extern void X11_HandleButtonRelease(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button); extern SDL_WindowData *X11_FindWindow(SDL_VideoDevice *_this, Window window); -extern SDL_bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, SDL_bool force_new_result); -extern SDL_bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y); +extern bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, bool force_new_result); +extern bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y); #endif // SDL_x11events_h_ diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index ad26988619..48d2a18f1d 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -39,10 +39,10 @@ static int shm_errhandler(Display *d, XErrorEvent *e) return X_handler(d, e); } -static SDL_bool have_mitshm(Display *dpy) +static bool have_mitshm(Display *dpy) { // Only use shared memory on local X servers - return X11_XShmQueryExtension(dpy) ? SDL_X11_HAVE_SHM : SDL_FALSE; + return X11_XShmQueryExtension(dpy) ? SDL_X11_HAVE_SHM : false; } #endif // !NO_SHARED_MEMORY @@ -118,7 +118,7 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_ } else { // Done! data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst; - data->use_mitshm = SDL_TRUE; + data->use_mitshm = true; *pixels = shminfo->shmaddr; return 0; } @@ -241,7 +241,7 @@ void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) X11_XShmDetach(display, &data->shminfo); X11_XSync(display, False); shmdt(data->shminfo.shmaddr); - data->use_mitshm = SDL_FALSE; + data->use_mitshm = false; } #endif // !NO_SHARED_MEMORY diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 333b37c5f7..fd178b79ce 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -44,7 +44,7 @@ static SDL_ScancodeTable scancode_set[] = { SDL_SCANCODE_TABLE_XVNC, }; -static SDL_bool X11_ScancodeIsRemappable(SDL_Scancode scancode) +static bool X11_ScancodeIsRemappable(SDL_Scancode scancode) { /* * XKB remappings can assign different keysyms for these scancodes, but @@ -63,9 +63,9 @@ static SDL_bool X11_ScancodeIsRemappable(SDL_Scancode scancode) case SDL_SCANCODE_RALT: case SDL_SCANCODE_LGUI: case SDL_SCANCODE_RGUI: - return SDL_FALSE; + return false; default: - return SDL_TRUE; + return true; } } @@ -170,7 +170,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) char *prev_xmods = X11_XSetLocaleModifiers(NULL); const char *new_xmods = ""; const char *env_xmods = SDL_getenv("XMODIFIERS"); - SDL_bool has_dbus_ime_support = SDL_FALSE; + bool has_dbus_ime_support = false; if (prev_locale) { prev_locale = SDL_strdup(prev_locale); @@ -185,10 +185,10 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) @im=none if XMODIFIERS contains @im=ibus. IBus can still be used via the DBus implementation, which also has support for pre-editing. */ if (env_xmods && SDL_strstr(env_xmods, "@im=ibus") != NULL) { - has_dbus_ime_support = SDL_TRUE; + has_dbus_ime_support = true; } if (env_xmods && SDL_strstr(env_xmods, "@im=fcitx") != NULL) { - has_dbus_ime_support = SDL_TRUE; + has_dbus_ime_support = true; } if (has_dbus_ime_support || !xkb_repeat) { new_xmods = "@im=none"; @@ -313,7 +313,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) } } - X11_UpdateKeymap(_this, SDL_FALSE); + X11_UpdateKeymap(_this, false); SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); @@ -326,7 +326,7 @@ int X11_InitKeyboard(SDL_VideoDevice *_this) return 0; } -void X11_UpdateKeymap(SDL_VideoDevice *_this, SDL_bool send_event) +void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event) { struct Keymod_masks { @@ -445,7 +445,7 @@ int X11_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) return 0; } -SDL_bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this) { SDL_VideoData *videodata = _this->internal; return videodata->is_steam_deck; @@ -487,7 +487,7 @@ void X11_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_Prop "steam://open/keyboard?XPosition=0&YPosition=0&Width=0&Height=0&Mode=%d", mode); SDL_OpenURL(deeplink); - videodata->steam_keyboard_open = SDL_TRUE; + videodata->steam_keyboard_open = true; } } @@ -497,11 +497,11 @@ void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) if (videodata->is_steam_deck) { SDL_OpenURL("steam://close/keyboard"); - videodata->steam_keyboard_open = SDL_FALSE; + videodata->steam_keyboard_open = false; } } -SDL_bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) { SDL_VideoData *videodata = _this->internal; diff --git a/src/video/x11/SDL_x11keyboard.h b/src/video/x11/SDL_x11keyboard.h index 0781890deb..5de4fd44ac 100644 --- a/src/video/x11/SDL_x11keyboard.h +++ b/src/video/x11/SDL_x11keyboard.h @@ -24,15 +24,15 @@ #define SDL_x11keyboard_h_ extern int X11_InitKeyboard(SDL_VideoDevice *_this); -extern void X11_UpdateKeymap(SDL_VideoDevice *_this, SDL_bool send_event); +extern void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event); extern void X11_QuitKeyboard(SDL_VideoDevice *_this); extern int X11_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); extern int X11_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this); extern void X11_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); extern void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); extern KeySym X11_KeyCodeToSym(SDL_VideoDevice *_this, KeyCode, unsigned char group, unsigned int mod_mask); #endif // SDL_x11keyboard_h_ diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index cef93c7b35..1073d2ddbe 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -85,7 +85,7 @@ typedef struct SDL_MessageBoxDataX11 Window window; #ifdef SDL_VIDEO_DRIVER_X11_XDBE XdbeBackBuffer buf; - SDL_bool xdbe; // Whether Xdbe is present or not + bool xdbe; // Whether Xdbe is present or not #endif long event_mask; Atom wm_protocols; @@ -508,10 +508,10 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) if (SDL_X11_HAVE_XDBE) { int xdbe_major, xdbe_minor; if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) { - data->xdbe = SDL_TRUE; + data->xdbe = true; data->buf = X11_XdbeAllocateBackBufferName(display, data->window, XdbeUndefined); } else { - data->xdbe = SDL_FALSE; + data->xdbe = false; } } #endif @@ -610,8 +610,8 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) { GC ctx; XGCValues ctx_vals; - SDL_bool close_dialog = SDL_FALSE; - SDL_bool has_focus = SDL_TRUE; + bool close_dialog = false; + bool has_focus = true; KeySym last_key_pressed = XK_VoidSymbol; unsigned long gcflags = GCForeground | GCBackground; #ifdef X_HAVE_UTF8_STRING @@ -639,7 +639,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) while (!close_dialog) { XEvent e; - SDL_bool draw = SDL_TRUE; + bool draw = true; // can't use XWindowEvent() because it can't handle ClientMessage events. // can't use XNextEvent() because we only want events for this window. @@ -654,18 +654,18 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) switch (e.type) { case Expose: if (e.xexpose.count > 0) { - draw = SDL_FALSE; + draw = false; } break; case FocusIn: // Got focus. - has_focus = SDL_TRUE; + has_focus = true; break; case FocusOut: // lost focus. Reset button and mouse info. - has_focus = SDL_FALSE; + has_focus = false; data->button_press_index = -1; data->mouse_over_index = -1; break; @@ -676,7 +676,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) const int previndex = data->mouse_over_index; data->mouse_over_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); if (data->mouse_over_index == previndex) { - draw = SDL_FALSE; + draw = false; } } break; @@ -685,7 +685,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) if (e.xclient.message_type == data->wm_protocols && e.xclient.format == 32 && e.xclient.data.l[0] == data->wm_delete_message) { - close_dialog = SDL_TRUE; + close_dialog = true; } break; @@ -719,7 +719,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) if (buttondatax11->buttondata->flags & mask) { *data->pbuttonid = buttondatax11->buttondata->buttonID; - close_dialog = SDL_TRUE; + close_dialog = true; break; } } @@ -744,7 +744,7 @@ static int X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[button]; *data->pbuttonid = buttondatax11->buttondata->buttonID; - close_dialog = SDL_TRUE; + close_dialog = true; } } data->button_press_index = -1; diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 723bf9d6a3..7d6100e033 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -75,28 +75,28 @@ static DBusMessage *ReadDBusSetting(SDL_DBusContext *dbus, const char *key) return reply; } -static SDL_bool ParseDBusReply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) +static bool ParseDBusReply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) { DBusMessageIter iter[3]; dbus->message_iter_init(reply, &iter[0]); if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_VARIANT) { - return SDL_FALSE; + return false; } dbus->message_iter_recurse(&iter[0], &iter[1]); if (dbus->message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_VARIANT) { - return SDL_FALSE; + return false; } dbus->message_iter_recurse(&iter[1], &iter[2]); if (dbus->message_iter_get_arg_type(&iter[2]) != type) { - return SDL_FALSE; + return false; } dbus->message_iter_get_basic(&iter[2], value); - return SDL_TRUE; + return true; } static void UpdateDisplayContentScale(float scale) @@ -367,25 +367,25 @@ SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo * } #ifdef SDL_VIDEO_DRIVER_X11_XRANDR -static SDL_bool CheckXRandR(Display *display, int *major, int *minor) +static bool CheckXRandR(Display *display, int *major, int *minor) { // Default the extension not available *major = *minor = 0; // Allow environment override #ifdef XRANDR_DISABLED_BY_DEFAULT - if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_FALSE)) { + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, false)) { #ifdef X11MODES_DEBUG printf("XRandR disabled by default due to window manager issues\n"); #endif - return SDL_FALSE; + return false; } #else - if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, SDL_TRUE)) { + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, true)) { #ifdef X11MODES_DEBUG printf("XRandR disabled due to hint\n"); #endif - return SDL_FALSE; + return false; } #endif // XRANDR_DISABLED_BY_DEFAULT @@ -393,7 +393,7 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor) #ifdef X11MODES_DEBUG printf("XRandR support not available\n"); #endif - return SDL_FALSE; + return false; } // Query the extension version @@ -404,12 +404,12 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor) printf("XRandR not active on the display\n"); #endif *major = *minor = 0; - return SDL_FALSE; + return false; } #ifdef X11MODES_DEBUG printf("XRandR available at version %d.%d!\n", *major, *minor); #endif - return SDL_TRUE; + return true; } #define XRANDR_ROTATION_LEFT (1 << 1) @@ -439,7 +439,7 @@ static void CalculateXRandRRefreshRate(const XRRModeInfo *info, int *numerator, } } -static SDL_bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, +static bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, RRMode modeID, SDL_DisplayMode *mode) { int i; @@ -475,10 +475,10 @@ static SDL_bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRC printf("XRandR mode %d: %dx%d@%d/%dHz\n", (int)modeID, mode->screen_w, mode->screen_h, mode->refresh_rate_numerator, mode->refresh_rate_denominator); #endif - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, RROutput output, const unsigned long widthmm, const unsigned long heightmm) @@ -621,7 +621,7 @@ static int X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int s displaydata->scanline_pad = scanline_pad; displaydata->x = display_x; displaydata->y = display_y; - displaydata->use_xrandr = SDL_TRUE; + displaydata->use_xrandr = true; displaydata->xrandr_output = outputid; SetXRandRModeInfo(dpy, res, output_crtc, modeID, &mode); @@ -638,7 +638,7 @@ static int X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int s return 0; } -static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, SDL_bool send_event) +static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, bool send_event) { SDL_VideoDisplay display; char display_name[128]; @@ -709,7 +709,7 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput if (ev->connection == RR_Disconnected) { // output is going away if (display) { - SDL_DelVideoDisplay(display->id, SDL_TRUE); + SDL_DelVideoDisplay(display->id, true); } } else if (ev->connection == RR_Connected) { // output is coming online Display *dpy = ev->display; @@ -729,7 +729,7 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput X11_UpdateXRandRDisplay(_this, dpy, screen, ev->output, res, display); } else { - X11_AddXRandRDisplay(_this, dpy, screen, ev->output, res, SDL_TRUE); + X11_AddXRandRDisplay(_this, dpy, screen, ev->output, res, true); } X11_XRRFreeScreenResources(res); @@ -795,7 +795,7 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) (!looking_for_primary && (screen == default_screen) && (res->outputs[output] == primary))) { continue; } - if (X11_AddXRandRDisplay(_this, dpy, screen, res->outputs[output], res, SDL_FALSE) == -1) { + if (X11_AddXRandRDisplay(_this, dpy, screen, res->outputs[output], res, false) == -1) { break; } } @@ -881,14 +881,14 @@ static int X11_InitModes_StdXlib(SDL_VideoDevice *_this) displaydata->scanline_pad = scanline_pad; displaydata->x = 0; displaydata->y = 0; - displaydata->use_xrandr = SDL_FALSE; + displaydata->use_xrandr = false; SDL_zero(display); display.name = (char *)"Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */ display.desktop_mode = mode; display.internal = displaydata; display.content_scale = GetGlobalContentScale(_this); - if (SDL_AddVideoDisplay(&display, SDL_TRUE) == 0) { + if (SDL_AddVideoDisplay(&display, true) == 0) { return -1; } return 0; diff --git a/src/video/x11/SDL_x11modes.h b/src/video/x11/SDL_x11modes.h index 937269dd4b..f595289508 100644 --- a/src/video/x11/SDL_x11modes.h +++ b/src/video/x11/SDL_x11modes.h @@ -34,7 +34,7 @@ struct SDL_DisplayData Uint64 mode_switch_deadline_ns; - SDL_bool use_xrandr; + bool use_xrandr; #ifdef SDL_VIDEO_DRIVER_X11_XRANDR RROutput xrandr_output; diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index e8aaa0ba73..8e1ebb6c68 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -36,7 +36,7 @@ struct SDL_CursorData // FIXME: Find a better place to put this... static Cursor x11_empty_cursor = None; -static SDL_bool x11_cursor_visible = SDL_TRUE; +static bool x11_cursor_visible = true; static SDL_Cursor *sys_cursors[SDL_HITTEST_RESIZE_LEFT + 1]; @@ -327,11 +327,11 @@ static void X11_WarpMouseInternal(Window xwindow, float x, float y) { SDL_VideoData *videodata = SDL_GetVideoDevice()->internal; Display *display = videodata->display; - SDL_bool warp_hack = SDL_FALSE; + bool warp_hack = false; // XWayland will only warp the cursor if it is hidden, so this workaround is required. if (videodata->is_xwayland && x11_cursor_visible) { - warp_hack = SDL_TRUE; + warp_hack = true; } if (warp_hack) { @@ -360,7 +360,7 @@ static void X11_WarpMouseInternal(Window xwindow, float x, float y) X11_ShowCursor(SDL_GetCursor()); } X11_XSync(display, False); - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = true; } static int X11_WarpMouse(SDL_Window *window, float x, float y) @@ -369,7 +369,7 @@ static int X11_WarpMouse(SDL_Window *window, float x, float y) #ifdef SDL_VIDEO_DRIVER_X11_XFIXES // If we have no barrier, we need to warp - if (data->pointer_barrier_active == SDL_FALSE) { + if (data->pointer_barrier_active == false) { X11_WarpMouseInternal(data->xwindow, x, y); } #else @@ -384,7 +384,7 @@ static int X11_WarpMouseGlobal(float x, float y) return 0; } -static int X11_SetRelativeMouseMode(SDL_bool enabled) +static int X11_SetRelativeMouseMode(bool enabled) { if (!X11_Xinput2IsInitialized()) { return SDL_Unsupported(); @@ -434,7 +434,7 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y) // !!! FIXME: should we XSync() here first? if (!X11_Xinput2IsInitialized()) { - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = true; } // check if we have this cached since XInput last saw the mouse move. @@ -464,7 +464,7 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y) videodata->global_mouse_position.x = root_attrs.x + rootx; videodata->global_mouse_position.y = root_attrs.y + rooty; videodata->global_mouse_buttons = buttons; - videodata->global_mouse_changed = SDL_FALSE; + videodata->global_mouse_changed = false; break; } } diff --git a/src/video/x11/SDL_x11mouse.h b/src/video/x11/SDL_x11mouse.h index e8a993d177..0d150630a6 100644 --- a/src/video/x11/SDL_x11mouse.h +++ b/src/video/x11/SDL_x11mouse.h @@ -26,7 +26,7 @@ typedef struct SDL_XInput2DeviceInfo { int device_id; - SDL_bool relative[2]; + bool relative[2]; double minval[2]; double maxval[2]; double prev_coords[2]; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 89592b6b67..d2a6c56ac1 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -250,7 +250,7 @@ int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions */ if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || - SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) && + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) && X11_GL_UseEGL(_this)) { #ifdef SDL_VIDEO_OPENGL_EGL X11_GL_UnloadLibrary(_this); @@ -296,19 +296,19 @@ void X11_GL_UnloadLibrary(SDL_VideoDevice *_this) _this->gl_data = NULL; } -static SDL_bool HasExtension(const char *extension, const char *extensions) +static bool HasExtension(const char *extension, const char *extensions) { const char *start; const char *where, *terminator; if (!extensions) { - return SDL_FALSE; + return false; } // Extension names should not have spaces. where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { - return SDL_FALSE; + return false; } /* It takes a bit of care to be fool-proof about parsing the @@ -326,13 +326,13 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) terminator = where + SDL_strlen(extension); if (where == start || *(where - 1) == ' ') { if (*terminator == ' ' || *terminator == '\0') { - return SDL_TRUE; + return true; } } start = terminator; } - return SDL_FALSE; + return false; } static void X11_GL_InitExtensions(SDL_VideoDevice *_this) @@ -347,7 +347,7 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) const char *(*glXQueryExtensionsStringFunc)(Display *, int); const char *extensions; - vinfo = X11_GL_GetVisual(_this, display, screen, SDL_FALSE); + vinfo = X11_GL_GetVisual(_this, display, screen, false); if (vinfo) { GLXContext (*glXGetCurrentContextFunc)(void) = (GLXContext(*)(void)) @@ -391,13 +391,13 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) } // Check for GLX_EXT_swap_control(_tear) - _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE; + _this->gl_data->HAS_GLX_EXT_swap_control_tear = false; if (HasExtension("GLX_EXT_swap_control", extensions)) { _this->gl_data->glXSwapIntervalEXT = (void (*)(Display *, GLXDrawable, int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); if (HasExtension("GLX_EXT_swap_control_tear", extensions)) { - _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_TRUE; + _this->gl_data->HAS_GLX_EXT_swap_control_tear = true; } } @@ -431,12 +431,12 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) // Check for GLX_EXT_visual_rating if (HasExtension("GLX_EXT_visual_rating", extensions)) { - _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; + _this->gl_data->HAS_GLX_EXT_visual_rating = true; } // Check for GLX_EXT_visual_info if (HasExtension("GLX_EXT_visual_info", extensions)) { - _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; + _this->gl_data->HAS_GLX_EXT_visual_info = true; } // Check for GLX_EXT_create_context_es2_profile @@ -452,17 +452,17 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) // Check for GLX_ARB_context_flush_control if (HasExtension("GLX_ARB_context_flush_control", extensions)) { - _this->gl_data->HAS_GLX_ARB_context_flush_control = SDL_TRUE; + _this->gl_data->HAS_GLX_ARB_context_flush_control = true; } // Check for GLX_ARB_create_context_robustness if (HasExtension("GLX_ARB_create_context_robustness", extensions)) { - _this->gl_data->HAS_GLX_ARB_create_context_robustness = SDL_TRUE; + _this->gl_data->HAS_GLX_ARB_create_context_robustness = true; } // Check for GLX_ARB_create_context_no_error if (HasExtension("GLX_ARB_create_context_no_error", extensions)) { - _this->gl_data->HAS_GLX_ARB_create_context_no_error = SDL_TRUE; + _this->gl_data->HAS_GLX_ARB_create_context_no_error = true; } if (context) { @@ -486,7 +486,7 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this) * In case of failure, if that pointer is not NULL, set that pointer to None * and try again. */ -static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int screen, int *attribs, int size, Bool for_FBConfig, int **_pvistypeattr, SDL_bool transparent) +static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int screen, int *attribs, int size, Bool for_FBConfig, int **_pvistypeattr, bool transparent) { int i = 0; const int MAX_ATTRIBUTES = 64; @@ -608,7 +608,7 @@ static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int sc return i; } -XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, SDL_bool transparent) +XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent) { // 64 seems nice. int attribs[64]; @@ -625,7 +625,7 @@ XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int scre GLXFBConfig *framebuffer_config = NULL; int fbcount = 0; - X11_GL_GetAttributes(_this, display, screen, attribs, 64, SDL_TRUE, &pvistypeattr, transparent); + X11_GL_GetAttributes(_this, display, screen, attribs, 64, true, &pvistypeattr, transparent); framebuffer_config = _this->gl_data->glXChooseFBConfig(display, screen, attribs, &fbcount); if (!framebuffer_config && (pvistypeattr != NULL)) { *pvistypeattr = None; @@ -657,7 +657,7 @@ XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int scre } if (!vinfo) { - X11_GL_GetAttributes(_this, display, screen, attribs, 64, SDL_FALSE, &pvistypeattr, transparent); + X11_GL_GetAttributes(_this, display, screen, attribs, 64, false, &pvistypeattr, transparent); vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); if (!vinfo && (pvistypeattr != NULL)) { @@ -696,16 +696,16 @@ static int X11_GL_ErrorHandler(Display *d, XErrorEvent *e) return (0); } -SDL_bool X11_GL_UseEGL(SDL_VideoDevice *_this) +bool X11_GL_UseEGL(SDL_VideoDevice *_this) { SDL_assert(_this->gl_data != NULL); - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { // use of EGL has been requested, even for desktop GL - return SDL_TRUE; + return true; } SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); - return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 // No GLX extension for OpenGL ES 1.x profiles. + return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, false) || _this->gl_config.major_version == 1 // No GLX extension for OpenGL ES 1.x profiles. || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor)); } @@ -719,7 +719,7 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) int n; SDL_GLContext context = NULL; GLXContext share_context; - const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE; + const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; if (_this->gl_config.share_with_current_context) { share_context = (GLXContext)SDL_GL_GetCurrentContext(); @@ -800,7 +800,7 @@ SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) int fbcount = 0; int *pvistypeattr = NULL; - X11_GL_GetAttributes(_this, display, screen, glxAttribs, 64, SDL_TRUE, &pvistypeattr, transparent); + X11_GL_GetAttributes(_this, display, screen, glxAttribs, 64, true, &pvistypeattr, transparent); if (_this->gl_data->glXChooseFBConfig) { framebuffer_config = _this->gl_data->glXChooseFBConfig(display, diff --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h index c2c494edb6..8810837f7c 100644 --- a/src/video/x11/SDL_x11opengl.h +++ b/src/video/x11/SDL_x11opengl.h @@ -41,12 +41,12 @@ struct SDL_GLDriverData { int errorBase, eventBase; - SDL_bool HAS_GLX_EXT_visual_rating; - SDL_bool HAS_GLX_EXT_visual_info; - SDL_bool HAS_GLX_EXT_swap_control_tear; - SDL_bool HAS_GLX_ARB_context_flush_control; - SDL_bool HAS_GLX_ARB_create_context_robustness; - SDL_bool HAS_GLX_ARB_create_context_no_error; + bool HAS_GLX_EXT_visual_rating; + bool HAS_GLX_EXT_visual_info; + bool HAS_GLX_EXT_swap_control_tear; + bool HAS_GLX_ARB_context_flush_control; + bool HAS_GLX_ARB_create_context_robustness; + bool HAS_GLX_ARB_create_context_no_error; /* Max version of OpenGL ES context that can be created if the implementation supports GLX_EXT_create_context_es2_profile. @@ -81,8 +81,8 @@ struct SDL_GLDriverData extern int X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_FunctionPointer X11_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); extern void X11_GL_UnloadLibrary(SDL_VideoDevice *_this); -extern SDL_bool X11_GL_UseEGL(SDL_VideoDevice *_this); -extern XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, SDL_bool transparent); +extern bool X11_GL_UseEGL(SDL_VideoDevice *_this); +extern XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent); extern SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 072f39db11..3c15ef4dea 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -34,7 +34,7 @@ int X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) // If the profile requested is not GL ES, switch over to X11_GL functions if ((_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) && - !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { #ifdef SDL_VIDEO_OPENGL_GLX X11_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = X11_GL_LoadLibrary; @@ -55,7 +55,7 @@ int X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform); } -XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, SDL_bool transparent) +XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent) { XVisualInfo *egl_visualinfo = NULL; diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h index a99d076936..25e152afa8 100644 --- a/src/video/x11/SDL_x11opengles.h +++ b/src/video/x11/SDL_x11opengles.h @@ -44,7 +44,7 @@ typedef struct SDL_PrivateGLESData #define X11_GLES_DeleteContext SDL_EGL_DeleteContext extern int X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); -extern XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, SDL_bool transparent); +extern XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent); extern SDL_GLContext X11_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern int X11_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c index d85d2d238f..f354875196 100644 --- a/src/video/x11/SDL_x11pen.c +++ b/src/video/x11/SDL_x11pen.c @@ -29,7 +29,7 @@ #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 // Does this device have a valuator for pressure sensitivity? -static SDL_bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev) +static bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev) { const SDL_VideoData *data = (SDL_VideoData *)_this->internal; for (int i = 0; i < dev->num_classes; i++) { @@ -37,16 +37,16 @@ static SDL_bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInf if (classinfo->type == XIValuatorClass) { const XIValuatorClassInfo *val_classinfo = (const XIValuatorClassInfo *)classinfo; if (val_classinfo->label == data->pen_atom_abs_pressure) { - return SDL_TRUE; + return true; } } } - return SDL_FALSE; + return false; } // Heuristically determines if device is an eraser -static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, char *devicename) +static bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, char *devicename) { #define PEN_ERASER_NAME_TAG "eraser" // String constant to identify erasers SDL_VideoData *data = (SDL_VideoData *)_this->internal; @@ -67,7 +67,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha &tooltype_name_info) && tooltype_name_info != NULL && num_items_return > 0) { - SDL_bool result = SDL_FALSE; + bool result = false; char *tooltype_name = NULL; if (type_return == XA_ATOM) { @@ -82,7 +82,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha if (tooltype_name) { if (0 == SDL_strcasecmp(tooltype_name, PEN_ERASER_NAME_TAG)) { - result = SDL_TRUE; + result = true; } X11_XFree(tooltype_name_info); @@ -95,7 +95,7 @@ static SDL_bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, cha /* We assume that a device is an eraser if its name contains the string "eraser". * Unfortunately there doesn't seem to be a clean way to distinguish these cases (as of 2022-03). */ - return (SDL_strcasestr(devicename, PEN_ERASER_NAME_TAG)) ? SDL_TRUE : SDL_FALSE; + return (SDL_strcasestr(devicename, PEN_ERASER_NAME_TAG)) ? true : false; } // Read out an integer property and store into a preallocated Sint32 array, extending 8 and 16 bit values suitably. @@ -147,8 +147,8 @@ static size_t X11_XInput2PenGetIntProperty(SDL_VideoDevice *_this, int deviceid, return 0; // type mismatch } -// Identify Wacom devices (if SDL_TRUE is returned) and extract their device type and serial IDs -static SDL_bool X11_XInput2PenWacomDeviceID(SDL_VideoDevice *_this, int deviceid, Uint32 *wacom_devicetype_id, Uint32 *wacom_serial) +// Identify Wacom devices (if true is returned) and extract their device type and serial IDs +static bool X11_XInput2PenWacomDeviceID(SDL_VideoDevice *_this, int deviceid, Uint32 *wacom_devicetype_id, Uint32 *wacom_serial) { SDL_VideoData *data = (SDL_VideoData *)_this->internal; Sint32 serial_id_buf[3]; @@ -157,11 +157,11 @@ static SDL_bool X11_XInput2PenWacomDeviceID(SDL_VideoDevice *_this, int deviceid if ((result = X11_XInput2PenGetIntProperty(_this, deviceid, data->pen_atom_wacom_serial_ids, serial_id_buf, 3)) == 3) { *wacom_devicetype_id = serial_id_buf[2]; *wacom_serial = serial_id_buf[1]; - return SDL_TRUE; + return true; } *wacom_devicetype_id = *wacom_serial = 0; - return SDL_FALSE; + return false; } @@ -171,15 +171,15 @@ typedef struct FindPenByDeviceIDData void *handle; } FindPenByDeviceIDData; -static SDL_bool FindPenByDeviceID(void *handle, void *userdata) +static bool FindPenByDeviceID(void *handle, void *userdata) { const X11_PenHandle *x11_handle = (const X11_PenHandle *) handle; FindPenByDeviceIDData *data = (FindPenByDeviceIDData *) userdata; if (x11_handle->x11_deviceid != data->x11_deviceid) { - return SDL_FALSE; + return false; } data->handle = handle; - return SDL_TRUE; + return true; } X11_PenHandle *X11_FindPenByDeviceID(int deviceid) @@ -221,7 +221,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo const Atom vname = val_classinfo->label; const float min = (float)val_classinfo->min; const float max = (float)val_classinfo->max; - SDL_bool use_this_axis = SDL_TRUE; + bool use_this_axis = true; SDL_PenAxis axis = SDL_PEN_NUM_AXES; // afaict, SDL_PEN_AXIS_DISTANCE is never reported by XInput2 (Wayland can offer it, though) @@ -232,7 +232,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo } else if (vname == data->pen_atom_abs_tilt_y) { axis = SDL_PEN_AXIS_YTILT; } else { - use_this_axis = SDL_FALSE; + use_this_axis = false; } // !!! FIXME: there are wacom-specific hacks for getting SDL_PEN_AXIS_(ROTATION|SLIDER) on some devices, but for simplicity, we're skipping all that for now. @@ -250,7 +250,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo // We checked this in X11_XInput2DeviceIsPen, so just assert it here. SDL_assert(capabilities & SDL_PEN_CAPABILITY_PRESSURE); - const SDL_bool is_eraser = X11_XInput2PenIsEraser(_this, dev->deviceid, dev->name); + const bool is_eraser = X11_XInput2PenIsEraser(_this, dev->deviceid, dev->name); Uint32 wacom_devicetype_id = 0; Uint32 wacom_serial = 0; X11_XInput2PenWacomDeviceID(_this, dev->deviceid, &wacom_devicetype_id, &wacom_serial); diff --git a/src/video/x11/SDL_x11pen.h b/src/video/x11/SDL_x11pen.h index b5e0be0116..ba998763b1 100644 --- a/src/video/x11/SDL_x11pen.h +++ b/src/video/x11/SDL_x11pen.h @@ -44,7 +44,7 @@ struct SDL_VideoData; typedef struct X11_PenHandle { SDL_PenID pen; - SDL_bool is_eraser; + bool is_eraser; int x11_deviceid; int valuator_for_axis[SDL_PEN_NUM_AXES]; float slider_bias; // shift value to add to PEN_AXIS_SLIDER (before normalisation) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 86dabf6824..b9b755729a 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -75,13 +75,13 @@ static void X11_DeleteDevice(SDL_VideoDevice *device) } // An error handler to reset the vidmode and then call the default handler. -static SDL_bool safety_net_triggered = SDL_FALSE; +static bool safety_net_triggered = false; static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) { SDL_VideoDevice *device = NULL; // if we trigger an error in our error handler, don't try again. if (!safety_net_triggered) { - safety_net_triggered = SDL_TRUE; + safety_net_triggered = true; device = SDL_GetVideoDevice(); if (device) { int i; @@ -101,7 +101,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) return 0; } -static SDL_bool X11_IsXWayland(Display *d) +static bool X11_IsXWayland(Display *d) { int opcode, event, error; return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True; @@ -142,7 +142,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) } device->internal = data; - data->global_mouse_changed = SDL_TRUE; + data->global_mouse_changed = true; #ifdef SDL_VIDEO_DRIVER_X11_XFIXES data->active_cursor_confined_window = NULL; @@ -165,13 +165,13 @@ static SDL_VideoDevice *X11_CreateDevice(void) #endif // Hook up an X11 error handler to recover the desktop resolution. - safety_net_triggered = SDL_FALSE; + safety_net_triggered = false; orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); /* Steam Deck will have an on-screen keyboard, so check their environment * variable so we can make use of SDL_StartTextInput. */ - data->is_steam_deck = SDL_GetHintBoolean("SteamDeck", SDL_FALSE); + data->is_steam_deck = SDL_GetHintBoolean("SteamDeck", false); // Set the function pointers device->VideoInit = X11_VideoInit; @@ -240,7 +240,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) #endif #ifdef SDL_VIDEO_OPENGL_EGL #ifdef SDL_VIDEO_OPENGL_GLX - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { #endif device->GL_LoadLibrary = X11_GLES_LoadLibrary; device->GL_GetProcAddress = X11_GLES_GetProcAddress; @@ -367,7 +367,7 @@ static void X11_CheckWindowManager(SDL_VideoDevice *_this) #endif return; } - data->net_wm = SDL_TRUE; + data->net_wm = true; #ifdef DEBUG_WINDOW_MANAGER wm_name = X11_GetWindowTitle(_this, wm_window); @@ -435,8 +435,8 @@ int X11_VideoInit(SDL_VideoDevice *_this) if (!X11_InitXinput2(_this)) { // Assume a mouse and keyboard are attached - SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, SDL_FALSE); - SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, SDL_FALSE); + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); } #ifdef SDL_VIDEO_DRIVER_X11_XFIXES @@ -488,12 +488,12 @@ void X11_VideoQuit(SDL_VideoDevice *_this) X11_QuitXsettings(_this); } -SDL_bool X11_UseDirectColorVisuals(void) +bool X11_UseDirectColorVisuals(void) { - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NODIRECTCOLOR, SDL_FALSE)) { - return SDL_FALSE; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NODIRECTCOLOR, false)) { + return false; } - return SDL_TRUE; + return true; } #endif // SDL_VIDEO_DRIVER_X11 diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 4a442b587a..e05d454ecb 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -63,7 +63,7 @@ struct SDL_VideoData SDLX11_SettingsData xsettings_data; // This is true for ICCCM2.0-compliant window managers - SDL_bool net_wm; + bool net_wm; // Useful atoms Atom WM_PROTOCOLS; @@ -113,19 +113,19 @@ struct SDL_VideoData Atom pen_atom_wacom_tool_type; SDL_Scancode key_layout[256]; - SDL_bool selection_waiting; - SDL_bool selection_incr_waiting; + bool selection_waiting; + bool selection_incr_waiting; - SDL_bool broken_pointer_grab; // true if XGrabPointer seems unreliable. + bool broken_pointer_grab; // true if XGrabPointer seems unreliable. Uint64 last_mode_change_deadline; - SDL_bool global_mouse_changed; + bool global_mouse_changed; SDL_Point global_mouse_position; Uint32 global_mouse_buttons; SDL_XInput2DeviceInfo *mouse_device_info; - SDL_bool xinput_hierarchy_changed; + bool xinput_hierarchy_changed; int xrandr_event_base; @@ -145,12 +145,12 @@ struct SDL_VideoData #endif // Used to interact with the on-screen keyboard - SDL_bool is_steam_deck; - SDL_bool steam_keyboard_open; + bool is_steam_deck; + bool steam_keyboard_open; - SDL_bool is_xwayland; + bool is_xwayland; }; -extern SDL_bool X11_UseDirectColorVisuals(void); +extern bool X11_UseDirectColorVisuals(void); #endif // SDL_x11video_h_ diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index b8cba1d21e..d7821ddd59 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -47,9 +47,9 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_VideoData *videoData = _this->internal; VkExtensionProperties *extensions = NULL; Uint32 extensionCount = 0; - SDL_bool hasSurfaceExtension = SDL_FALSE; - SDL_bool hasXlibSurfaceExtension = SDL_FALSE; - SDL_bool hasXCBSurfaceExtension = SDL_FALSE; + bool hasSurfaceExtension = false; + bool hasXlibSurfaceExtension = false; + bool hasXCBSurfaceExtension = false; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; Uint32 i; if (_this->vulkan_config.loader_handle) { @@ -89,11 +89,11 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } for (i = 0; i < extensionCount; i++) { if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasSurfaceExtension = SDL_TRUE; + hasSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_XCB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasXCBSurfaceExtension = SDL_TRUE; + hasXCBSurfaceExtension = true; } else if (SDL_strcmp(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { - hasXlibSurfaceExtension = SDL_TRUE; + hasXlibSurfaceExtension = true; } } SDL_free(extensions); @@ -232,7 +232,7 @@ void X11_Vulkan_DestroySurface(SDL_VideoDevice *_this, } } -SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex) @@ -244,7 +244,7 @@ SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, if (!_this->vulkan_config.loader_handle) { SDL_SetError("Vulkan is not loaded"); - return SDL_FALSE; + return false; } vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; @@ -263,7 +263,7 @@ SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, if (!vkGetPhysicalDeviceXcbPresentationSupportKHR) { SDL_SetError(VK_KHR_XCB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); - return SDL_FALSE; + return false; } return vkGetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, @@ -278,7 +278,7 @@ SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, if (!vkGetPhysicalDeviceXlibPresentationSupportKHR) { SDL_SetError(VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); - return SDL_FALSE; + return false; } return vkGetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, diff --git a/src/video/x11/SDL_x11vulkan.h b/src/video/x11/SDL_x11vulkan.h index 86a2fa9da8..9816ae6323 100644 --- a/src/video/x11/SDL_x11vulkan.h +++ b/src/video/x11/SDL_x11vulkan.h @@ -43,7 +43,7 @@ void X11_Vulkan_DestroySurface(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); -SDL_bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, +bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 490e2438d8..9a50314373 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -84,7 +84,7 @@ static Bool X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*p } */ -static SDL_bool X11_IsWindowMapped(SDL_VideoDevice *_this, SDL_Window *window) +static bool X11_IsWindowMapped(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->internal; SDL_VideoData *videodata = _this->internal; @@ -92,14 +92,14 @@ static SDL_bool X11_IsWindowMapped(SDL_VideoDevice *_this, SDL_Window *window) X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); if (attr.map_state != IsUnmapped) { - return SDL_TRUE; + return true; } else { - return SDL_FALSE; + return false; } } #if 0 -static SDL_bool X11_IsActionAllowed(SDL_Window *window, Atom action) +static bool X11_IsActionAllowed(SDL_Window *window, Atom action) { SDL_WindowData *data = window->internal; Atom _NET_WM_ALLOWED_ACTIONS = data->videodata->_NET_WM_ALLOWED_ACTIONS; @@ -109,12 +109,12 @@ static SDL_bool X11_IsActionAllowed(SDL_Window *window, Atom action) unsigned long remain; unsigned long len, i; Atom *list; - SDL_bool ret = SDL_FALSE; + bool ret = false; if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) { for (i=0; idisplay; int screen = displaydata->screen; @@ -526,10 +526,10 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI Atom _NET_WM_PID; const char *hint = NULL; int win_x, win_y; - SDL_bool undefined_position = SDL_FALSE; + bool undefined_position = false; #if defined(SDL_VIDEO_OPENGL_GLX) || defined(SDL_VIDEO_OPENGL_EGL) - const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE; + const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); const char *display_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_VISUALID); @@ -553,7 +553,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI #ifdef SDL_VIDEO_OPENGL_EGL if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || - SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) #ifdef SDL_VIDEO_OPENGL_GLX && (!_this->gl_data || X11_GL_UseEGL(_this)) #endif @@ -666,7 +666,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI if (window->undefined_x && window->undefined_y && window->last_displayID == SDL_GetPrimaryDisplay()) { - undefined_position = SDL_TRUE; + undefined_position = true; } if (SDL_WINDOW_IS_POPUP(window)) { @@ -762,7 +762,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI wintype = X11_XInternAtom(display, wintype_name, False); X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wintype, 1); - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, true)) { _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, @@ -777,7 +777,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI protocols[proto_count++] = data->WM_TAKE_FOCUS; // Since we will want to set input focus explicitly // Default to using ping if there is no hint - if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, SDL_TRUE)) { + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, true)) { protocols[proto_count++] = data->_NET_WM_PING; // Respond so WM knows we're alive } @@ -799,7 +799,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI #if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL) if ((window->flags & SDL_WINDOW_OPENGL) && ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || - SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) #ifdef SDL_VIDEO_OPENGL_GLX && (!_this->gl_data || X11_GL_UseEGL(_this)) #endif @@ -882,12 +882,12 @@ void X11_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) SDL_X11_SetWindowTitle(display, xwindow, title); } -static SDL_bool caught_x11_error = SDL_FALSE; +static bool caught_x11_error = false; static int X11_CatchAnyError(Display *d, XErrorEvent *e) { /* this may happen during tumultuous times when we are polling anyhow, so just note we had an error and return control. */ - caught_x11_error = SDL_TRUE; + caught_x11_error = true; return 0; } @@ -900,7 +900,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin int (*prev_handler)(Display *, XErrorEvent *); Uint64 timeout = 0; int ret = 0; - SDL_bool force_exit = SDL_FALSE; + bool force_exit = false; X11_XSync(display, False); prev_handler = X11_XSetErrorHandler(X11_CatchAnyError); @@ -909,7 +909,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin timeout = SDL_GetTicksNS() + param_timeout; } - while (SDL_TRUE) { + while (true) { X11_XSync(display, False); X11_PumpEvents(_this); @@ -931,7 +931,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin /* No operations are pending, but the window still isn't in the expected state. * Try one more time before exiting. */ - force_exit = SDL_TRUE; + force_exit = true; } if (SDL_GetTicksNS() >= timeout) { @@ -957,7 +957,7 @@ static int X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uin } X11_XSetErrorHandler(prev_handler); - caught_x11_error = SDL_FALSE; + caught_x11_error = false; return ret; } @@ -1014,13 +1014,13 @@ int X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i if (prevHandler) { X11_XSetErrorHandler(prevHandler); - caught_x11_error = SDL_FALSE; + caught_x11_error = false; } return rc; } -void X11_UpdateWindowPosition(SDL_Window *window, SDL_bool use_current_position) +void X11_UpdateWindowPosition(SDL_Window *window, bool use_current_position) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; @@ -1052,9 +1052,9 @@ int X11_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) if (SDL_WINDOW_IS_POPUP(window)) { X11_ConstrainPopup(window); } - X11_UpdateWindowPosition(window, SDL_FALSE); + X11_UpdateWindowPosition(window, false); } else { - SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, SDL_TRUE); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); } return 0; } @@ -1092,7 +1092,7 @@ static void X11_SetWMNormalHints(SDL_VideoDevice *_this, SDL_Window *window, XSi X11_XRaiseWindow(display, data->xwindow); } -void X11_SetWindowMinMax(SDL_Window *window, SDL_bool use_current) +void X11_SetWindowMinMax(SDL_Window *window, bool use_current) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; @@ -1136,7 +1136,7 @@ void X11_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window) } if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowMinMax(window, SDL_TRUE); + X11_SetWindowMinMax(window, true); } } @@ -1147,7 +1147,7 @@ void X11_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window) } if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowMinMax(window, SDL_TRUE); + X11_SetWindowMinMax(window, true); } } @@ -1158,7 +1158,7 @@ void X11_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window) } if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowMinMax(window, SDL_TRUE); + X11_SetWindowMinMax(window, true); } } @@ -1278,10 +1278,10 @@ int X11_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_ return 0; } -void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered) +void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) { - const SDL_bool focused = (window->flags & SDL_WINDOW_INPUT_FOCUS) ? SDL_TRUE : SDL_FALSE; - const SDL_bool visible = (!(window->flags & SDL_WINDOW_HIDDEN)) ? SDL_TRUE : SDL_FALSE; + const bool focused = (window->flags & SDL_WINDOW_INPUT_FOCUS) ? true : false; + const bool visible = (!(window->flags & SDL_WINDOW_HIDDEN)) ? true : false; SDL_WindowData *data = window->internal; SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); Display *display = data->videodata->display; @@ -1321,12 +1321,12 @@ void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool X11_XSync(display, False); } else { // If fullscreen, set a flag to toggle the borders when returning to windowed mode. - data->toggle_borders = SDL_TRUE; - data->fullscreen_borders_forced_on = SDL_FALSE; + data->toggle_borders = true; + data->fullscreen_borders_forced_on = false; } } -void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable) +void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) { SDL_WindowData *data = window->internal; @@ -1336,11 +1336,11 @@ void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool // If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { - X11_SetWindowMinMax(window, SDL_TRUE); + X11_SetWindowMinMax(window, true); } } -void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top) +void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) { SDL_WindowData *data = window->internal; SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); @@ -1373,12 +1373,12 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); XEvent event; if (window->parent) { // Update our position in case our parent moved while we were hidden - X11_UpdateWindowPosition(window, SDL_TRUE); + X11_UpdateWindowPosition(window, true); } /* Whether XMapRaised focuses the window is based on the window type and it is @@ -1421,7 +1421,7 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) * Don't emit size and position events during the initial configure events, they will be sent afterwards, when the * final coordinates are available to avoid sending garbage values. */ - data->disable_size_position_events = SDL_TRUE; + data->disable_size_position_events = true; X11_XSync(display, False); X11_PumpEvents(_this); @@ -1441,7 +1441,7 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); } - data->disable_size_position_events = SDL_FALSE; + data->disable_size_position_events = false; } void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) @@ -1514,7 +1514,7 @@ void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; - SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, SDL_TRUE); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); X11_XRaiseWindow(display, data->xwindow); if (bActivate) { @@ -1523,7 +1523,7 @@ void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) X11_XFlush(display); } -static int X11_SetWindowMaximized(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool maximized) +static int X11_SetWindowMaximized(SDL_VideoDevice *_this, SDL_Window *window, bool maximized) { CHECK_WINDOW_DATA(window); @@ -1592,7 +1592,7 @@ void X11_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MINIMIZED))) { window->internal->pending_operation |= X11_PENDING_OP_MAXIMIZE; - X11_SetWindowMaximized(_this, window, SDL_TRUE); + X11_SetWindowMaximized(_this, window, true); } } @@ -1620,8 +1620,8 @@ void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) } // If the window was minimized while maximized, restore as maximized. - const SDL_bool maximize = !!(window->flags & SDL_WINDOW_MINIMIZED) && window->internal->window_was_maximized; - window->internal->window_was_maximized = SDL_FALSE; + const bool maximize = !!(window->flags & SDL_WINDOW_MINIMIZED) && window->internal->window_was_maximized; + window->internal->window_was_maximized = false; X11_SetWindowMaximized(_this, window, maximize); X11_ShowWindow(_this, window); X11_SetWindowActive(_this, window); @@ -1834,7 +1834,7 @@ void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t return ret_icc_profile_data; } -int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { SDL_WindowData *data = window->internal; Display *display; @@ -1842,7 +1842,7 @@ int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool if (!data) { return SDL_SetError("Invalid window data"); } - data->mouse_grabbed = SDL_FALSE; + data->mouse_grabbed = false; display = data->videodata->display; @@ -1874,14 +1874,14 @@ int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool result = X11_XGrabPointer(display, data->xwindow, False, mask, GrabModeAsync, GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { - data->mouse_grabbed = SDL_TRUE; + data->mouse_grabbed = true; break; } SDL_Delay(50); } if (result != GrabSuccess) { - data->videodata->broken_pointer_grab = SDL_TRUE; // don't try again. + data->videodata->broken_pointer_grab = true; // don't try again. } } @@ -1903,7 +1903,7 @@ int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool } } -int X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed) +int X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) { SDL_WindowData *data = window->internal; Display *display; @@ -1974,12 +1974,12 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) window->internal = NULL; } -int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) +int X11_SetWindowHitTest(SDL_Window *window, bool enabled) { return 0; // just succeed, the real work is done elsewhere. } -void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) +void X11_AcceptDragAndDrop(SDL_Window *window, bool accept) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; @@ -2006,7 +2006,7 @@ int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati } wmhints->flags &= ~XUrgencyHint; - data->flashing_window = SDL_FALSE; + data->flashing_window = false; data->flash_cancel_time = 0; switch (operation) { @@ -2016,7 +2016,7 @@ int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati case SDL_FLASH_BRIEFLY: if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { wmhints->flags |= XUrgencyHint; - data->flashing_window = SDL_TRUE; + data->flashing_window = true; // On Ubuntu 21.04 this causes a dialog to pop up, so leave it up for a full second so users can see it data->flash_cancel_time = SDL_GetTicks() + 1000; } @@ -2024,7 +2024,7 @@ int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati case SDL_FLASH_UNTIL_FOCUSED: if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { wmhints->flags |= XUrgencyHint; - data->flashing_window = SDL_TRUE; + data->flashing_window = true; } break; default: @@ -2118,7 +2118,7 @@ int X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) return X11_SyncWindowTimeout(_this, window, timeout); } -int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable) +int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) { SDL_WindowData *data = window->internal; Display *display = data->videodata->display; diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 615ee9087c..031287df39 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -48,38 +48,38 @@ struct SDL_WindowData Colormap colormap; #ifndef NO_SHARED_MEMORY // MIT shared memory extension information - SDL_bool use_mitshm; + bool use_mitshm; XShmSegmentInfo shminfo; #endif XImage *ximage; GC gc; XIC ic; - SDL_bool created; + bool created; int border_left; int border_right; int border_top; int border_bottom; - SDL_bool xinput2_mouse_enabled; - SDL_bool xinput2_keyboard_enabled; - SDL_bool mouse_grabbed; + bool xinput2_mouse_enabled; + bool xinput2_keyboard_enabled; + bool mouse_grabbed; Uint64 last_focus_event_time; PendingFocusEnum pending_focus; Uint64 pending_focus_time; - SDL_bool pending_move; + bool pending_move; SDL_Point pending_move_point; XConfigureEvent last_xconfigure; struct SDL_VideoData *videodata; unsigned long user_time; Atom xdnd_req; Window xdnd_source; - SDL_bool flashing_window; + bool flashing_window; Uint64 flash_cancel_time; SDL_Window *keyboard_focus; #ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif #ifdef SDL_VIDEO_DRIVER_X11_XFIXES - SDL_bool pointer_barrier_active; + bool pointer_barrier_active; PointerBarrier barrier[4]; SDL_Rect barrier_rect; #endif // SDL_VIDEO_DRIVER_X11_XFIXES @@ -97,11 +97,11 @@ struct SDL_WindowData X11_PENDING_OP_RESIZE = 0x20 } pending_operation; - SDL_bool window_was_maximized; - SDL_bool disable_size_position_events; - SDL_bool previous_borders_nonzero; - SDL_bool toggle_borders; - SDL_bool fullscreen_borders_forced_on; + bool window_was_maximized; + bool disable_size_position_events; + bool previous_borders_nonzero; + bool toggle_borders; + bool fullscreen_borders_forced_on; SDL_HitTestResult hit_test_result; }; @@ -126,23 +126,23 @@ extern void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered); -extern void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable); -extern void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool on_top); +extern void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); extern int X11_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); extern void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); -extern int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); -extern int X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed); +extern int X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern int X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); extern void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); -extern void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept); +extern int X11_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void X11_AcceptDragAndDrop(SDL_Window *window, bool accept); extern int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); extern void X11_ShowWindowSystemMenu(SDL_Window *window, int x, int y); extern int X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); -extern int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable); +extern int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); int SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title); -void X11_UpdateWindowPosition(SDL_Window *window, SDL_bool use_current_position); -void X11_SetWindowMinMax(SDL_Window *window, SDL_bool use_current); +void X11_UpdateWindowPosition(SDL_Window *window, bool use_current_position); +void X11_SetWindowMinMax(SDL_Window *window, bool use_current); #endif // SDL_x11window_h_ diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index 1adcc63894..0cfca0a185 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -38,7 +38,7 @@ static int query_xfixes_version(Display *display, int major, int minor) return (major * 1000) + minor; } -static SDL_bool xfixes_version_atleast(const int version, const int wantmajor, const int wantminor) +static bool xfixes_version_atleast(const int version, const int wantmajor, const int wantminor) { return version >= ((wantmajor * 1000) + wantminor); } @@ -97,7 +97,7 @@ int X11_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) SDL_memcpy(&wdata->barrier_rect, &window->mouse_rect, sizeof(wdata->barrier_rect)); - wdata->pointer_barrier_active = SDL_TRUE; + wdata->pointer_barrier_active = true; } } @@ -181,13 +181,13 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const /* User activated the confinement for this window. We use this later to reactivate * the confinement if it got deactivated by FocusOut or UnmapNotify */ - wdata->pointer_barrier_active = SDL_TRUE; + wdata->pointer_barrier_active = true; } else { X11_DestroyPointerBarrier(_this, window); // Only set barrier inactive when user specified NULL and not handled by focus out. if (flags != X11_BARRIER_HANDLED_BY_EVENT) { - wdata->pointer_barrier_active = SDL_FALSE; + wdata->pointer_barrier_active = false; } } return 0; diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 67f8a410bd..61798123ac 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -72,7 +72,7 @@ static int query_xinput2_version(Display *display, int major, int minor) return (major * 1000) + minor; } -static SDL_bool xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) +static bool xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) { return version >= ((wantmajor * 1000) + wantminor); } @@ -119,7 +119,7 @@ static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, #endif // SDL_VIDEO_DRIVER_X11_XINPUT2 -SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) +bool X11_InitXinput2(SDL_VideoDevice *_this) { #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_VideoData *data = _this->internal; @@ -140,13 +140,13 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) */ if (!SDL_X11_HAVE_XINPUT2 || !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { - return SDL_FALSE; // X server does not have XInput at all + return false; // X server does not have XInput at all } // We need at least 2.2 for Multitouch, 2.0 otherwise. version = query_xinput2_version(data->display, 2, 2); if (!xinput2_version_atleast(version, 2, 0)) { - return SDL_FALSE; // X server does not support the version we want at all. + return false; // X server does not support the version we want at all. } xinput2_initialized = 1; @@ -186,11 +186,11 @@ SDL_bool X11_InitXinput2(SDL_VideoDevice *_this) XISetMask(mask, XI_HierarchyChanged); X11_XISelectEvents(data->display, DefaultRootWindow(data->display), &eventmask, 1); - X11_Xinput2UpdateDevices(_this, SDL_TRUE); + X11_Xinput2UpdateDevices(_this, true); - return SDL_TRUE; + return true; #else - return SDL_FALSE; + return false; #endif } @@ -303,7 +303,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) xinput2_remove_device_info(videodata, hierev->info[i].deviceid); } } - videodata->xinput_hierarchy_changed = SDL_TRUE; + videodata->xinput_hierarchy_changed = true; } break; // !!! FIXME: the pen code used to rescan all devices here, but we can do this device-by-device with XI_HierarchyChanged. When do these events fire and why? @@ -313,14 +313,14 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) case XI_RawMotion: { const XIRawEvent *rawev = (const XIRawEvent *)cookie->data; - const SDL_bool is_pen = X11_FindPenByDeviceID(rawev->sourceid) != NULL; + const bool is_pen = X11_FindPenByDeviceID(rawev->sourceid) != NULL; SDL_Mouse *mouse = SDL_GetMouse(); SDL_XInput2DeviceInfo *devinfo; double coords[2]; double processed_coords[2]; int i; - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = true; if (is_pen) { break; // Pens check for XI_Motion instead } @@ -350,7 +350,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) } } - SDL_SendMouseMotion(0, mouse->focus, (SDL_MouseID)rawev->sourceid, SDL_TRUE, (float)processed_coords[0], (float)processed_coords[1]); + SDL_SendMouseMotion(0, mouse->focus, (SDL_MouseID)rawev->sourceid, true, (float)processed_coords[0], (float)processed_coords[1]); devinfo->prev_coords[0] = coords[0]; devinfo->prev_coords[1] = coords[1]; } break; @@ -398,7 +398,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) case XI_RawTouchEnd: #endif { - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = true; } break; case XI_ButtonPress: @@ -407,7 +407,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; X11_PenHandle *pen = X11_FindPenByDeviceID(xev->deviceid); const int button = xev->detail; - const SDL_bool pressed = (cookie->evtype == XI_ButtonPress) ? SDL_TRUE : SDL_FALSE; + const bool pressed = (cookie->evtype == XI_ButtonPress) ? true : false; if (pen) { // Only report button event; if there was also pen movement / pressure changes, we expect an XI_Motion event first anyway. @@ -441,12 +441,12 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) { const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - SDL_bool pointer_emulated = ((xev->flags & XIPointerEmulated) != 0); + bool pointer_emulated = ((xev->flags & XIPointerEmulated) != 0); #else - SDL_bool pointer_emulated = SDL_FALSE; + bool pointer_emulated = false; #endif - videodata->global_mouse_changed = SDL_TRUE; + videodata->global_mouse_changed = true; if (xev->deviceid != xev->sourceid) { // Discard events from "Master" devices to avoid duplicates. @@ -471,8 +471,8 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) if (!mouse->relative_mode || mouse->relative_mode_warp) { SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); if (window) { - X11_ProcessHitTest(_this, window->internal, (float)xev->event_x, (float)xev->event_y, SDL_FALSE); - SDL_SendMouseMotion(0, window, (SDL_MouseID)xev->sourceid, SDL_FALSE, (float)xev->event_x, (float)xev->event_y); + X11_ProcessHitTest(_this, window->internal, (float)xev->event_x, (float)xev->event_y, false); + SDL_SendMouseMotion(0, window, (SDL_MouseID)xev->sourceid, false, (float)xev->event_x, (float)xev->event_y); } } } @@ -485,7 +485,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) float x, y; SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); - SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_TRUE, x, y, 1.0); + SDL_SendTouch(0, xev->sourceid, xev->detail, window, true, x, y, 1.0); } break; case XI_TouchEnd: @@ -494,7 +494,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) float x, y; SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); - SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_FALSE, x, y, 1.0); + SDL_SendTouch(0, xev->sourceid, xev->detail, window, false, x, y, 1.0); } break; case XI_TouchUpdate: @@ -551,7 +551,7 @@ int X11_Xinput2IsInitialized(void) #endif } -SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *windowdata = (SDL_WindowData *)window->internal; @@ -570,13 +570,13 @@ SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *w #ifdef USE_XINPUT2_KEYBOARD XISetMask(mask, XI_KeyPress); XISetMask(mask, XI_KeyRelease); - windowdata->xinput2_keyboard_enabled = SDL_TRUE; + windowdata->xinput2_keyboard_enabled = true; #endif XISetMask(mask, XI_ButtonPress); XISetMask(mask, XI_ButtonRelease); XISetMask(mask, XI_Motion); - windowdata->xinput2_mouse_enabled = SDL_TRUE; + windowdata->xinput2_mouse_enabled = true; XISetMask(mask, XI_Enter); XISetMask(mask, XI_Leave); @@ -588,16 +588,16 @@ SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *w if (X11_XISelectEvents(data->display, windowdata->xwindow, &eventmask, 1) != Success) { SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Could not enable XInput2 event handling\n"); - windowdata->xinput2_keyboard_enabled = SDL_FALSE; - windowdata->xinput2_mouse_enabled = SDL_FALSE; + windowdata->xinput2_keyboard_enabled = false; + windowdata->xinput2_mouse_enabled = false; } } #endif if (windowdata->xinput2_keyboard_enabled || windowdata->xinput2_mouse_enabled) { - return SDL_TRUE; + return true; } - return SDL_FALSE; + return false; } int X11_Xinput2IsMultitouchSupported(void) @@ -674,14 +674,14 @@ static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) *list = new_list; } -static SDL_bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) +static bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) { for (int i = 0; i < count; ++i) { if (deviceID == list[i]) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } static void AddDeviceID64(Uint64 deviceID, Uint64 **list, int *count) @@ -698,19 +698,19 @@ static void AddDeviceID64(Uint64 deviceID, Uint64 **list, int *count) *list = new_list; } -static SDL_bool HasDeviceID64(Uint64 deviceID, const Uint64 *list, int count) +static bool HasDeviceID64(Uint64 deviceID, const Uint64 *list, int count) { for (int i = 0; i < count; ++i) { if (deviceID == list[i]) { - return SDL_TRUE; + return true; } } - return SDL_FALSE; + return false; } #endif // SDL_VIDEO_DRIVER_X11_XINPUT2 -void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check) +void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, bool initial_check) { #ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_VideoData *data = _this->internal; @@ -728,7 +728,7 @@ void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check) Uint64 *old_touch_devices = NULL; int new_touch_count = 0; Uint64 *new_touch_devices = NULL; - SDL_bool send_event = !initial_check; + bool send_event = !initial_check; SDL_assert(X11_Xinput2IsInitialized()); diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index 8f16525d8a..a658a504c3 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -30,7 +30,7 @@ struct XGenericEventCookie; typedef struct XGenericEventCookie XGenericEventCookie; #endif -extern SDL_bool X11_InitXinput2(SDL_VideoDevice *_this); +extern bool X11_InitXinput2(SDL_VideoDevice *_this); extern void X11_InitXinput2Multitouch(SDL_VideoDevice *_this); extern void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie); extern int X11_Xinput2IsInitialized(void); @@ -38,7 +38,7 @@ extern int X11_Xinput2IsMultitouchSupported(void); extern void X11_Xinput2SelectTouch(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_Xinput2GrabTouch(SDL_VideoDevice *_this, SDL_Window *window); extern void X11_Xinput2UngrabTouch(SDL_VideoDevice *_this, SDL_Window *window); -extern SDL_bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window); -extern void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, SDL_bool initial_check); +extern bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, bool initial_check); #endif // SDL_x11xinput2_h_ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 80348499d6..3163f2a4eb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -315,7 +315,7 @@ add_sdl_test_executable(testerror NONINTERACTIVE DISABLE_THREADS_ARGS "--no-thre set(build_options_dependent_tests ) -add_sdl_test_executable(testevdev BUILD_DEPENDENT NONINTERACTIVE SOURCES testevdev.c) +add_sdl_test_executable(testevdev BUILD_DEPENDENT NONINTERACTIVE NO_C90 SOURCES testevdev.c) if(MACOS) add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS