-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Touchpad magnify and rotate events (#8791)
# Objective The goal of this PR is to receive touchpad magnification and rotation events. ## Solution Implement pendants for winit's `TouchpadMagnify` and `TouchpadRotate` events. Adjust the `mouse_input_events.rs` example to debug magnify and rotate events. Since winit only reports these events on macOS, the Bevy events for touchpad magnification and rotation are currently only fired on macOS.
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use bevy_ecs::event::Event; | ||
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect}; | ||
|
||
#[cfg(feature = "serialize")] | ||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; | ||
|
||
/// Touchpad magnification event with two-finger pinch gesture. | ||
/// | ||
/// Positive delta values indicate magnification (zooming in) and | ||
/// negative delta values indicate shrinking (zooming out). | ||
/// | ||
/// ## Platform-specific | ||
/// | ||
/// - Only available on **`macOS`**. | ||
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)] | ||
#[reflect(Debug, PartialEq, FromReflect)] | ||
#[cfg_attr( | ||
feature = "serialize", | ||
derive(serde::Serialize, serde::Deserialize), | ||
reflect(Serialize, Deserialize) | ||
)] | ||
pub struct TouchpadMagnify(pub f32); | ||
|
||
/// Touchpad rotation event with two-finger rotation gesture. | ||
/// | ||
/// Positive delta values indicate rotation counterclockwise and | ||
/// negative delta values indicate rotation clockwise. | ||
/// | ||
/// ## Platform-specific | ||
/// | ||
/// - Only available on **`macOS`**. | ||
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)] | ||
#[reflect(Debug, PartialEq, FromReflect)] | ||
#[cfg_attr( | ||
feature = "serialize", | ||
derive(serde::Serialize, serde::Deserialize), | ||
reflect(Serialize, Deserialize) | ||
)] | ||
pub struct TouchpadRotate(pub f32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters