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

implement pen for X11 #2647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DorianRudolph
Copy link

Issue: #99

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

I 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 into force. 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 the EventProcessor struct directly. Specifically, where should I put the PenStatus struct?

I'm also not sure which button to map to barrel and eraser. 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.

@lictex
Copy link

lictex commented Jan 24, 2023

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

Comment on lines +996 to +1002
/// 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),
Copy link
Contributor

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.

@Bloeckchengrafik
Copy link

Any updates?

@DorianRudolph
Copy link
Author

@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.

@notgull
Copy link
Member

notgull commented Nov 14, 2023

@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.

@kchibisov
Copy link
Member

Do we have a plan-of-attack for pen events like this?

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.

@daxpedda
Copy link
Member

Implementing pen events for Web would be simple, everything is already in place to add it.

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

Successfully merging this pull request may close these issues.

8 participants