From 37c9fb490ef12f9ec8d3abfdedb2bc33117eca21 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 11 Sep 2024 08:08:18 -0700
Subject: [PATCH] Changed enums to use XXX_COUNT for the count or number of
values
Fixes https://github.com/libsdl-org/SDL/issues/10763
---
build-scripts/SDL_migration.cocci | 20 +++++-
docs/README-migration.md | 12 +++-
include/SDL3/SDL_filesystem.h | 72 +++++++++-------------
include/SDL3/SDL_gamepad.h | 6 +-
include/SDL3/SDL_joystick.h | 3 +-
include/SDL3/SDL_log.h | 2 +-
include/SDL3/SDL_messagebox.h | 4 +-
include/SDL3/SDL_mouse.h | 2 +-
include/SDL3/SDL_oldnames.h | 12 ++++
include/SDL3/SDL_pen.h | 2 +-
include/SDL3/SDL_scancode.h | 4 +-
src/SDL_log.c | 20 +++---
src/core/android/SDL_android.c | 4 +-
src/core/openbsd/SDL_wscons_kbd.c | 2 +-
src/events/SDL_events.c | 2 +-
src/events/SDL_keyboard.c | 14 ++---
src/events/SDL_keymap.c | 8 +--
src/events/SDL_pen.c | 10 +--
src/filesystem/SDL_filesystem.c | 2 +-
src/joystick/SDL_gamepad.c | 16 ++---
src/joystick/hidapi/SDL_hidapi_gamecube.c | 34 +++++-----
src/joystick/hidapi/SDL_hidapi_luna.c | 2 +-
src/joystick/hidapi/SDL_hidapi_ps4.c | 2 +-
src/joystick/hidapi/SDL_hidapi_ps5.c | 2 +-
src/joystick/hidapi/SDL_hidapi_shield.c | 4 +-
src/joystick/hidapi/SDL_hidapi_stadia.c | 2 +-
src/joystick/hidapi/SDL_hidapi_steam.c | 2 +-
src/joystick/hidapi/SDL_hidapi_steamdeck.c | 2 +-
src/joystick/hidapi/SDL_hidapi_switch.c | 2 +-
src/joystick/hidapi/SDL_hidapi_wii.c | 2 +-
src/joystick/hidapi/SDL_hidapi_xbox360.c | 2 +-
src/joystick/hidapi/SDL_hidapi_xbox360w.c | 2 +-
src/joystick/hidapi/SDL_hidapi_xboxone.c | 2 +-
src/joystick/virtual/SDL_virtualjoystick.c | 2 +-
src/video/wayland/SDL_waylandevents.c | 4 +-
src/video/x11/SDL_x11messagebox.c | 6 +-
src/video/x11/SDL_x11mouse.c | 2 +-
src/video/x11/SDL_x11pen.c | 8 +--
src/video/x11/SDL_x11pen.h | 8 +--
src/video/x11/SDL_x11xinput2.c | 2 +-
test/gamepadutils.c | 28 ++++-----
test/gamepadutils.h | 2 +-
test/testautomation_joystick.c | 4 +-
test/testautomation_keyboard.c | 2 +-
test/testcontroller.c | 10 +--
test/testcustomcursor.c | 6 +-
test/testkeys.c | 2 +-
test/testpen.c | 2 +-
test/testwm.c | 6 +-
49 files changed, 197 insertions(+), 174 deletions(-)
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index f5b9554ba3076..145760f339927 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 e4de4e14555ad..2a303c2fa52f4 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 553f56b6c06f1..0afe3cb744ba0 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 450261b081e65..5ba2f8b5ba6d3 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 1d6351ffe2f86..7c043090dee8e 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 0a5379633cf19..e098af3319ac6 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 c626b22835ed3..bae603cd847d4 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 71e2b685ca6e1..4d870b6528536 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 de5e69842cd6f..9cb1324532fc0 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 ebb08dc47f992..e939cab2b1a97 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 ccf8bb5f79daa..16fb2a82835ac 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 d3f03445bfd9b..9f78a6c6a18c0 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 2a8e310bac0be..e24eaea13c73d 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 9dcf94df0e192..281d2eca252eb 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 f5d37e097d652..161a52f6f3bf8 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 b1636c7e1225b..3ba9da7ecb274 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 dc1b31177cf55..644688698f5e6 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 819946ba4b538..63d1c975e438d 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 5b16a4e1f8734..775c9f8524413 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 732f0796a58fa..f1ed38e953ca1 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) ==
(Patch may be truncated, please check the link at the top of this post.)