Skip to content
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: SDL3 Rename QUOTE and BACKQUOTE to APOSTROPHE and GRAVE #7580

Closed
wants to merge 1 commit into from

Conversation

kuvaus
Copy link
Contributor

@kuvaus kuvaus commented May 14, 2024

Motivation

Currently building Dear ImGui with newest SDL3 cloned from SDL3 github fails because libsdl-org/SDL#9774 just got merged. That PR changed the APOSTROPHE and GRAVE keys as per SDL_Keycode:

#define SDLK_APOSTROPHE  '\''
#define SDLK_GRAVE  '`'

What this PR does

This tiny PR fixes the two keys by changing QUOTE and BACKQUOTE in imgui_impl_sdl3.cpp

        case SDLK_QUOTE: return ImGuiKey_Apostrophe;
        case SDLK_BACKQUOTE: return ImGuiKey_GraveAccent;

to APOSTROPHE and GRAVE

        case SDLK_APOSTROPHE: return ImGuiKey_Apostrophe;
        case SDLK_GRAVE: return ImGuiKey_GraveAccent;

Result

Before this PR I get two compilation errors (below) but after making above changes the errors are fixed.

imgui_impl_sdl3.cpp:148:14: error: use of undeclared identifier 'SDLK_QUOTE_renamed_SDLK_APOSTROPHE'
        case SDLK_QUOTE: return ImGuiKey_Apostrophe;
             ^
imgui_impl_sdl3.cpp:158:14: error: use of undeclared identifier 'SDLK_BACKQUOTE_renamed_SDLK_GRAVE'
        case SDLK_BACKQUOTE: return ImGuiKey_GraveAccent;
             ^
1 warning and 2 errors generated.

Note

Warning

It might be useful to postpone merging this PR until SDL 3.1.3 Preview is released.

I don't think these key changes were included in 3.1.2 Preview since they were only just merged on the SDL3 github repo. But I hope this PR is at least little bit useful for those that clone SDL3 from github and in the future when SDL 3.1.3 is officially released.

@ocornut
Copy link
Owner

ocornut commented May 14, 2024

Thank you.

I am often a bit confused by their handing backward compatibility for intermediate versions:

  • You have to dig to find SDL_Version.h to find which versions of header you are using (vs in dear imgui full version data appear near the top of imgui.h AND every other source file has a simplified version number at the top).
  • Breaking changes this like one (libsdl-org/SDL@94cbaaa) aren't immediately tagged with a micro version increment, making it difficult to support intermediate, home built versions. Given SDL3 development status I would assume a lots of people are pulling SDL3 from sources and affected. A vast majority of minor breaking changes, new features, or behavioral changes in dear imgui immediately increasing IMGUI_VERSION_NUM to allow for checks.

@ocornut
Copy link
Owner

ocornut commented May 14, 2024

It turns out that I made a proposal to SDL following this, and they seems to be tempted by it:
libsdl-org/SDL#9788
libsdl-org/SDL#9790

Copy link
Contributor

@Green-Sky Green-Sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to postpone merging this PR until SDL 3.1.3 Preview is released.

No. They where very preview, so imgui master should follow sdl master.

ocornut pushed a commit that referenced this pull request May 15, 2024
@ocornut
Copy link
Owner

ocornut commented May 15, 2024

Merged e45efa9 + 93daf23, thank you!

@ocornut ocornut closed this May 15, 2024
ocornut pushed a commit that referenced this pull request May 15, 2024
@Green-Sky
Copy link
Contributor

To clarify a little bit more: there is no sdl3 release to be backwards compatible with yet.

@ocornut
Copy link
Owner

ocornut commented May 15, 2024

I don't fully agree IMHO
https://github.com/libsdl-org/SDL/releases/tag/prerelease-3.1.2 is a release to be backwards compatible with, in the sense that users of 3.1.2 grabbed a zip, asking them to pull and build from sources is requesting them to change their integration (rather than just "update").

@adrian-purser
Copy link

Hi, can we get this fix in the docking branch as well please.

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

Successfully merging this pull request may close these issues.

None yet

4 participants