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

Implement Touch events for OSX #54

Closed
tomaka opened this issue Nov 3, 2016 · 4 comments
Closed

Implement Touch events for OSX #54

tomaka opened this issue Nov 3, 2016 · 4 comments
Labels
D - average Likely as difficult as most tasks here DS - macos H - help wanted Someone please save us P - normal Great to have S - platform parity Unintended platform differences

Comments

@tomaka
Copy link
Contributor

tomaka commented Nov 3, 2016

Original: rust-windowing/glutin#592

@chances
Copy link

chances commented Jan 20, 2017

Apart from the already existing Touch events, has any progress been made on this front?

I'm particularly interested in AppKit's gesture events. If not, I'd be happy to contribute integrations for gesture events utilizing AppKit's gesture primitives.

@francesca64 francesca64 added H - help wanted Someone please save us D - average Likely as difficult as most tasks here P - normal Great to have S - platform parity Unintended platform differences labels May 6, 2018
@adamnemecek
Copy link

What's the situation with this? I'm considering adding this functionality.

@goddessfreya
Copy link
Contributor

You would have to ask @vbogaevsky.

emilk added a commit to emilk/egui that referenced this issue May 6, 2021
* translate touch events from glium to egui

Unfortunately, winit does not seem to create _Touch_ events for the touch pad
on my mac.  Only _TouchpadPressure_ events are sent.

Found some issues (like
[this](rust-windowing/winit#54)), but I am not sure
what they exactly mean:  Sometimes, touch events are mixed with
touch-to-pointer translation in the discussions.

* translate touch events from web_sys to egui

The are a few open topics:
- egui_web currently translates touch events into pointer events.
  I guess this should change, such that egui itself performs this kind of
  conversion.
- `pub fn egui_web::pos_from_touch_event` is a public function, but I
  would like to change the return type to an `Option`.  Shouldn't this
  function be private, anyway?

* introduce `TouchState` and `Gesture`

InputState.touch was introduced with type `TouchState`, just as
InputState.pointer is of type `Pointer`.

The TouchState internally relies on a collection of `Gesture`s.  This commit
provides the first rudimentary implementation of a Gesture, but has no
functionality, yet.

* add method InputState::zoom()

So far, the method always returns `None`, but it should work as soon as the
`Zoom` gesture is implemented.

* manage one `TouchState` per individual device

Although quite unlikely, it is still possible to connect more than one touch
device. (I have three touch pads connected to my MacBook in total, but
unfortunately `winit` sends touch events for none of them.)

We do not want to mix-up the touches from different devices.

* implement control loop for gesture detection

The basic idea is that each gesture can focus on detection logic and does not
have to care (too much) about managing touch state in general.

* streamline `Gesture` trait, simplifying impl's

* implement first version of Zoom gesture

* fix failing doctest

a simple `TODO` should be enough

* get rid of `Gesture`s

* Provide a Zoom/Rotate window in the demo app

For now, it works for two fingers only.  The third finger interrupts the
gesture.

Bugs:
- Pinching in the demo window also moves the window -> Pointer events must be
  ignored when touch is active
- Pinching also works when doing it outside the demo window -> it would be nice
  to return the touch info in the `Response` of the painter allocation

* fix comments and non-idiomatic code

* update touch state *each frame*

* change egui_demo to use *relative* touch data

* support more than two fingers

This commit includes an improved Demo Window for egui_demo, and a complete
re-write of the gesture detection.  The PR should be ready for review, soon.

* cleanup code and comments for review

* minor code simplifications

* oops – forgot the changelog

* resolve comment https://github.com/emilk/egui/pull/306/files/fee8ed83dbe715b5b70433faacfe74b59c99e4a4#r623226656

* accept suggestion #306 (comment)

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* fix syntax error (dough!)

* remove `dbg!` (why didnt clippy see this?)

* apply suggested diffs from review

* fix conversion of physical location to Pos2

* remove redundanct type `TouchAverages`

* remove trailing space

* avoid initial translation jump in plot demo

* extend the demo so it shows off translation

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
@madsmtm
Copy link
Member

madsmtm commented Aug 24, 2023

I think the closest we're going to get to supporting touch events is #2157, which adds support for trackpad gestures.

At least, as far as I know, Apple doesn't (yet) support touch displays to any further extent than just simulating a cursor (the best alternative I know would be to use an iPad as an external display, called Sidecar, but that uses the trackpad gestures as well, it doesn't have true multi touch support).

@madsmtm madsmtm closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D - average Likely as difficult as most tasks here DS - macos H - help wanted Someone please save us P - normal Great to have S - platform parity Unintended platform differences
Development

No branches or pull requests

6 participants