-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BACKENDS: Add SDL3 backend + update imgui #6312
base: master
Are you sure you want to change the base?
Conversation
Since there are a lot of repeated |
Thanks for your advice. Here is an example with static functions: Before: #if SDL_VERSION_ATLEAST(3, 0, 0)
if (!SDL_AddGamepadMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()))
#else
if (SDL_GameControllerAddMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()) < 0)
#endif
error("File %s not valid: %s", file.getPath().toString(Common::Path::kNativeSeparator).c_str(), SDL_GetError()); After with static functions: static bool gameControllerAddMappingsFromFile(const char *file) {
#if SDL_VERSION_ATLEAST(3, 0, 0)
return SDL_AddGamepadMappingsFromFile(file);
#else
return SDL_GameControllerAddMappingsFromFile(file) >= 0;
#endif
}
...
if (!gameControllerAddMappingsFromFile(file.getPath().toString(Common::Path::kNativeSeparator).c_str()))
error("File %s not valid: %s", file.getPath().toString(Common::Path::kNativeSeparator).c_str(), SDL_GetError());
|
Regarding the imgui update, did you add the files from the matching git commit as rest of the code? |
Yes I used the commit ocornut/imgui@cb16568 corresponding to the tag https://github.com/ocornut/imgui/releases/tag/v1.91.3 About this, I see that there is a |
Tell me if it's OK now or did you think something different? |
26a395e
to
117ab44
Compare
|
d0f76eb
to
fbd5a5a
Compare
I updated the patch file, but I have a lot more changes than the previous one, can you have a look @sev- please? |
There is no definite answer here... use whatever makes the code easier to read and maintain. From the three options you provided:
So, from the options above, we could either use a C-style implementation (static wrapper functions) or a C++-style implementation (different class per SDL version, inherited from a common parent class, with member functions). I personally like the C++ approach better, but function wrappers would also work just fine :) |
I made my choice already, sorry I'm not a huge fan of inheritance and I don't see the benefit of creating 1 class by version. |
That's fine :) Nice implementation! |
Thank you for looking into this! I wanted to give it a try on Mingw64, and currently it seems that Win32 isn't fully supported yet:
I quickly went through the release notes and indeed it looks like |
That's nice of you, thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Colossal work, thank you!
Have number of comments, mainly on formatting and suggestion to add more wrappers.
I am concerned that the code now becomes much harder to maintain with this amount of ifdefs
, so maybe splitting files/adding more wrappers could make it easier to read and less fragile?
backends/events/sdl/sdl-events.cpp
Outdated
@@ -46,13 +50,133 @@ static uint32 convUTF8ToUTF32(const char *src) { | |||
Common::U32String u32(src); | |||
return u32[0]; | |||
} | |||
#endif | |||
|
|||
#if SDL_VERSION_ATLEAST(3, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the number of ifdefs, wouldn't it be easier to split this file into three, e.g.
sdl#-events.cpp:
#if SDL_VERSION(ATLEAST(3,0,0)
... all the contents
then sdl2-events.cpp
and finally sdl-common-events.cpp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you had in mind?
Sorry I've been sick for a few days, as soon as I feel better I'll take care of it. |
This PR modifies the current SDL backend to add SDL3 support.
There are a lot of combinations so don't hesitate to read it carefully and/or test it.
I didn't test the SDL3_net library.
This is the first time I modify the configure file, so have a look and tell me if I need to do some changes (I'm sure you will ;)).
And maybe the way I handled all the
#ifdef
are not at your taste, so feel free to give some advice.To do this PR I used these recommendations: https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md and of course https://wiki.libsdl.org/SDL3/CategoryAPI