Skip to content

Expose backend event handling features#42

Open
Demorome wants to merge 2 commits intoMoonsideGames:mainfrom
Demorome:expose-backend-event-handling
Open

Expose backend event handling features#42
Demorome wants to merge 2 commits intoMoonsideGames:mainfrom
Demorome:expose-backend-event-handling

Conversation

@Demorome
Copy link
Contributor

@Demorome Demorome commented Jan 13, 2026

This is mostly so anyone can easily use the ImGui SDL_GPU backend's ProcessEvents to automatically handle all SDL events.

For example, my OnReceiveEvent callback currently looks like:

    private unsafe void ProcessEvents(SDL.SDL_Event e)
    {
        ImGuiImplSDL3.ProcessEvent((ImSDLEvent*)&e);

        // Prevent editor-captured inputs from leaking over into the game.
        var io = ImGui.GetIO();
        Game.PreventKeyboardInputs = io.WantCaptureKeyboard;
        Game.PreventMouseInputs = io.WantCaptureMouse;
    }

(Using the Hexa ImGui C# port for the ImGui SDL_GPU backend).

@Demorome Demorome marked this pull request as draft January 17, 2026 03:39
@Demorome
Copy link
Contributor Author

Marking this as a draft, since I found an issue with my implementation for the Prevent(...)Inputs option:

If an input was pressed and PreventInputs is switched on, then later switched off, it might discard the input-released event and leave the input in a pressed-down state, at least until the button is re-pressed and let go.

@Demorome Demorome marked this pull request as ready for review January 17, 2026 07:02
@Demorome
Copy link
Contributor Author

Demorome commented Jan 17, 2026

The fix I went with was to just constantly set buttons as non-pressed and deltas to 0 while inputs are prevented.

I could do a cached bool check to prevent redundant changes but that didn't seem necessary.

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.

1 participant

Comments