-
Notifications
You must be signed in to change notification settings - Fork 1.1k
winit-core:winit: add tablet input support #4318
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
Conversation
3e5cbff
to
d37dc28
Compare
@wareya Hi, would you mind to look into this wrt Windows stuff? I've did some basic testing(qemu + usb passthrough), and it kind of works. Though, there's an issue with button not being registered, if you 1. press a button, 2. touch surface, 3. lift pen 4. release the button. This sequence results only in 3 button events and not sure that anything can be done here (we don't get more messages from windows). |
Thanks for the ping, I'll try to take a look soon! |
As for the API. Do we really need I'd also go forward with adding new types to ensure the boundaries of the values instead of writing those boundaries in docs. |
Morally, yes, because applications may need to synthesize tilt if it's not actually supported. But in practice a lot of hardware or drivers will report having tilt but then always report a dummy value, so it might actually be misleading. Either you go with Option and document that some systems falsely report Some even when there's no real data, or you go with bare tilt and document that the application needs to watch for changes in the value to see if it's supported. (The same is true of azimuth/altitude, by the way!) |
The thing is that on win32/wayland/etc it seems like there's only tilt and you synth the other one. Though, I haven't looked into what macOS delivers actually. The thing is that my tablet doesn't support |
Yep, this is the main problem. I guess winit could track tilt over time and look for changes for a given pointer, and only start reporting it as Some if it ever changes...? But that's oddly high-level behavior for a windowing library, maybe. |
The thing is that windows reports |
Initial notes after poking around for a few minutes on windows (in a slightly modified version of #4219):
|
it is not there, yes. I also think that probably should. But also, at the same time, I'm not against adding though.
I'd suggest to check events that are coming, but generally, it seems like a button state. Seems like due to how you setup git. |
I'm trying to think through this: if my application ignores inputs until it sees a button press, it'll be lacking tilt info until the first move event after the button press. If my application is trying to do something like "rotate 3d object to specific orientation when you press on it with the pen", it shouldn't have to wait for a movement event after the button press to be able to do that, I think. As another example, a painting program that works by splatting oriented copies of a brush image onto the canvas, which for some reason also ignores all the data from the pen until it's pressed onto the the screen, may have the first splat use the wrong orientation. |
I have the same remarks as I did back here #2396 (comment) for the window backend. That boils down to
3 - I'll try to setup things to retest on my side (on surface official drivers). Having a somewhat state-less API (send button presses/releases) 4 - Yes this is git config, do a Another issue: is the event a button AND position or one XOR the other? I don't think it's great if that's an exclusive as you'd totally lose the first pen position on the screen (chances are the BARREL signal is sent at the same exact time because of the lack of this information on hover)
When are these 3 events sent? Do you get a pen down/up + a release on lifting the pen? My guess is that it's related to Win32 API limitations (hence my suggestion to use the WinRT one) |
Re: precision: the way tablet pens communicate auxiliary data like pressure and tilt to the digitizer is so noisy that 1024 levels is easily far more than enough. 8k pressure levels is basically marketing snake oil. Re: button vs position: yes, absolutely, for tablets in particular it's very important for the user to get all the position data and auxiliary data in the same event as whatever event they get button press changes in. I'm not sure why this is the way that it is. Re: WinRT: Do you mean RealTimeStylus, or the "Inking" API, or something else? RealTimeStylus is meant for handwriting-related stuff and is buggy for anything else, while the "Inking" API adds a whole lot of abstractions that are problematic for graphics program use (it has its own canvas context and stroke management system etc), and IIRC it's annoying to use from not-C#. Firefox uses WM_POINTER events (like this PR does) because of these problems. |
WinRT : I mean using this method from the windows rust crate https://microsoft.github.io/windows-docs-rs/doc/windows/UI/Input/struct.PointerPoint.html#method.GetCurrentPoint |
I thiiink that one's probably connected to the same system as WM_POINTER, but I don't know if it's a wrapper around WM_POINTER or an alternative API to the same data. If it is part of the same system as WM_POINTER like I think then it should be safe? But if the data is mostly the same and it's just a different API, it could probably be a later refactoring thing. |
This matches what I've observed, but it's partially true, since it only breaks if you "mix" button presses release/press sequences. See example I've provided, since I've tried to test that.
as you can see I think you can not mix |
Seems it can be done and I've succeeded in making it work. Get the pen event and pointer id from For the button press/release mixes, I can't reproduce getting 3 on my side, but I can get the barrel press/contact release situation (and nothing sent on hover). |
Yeah, I count |
d37dc28
to
93b3fa0
Compare
Added the tool data to the |
I wonder if we should just derive |
93b3fa0
to
c8c54c3
Compare
c8c54c3
to
6d11fb7
Compare
The API is integrated into the `WindowEvent::Pointer*` API and is present in form of `TabletTool` variant on corresponding data entries. For now implemented for Web, Windows, and with limitations for Wayland. Fixes #99.
6d11fb7
to
1e5dc2e
Compare
The API is integrated into the
WindowEvent::Pointer*
API and is present in form ofTabletTool
variant on corresponding data entries.For now implemented for Web, Windows, and with limitations for Wayland.
Replaces #3810 and #4287.