rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.76k stars 892 forks source link

Winit apple pen #3763

Closed ActuallyHappening closed 3 months ago

ActuallyHappening commented 3 months ago

Implements #3759 Also see #99

I split the implementation and documentation into seperate commits, because I don't know if for the branch I am targeting the way I have updated the change-log is valid and expect to be corrected. (I've written the change under the heading 0.30.4 even though that version hasn't been released yet, since the unreleased.md was empty on the v0.30.x branch but populated on the master branch)

I have tested these changes on my iPad and they work exactly as expected. In an ideal world, I would like this to be released on crates.io in a way that bevy could integrate so I could use it in my bevy application (tracking issue), which is why I was working off the v0.30.x branch so I could seamlessly patch.

Also, the public API I have chosen seems reasonable to me but I am totally open to it being tweaked or re-worked. But I would ideally want this functionality exposed in some way without me having to maintain my own fork as bevy releases roll around. I have intentionally included #[non_exhaustive] in places that I or other developers may add or improve features to. Notably, this PR only handles pen double tap events since that is all I can physically test with my current hardware, but newer Apple Pencil models support squeeze actions that I know (theoretically) how to implement but haven't. The API intentionally allows for this addition later. The public API I added is also intended to be extendable by other platform implementations, but again I can't test them physically so haven't included here. Each section has ## Platform Specific \n - iOS only documentation for that reason.

This is my first contribution to winit (and my first major feature contribution in general using Open Source) so please tell me if I've done anything wrong! And thanks so much for this awesome crate, contributing to it has taught me a lot about objc2, UIKit and iOS development!

kchibisov commented 3 months ago

You must always target the master. Though, you could still provide with a backport patch once the master implementation is available.

kchibisov commented 3 months ago

Oh, also, you can not target 0.30 branch, because you're adding breaking changes, thus they can not be a part of the patch release.

ActuallyHappening commented 3 months ago

OK, so if I understand correctly this change since it adds new API surface and so can't are released as a patch version 0.30.4. I'll have to make a new PR I presume adding this functionality to the master branch then, and I think I'll change the naming to PenSpecialAction, see #99