Skip to content

Touch input for SDL2 - #2650

Open
nkast wants to merge 1 commit into
mainfrom
SDL2Touch
Open

Touch input for SDL2#2650
nkast wants to merge 1 commit into
mainfrom
SDL2Touch

Conversation

@nkast

@nkast nkast commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

This implements Touch input for the SDL2 backend.

In order to prevent Touches to appear as Mouse input, we now use SDL_GetMouseState instead of https://wiki.libsdl.org/SDL2/SDL_GetGlobalMouseState, which change the behavior of Mouse.GetState().

  • Mouse input doesn't escape the Window bounds. This makes windowed mode behave more like a fullscreen mode. This is also how touch input is implemented in this PR and on the WinForms backend. Touch outside the window are released.
  • We lost the ability to query up to date mouse position, because GetMouseState is updated during the event pump.
  • docs report that GetGlobalMouseState was less efficient.
  • The change could fix a reported bug on linux/hyprland.

related to #2619
closes #2603
resolves #2562

@squarebananas

squarebananas commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Mouse input doesn't escape the Window bounds.

That differs quite differently in behavior compared to other platforms. Wouldn't that mean in windowed mode:

  • Custom game cursors get stuck on the window edge rather than leave the window as expected.
  • 3d camera controls where you drag the mouse to move the camera around would seem glitchy if the mouse leaves the window.
  • If the user places a custom scroll bar against a side of a window edge, momentarily moving slightly outside the window while dragging the scroll element would stop input updates occurring.

# Conflicts:
#	Platforms/Game/.SDL2/SDLGameWindow.cs
#	Platforms/Input/.SDL2/ConcreteMouse.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants