diff options
Diffstat (limited to 'native/src/input')
| -rw-r--r-- | native/src/input/mouse/event.rs | 9 | ||||
| -rw-r--r-- | native/src/input/touch.rs | 69 | 
2 files changed, 36 insertions, 42 deletions
diff --git a/native/src/input/mouse/event.rs b/native/src/input/mouse/event.rs index aafc4fe3..5068d634 100644 --- a/native/src/input/mouse/event.rs +++ b/native/src/input/mouse/event.rs @@ -1,5 +1,5 @@  use super::Button; -use crate::input::ButtonState; +use crate::{input::ButtonState, Point};  /// A mouse event.  /// @@ -17,11 +17,8 @@ pub enum Event {      /// The mouse cursor was moved      CursorMoved { -        /// The X coordinate of the mouse position -        x: f32, - -        /// The Y coordinate of the mouse position -        y: f32, +        /// The new position of the mouse cursor +        position: Point,      },      /// A mouse button was pressed or released. diff --git a/native/src/input/touch.rs b/native/src/input/touch.rs index 7c4a6210..ea879427 100644 --- a/native/src/input/touch.rs +++ b/native/src/input/touch.rs @@ -1,39 +1,36 @@  //! Build touch events. -/// The touch of a mobile device. + +use crate::Point; + +/// A touch interaction.  #[derive(Debug, Clone, Copy, PartialEq)] -pub enum Touch { -    /// The touch cursor was started -    Started { -        /// The X coordinate of the touch position -        x: f32, - -        /// The Y coordinate of the touch position -        y: f32, -    }, -    /// The touch cursor was ended -    Ended { -        /// The X coordinate of the touch position -        x: f32, - -        /// The Y coordinate of the touch position -        y: f32, -    }, - -    /// The touch was moved. -    Moved { -        /// The X coordinate of the touch position -        x: f32, - -        /// The Y coordinate of the touch position -        y: f32, -    }, - -    /// Some canceled button. -    Cancelled { -        /// The X coordinate of the touch position -        x: f32, - -        /// The Y coordinate of the touch position -        y: f32, -    }, +pub struct Touch { +    /// The finger of the touch. +    pub finger: Finger, + +    /// The position of the touch. +    pub position: Point, + +    /// The state of the touch. +    pub phase: Phase, +} + +/// A unique identifier representing a finger on a touch interaction. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct Finger(pub u64); + +/// The state of a touch interaction. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Phase { +    /// A touch interaction was started. +    Started, + +    /// An on-going touch interaction was moved. +    Moved, + +    /// A touch interaction was ended. +    Ended, + +    /// A touch interaction was canceled. +    Canceled,  }  | 
