From 15b406d652729fb4a7a61b75120fbfbe72aafbbc Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 12 Jul 2026 14:29:58 -0400 Subject: [PATCH 1/2] Add SDL_PhysFS_GetVersion() --- README.md | 3 ++- include/SDL_PhysFS.h | 18 +++++++++++++++++- test/SDL_PhysFS_Test.c | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18de4e3..576cb95 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,13 @@ bool SDL_PhysFS_LoadWAV(const char* filename, SDL_AudioSpec* spec, Uint8** audio void* SDL_PhysFS_LoadFile(const char* filename, size_t* datasize); size_t SDL_PhysFS_WriteFile(const char* file, const void* buffer, size_t size); bool SDL_PhysFS_SetWriteDir(const char* path); -const char* SDL_PhysFS_GetWriteDir(void); +const char* SDL_PhysFS_GetWriteDir(); char** SDL_PhysFS_LoadDirectoryFiles(const char* directory); bool SDL_PhysFS_EnumerateDirectory(const char* path, SDL_EnumerateDirectoryCallback callback, void* userdata); void SDL_PhysFS_FreeDirectoryFiles(char** files); bool SDL_PhysFS_Exists(const char* file); SDL_IOStatus SDL_PhysFS_IOStatus(int error); +int SDL_PhysFS_GetVersion(); // Optional Integrations SDL_Surface* SDL_PhysFS_IMG_Load(const char* filename); // SDL_image diff --git a/include/SDL_PhysFS.h b/include/SDL_PhysFS.h index b85a274..3a76d63 100644 --- a/include/SDL_PhysFS.h +++ b/include/SDL_PhysFS.h @@ -1,5 +1,5 @@ /** - * SDL_PhysFS.h v3.1.0 - PhysFS virtual file system support for SDL. + * SDL_PhysFS.h v3.2.1 - PhysFS virtual file system support for SDL. * * https://github.com/RobLoach/SDL_PhysFS * @@ -36,10 +36,17 @@ #endif #endif +#define SDL_PHYSFS_MAJOR_VERSION 3 +#define SDL_PHYSFS_MINOR_VERSION 2 +#define SDL_PHYSFS_MICRO_VERSION 1 +#define SDL_PHYSFS_VERSION SDL_VERSIONNUM(SDL_PHYSFS_MAJOR_VERSION, SDL_PHYSFS_MINOR_VERSION, SDL_PHYSFS_MICRO_VERSION) +#define SDL_PHYSFS_VERSION_ATLEAST(X, Y, Z) (SDL_PHYSFS_VERSION >= SDL_VERSIONNUM(X, Y, Z)) + #ifdef __cplusplus extern "C" { #endif +SDL_PHYSFS_DEF int SDL_PhysFS_GetVersion(void); SDL_PHYSFS_DEF bool SDL_PhysFS_Init(const char* argv); SDL_PHYSFS_DEF bool SDL_PhysFS_InitEx(const char* argv, const char* org, const char* app); SDL_PHYSFS_DEF bool SDL_PhysFS_Quit(); @@ -183,6 +190,15 @@ static void SDL_PhysFS_AllocatorFree(void* mem) { return free_func(mem); } +/** + * Get the version of SDL_PhysFS that is linked against your program. + * + * @return Returns the version of the linked library. + */ +int SDL_PhysFS_GetVersion(void) { + return SDL_PHYSFS_VERSION; +} + /** * Initialize the PhysFS virtual file system. * diff --git a/test/SDL_PhysFS_Test.c b/test/SDL_PhysFS_Test.c index 535f04b..b5cb405 100644 --- a/test/SDL_PhysFS_Test.c +++ b/test/SDL_PhysFS_Test.c @@ -114,6 +114,9 @@ int main(int argc, char* argv[]) { SDL_assert(SDL_PhysFS_Exists("res/test.bmp") == true); SDL_assert(SDL_PhysFS_Exists("res/notfound.txt") == false); + // SDL_PhysFS_GetVersion + SDL_assert(SDL_PhysFS_GetVersion() > 2); + // SDL_PhysFS_LoadDirectoryFiles { char** files = SDL_PhysFS_LoadDirectoryFiles("res"); From c0c2963db5567f74137f930468bbb424f0fd7a27 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 12 Jul 2026 15:03:53 -0400 Subject: [PATCH 2/2] Add AddGamepadMapping() --- include/SDL_PhysFS.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/SDL_PhysFS.h b/include/SDL_PhysFS.h index 3a76d63..fa39295 100644 --- a/include/SDL_PhysFS.h +++ b/include/SDL_PhysFS.h @@ -126,6 +126,19 @@ SDL_PHYSFS_DEF SDL_IOStream *SDL_PhysFS_OpenIO(PHYSFS_File *handle); #define SDL_PhysFS_TTF_OpenFont(filename, ptsize) (TTF_OpenFontIO(SDL_PhysFS_IOFromFile(filename), true, ptsize)) #endif // SDL_PhysFS_TTF_OpenFont +#ifndef SDL_PhysFS_AddGamepadMappings +/** + * Load a set of gamepad mappings from PhysFS. + * + * @param filename A const char* representing the file to load from PhysFS. + * + * @return Returns the number of mappings added or -1 on failure; call SDL_GetError() for more information. + * + * @see https://wiki.libsdl.org/SDL3/SDL_AddGamepadMappingsFromIO + */ +#define SDL_PhysFS_AddGamepadMappings(filename) (SDL_AddGamepadMappingsFromIO(SDL_PhysFS_IOFromFile(filename), true)) +#endif // SDL_PhysFS_AddGamepadMappings + #ifdef __cplusplus } #endif