three-d icon indicating copy to clipboard operation
three-d copied to clipboard

Trackpad-specific input event support

Open thatcomputerguy0101 opened this issue 1 year ago • 2 comments

This adds support for pinch and rotation gesture events, as exposed from winit on MacOS platforms. Additionally, this associates ctrl-scrolling with the pinch gesture unless actual gesture events are detected since some Windows trackpads expose pinch information as scrolling with the ctrl key held. This somewhat breaks any custom control systems that expect pinch to zoom until they are updated with the new pinch event. However, since key modifiers are not made accessible to the camera control interface, any old handlers are still accessible by scrolling vertically.

thatcomputerguy0101 avatar Sep 14 '24 18:09 thatcomputerguy0101

Instead of remapping events, I added the capability to execute different camera actions depending on the state of the modifier keys. This removed the Copy trait from CameraAction and CameraControl due to Box now being involved, but standard uses of those two types outside of the three-d crate should not be affected.

thatcomputerguy0101 avatar Oct 01 '24 18:10 thatcomputerguy0101

On further consideration, I'm not sure I'm happy with the Box-based modifier map, so I'm going to separate that from this PR to allow for further design revision. In the meantime, custom control interfaces could handle modifier keys before passing the event list to CameraControl::handle_events.

thatcomputerguy0101 avatar Oct 07 '24 20:10 thatcomputerguy0101

I think it looks really good. Since I was so slow responding, I resolved the merge conflict and merged the changes. If you think there's more changes needed, feel free to open another PR 🙂 Thanks for the contribution, yet again 🙏

asny avatar Nov 11 '24 09:11 asny

@thatcomputerguy0101 While looking at your changes, I realised that the whole control setup is a bit over engineered. Therefore, I tried to remove the CameraControl and the CameraAction in https://github.com/asny/three-d/pull/507. It simply applies the incoming events directly to the camera. This actually made the whole setup much simpler, so I'm going to merge that. Feedback to this approach is very welcome 🙏

asny avatar Nov 11 '24 10:11 asny