Skip to content

Add true multitouch trackpad support. #6174

Open
@wusticality

Description

@wusticality

What problem does this solve or what need does it fill?

At present, trackpad events are captured as if the trackpad were a mouse. For example, on a MacBook Pro, events come in as a left mouse press / release event. The MacBook Pro trackpad is actually a multitouch display, however. Bevy should emit touches as if it were any other multitouch display, along with press / release events.

What solution would you like?

After talking to @alice-i-cecile, it seems the solution is to have Bevy emit touches (as if it were a multitouch display) and emit the mouse behavior if someone wants to opt into that default behavior. An example of what I'd like to accomplish using the trackpad is:

  • Pan the camera by dragging two fingers on the trackpad.
  • Zoom in and out by detecting pinch to zoom gestures.
  • Other multitouch gestures as things come up.

One potential issue is that the MacBook Pro trackpad touch events should support press / release states when your finger touches and releases from the screen, and also trackpad click events as the trackpad itself can be fully depressed. Both types of touches should be supported which might be an issue with the current Touches implementation:

pub struct Touches {
    /// A collection of every [`Touch`] that is currently being pressed.
    pressed: HashMap<u64, Touch>,
    /// A collection of every [`Touch`] that just got pressed.
    just_pressed: HashMap<u64, Touch>,
    /// A collection of every [`Touch`] that just got released.
    just_released: HashMap<u64, Touch>,
    /// A collection of every [`Touch`] that just got cancelled.
    just_cancelled: HashMap<u64, Touch>,
}

It may be that Bevy should have a Trackpad input abstraction for this case that supports both touch events and button-click events in one interface but I'm not sure. There may even be trackpads that support multitouch but also have separate physical buttons.

What alternative(s) have you considered?

For now, I'm getting around this by using keyboard shortcuts to zoom the world and holding a modifier key while dragging my finger on the trackpad for drag events which is not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions