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

Adding touchpad multitouch support #2379

Open
simon-frankau opened this issue Jul 18, 2022 · 4 comments
Open

Adding touchpad multitouch support #2379

simon-frankau opened this issue Jul 18, 2022 · 4 comments
Labels
S - enhancement Wouldn't this be the coolest?

Comments

@simon-frankau
Copy link

Hi.

I'm interested in adding touchpad multitouch support to winit, with an implementation for MacOS. I'm new to winit, so I'd be keen to get feedback on whether this is worth implementing before I start coding. I'll try to pre-empt a few questions here:

  • What is "touchpad multitouch support"? winit already supports multitouch, but (I believe) it assumes that you're touching the screen, so touches are in screen coordinates. This would be supporting touches where the coordinates are touchpad coordinates.
  • Why would this support be useful? I'm aware of Add touchpad magnify and rotate gestures support for macOS #2157 - touchpad gestures. This is another approach: Having the raw touches available allows extra flexibility, so that the library user can interpret a wider range of multitouch movements. For example, the touches can be interpreted to provide pinch-to-zoom with different scales on the different axes, or custom gestures.
  • So, couldn't similar functionality be provided by extending Add touchpad magnify and rotate gestures support for macOS #2157?. Yes-ish. Recognition for extra gestures could be coded into winit, but passing touches straight through to the user seems more flexible and potentially less complex for winit, if you were to support such gestures.
  • Is this instead of Add touchpad magnify and rotate gestures support for macOS #2157? No, this provides more flexibility for those that want it, enabling access to raw touches, as well as gestures. Gestures are still very useful.
  • Should winit supporting touchpad multitouch? Looking at the list in FEATURES.md, there is already support for a) multitouch and b) touchpad functionality. It feels to me like it's pretty much inside the boundaries defined by existing features, although I do have sympathy for "Yeah, but can we avoid scope creep on potentially marginal features?".
  • What would this look like, API-wise? I think the assumption is that Touch coordinates are screen coordinates. My suggestion would be to add an enum member to Touch for the coordinate system used - something like "screen" for touch screen, and "device" for trackpad. Maybe these events should be delivered as DeviceEvents rather than WindowEvents?
  • Why do you personally want this? While I hope this feature would be useful to other people, I'd like egui to support zooming by different amounts in the X and Y axes from the same gesture, which is not supported with the MacOS pinch gesture, but is supported with multitouch.
  • What platforms would you support? I only have MacOS to hand, so my implementation would only cover MacOS.

As I said at the start, I'm new to winit, so I may have made some incorrect assumptions, or be thinking about this incorrectly. Please do correct me.

Thanks,
Simon.

@maroider maroider added the S - enhancement Wouldn't this be the coolest? label Jul 20, 2022
@maroider
Copy link
Member

I suppose that would be useful, but I'm not sure if we can implement it on other platforms (or how you'd even implement it on macOS).

@madsmtm
Copy link
Member

madsmtm commented Aug 10, 2022

We'll probably be merging #2157, so that part is at least covered.

Good issue description, I agree that this is in-scope and the path you've laid out (modifying the Touch enum) sounds fine. Ping me when you have something!

@simon-frankau
Copy link
Author

Ooops, sorry for not replying earlier - some "real-world issues" got in the way.

If "single platform only implementation" is an problem, I can understand if people want to call it out of scope. I can also take a quick look to see if other platforms have a way to support this (even if I'm not in a position to implement it myself).

My proof-of-concept implementation relies on listening for touches{Began,Moved,Ended,Cancelled}WithEvent: events. The main issues I have so far are:

  • Lack of familiarity with the Apple APIs.
  • Thoughts on how to correctly handle "multi-touch" - I think this API also reports single touch events as a sub-set of multi-touch events, and probably these should be filtered out given they're also reported as mouse movements. It feels like there are corner cases worth getting right.

I'll try to follow up when I have something worth looking at, but the "real-world issues" mentioned above might still slow me down somewhat. In the meantime, I'm glad to hear #2157 is likely to get merged.

@madsmtm
Copy link
Member

madsmtm commented Aug 14, 2022

Take your time, no worries!

Thoughts on how to correctly handle "multi-touch"

Honestly, no idea, but I guess any API is better than no API, so just getting something that somewhat works to begin with would be an improvement

JeanMertz added a commit to dcdpr/BDSL that referenced this issue Feb 23, 2024
This plugin uses the `PanCam` crate to handle camera-movement input.

It currently support zooming via scrolling (or equivalent touch
gestures) and panning via left-click and drag (or touch gestures).

Multi-touch gestures are not yet supported, this is mainly because the
`winit` crate does not yet support them.

See: <rust-windowing/winit#2379>

Signed-off-by: Jean Mertz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

3 participants