Skip to content

Added SDL3 Checks To Imgui To Fix Clipboard And Typing #867

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

aardv4rk
Copy link
Contributor

@aardv4rk aardv4rk commented Mar 8, 2025

Small PR that adds a few try/catches to swap SDL2 calls with SDL3 for developers on newer FNA since the full swap to SDL3, whilst retaining original functionality.

This in specific addresses an issue with typing, as SDL3 changed the default behaviour to turn on/off typing, in addition fixing the clipboard to use the proper SDL methods.

@stallratte
Copy link
Contributor

Hey @aardv4rk,

I looked at the code changes. Currently this won't compile for monogame users. (Nez.MG38.ImGui.csproj)
All the FNA specific code should be in FNA preprocessor directive sections.
E.g.:

I think it may be possible to get rid of _isSdl3-Attribute all together.
There's a chance calling TextInputEXT.StartTextInput(); won't have any negative impact on FNA users still depending on SDL2. Maybe someone on discord still using SDL2 would be interested to test it?

@aardv4rk
Copy link
Contributor Author

aardv4rk commented Mar 10, 2025

@stallratte Good call. I've actually just now I managed to test the SDL2 implementation using Environment.SetEnvironmentVariable("FNA_PLATFORM_BACKEND", "SDL2"); at the top of my Main method, replacing the fnalibs with older SDL2 ones, and removing the SDL3 check, and the logic within CheckForTextInput doesn't seem to have any negative impacts, but I'll try to get more testing on it just in case.

Regarding the FNA preprocessor directives; I've not had experience with Monogame in some time. Does the whole SDL3 thing not exist over there? If so, I can wrap the crux of the fix in CheckForTextInput in an FNA preprocessor directive so it's just an empty method for Monogame.

@stallratte
Copy link
Contributor

Regarding the FNA preprocessor directives; I've not had experience with Monogame in some time. Does the whole SDL3 thing not exist over there?

FNA provides custom wrappers for SDL2 and SDL3. They don't exist in monogame. Also 'TextInputEXT' is a FNA exclusive extension.
Here you can see the differences:
fna_monogame

- moved UpdateTextInput to sEtup & Update region
- removed isSdl3 bool
- Wrapped UpdateTextInput contents in FNA directive
@aardv4rk
Copy link
Contributor Author

@stallratte Makes sense!

@stallratte
Copy link
Contributor

@aardv4rk I think your changes are really good now.
Tested it with monogame: Works perfectly fine.
And input in ImGUI is finally also working with FNA + SDL3. 👍

@aardv4rk
Copy link
Contributor Author

Thank you for the help with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants