diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index f5b9554ba..145760f33 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -851,7 +851,7 @@ typedef SDL_ControllerTouchpadEvent, SDL_GamepadTouchpadEvent; @@ @@ - SDL_CONTROLLER_AXIS_MAX -+ SDL_GAMEPAD_AXIS_MAX ++ SDL_GAMEPAD_AXIS_COUNT @@ @@ - SDL_CONTROLLER_AXIS_RIGHTX @@ -931,7 +931,7 @@ typedef SDL_ControllerTouchpadEvent, SDL_GamepadTouchpadEvent; @@ @@ - SDL_CONTROLLER_BUTTON_MAX -+ SDL_GAMEPAD_BUTTON_MAX ++ SDL_GAMEPAD_BUTTON_COUNT @@ @@ - SDL_CONTROLLER_BUTTON_MISC1 @@ -3651,3 +3651,19 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern ) - == -1 ) +@@ +@@ +- SDL_NUM_LOG_PRIORITIES ++ SDL_LOG_PRIORITY_COUNT +@@ +@@ +- SDL_MESSAGEBOX_COLOR_MAX ++ SDL_MESSAGEBOX_COLOR_COUNT +@@ +@@ +- SDL_NUM_SYSTEM_CURSORS ++ SDL_SYSTEM_CURSOR_COUNT +@@ +@@ +- SDL_NUM_SCANCODES ++ SDL_SCANCODE_COUNT diff --git a/docs/README-migration.md b/docs/README-migration.md index e4de4e145..2a303c2fa 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -675,7 +675,7 @@ The following symbols have been renamed: * SDL_CONTROLLER_AXIS_INVALID => SDL_GAMEPAD_AXIS_INVALID * SDL_CONTROLLER_AXIS_LEFTX => SDL_GAMEPAD_AXIS_LEFTX * SDL_CONTROLLER_AXIS_LEFTY => SDL_GAMEPAD_AXIS_LEFTY -* SDL_CONTROLLER_AXIS_MAX => SDL_GAMEPAD_AXIS_MAX +* SDL_CONTROLLER_AXIS_MAX => SDL_GAMEPAD_AXIS_COUNT * SDL_CONTROLLER_AXIS_RIGHTX => SDL_GAMEPAD_AXIS_RIGHTX * SDL_CONTROLLER_AXIS_RIGHTY => SDL_GAMEPAD_AXIS_RIGHTY * SDL_CONTROLLER_AXIS_TRIGGERLEFT => SDL_GAMEPAD_AXIS_LEFT_TRIGGER @@ -695,7 +695,7 @@ The following symbols have been renamed: * SDL_CONTROLLER_BUTTON_INVALID => SDL_GAMEPAD_BUTTON_INVALID * SDL_CONTROLLER_BUTTON_LEFTSHOULDER => SDL_GAMEPAD_BUTTON_LEFT_SHOULDER * SDL_CONTROLLER_BUTTON_LEFTSTICK => SDL_GAMEPAD_BUTTON_LEFT_STICK -* SDL_CONTROLLER_BUTTON_MAX => SDL_GAMEPAD_BUTTON_MAX +* SDL_CONTROLLER_BUTTON_MAX => SDL_GAMEPAD_BUTTON_COUNT * SDL_CONTROLLER_BUTTON_MISC1 => SDL_GAMEPAD_BUTTON_MISC1 * SDL_CONTROLLER_BUTTON_PADDLE1 => SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 * SDL_CONTROLLER_BUTTON_PADDLE2 => SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 @@ -1116,6 +1116,9 @@ The following functions have been renamed: * SDL_LogSetOutputFunction() => SDL_SetLogOutputFunction() * SDL_LogSetPriority() => SDL_SetLogPriority() +The following symbols have been renamed: +* SDL_NUM_LOG_PRIORITIES => SDL_LOG_PRIORITY_COUNT + ## SDL_main.h SDL3 doesn't have a static libSDLmain to link against anymore. @@ -1139,6 +1142,9 @@ The following functions have been removed: The buttonid field of SDL_MessageBoxButtonData has been renamed buttonID. +The following symbols have been renamed: +* SDL_MESSAGEBOX_COLOR_MAX => SDL_MESSAGEBOX_COLOR_COUNT + ## SDL_metal.h SDL_Metal_GetDrawableSize() has been removed. SDL_GetWindowSizeInPixels() can be used in its place. @@ -1159,6 +1165,7 @@ The following functions have been removed: * SDL_GetRelativeMouseMode() - replaced with SDL_GetWindowRelativeMouseMode() The following symbols have been renamed: +* SDL_NUM_SYSTEM_CURSORS => SDL_SYSTEM_CURSOR_COUNT * SDL_SYSTEM_CURSOR_ARROW => SDL_SYSTEM_CURSOR_DEFAULT * SDL_SYSTEM_CURSOR_HAND => SDL_SYSTEM_CURSOR_POINTER * SDL_SYSTEM_CURSOR_IBEAM => SDL_SYSTEM_CURSOR_TEXT @@ -1650,6 +1657,7 @@ The following symbols have been removed: * SDL_SCANCODE_APP2 The following symbols have been renamed: +* SDL_NUM_SCANCODES => SDL_SCANCODE_COUNT * SDL_SCANCODE_AUDIOFASTFORWARD => SDL_SCANCODE_MEDIA_FAST_FORWARD * SDL_SCANCODE_AUDIOMUTE => SDL_SCANCODE_MUTE * SDL_SCANCODE_AUDIONEXT => SDL_SCANCODE_MEDIA_NEXT_TRACK diff --git a/include/SDL3/SDL_filesystem.h b/include/SDL3/SDL_filesystem.h index 553f56b6c..0afe3cb74 100644 --- a/include/SDL3/SDL_filesystem.h +++ b/include/SDL3/SDL_filesystem.h @@ -165,44 +165,30 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetPrefPath(const char *org, const char * */ typedef enum SDL_Folder { - /** The folder which contains all of the current user's data, preferences, - and documents. It usually contains most of the other folders. If a - requested folder does not exist, the home folder can be considered a safe - fallback to store a user's documents. */ - SDL_FOLDER_HOME, - /** The folder of files that are displayed on the desktop. Note that the - existence of a desktop folder does not guarantee that the system does - show icons on its desktop; certain GNU/Linux distros with a graphical - environment may not have desktop icons. */ - SDL_FOLDER_DESKTOP, - /** User document files, possibly application-specific. This is a good - place to save a user's projects. */ - SDL_FOLDER_DOCUMENTS, - /** Standard folder for user files downloaded from the internet. */ - SDL_FOLDER_DOWNLOADS, - /** Music files that can be played using a standard music player (mp3, - ogg...). */ - SDL_FOLDER_MUSIC, - /** Image files that can be displayed using a standard viewer (png, - jpg...). */ - SDL_FOLDER_PICTURES, - /** Files that are meant to be shared with other users on the same - computer. */ - SDL_FOLDER_PUBLICSHARE, - /** Save files for games. */ - SDL_FOLDER_SAVEDGAMES, - /** Application screenshots. */ - SDL_FOLDER_SCREENSHOTS, - /** Template files to be used when the user requests the desktop environment - to create a new file in a certain folder, such as "New Text File.txt". - Any file in the Templates folder can be used as a starting point for a - new file. */ - SDL_FOLDER_TEMPLATES, - /** Video files that can be played using a standard video player (mp4, - webm...). */ - SDL_FOLDER_VIDEOS, - /** total number of types in this enum, not a folder type by itself. */ - SDL_FOLDER_TOTAL + SDL_FOLDER_HOME, /**< The folder which contains all of the current user's data, preferences, and documents. It usually contains most of the other folders. If a requested folder does not exist, the home folder can be considered a safe fallback to store a user's documents. */ + + SDL_FOLDER_DESKTOP, /**< The folder of files that are displayed on the desktop. Note that the existence of a desktop folder does not guarantee that the system does show icons on its desktop; certain GNU/Linux distros with a graphical environment may not have desktop icons. */ + + SDL_FOLDER_DOCUMENTS, /**< User document files, possibly application-specific. This is a good place to save a user's projects. */ + + SDL_FOLDER_DOWNLOADS, /**< Standard folder for user files downloaded from the internet. */ + + SDL_FOLDER_MUSIC, /**< Music files that can be played using a standard music player (mp3, ogg...). */ + + SDL_FOLDER_PICTURES, /**< Image files that can be displayed using a standard viewer (png, jpg...). */ + + SDL_FOLDER_PUBLICSHARE, /**< Files that are meant to be shared with other users on the same computer. */ + + SDL_FOLDER_SAVEDGAMES, /**< Save files for games. */ + + SDL_FOLDER_SCREENSHOTS, /**< Application screenshots. */ + + SDL_FOLDER_TEMPLATES, /**< Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file. */ + + SDL_FOLDER_VIDEOS, /**< Video files that can be played using a standard video player (mp4, webm...). */ + + SDL_FOLDER_COUNT /**< Total number of types in this enum, not a folder type by itself. */ + } SDL_Folder; /** @@ -243,11 +229,11 @@ typedef enum SDL_PathType typedef struct SDL_PathInfo { - SDL_PathType type; /* the path type */ - Uint64 size; /* the file size in bytes */ - SDL_Time create_time; /* the time when the path was created */ - SDL_Time modify_time; /* the last time the path was modified */ - SDL_Time access_time; /* the last time the path was read */ + SDL_PathType type; /**< the path type */ + Uint64 size; /**< the file size in bytes */ + SDL_Time create_time; /**< the time when the path was created */ + SDL_Time modify_time; /**< the last time the path was modified */ + SDL_Time access_time; /**< the last time the path was read */ } SDL_PathInfo; /** diff --git a/include/SDL3/SDL_gamepad.h b/include/SDL3/SDL_gamepad.h index 450261b08..5ba2f8b5b 100644 --- a/include/SDL3/SDL_gamepad.h +++ b/include/SDL3/SDL_gamepad.h @@ -100,7 +100,7 @@ typedef enum SDL_GamepadType SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, - SDL_GAMEPAD_TYPE_MAX + SDL_GAMEPAD_TYPE_COUNT } SDL_GamepadType; /** @@ -155,7 +155,7 @@ typedef enum SDL_GamepadButton SDL_GAMEPAD_BUTTON_MISC4, /* Additional button */ SDL_GAMEPAD_BUTTON_MISC5, /* Additional button */ SDL_GAMEPAD_BUTTON_MISC6, /* Additional button */ - SDL_GAMEPAD_BUTTON_MAX + SDL_GAMEPAD_BUTTON_COUNT } SDL_GamepadButton; /** @@ -205,7 +205,7 @@ typedef enum SDL_GamepadAxis SDL_GAMEPAD_AXIS_RIGHTY, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, - SDL_GAMEPAD_AXIS_MAX + SDL_GAMEPAD_AXIS_COUNT } SDL_GamepadAxis; /** diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h index 1d6351ffe..7c043090d 100644 --- a/include/SDL3/SDL_joystick.h +++ b/include/SDL3/SDL_joystick.h @@ -120,7 +120,8 @@ typedef enum SDL_JoystickType SDL_JOYSTICK_TYPE_GUITAR, SDL_JOYSTICK_TYPE_DRUM_KIT, SDL_JOYSTICK_TYPE_ARCADE_PAD, - SDL_JOYSTICK_TYPE_THROTTLE + SDL_JOYSTICK_TYPE_THROTTLE, + SDL_JOYSTICK_TYPE_COUNT } SDL_JoystickType; /** diff --git a/include/SDL3/SDL_log.h b/include/SDL3/SDL_log.h index 0a5379633..e098af331 100644 --- a/include/SDL3/SDL_log.h +++ b/include/SDL3/SDL_log.h @@ -126,7 +126,7 @@ typedef enum SDL_LogPriority SDL_LOG_PRIORITY_WARN, SDL_LOG_PRIORITY_ERROR, SDL_LOG_PRIORITY_CRITICAL, - SDL_NUM_LOG_PRIORITIES + SDL_LOG_PRIORITY_COUNT } SDL_LogPriority; diff --git a/include/SDL3/SDL_messagebox.h b/include/SDL3/SDL_messagebox.h index c626b2283..bae603cd8 100644 --- a/include/SDL3/SDL_messagebox.h +++ b/include/SDL3/SDL_messagebox.h @@ -96,7 +96,7 @@ typedef enum SDL_MessageBoxColorType SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, - SDL_MESSAGEBOX_COLOR_MAX /**< Size of the colors array of SDL_MessageBoxColorScheme. */ + SDL_MESSAGEBOX_COLOR_COUNT /**< Size of the colors array of SDL_MessageBoxColorScheme. */ } SDL_MessageBoxColorType; /** @@ -106,7 +106,7 @@ typedef enum SDL_MessageBoxColorType */ typedef struct SDL_MessageBoxColorScheme { - SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_COUNT]; } SDL_MessageBoxColorScheme; /** diff --git a/include/SDL3/SDL_mouse.h b/include/SDL3/SDL_mouse.h index 71e2b685c..4d870b652 100644 --- a/include/SDL3/SDL_mouse.h +++ b/include/SDL3/SDL_mouse.h @@ -87,7 +87,7 @@ typedef enum SDL_SystemCursor SDL_SYSTEM_CURSOR_S_RESIZE, /**< Window resize bottom. May be NS_RESIZE. */ SDL_SYSTEM_CURSOR_SW_RESIZE, /**< Window resize bottom-left. May be NESW_RESIZE. */ SDL_SYSTEM_CURSOR_W_RESIZE, /**< Window resize left. May be EW_RESIZE. */ - SDL_NUM_SYSTEM_CURSORS + SDL_SYSTEM_CURSOR_COUNT } SDL_SystemCursor; /** diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index de5e69842..9cb132453 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -419,9 +419,14 @@ #define SDL_LogSetAllPriority SDL_SetLogPriorities #define SDL_LogSetOutputFunction SDL_SetLogOutputFunction #define SDL_LogSetPriority SDL_SetLogPriority +#define SDL_NUM_LOG_PRIORITIES SDL_LOG_PRIORITY_COUNT + +/* ##SDL_messagebox.h */ +#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_COUNT /* ##SDL_mouse.h */ #define SDL_FreeCursor SDL_DestroyCursor +#define SDL_NUM_SYSTEM_CURSORS SDL_SYSTEM_CURSOR_COUNT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_POINTER #define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_TEXT @@ -558,6 +563,7 @@ #define SDL_WriteLE64 SDL_WriteU64LE /* ##SDL_scancode.h */ +#define SDL_NUM_SCANCODES SDL_SCANCODE_COUNT #define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_MEDIA_FAST_FORWARD #define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_MUTE #define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_MEDIA_NEXT_TRACK @@ -1043,9 +1049,14 @@ #define SDL_LogSetAllPriority SDL_LogSetAllPriority_renamed_SDL_SetLogPriorities #define SDL_LogSetOutputFunction SDL_LogSetOutputFunction_renamed_SDL_SetLogOutputFunction #define SDL_LogSetPriority SDL_LogSetPriority_renamed_SDL_SetLogPriority +#define SDL_NUM_LOG_PRIORITIES SDL_NUM_LOG_PRIORITIES_renamed_SDL_LOG_PRIORITY_COUNT + +/* ##SDL_messagebox.h */ +#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_MAX_renamed_SDL_MESSAGEBOX_COLOR_COUNT /* ##SDL_mouse.h */ #define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor +#define SDL_NUM_SYSTEM_CURSORS SDL_NUM_SYSTEM_CURSORS_renamed_SDL_SYSTEM_CURSOR_COUNT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_ARROW_renamed_SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_HAND_renamed_SDL_SYSTEM_CURSOR_POINTER #define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_IBEAM_renamed_SDL_SYSTEM_CURSOR_TEXT @@ -1182,6 +1193,7 @@ #define SDL_WriteLE64 SDL_WriteLE64_renamed_SDL_WriteU64LE /* ##SDL_scancode.h */ +#define SDL_NUM_SCANCODES SDL_NUM_SCANCODES_renamed_SDL_SCANCODE_COUNT #define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_AUDIOFASTFORWARD_renamed_SDL_SCANCODE_MEDIA_FAST_FORWARD #define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_AUDIOMUTE_renamed_SDL_SCANCODE_MUTE #define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_AUDIONEXT_renamed_SDL_SCANCODE_MEDIA_NEXT_TRACK diff --git a/include/SDL3/SDL_pen.h b/include/SDL3/SDL_pen.h index ebb08dc47..e939cab2b 100644 --- a/include/SDL3/SDL_pen.h +++ b/include/SDL3/SDL_pen.h @@ -101,7 +101,7 @@ typedef enum SDL_PenAxis SDL_PEN_AXIS_ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */ SDL_PEN_AXIS_SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */ SDL_PEN_AXIS_TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */ - SDL_PEN_NUM_AXES /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ + SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ } SDL_PenAxis; /* Ends C function definitions when using C++ */ diff --git a/include/SDL3/SDL_scancode.h b/include/SDL3/SDL_scancode.h index ccf8bb5f7..16fb2a828 100644 --- a/include/SDL3/SDL_scancode.h +++ b/include/SDL3/SDL_scancode.h @@ -417,8 +417,8 @@ typedef enum SDL_Scancode SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */ - SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes - for array bounds */ + SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */ + } SDL_Scancode; #endif /* SDL_scancode_h_ */ diff --git a/src/SDL_log.c b/src/SDL_log.c index d3f03445b..9f78a6c6a 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -78,9 +78,9 @@ static const char * const SDL_priority_names[] = { "ERROR", "CRITICAL" }; -SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL_NUM_LOG_PRIORITIES); +SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL_LOG_PRIORITY_COUNT); -static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES]; +static const char *SDL_priority_prefixes[SDL_LOG_PRIORITY_COUNT]; // If this list changes, update the documentation for SDL_HINT_LOGGING static const char * const SDL_category_names[] = { @@ -102,7 +102,7 @@ SDL_COMPILE_TIME_ASSERT(category_names, SDL_arraysize(SDL_category_names) == SDL #endif #ifdef SDL_PLATFORM_ANDROID -static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { +static int SDL_android_priority[SDL_LOG_PRIORITY_COUNT] = { ANDROID_LOG_UNKNOWN, ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, @@ -196,10 +196,10 @@ static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPrior i = SDL_atoi(string); if (i == 0) { // 0 has a special meaning of "disable this category" - *priority = SDL_NUM_LOG_PRIORITIES; + *priority = SDL_LOG_PRIORITY_COUNT; return true; } - if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_NUM_LOG_PRIORITIES) { + if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_LOG_PRIORITY_COUNT) { *priority = (SDL_LogPriority)i; return true; } @@ -207,11 +207,11 @@ static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPrior } if (SDL_strncasecmp(string, "quiet", length) == 0) { - *priority = SDL_NUM_LOG_PRIORITIES; + *priority = SDL_LOG_PRIORITY_COUNT; return true; } - for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_NUM_LOG_PRIORITIES; ++i) { + for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_LOG_PRIORITY_COUNT; ++i) { if (SDL_strncasecmp(string, SDL_priority_names[i], length) == 0) { *priority = (SDL_LogPriority)i; return true; @@ -319,7 +319,7 @@ static void SDL_ResetLogPrefixes(void) static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority) { - if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_NUM_LOG_PRIORITIES) { + if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_LOG_PRIORITY_COUNT) { return ""; } @@ -341,7 +341,7 @@ static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority) SDL_bool SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix) { - if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_NUM_LOG_PRIORITIES) { + if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_LOG_PRIORITY_COUNT) { return SDL_InvalidParamError("priority"); } @@ -456,7 +456,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S } // Make sure we don't exceed array bounds - if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { + if ((int)priority < 0 || priority >= SDL_LOG_PRIORITY_COUNT) { return; } diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 2a8e310ba..e24eaea13 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -2122,8 +2122,8 @@ bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *b } if (messageboxdata->colorScheme) { - colors = (*env)->NewIntArray(env, SDL_MESSAGEBOX_COLOR_MAX); - for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; ++i) { + colors = (*env)->NewIntArray(env, SDL_MESSAGEBOX_COLOR_COUNT); + for (i = 0; i < SDL_MESSAGEBOX_COLOR_COUNT; ++i) { temp = (0xFFU << 24) | (messageboxdata->colorScheme->colors[i].r << 16) | (messageboxdata->colorScheme->colors[i].g << 8) | diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index 9dcf94df0..281d2eca2 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -808,7 +808,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input) } } break; case WSCONS_EVENT_ALL_KEYS_UP: - for (i = 0; i < SDL_NUM_SCANCODES; i++) { + for (i = 0; i < SDL_SCANCODE_COUNT; i++) { SDL_SendKeyboardKey(0, input->keyboardID, 0, (SDL_Scancode)i, false); } break; diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index f5d37e097..161a52f6f 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -379,7 +379,7 @@ static void SDLCALL SDL_EventLoggingChanged(void *userdata, const char *name, co static void SDL_LogEvent(const SDL_Event *event) { static const char *pen_axisnames[] = { "PRESSURE", "XTILT", "YTILT", "DISTANCE", "ROTATION", "SLIDER", "TANGENTIAL_PRESSURE" }; - SDL_COMPILE_TIME_ASSERT(pen_axisnames_array_matches, SDL_arraysize(pen_axisnames) == SDL_PEN_NUM_AXES); + SDL_COMPILE_TIME_ASSERT(pen_axisnames_array_matches, SDL_arraysize(pen_axisnames) == SDL_PEN_AXIS_COUNT); char name[64]; char details[128]; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index b1636c7e1..3ba9da7ec 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -53,8 +53,8 @@ typedef struct SDL_Keyboard // Data common to all keyboards SDL_Window *focus; SDL_Keymod modstate; - Uint8 keysource[SDL_NUM_SCANCODES]; - SDL_bool keystate[SDL_NUM_SCANCODES]; + Uint8 keysource[SDL_SCANCODE_COUNT]; + SDL_bool keystate[SDL_SCANCODE_COUNT]; SDL_Keymap *keymap; bool french_numbers; bool latin_letters; @@ -219,7 +219,7 @@ void SDL_ResetKeyboard(void) #ifdef DEBUG_KEYBOARD printf("Resetting keyboard\n"); #endif - for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_SCANCODE_COUNT; ++scancode) { if (keyboard->keystate[scancode]) { SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, (SDL_Scancode)scancode, false); } @@ -510,7 +510,7 @@ static bool SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_Keyb type = SDL_EVENT_KEY_UP; } - if (scancode > SDL_SCANCODE_UNKNOWN && scancode < SDL_NUM_SCANCODES) { + if (scancode > SDL_SCANCODE_UNKNOWN && scancode < SDL_SCANCODE_COUNT) { // Drop events that don't change state if (down) { if (keyboard->keystate[scancode]) { @@ -691,7 +691,7 @@ void SDL_ReleaseAutoReleaseKeys(void) int scancode; if (keyboard->autorelease_pending) { - for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_SCANCODE_COUNT; ++scancode) { if (keyboard->keysource[scancode] == KEYBOARD_AUTORELEASE) { SDL_SendKeyboardKeyInternal(0, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, 0, (SDL_Scancode)scancode, false); } @@ -712,7 +712,7 @@ bool SDL_HardwareKeyboardKeyPressed(void) SDL_Keyboard *keyboard = &SDL_keyboard; int scancode; - for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_SCANCODE_COUNT; ++scancode) { if (keyboard->keysource[scancode] & KEYBOARD_HARDWARE) { return true; } @@ -868,7 +868,7 @@ const SDL_bool *SDL_GetKeyboardState(int *numkeys) SDL_Keyboard *keyboard = &SDL_keyboard; if (numkeys != (int *)0) { - *numkeys = SDL_NUM_SCANCODES; + *numkeys = SDL_SCANCODE_COUNT; } return keyboard->keystate; } diff --git a/src/events/SDL_keymap.c b/src/events/SDL_keymap.c index dc1b31177..644688698 100644 --- a/src/events/SDL_keymap.c +++ b/src/events/SDL_keymap.c @@ -192,7 +192,7 @@ static const SDL_Keycode shifted_default_symbols[] = { static SDL_Keycode SDL_GetDefaultKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate) { - if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { + if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_SCANCODE_COUNT) { SDL_InvalidParamError("scancode"); return SDLK_UNKNOWN; } @@ -638,7 +638,7 @@ static SDL_Scancode SDL_GetDefaultScancodeFromKey(SDL_Keycode key, SDL_Keymod *m return SDL_SCANCODE_UNKNOWN; } -static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = +static const char *SDL_scancode_names[SDL_SCANCODE_COUNT] = { /* 0 */ NULL, /* 1 */ NULL, @@ -935,7 +935,7 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = SDL_bool SDL_SetScancodeName(SDL_Scancode scancode, const char *name) { - if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { + if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_SCANCODE_COUNT) { return SDL_InvalidParamError("scancode"); } @@ -946,7 +946,7 @@ SDL_bool SDL_SetScancodeName(SDL_Scancode scancode, const char *name) const char *SDL_GetScancodeName(SDL_Scancode scancode) { const char *name; - if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { + if (((int)scancode) < SDL_SCANCODE_UNKNOWN || scancode >= SDL_SCANCODE_COUNT) { SDL_InvalidParamError("scancode"); return ""; } diff --git a/src/events/SDL_pen.c b/src/events/SDL_pen.c index 819946ba4..63d1c975e 100644 --- a/src/events/SDL_pen.c +++ b/src/events/SDL_pen.c @@ -31,7 +31,7 @@ typedef struct SDL_Pen SDL_PenID instance_id; char *name; SDL_PenInfo info; - float axes[SDL_PEN_NUM_AXES]; + float axes[SDL_PEN_AXIS_COUNT]; float x; float y; SDL_PenInputFlags input_state; @@ -170,10 +170,10 @@ SDL_PenInputFlags SDL_GetPenStatus(SDL_PenID instance_id, float *axes, int num_a if (pen) { result = pen->input_state; if (axes && num_axes) { - SDL_memcpy(axes, pen->axes, SDL_min(num_axes, SDL_PEN_NUM_AXES) * sizeof (*axes)); + SDL_memcpy(axes, pen->axes, SDL_min(num_axes, SDL_PEN_AXIS_COUNT) * sizeof (*axes)); // zero out axes we don't know about, in case the caller built with newer SDL headers that support more of them. - if (num_axes > SDL_PEN_NUM_AXES) { - SDL_memset(&axes[SDL_PEN_NUM_AXES], '\0', (num_axes - SDL_PEN_NUM_AXES) * sizeof (*axes)); + if (num_axes > SDL_PEN_AXIS_COUNT) { + SDL_memset(&axes[SDL_PEN_AXIS_COUNT], '\0', (num_axes - SDL_PEN_AXIS_COUNT) * sizeof (*axes)); } } } @@ -368,7 +368,7 @@ void SDL_SendPenTouch(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window void SDL_SendPenAxis(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *window, SDL_PenAxis axis, float value) { - SDL_assert((axis >= 0) && (axis < SDL_PEN_NUM_AXES)); // fix the backend if this triggers. + SDL_assert((axis >= 0) && (axis < SDL_PEN_AXIS_COUNT)); // fix the backend if this triggers. bool send_event = false; SDL_PenInputFlags input_state = 0; diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c index 5b16a4e1f..775c9f852 100644 --- a/src/filesystem/SDL_filesystem.c +++ b/src/filesystem/SDL_filesystem.c @@ -427,7 +427,7 @@ const char *SDL_GetBasePath(void) } -static char *CachedUserFolders[SDL_FOLDER_TOTAL]; +static char *CachedUserFolders[SDL_FOLDER_COUNT]; const char *SDL_GetUserFolder(SDL_Folder folder) { diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index 732f0796a..f1ed38e95 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -293,14 +293,14 @@ static void RecenterGamepad(SDL_Gamepad *gamepad) int i; Uint64 timestamp = SDL_GetTicksNS(); - for (i = 0; i < SDL_GAMEPAD_BUTTON_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_BUTTON_COUNT; ++i) { SDL_GamepadButton button = (SDL_GamepadButton)i; if (SDL_GetGamepadButton(gamepad, button)) { SDL_SendGamepadButton(timestamp, gamepad, button, false); } } - for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) { SDL_GamepadAxis axis = (SDL_GamepadAxis)i; if (SDL_GetGamepadAxis(gamepad, axis) != 0) { SDL_SendGamepadAxis(timestamp, gamepad, axis, 0); @@ -979,7 +979,7 @@ static const char *map_StringForGamepadType[] = { "joyconright", "joyconpair" }; -SDL_COMPILE_TIME_ASSERT(map_StringForGamepadType, SDL_arraysize(map_StringForGamepadType) == SDL_GAMEPAD_TYPE_MAX); +SDL_COMPILE_TIME_ASSERT(map_StringForGamepadType, SDL_arraysize(map_StringForGamepadType) == SDL_GAMEPAD_TYPE_COUNT); /* * convert a string to its enum equivalent @@ -1009,7 +1009,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromString(const char *str) */ const char *SDL_GetGamepadStringForType(SDL_GamepadType type) { - if (type >= SDL_GAMEPAD_TYPE_STANDARD && type < SDL_GAMEPAD_TYPE_MAX) { + if (type >= SDL_GAMEPAD_TYPE_STANDARD && type < SDL_GAMEPAD_TYPE_COUNT) { return map_StringForGamepadType[type]; } return NULL; @@ -1023,7 +1023,7 @@ static const char *map_StringForGamepadAxis[] = { "lefttrigger", "righttrigger" }; -SDL_COMPILE_TIME_ASSERT(map_StringForGamepadAxis, SDL_arraysize(map_StringForGamepadAxis) == SDL_GAMEPAD_AXIS_MAX); +SDL_COMPILE_TIME_ASSERT(map_StringForGamepadAxis, SDL_arraysize(map_StringForGamepadAxis) == SDL_GAMEPAD_AXIS_COUNT); /* * convert a string to its enum equivalent @@ -1053,7 +1053,7 @@ SDL_GamepadAxis SDL_GetGamepadAxisFromString(const char *str) */ const char *SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis) { - if (axis > SDL_GAMEPAD_AXIS_INVALID && axis < SDL_GAMEPAD_AXIS_MAX) { + if (axis > SDL_GAMEPAD_AXIS_INVALID && axis < SDL_GAMEPAD_AXIS_COUNT) { return map_StringForGamepadAxis[axis]; } return NULL; @@ -1087,7 +1087,7 @@ static const char *map_StringForGamepadButton[] = { "misc5", "misc6" }; -SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == SDL_GAMEPAD_BUTTON_MAX); +SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == SDL_GAMEPAD_BUTTON_COUNT); /* * convert a string to its enum equivalent @@ -1132,7 +1132,7 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str) */ const char *SDL_GetGamepadStringForButton(SDL_GamepadButton button) { - if (button > SDL_GAMEPAD_BUTTON_INVALID && button < SDL_GAMEPAD_BUTTON_MAX) { + if (button > SDL_GAMEPAD_BUTTON_INVALID && button < SDL_GAMEPAD_BUTTON_COUNT) { return map_StringForGamepadButton[button]; } return NULL; diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 468bd3988..558588d98 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -40,8 +40,8 @@ typedef struct bool pc_mode; SDL_JoystickID joysticks[MAX_CONTROLLERS]; Uint8 wireless[MAX_CONTROLLERS]; - Uint8 min_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_MAX]; - Uint8 max_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_MAX]; + Uint8 min_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_COUNT]; + Uint8 max_axis[MAX_CONTROLLERS * SDL_GAMEPAD_AXIS_COUNT]; Uint8 rumbleAllowed[MAX_CONTROLLERS]; Uint8 rumble[1 + MAX_CONTROLLERS]; // Without this variable, hid_write starts to lag a TON @@ -83,12 +83,12 @@ static bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *device, c static void ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) { - SDL_memset(&ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX], 128 - 88, SDL_GAMEPAD_AXIS_MAX); - SDL_memset(&ctx->max_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX], 128 + 88, SDL_GAMEPAD_AXIS_MAX); + SDL_memset(&ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_COUNT], 128 - 88, SDL_GAMEPAD_AXIS_COUNT); + SDL_memset(&ctx->max_axis[joystick_index * SDL_GAMEPAD_AXIS_COUNT], 128 + 88, SDL_GAMEPAD_AXIS_COUNT); // Trigger axes may have a higher resting value - ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX + SDL_GAMEPAD_AXIS_LEFT_TRIGGER] = 40; - ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_MAX + SDL_GAMEPAD_AXIS_RIGHT_TRIGGER] = 40; + ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_COUNT + SDL_GAMEPAD_AXIS_LEFT_TRIGGER] = 40; + ctx->min_axis[joystick_index * SDL_GAMEPAD_AXIS_COUNT + SDL_GAMEPAD_AXIS_RIGHT_TRIGGER] = 40; } static void SDLCALL SDL_JoystickGameCubeRumbleBrakeHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) @@ -252,11 +252,11 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device #define READ_AXIS(off, axis, invert) \ v = invert ? (0xff - packet[off]) : packet[off]; \ - if (v < ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \ - ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = v; \ - if (v > ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \ - ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = v; \ - axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + if (v < ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis]) \ + ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis] = v; \ + if (v > ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis]) \ + ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis] = v; \ + axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ SDL_SendJoystickAxis( \ timestamp, \ joystick, \ @@ -334,11 +334,11 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device #undef READ_BUTTON #define READ_AXIS(off, axis) \ - if (curSlot[off] < ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \ - ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = curSlot[off]; \ - if (curSlot[off] > ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis]) \ - ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis] = curSlot[off]; \ - axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_MAX + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + if (curSlot[off] < ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis]) \ + ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis] = curSlot[off]; \ + if (curSlot[off] > ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis]) \ + ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis] = curSlot[off]; \ + axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis], ctx->max_axis[i * SDL_GAMEPAD_AXIS_COUNT + axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ SDL_SendJoystickAxis( \ timestamp, \ joystick, \ @@ -391,7 +391,7 @@ static bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo for (i = 0; i < MAX_CONTROLLERS; i += 1) { if (joystick->instance_id == ctx->joysticks[i]) { joystick->nbuttons = 12; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; if (ctx->wireless[i]) { joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS; } else { diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 8d48e977c..d108f83f9 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -101,7 +101,7 @@ static bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joysti // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_LUNA_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; return true; diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index 60a7e8620..196aafcc1 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -863,7 +863,7 @@ static bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystic if (ctx->touchpad_supported) { joystick->nbuttons += 1; } - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL, diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index 7dba35a56..c0604152d 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -958,7 +958,7 @@ static bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystic } else { joystick->nbuttons = 11; } - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; joystick->firmware_version = ctx->firmware_version; diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index f385d3128..227b00b55 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -184,13 +184,13 @@ static bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys // Initialize the joystick capabilities if (device->product_id == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) { joystick->nbuttons = SDL_GAMEPAD_NUM_SHIELD_V103_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; SDL_PrivateJoystickAddTouchpad(joystick, 1); } else { joystick->nbuttons = SDL_GAMEPAD_NUM_SHIELD_V104_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; } diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index 349526bb4..8bcfdd4bf 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -107,7 +107,7 @@ static bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_STADIA_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; return true; diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 8d021303b..5116e84fb 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -1022,7 +1022,7 @@ static bool HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joyst // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_STEAM_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, update_rate_in_hz); diff --git a/src/joystick/hidapi/SDL_hidapi_steamdeck.c b/src/joystick/hidapi/SDL_hidapi_steamdeck.c index 0efc7e5a0..75a13cc1b 100644 --- a/src/joystick/hidapi/SDL_hidapi_steamdeck.c +++ b/src/joystick/hidapi/SDL_hidapi_steamdeck.c @@ -360,7 +360,7 @@ static bool HIDAPI_DriverSteamDeck_OpenJoystick(SDL_HIDAPI_Device *device, SDL_J // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_STEAM_DECK_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, update_rate_in_hz); diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index 10f2ce708..69f6f9de4 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -1498,7 +1498,7 @@ static bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys // Initialize the joystick capabilities joystick->nbuttons = SDL_GAMEPAD_NUM_SWITCH_BUTTONS; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; // Set up for input diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index e8e1d9d9e..23883544c 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -813,7 +813,7 @@ static bool HIDAPI_DriverWii_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystic // Maximum is Classic Controller + Wiimote joystick->nbuttons = k_eWiiButtons_Max; } - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; ctx->m_ulLastInput = SDL_GetTicks(); diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index 4b4c3008b..f7217233a 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -189,7 +189,7 @@ static bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy // Initialize the joystick capabilities joystick->nbuttons = 11; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; return true; diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 0a09e1269..61b8c75a6 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -176,7 +176,7 @@ static bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo // Initialize the joystick capabilities joystick->nbuttons = 15; - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; return true; } diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index a003a172b..0ae820ddc 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -429,7 +429,7 @@ static bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy if (ctx->has_paddles) { joystick->nbuttons += 4; } - joystick->naxes = SDL_GAMEPAD_AXIS_MAX; + joystick->naxes = SDL_GAMEPAD_AXIS_COUNT; joystick->nhats = 1; SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED, diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index e86e2fd06..bae4d7cae 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -218,7 +218,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des // Find the trigger axes axis = 0; - for (i = 0; axis < hwdata->desc.naxes && i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; axis < hwdata->desc.naxes && i < SDL_GAMEPAD_AXIS_COUNT; ++i) { if (hwdata->desc.axis_mask & (1 << i)) { if (i == SDL_GAMEPAD_AXIS_LEFT_TRIGGER) { axis_triggerleft = axis; diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 9b975a0fb..e5b9fd03e 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -2486,7 +2486,7 @@ typedef struct SDL_WaylandPenTool // a stylus, etc, on a tablet. float x; float y; bool frame_motion_set; - float frame_axes[SDL_PEN_NUM_AXES]; + float frame_axes[SDL_PEN_AXIS_COUNT]; Uint32 frame_axes_set; int frame_pen_down; int frame_buttons[3]; @@ -2705,7 +2705,7 @@ static void tablet_tool_handle_frame(void *data, struct zwp_tablet_tool_v2 *tool } } - for (SDL_PenAxis i = 0; i < SDL_PEN_NUM_AXES; i++) { + for (SDL_PenAxis i = 0; i < SDL_PEN_AXIS_COUNT; i++) { if (sdltool->frame_axes_set & (1u << i)) { SDL_SendPenAxis(timestamp, instance_id, window, i, sdltool->frame_axes[i]); } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index ae5d61c72..f2a5e59c3 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -48,7 +48,7 @@ static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1"; static const char g_MessageBoxFont[] = "-*-*-medium-r-normal--*-120-*-*-*-*-*-*"; -static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_MAX] = { +static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_COUNT] = { { 56, 54, 53 }, // SDL_MESSAGEBOX_COLOR_BACKGROUND, { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT, { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, @@ -110,7 +110,7 @@ typedef struct SDL_MessageBoxDataX11 const SDL_MessageBoxButtonData *buttondata; SDL_MessageBoxButtonDataX11 buttonpos[MAX_BUTTONS]; - Uint32 color[SDL_MESSAGEBOX_COLOR_MAX]; + Uint32 color[SDL_MESSAGEBOX_COLOR_COUNT]; const SDL_MessageBoxData *messageboxdata; } SDL_MessageBoxDataX11; @@ -216,7 +216,7 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox } // Convert our SDL_MessageBoxColor r,g,b values to packed RGB format. - for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; i++) { + for (i = 0; i < SDL_MESSAGEBOX_COLOR_COUNT; i++) { data->color[i] = SDL_MAKE_RGB(colorhints[i].r, colorhints[i].g, colorhints[i].b); } diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 05b81210d..decd76396 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -249,7 +249,7 @@ static unsigned int GetLegacySystemCursorShape(SDL_SystemCursor id) case SDL_SYSTEM_CURSOR_S_RESIZE: return XC_bottom_side; case SDL_SYSTEM_CURSOR_SW_RESIZE: return XC_bottom_left_corner; case SDL_SYSTEM_CURSOR_W_RESIZE: return XC_left_side; - case SDL_NUM_SYSTEM_CURSORS: break; // so the compiler might notice if an enum value is missing here. + case SDL_SYSTEM_CURSOR_COUNT: break; // so the compiler might notice if an enum value is missing here. } SDL_assert(0); diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c index f35487519..d08d0f2bb 100644 --- a/src/video/x11/SDL_x11pen.c +++ b/src/video/x11/SDL_x11pen.c @@ -222,7 +222,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo const float min = (float)val_classinfo->min; const float max = (float)val_classinfo->max; bool use_this_axis = true; - SDL_PenAxis axis = SDL_PEN_NUM_AXES; + SDL_PenAxis axis = SDL_PEN_AXIS_COUNT; // afaict, SDL_PEN_AXIS_DISTANCE is never reported by XInput2 (Wayland can offer it, though) if (vname == data->pen_atom_abs_pressure) { @@ -336,7 +336,7 @@ void X11_QuitPen(SDL_VideoDevice *_this) static void X11_XInput2NormalizePenAxes(const X11_PenHandle *pen, float *coords) { // Normalise axes - for (int axis = 0; axis < SDL_PEN_NUM_AXES; ++axis) { + for (int axis = 0; axis < SDL_PEN_AXIS_COUNT; ++axis) { const int valuator = pen->valuator_for_axis[axis]; if (valuator == SDL_X11_PEN_AXIS_VALUATOR_MISSING) { continue; @@ -403,9 +403,9 @@ static void X11_XInput2NormalizePenAxes(const X11_PenHandle *pen, float *coords) void X11_PenAxesFromValuators(const X11_PenHandle *pen, const double *input_values, const unsigned char *mask, const int mask_len, - float axis_values[SDL_PEN_NUM_AXES]) + float axis_values[SDL_PEN_AXIS_COUNT]) { - for (int i = 0; i < SDL_PEN_NUM_AXES; i++) { + for (int i = 0; i < SDL_PEN_AXIS_COUNT; i++) { const int valuator = pen->valuator_for_axis[i]; if ((valuator == SDL_X11_PEN_AXIS_VALUATOR_MISSING) || (valuator >= mask_len * 8) || !(XIMaskIsSet(mask, valuator))) { axis_values[i] = 0.0f; diff --git a/src/video/x11/SDL_x11pen.h b/src/video/x11/SDL_x11pen.h index ba998763b..b15d2a2dc 100644 --- a/src/video/x11/SDL_x11pen.h +++ b/src/video/x11/SDL_x11pen.h @@ -46,17 +46,17 @@ typedef struct X11_PenHandle SDL_PenID pen; bool is_eraser; int x11_deviceid; - int valuator_for_axis[SDL_PEN_NUM_AXES]; + int valuator_for_axis[SDL_PEN_AXIS_COUNT]; float slider_bias; // shift value to add to PEN_AXIS_SLIDER (before normalisation) float rotation_bias; // rotation to add to PEN_AXIS_ROTATION (after normalisation) - float axis_min[SDL_PEN_NUM_AXES]; - float axis_max[SDL_PEN_NUM_AXES]; + float axis_min[SDL_PEN_AXIS_COUNT]; + float axis_max[SDL_PEN_AXIS_COUNT]; } X11_PenHandle; // Converts XINPUT2 valuators into pen axis information, including normalisation. extern void X11_PenAxesFromValuators(const X11_PenHandle *pen, const double *input_values, const unsigned char *mask, const int mask_len, - float axis_values[SDL_PEN_NUM_AXES]); + float axis_values[SDL_PEN_AXIS_COUNT]); // Add a pen (if this function's further checks validate it). extern X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid); diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index bc8bbf1ae..1bdead851 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -458,7 +458,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); SDL_SendPenMotion(0, pen->pen, window, (float) xev->event_x, (float) xev->event_y); - float axes[SDL_PEN_NUM_AXES]; + float axes[SDL_PEN_AXIS_COUNT]; X11_PenAxesFromValuators(pen, xev->valuators.values, xev->valuators.mask, xev->valuators.mask_len, axes); for (int i = 0; i < SDL_arraysize(axes); i++) { diff --git a/test/gamepadutils.c b/test/gamepadutils.c index a4388455a..c9b691769 100644 --- a/test/gamepadutils.c +++ b/test/gamepadutils.c @@ -293,7 +293,7 @@ int GetGamepadImageElementAt(GamepadImage *ctx, float x, float y) if (ctx->showing_front) { for (i = 0; i < SDL_arraysize(axis_positions); ++i) { - const int element = SDL_GAMEPAD_BUTTON_MAX + i; + const int element = SDL_GAMEPAD_BUTTON_COUNT + i; SDL_FRect rect; if (element == SDL_GAMEPAD_ELEMENT_AXIS_LEFT_TRIGGER || @@ -431,7 +431,7 @@ void UpdateGamepadImageFromGamepad(GamepadImage *ctx, SDL_Gamepad *gamepad) SetGamepadImageElement(ctx, button, SDL_GetGamepadButton(gamepad, button)); } - for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) { const SDL_GamepadAxis axis = (SDL_GamepadAxis)i; const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ const Sint16 value = SDL_GetGamepadAxis(gamepad, axis); @@ -553,7 +553,7 @@ void RenderGamepadImage(GamepadImage *ctx) if (ctx->showing_front) { for (i = 0; i < SDL_arraysize(axis_positions); ++i) { - const int element = SDL_GAMEPAD_BUTTON_MAX + i; + const int element = SDL_GAMEPAD_BUTTON_COUNT + i; if (ctx->elements[element]) { const double angle = axis_positions[i].angle; dst.w = ctx->axis_width; @@ -676,7 +676,7 @@ static const char *gamepad_button_names[] = { "Misc5", "Misc6", }; -SDL_COMPILE_TIME_ASSERT(gamepad_button_names, SDL_arraysize(gamepad_button_names) == SDL_GAMEPAD_BUTTON_MAX); +SDL_COMPILE_TIME_ASSERT(gamepad_button_names, SDL_arraysize(gamepad_button_names) == SDL_GAMEPAD_BUTTON_COUNT); static const char *gamepad_axis_names[] = { "LeftX", @@ -686,7 +686,7 @@ static const char *gamepad_axis_names[] = { "Left Trigger", "Right Trigger", }; -SDL_COMPILE_TIME_ASSERT(gamepad_axis_names, SDL_arraysize(gamepad_axis_names) == SDL_GAMEPAD_AXIS_MAX); +SDL_COMPILE_TIME_ASSERT(gamepad_axis_names, SDL_arraysize(gamepad_axis_names) == SDL_GAMEPAD_AXIS_COUNT); struct GamepadDisplay { @@ -915,7 +915,7 @@ int GetGamepadDisplayElementAt(GamepadDisplay *ctx, SDL_Gamepad *gamepad, float rect.w = ctx->area.w - (margin * 2); rect.h = ctx->button_height; - for (i = 0; i < SDL_GAMEPAD_BUTTON_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_BUTTON_COUNT; ++i) { SDL_GamepadButton button = (SDL_GamepadButton)i; if (ctx->display_mode == CONTROLLER_MODE_TESTING && @@ -931,7 +931,7 @@ int GetGamepadDisplayElementAt(GamepadDisplay *ctx, SDL_Gamepad *gamepad, float rect.y += ctx->button_height + 2.0f; } - for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) { SDL_GamepadAxis axis = (SDL_GamepadAxis)i; SDL_FRect area; @@ -1033,7 +1033,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad) x = ctx->area.x + margin; y = ctx->area.y + margin; - for (i = 0; i < SDL_GAMEPAD_BUTTON_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_BUTTON_COUNT; ++i) { SDL_GamepadButton button = (SDL_GamepadButton)i; if (ctx->display_mode == CONTROLLER_MODE_TESTING && @@ -1072,7 +1072,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad) y += ctx->button_height + 2.0f; } - for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) { SDL_GamepadAxis axis = (SDL_GamepadAxis)i; SDL_bool has_negative = (axis != SDL_GAMEPAD_AXIS_LEFT_TRIGGER && axis != SDL_GAMEPAD_AXIS_RIGHT_TRIGGER); Sint16 value; @@ -1376,7 +1376,7 @@ int GetGamepadTypeDisplayAt(GamepadTypeDisplay *ctx, float x, float y) x = ctx->area.x + margin; y = ctx->area.y + margin; - for (i = SDL_GAMEPAD_TYPE_UNKNOWN; i < SDL_GAMEPAD_TYPE_MAX; ++i) { + for (i = SDL_GAMEPAD_TYPE_UNKNOWN; i < SDL_GAMEPAD_TYPE_COUNT; ++i) { highlight.x = x; highlight.y = y; highlight.w = ctx->area.w - (margin * 2); @@ -1430,7 +1430,7 @@ void RenderGamepadTypeDisplay(GamepadTypeDisplay *ctx) x = ctx->area.x + margin; y = ctx->area.y + margin; - for (i = SDL_GAMEPAD_TYPE_UNKNOWN; i < SDL_GAMEPAD_TYPE_MAX; ++i) { + for (i = SDL_GAMEPAD_TYPE_UNKNOWN; i < SDL_GAMEPAD_TYPE_COUNT; ++i) { highlight.x = x; highlight.y = y; highlight.w = ctx->area.w - (margin * 2); @@ -2662,14 +2662,14 @@ SDL_bool MappingHasBindings(const char *mapping) } SplitMapping(mapping, &parts); - for (i = 0; i < SDL_GAMEPAD_BUTTON_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_BUTTON_COUNT; ++i) { if (FindMappingKey(&parts, SDL_GetGamepadStringForButton((SDL_GamepadButton)i)) >= 0) { result = SDL_TRUE; break; } } if (!result) { - for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) { + for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) { if (FindMappingKey(&parts, SDL_GetGamepadStringForAxis((SDL_GamepadAxis)i)) >= 0) { result = SDL_TRUE; break; @@ -2795,7 +2795,7 @@ char *SetMappingType(char *mapping, SDL_GamepadType type) static const char *GetElementKey(int element) { - if (element < SDL_GAMEPAD_BUTTON_MAX) { + if (element < SDL_GAMEPAD_BUTTON_COUNT) { return SDL_GetGamepadStringForButton((SDL_GamepadButton)element); } else { static char key[16]; diff --git a/test/gamepadutils.h b/test/gamepadutils.h index a211fd22e..46de3afa6 100644 --- a/test/gamepadutils.h +++ b/test/gamepadutils.h @@ -26,7 +26,7 @@ enum /* ... SDL_GamepadButton ... */ - SDL_GAMEPAD_ELEMENT_AXIS_LEFTX_NEGATIVE = SDL_GAMEPAD_BUTTON_MAX, + SDL_GAMEPAD_ELEMENT_AXIS_LEFTX_NEGATIVE = SDL_GAMEPAD_BUTTON_COUNT, SDL_GAMEPAD_ELEMENT_AXIS_LEFTX_POSITIVE, SDL_GAMEPAD_ELEMENT_AXIS_LEFTY_NEGATIVE, SDL_GAMEPAD_ELEMENT_AXIS_LEFTY_POSITIVE, diff --git a/test/testautomation_joystick.c b/test/testautomation_joystick.c index 83e28c7bd..e85065d98 100644 --- a/test/testautomation_joystick.c +++ b/test/testautomation_joystick.c @@ -29,8 +29,8 @@ static int SDLCALL TestVirtualJoystick(void *arg) SDL_INIT_INTERFACE(&desc); desc.type = SDL_JOYSTICK_TYPE_GAMEPAD; - desc.naxes = SDL_GAMEPAD_AXIS_MAX; - desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX; + desc.naxes = SDL_GAMEPAD_AXIS_COUNT; + desc.nbuttons = SDL_GAMEPAD_BUTTON_COUNT; desc.vendor_id = USB_VENDOR_NVIDIA; desc.product_id = USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104; desc.name = "Virtual NVIDIA SHIELD Controller"; diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c index c0fd49650..be4f1be9d 100644 --- a/test/testautomation_keyboard.c +++ b/test/testautomation_keyboard.c @@ -223,7 +223,7 @@ static int SDLCALL keyboard_getScancodeNameNegative(void *arg) SDLTest_AssertPass("Call to SDL_ClearError()"); /* Out-of-bounds scancode */ - scancode = (SDL_Scancode)SDL_NUM_SCANCODES; + scancode = (SDL_Scancode)SDL_SCANCODE_COUNT; result = SDL_GetScancodeName(scancode); SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode); SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL"); diff --git a/test/testcontroller.c b/test/testcontroller.c index ff34524c3..ac6369036 100644 --- a/test/testcontroller.c +++ b/test/testcontroller.c @@ -479,8 +479,8 @@ static void CommitBindingElement(const char *binding, SDL_bool force) /* If the controller generates multiple events for a single element, pick the best one */ if (!force && binding_advance_time) { char *current = GetElementBinding(mapping, binding_element); - SDL_bool native_button = (binding_element < SDL_GAMEPAD_BUTTON_MAX); - SDL_bool native_axis = (binding_element >= SDL_GAMEPAD_BUTTON_MAX && + SDL_bool native_button = (binding_element < SDL_GAMEPAD_BUTTON_COUNT); + SDL_bool native_axis = (binding_element >= SDL_GAMEPAD_BUTTON_COUNT && binding_element <= SDL_GAMEPAD_ELEMENT_AXIS_MAX); SDL_bool native_trigger = (binding_element == SDL_GAMEPAD_ELEMENT_AXIS_LEFT_TRIGGER || binding_element == SDL_GAMEPAD_ELEMENT_AXIS_RIGHT_TRIGGER); @@ -1161,8 +1161,8 @@ static void OpenVirtualGamepad(void) SDL_INIT_INTERFACE(&desc); desc.type = SDL_JOYSTICK_TYPE_GAMEPAD; - desc.naxes = SDL_GAMEPAD_AXIS_MAX; - desc.nbuttons = SDL_GAMEPAD_BUTTON_MAX; + desc.naxes = SDL_GAMEPAD_AXIS_COUNT; + desc.nbuttons = SDL_GAMEPAD_BUTTON_COUNT; desc.ntouchpads = 1; desc.touchpads = &virtual_touchpad; desc.nsensors = 1; @@ -1269,7 +1269,7 @@ static void VirtualGamepadMouseDown(float x, float y) return; } - if (element < SDL_GAMEPAD_BUTTON_MAX) { + if (element < SDL_GAMEPAD_BUTTON_COUNT) { virtual_button_active = (SDL_GamepadButton)element; SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_TRUE); } else { diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index 79cb20cca..b362d148f 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -219,8 +219,8 @@ static SDL_Cursor *init_system_cursor(const char *image[]) static SDLTest_CommonState *state; static int done; -static SDL_Cursor *cursors[3 + SDL_NUM_SYSTEM_CURSORS]; -static SDL_SystemCursor cursor_types[3 + SDL_NUM_SYSTEM_CURSORS]; +static SDL_Cursor *cursors[3 + SDL_SYSTEM_CURSOR_COUNT]; +static SDL_SystemCursor cursor_types[3 + SDL_SYSTEM_CURSOR_COUNT]; static int num_cursors; static int current_cursor; static SDL_bool show_cursor; @@ -437,7 +437,7 @@ int main(int argc, char *argv[]) num_cursors++; } - for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) { + for (i = 0; i < SDL_SYSTEM_CURSOR_COUNT; ++i) { cursor = SDL_CreateSystemCursor((SDL_SystemCursor)i); if (cursor) { cursors[num_cursors] = cursor; diff --git a/test/testkeys.c b/test/testkeys.c index f8a006b12..ede13c887 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } - for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { + for (scancode = 0; scancode < SDL_SCANCODE_COUNT; ++scancode) { SDL_Log("Scancode #%d, \"%s\"\n", scancode, SDL_GetScancodeName(scancode)); } diff --git a/test/testpen.c b/test/testpen.c index 7cdb228ce..bc7dc1c9e 100644 --- a/test/testpen.c +++ b/test/testpen.c @@ -19,7 +19,7 @@ typedef struct Pen { SDL_PenID pen; Uint8 r, g, b; - float axes[SDL_PEN_NUM_AXES]; + float axes[SDL_PEN_AXIS_COUNT]; float x; float y; Uint32 buttons; diff --git a/test/testwm.c b/test/testwm.c index b3fddb283..e6fa65cab 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -43,7 +43,7 @@ static const char *cursorNames[] = { "window bottom left", "window left" }; -SDL_COMPILE_TIME_ASSERT(cursorNames, SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS); +SDL_COMPILE_TIME_ASSERT(cursorNames, SDL_arraysize(cursorNames) == SDL_SYSTEM_CURSOR_COUNT); static int system_cursor = -1; static SDL_Cursor *cursor = NULL; @@ -193,12 +193,12 @@ static void loop(void) } else if (event.key.key == SDLK_LEFT) { --system_cursor; if (system_cursor < 0) { - system_cursor = SDL_NUM_SYSTEM_CURSORS - 1; + system_cursor = SDL_SYSTEM_CURSOR_COUNT - 1; } updateCursor = SDL_TRUE; } else if (event.key.key == SDLK_RIGHT) { ++system_cursor; - if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) { + if (system_cursor >= SDL_SYSTEM_CURSOR_COUNT) { system_cursor = 0; } updateCursor = SDL_TRUE;