Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_input/src/gestures.rs
6595 views
1
//! Gestures functionality, from touchscreens and touchpads.
2
3
use bevy_ecs::event::BufferedEvent;
4
use bevy_math::Vec2;
5
#[cfg(feature = "bevy_reflect")]
6
use bevy_reflect::Reflect;
7
8
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
9
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
10
11
/// Two-finger pinch gesture, often used for magnifications.
12
///
13
/// Positive delta values indicate magnification (zooming in) and
14
/// negative delta values indicate shrinking (zooming out).
15
///
16
/// ## Platform-specific
17
///
18
/// - Only available on **`macOS`** and **`iOS`**.
19
/// - On **`iOS`**, must be enabled first
20
#[derive(BufferedEvent, Debug, Clone, Copy, PartialEq)]
21
#[cfg_attr(
22
feature = "bevy_reflect",
23
derive(Reflect),
24
reflect(Debug, PartialEq, Clone)
25
)]
26
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
27
#[cfg_attr(
28
all(feature = "serialize", feature = "bevy_reflect"),
29
reflect(Serialize, Deserialize)
30
)]
31
pub struct PinchGesture(pub f32);
32
33
/// Two-finger rotation gesture.
34
///
35
/// Positive delta values indicate rotation counterclockwise and
36
/// negative delta values indicate rotation clockwise.
37
///
38
/// ## Platform-specific
39
///
40
/// - Only available on **`macOS`** and **`iOS`**.
41
/// - On **`iOS`**, must be enabled first
42
#[derive(BufferedEvent, Debug, Clone, Copy, PartialEq)]
43
#[cfg_attr(
44
feature = "bevy_reflect",
45
derive(Reflect),
46
reflect(Debug, PartialEq, Clone)
47
)]
48
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
49
#[cfg_attr(
50
all(feature = "serialize", feature = "bevy_reflect"),
51
reflect(Serialize, Deserialize)
52
)]
53
pub struct RotationGesture(pub f32);
54
55
/// Double tap gesture.
56
///
57
/// ## Platform-specific
58
///
59
/// - Only available on **`macOS`** and **`iOS`**.
60
/// - On **`iOS`**, must be enabled first
61
#[derive(BufferedEvent, Debug, Clone, Copy, PartialEq)]
62
#[cfg_attr(
63
feature = "bevy_reflect",
64
derive(Reflect),
65
reflect(Debug, PartialEq, Clone)
66
)]
67
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
68
#[cfg_attr(
69
all(feature = "serialize", feature = "bevy_reflect"),
70
reflect(Serialize, Deserialize)
71
)]
72
pub struct DoubleTapGesture;
73
74
/// Pan gesture.
75
///
76
/// ## Platform-specific
77
///
78
/// - On **`iOS`**, must be enabled first
79
#[derive(BufferedEvent, Debug, Clone, Copy, PartialEq)]
80
#[cfg_attr(
81
feature = "bevy_reflect",
82
derive(Reflect),
83
reflect(Debug, PartialEq, Clone)
84
)]
85
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
86
#[cfg_attr(
87
all(feature = "serialize", feature = "bevy_reflect"),
88
reflect(Serialize, Deserialize)
89
)]
90
pub struct PanGesture(pub Vec2);
91
92