AppKit: Add tablet tool support#4593
Conversation
kchibisov
left a comment
There was a problem hiding this comment.
Just by looking into docs for tablet, it seems that tablet events has a property of
NSTabletPointEventSubtype or NSTabletPoint
Also, how handling works if you hover with tablet over window and also use mouse? is mouse treated as tablet in such case?
|
Thank you for the review!
Good catch and yeah I needed to change something. Firstly this is an edge case and I think relatively minor. But still I think this is kind of a bummer so I put it in the edited main comment as well. I changed it to kind=unknown for now, because that seems to be the only 100% correct option and winit is a foundation library. Besides
Right, and I think we need the subtype one here. The tablet NSEvents look the same as mouse events if you only look at .type (NSEventType) but the .subtype field (NSEventSubtype) has the tablet details we want - whether it's:
The . Inline comments addressedI also addressed the inline comments. The device-type chain is now a match, and the button mapping is extracted into a Appendix - just extra info if it helpsHere are summarized logs of
|
Add support to winit-appkit for tablet tools (pen/eraser) with rich inputs like pressure and tilt.
/begin Edit: (explain the issues with accessing data )
Apple's implementation has two difficulties we need to work around. The first is limited acccess to information about whether the event is from a tablet or a mouse (
NSEvent.subtype), and the second is limited access information about kind of pointer tool created the event (NSEvent.pointingdevicetype).So mouse_enter and mouse_exit have to be
unknownpointer type in appkit.So we keep that information cached in the ViewState.
/end edit
Tilt gets converted from -1,1 to -90,90.
yis negated, since AppKit is y-up and winit documents positive y as toward the user.Tested with a toy app that tracks a Wacom tablet pressure (sphere size) and tilt (the vector)
changelogmodule if knowledge of this change could be valuable to users