-
Notifications
You must be signed in to change notification settings - Fork 920
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
Pointer API Sketch #3001
Pointer API Sketch #3001
Conversation
I don't think we need all these different types, I think having one enum that can either be Generally speaking I'm in favor of unifying all three into one event though, it also fits well with the Pointer API on Web. |
The reason I went with the extra types is some states don't make sense. For example, a |
Yeah, you are right, maybe these types made sense after all? Let's wait for more input. |
There was an attempt to do it here #1374 before. |
I don't think I like splitting up all the information in separate events, but it makes remove the mess of having so many different types. |
Some thoughts and questions while designing this version:
(I didn't bother updating the wayland implementation, there's not really any point right now) |
I think that's #2942, so no, it's not necessary for a first implementation.
We don't currently support twist/angle/rotation, so I would argue we can leave this for another PR.
I can't really comment on that, I only maintain the Web backend where this doesn't happen, but I think we can figure that out when we get to the implementation phase.
in #1374
Depends on what exactly this would entail but it doesn't sound very appealing to me, in any case, I think this is a separate problem we can figure out outside this PR.
Probably not a bad idea, again though, imo we can figure this out later, cc #2963.
I think this is really over-complicating it. Maintainers just have to make a decision here. @kchibisov I would strongly prefer to send as much information as possible in a single event instead of splitting it up like #1374 did. So I prefer the original implementation of @0x182d4454fb211940: 71125f9. Hopefully we can clean this up a bit to reduce the amount of types, but that's what I would currently prefer, WDYT?
Don't waste your time on it, we can figure it out after we finish the design phase. |
So in the meantime I've made a rough fork of winit and bevy to start working on my project. What worked there has given me another potential idea: splitting the data from the event. let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
match event {
Event::WindowEvent {
event: WindowEvent::PointerDown(PointerId::Pen(id)),
..
} => {
println!("pen is down, with pressure of {}", window.pen(id).pressure.unwrap_or(f64::NAN));
},
Event::WindowEvent {
event: WindowEvent::PointerDown(PointerId::Mouse(id)),
..
} if window.mouse(id).just_pressed(MouseButton::Left) => {
println!("you just clicked at {:?}", window.mouse(id).position());
},
Event::WindowEvent {
event: WindowEvent::PointerUp(id),
..
} => {
println!("pointer {id:?} just lost contact with the screen at {:?}", window.pointer(id).position());
},
/* snip */
}
}); This is quite radically different from how winit currently does things, and I'm not sure if this is better (it would either require something which pre-processes events or some kind of cross-module interior mutability). But it does solve the problem of representing attached data correctly (in order to access the extra data, you need to use the id with the correct type), and would also mean that someone who wants to check if the user clicked in a certain area, they could just access the mouses position alongside the event. I've found a similar (integrated with bevy) approach to work quite well for my project. |
See #3876. |
CHANGELOG.md
if knowledge of this change could be valuable to users (No)This is a very rough sketch of what a pointer-based API could look like (based on #336). Personally I'm interested in moving winit towards an API that can support pen input, which is why I'm interested in this, and I'm willing to help implement it. But I'd like to make sure the WindowEvent API matches what the winit team wants and what would be useful and ergonomic for the user, so please let me know your thoughts!
It's worth noting that by heading in this direction we will be breaking apps which already use cursor and touch events. Would it be better to just add a "pen" event like with touch?