Struct piston_window::prelude::TouchArgs
source · pub struct TouchArgs {
pub device: i64,
pub id: i64,
pub position_3d: [f64; 3],
pub pressure_3d: [f64; 3],
pub is_3d: bool,
pub touch: Touch,
}
Expand description
Touch arguments
The id
might be reused for different touches that do not overlap in time.
- Coordinates are normalized to support both touch screens and trackpads
- Supports both 2D and 3D touch
- The pressure direction vector should have maximum length 1
For 2D touch the pressure is pointed in the z direction.
Use .pressure()
to get the pressure magnitude.
Fields§
§device: i64
A unique identifier for touch device.
id: i64
A unique identifier for touch event.
position_3d: [f64; 3]
The touch position, normalized 0..1.
pressure_3d: [f64; 3]
The touch pressure vector, normalized 0..1.
is_3d: bool
Whether the touch is in 3D.
touch: Touch
The touch state.
Implementations§
source§impl TouchArgs
impl TouchArgs
sourcepub fn new(
device: i64,
id: i64,
position: [f64; 2],
pressure: f64,
touch: Touch
) -> TouchArgs
pub fn new( device: i64, id: i64, position: [f64; 2], pressure: f64, touch: Touch ) -> TouchArgs
Creates arguments for 2D touch.
sourcepub fn new_3d(
device: i64,
id: i64,
position_3d: [f64; 3],
pressure_3d: [f64; 3],
touch: Touch
) -> TouchArgs
pub fn new_3d( device: i64, id: i64, position_3d: [f64; 3], pressure_3d: [f64; 3], touch: Touch ) -> TouchArgs
Creates arguments for 3D touch.
The pressure direction vector should have maximum length 1.
sourcepub fn position_3d(&self) -> [f64; 3]
pub fn position_3d(&self) -> [f64; 3]
The position of the touch in 3D.
sourcepub fn pressure_3d(&self) -> [f64; 3]
pub fn pressure_3d(&self) -> [f64; 3]
The pressure vector in 3D.
Trait Implementations§
source§impl<'de> Deserialize<'de> for TouchArgs
impl<'de> Deserialize<'de> for TouchArgs
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<TouchArgs, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<TouchArgs, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for TouchArgs
impl PartialEq for TouchArgs
source§impl PartialOrd for TouchArgs
impl PartialOrd for TouchArgs
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for TouchArgs
impl Serialize for TouchArgs
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for TouchArgs
impl StructuralPartialEq for TouchArgs
Auto Trait Implementations§
impl Freeze for TouchArgs
impl RefUnwindSafe for TouchArgs
impl Send for TouchArgs
impl Sync for TouchArgs
impl Unpin for TouchArgs
impl UnwindSafe for TouchArgs
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more