-
Notifications
You must be signed in to change notification settings - Fork 902
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
implement pen for X11 #2647
base: master
Are you sure you want to change the base?
implement pen for X11 #2647
Conversation
pen data shouldn't be merged with touch imo as it will complicate the touch events much. pen tablets are different from mouses and touchscreens in many ways, and they deserve their own event types. also, events can be easily combined on the app side if developers want to treat pen events as touches i did some experiments about basic wayland pen support before. it starts to work inside the client area, but the default window decor doesn't respond to pen events :( . seems like a sctk issue, not sure though |
/// The clockwise rotation of the pointer normalized in a range of 0 to 359. | ||
/// Defaults to 0 if not available on platform. | ||
pub rotation: f64, | ||
/// The angle of tilt of the pointer in a range of -90 to +90 for each axis, | ||
/// with a positive value indicating a tilt to the right or towards the user. | ||
/// Defaults to (0, 0) if not available on platform. | ||
pub tilt: (f64, f64), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem to be in degrees, probably best to explicitly mention that.
Any updates? |
@Bloeckchengrafik I was not really happy with gluing everything onto the touch event, and I haven't really had the time to work on that since. I do plan on building an app with pen support, but I can't say if and when that will happen. |
@kchibisov @madsmtm @daxpedda Do we have a plan-of-attack for pen events like this? I think that other platforms have concepts of this type of event as well. |
Not yet, but we'd need to decide whether we emulate internally certain things or we just don't try to use tablet when it's not present. |
Implementing pen events for Web would be simple, everything is already in place to add it. |
Issue: #99
CHANGELOG.md
if knowledge of this change could be valuable to usersI ported my previous pen work (#1879) over to the API from Android/Windows PR (#2396).
Though I have a couple of concerns with that API. I'm not sure if it is best to add the pen pressure on top of the normal touch event. I think an application developer would want to treat pens and touches quite differently. For example, you probably don't want a pinch-to-zoom gesture with one finger and the pen. Though I can also see that if the pen is the sole input, you would also treat it as a touch.
It also seems we break the "contract" of the touch phase, because we need to emit move emits between stop and start when the pen is hovering over the screen.
We could also simplify Touch event by putting
pen_state
intoforce
. The unsupported values can just be set to a sensible default.Note, the Apple Pencil 2 also supports hovering and has a button, so the additional
PenState
variable could probably be filled for that as well. Though I'm not an apple developer.It is also not clear to me what the difference between
SharedState
and putting state into theEventProcessor
struct directly. Specifically, where should I put thePenStatus
struct?I'm also not sure which button to map to
barrel
anderaser
. My pen has two side buttons, I mapped the lower to the eraser. Maybe if someone's pen has an actual eraser, they could comment to which button X11 maps that.Lastly, I would also like to have pen support on wayland, but right now seems an inopportune time to implement that since SCTK is currently being rewritten from scratch, so I don't want to spend much effort on adding pen support to the current version, which is used by winit. It also seems like a lot of work to port winit to the new version of SCTK since its API changes significantly.