Skip to content

Conversation

@icculus
Copy link
Collaborator

@icculus icculus commented Nov 19, 2025

Now everything will attempt to track pens through proximity changes (instead of removing the pen entirely). testpen.c has been updated to reflect this.

Some platforms and devices are better at this than others, but this seems like a significant usability improvement across the board.

This PR has not been tested on anything but X11, do not merge yet!

Fixes #12992.

Now everything will attempt to track pens through proximity changes (instead
of removing the pen entirely). testpen.c has been updated to reflect this.

Some platforms and devices are better at this than others, but this seems like
a significant usability improvement across the board.

Fixes libsdl-org#12992.
@icculus icculus force-pushed the sdl3-pen-proximity-improvements branch from 3b572dc to 00b233e Compare November 19, 2025 19:03
@icculus
Copy link
Collaborator Author

icculus commented Nov 19, 2025

X11 confirmed, Wayland confirmed (and pen button input fixed, too). iOS didn't change in any significant way, so we'll call that confirmed.

Still waiting: Windows, Emscripten, Android, macOS.

@icculus
Copy link
Collaborator Author

icculus commented Nov 19, 2025

Windows and Emscripten both seem to give you a new pointer ID every time you come into proximity; can't do anything with that. Allegedly WinTab can actually handle proximity, but we don't have support for it at the moment. Emscripten is probably a loss...it might make sense to just assume there's only one pen there and treat the pointer exits as proximity-outs on a single device. I don't know.

@icculus
Copy link
Collaborator Author

icculus commented Nov 19, 2025

It's also possible these incrementing IDs are "this is a single identifiable touch, so you can track it, and not intended to be a pen (or finger) that comes and goes." There might be a better piece of information, I'll have to check.

@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Yeah, looks like the IDs are for a single touch (or rather, interaction, because a hovering pen that hasn't left the window or proximity will keep the same ID).

Win32's GetPointerPenInfo() returns a struct with a sourceDevice handle, which is probably unique per-tablet, but wouldn't help if you have a tablet that supports multiple pens. I give up, honestly who is using two pens at once anyhow?

On Windows, and Emscripten, we're just going to say there's a single pen device, like how you might have 30 USB mice plugged in but you only get events from one logical mouse. Then we can at least fake proximity, sort of.

@maia-s
Copy link
Contributor

maia-s commented Nov 20, 2025

honestly who is using two pens at once anyhow?

Not at once, but some drawing tablets support multiple pens, and drawing apps use that to automatically select the current tool. On Wacom tablets for example, the eraser end of the pen is logically a different pen, so that when you flip the pen around to use the eraser end, the drawing app automatically switches to the eraser tool. Each pen has their own current tool.

This "fixes" proximity but limits you to a single pen device. But this is
probably okay for most reasonable use cases.
@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Not at once, but some drawing tablets support multiple pens, and drawing apps use that to automatically select the current tool.

Microsoft should have provided a better API. 🤷‍♀️

On Wacom tablets for example, the eraser end of the pen is logically a different pen,

We do report if the pen is inverted (eraser side is being used). I don't have a tablet that supports this to test it myself, but the code for that is wired up for Windows.

It's becoming more apparent, though, that we're going to need a WinTab code path to really get all the functionality exposed, which is super-annoying. The existing Windows code, using WM_POINTER* events, is maybe "good enough" but far from perfect.

@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Latest commit makes all Windows pen events act like one system pen, so proximity events work more closely like you'd expect them to (but see my previous comments about adding WinTab support, which has an actual proximity event. Probably not for 3.4.0).

Same deal as the current Windows code: this "fixes" proximity but limits you
to a single pen device. But this is probably okay for most reasonable use
cases.
@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Emscripten is sorted out. Moving on to Cocoa.

@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Cocoa is good to go. I'm probably not testing Android; if it's broken, people can send a bug report. :P

@icculus icculus marked this pull request as ready for review November 20, 2025 22:02
@icculus
Copy link
Collaborator Author

icculus commented Nov 20, 2025

Docs are updated, all the builders are passing (and presumably still are passing after this documentation commit), so this can merge whenever.

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.

SDL3 Pen: Confusing pen proximity api

2 participants