#[non_exhaustive]
pub enum Force {
Calibrated {
force: f64,
max_possible_force: f64,
altitude_angle: Option<f64>,
},
Normalized(f64),
}
Expand description
Describes the force of a touch event
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Calibrated
Fields
This variant is marked as non-exhaustive
force: f64
The force of the touch, where a value of 1.0 represents the force of an average touch (predetermined by the system, not user-specific).
The force reported by Apple Pencil is measured along the axis of the
pencil. If you want a force perpendicular to the device, you need to
calculate this value using the altitude_angle
value.
max_possible_force: f64
The maximum possible force for a touch.
The value of this field is sufficiently high to provide a wide
dynamic range for values of the force
field.
On iOS, the force is calibrated so that the same number corresponds to roughly the same amount of pressure on the screen regardless of the device.
Normalized(f64)
If the platform reports the force as normalized, we have no way of knowing how much pressure 1.0 corresponds to – we know it’s the maximum amount of force, but as to how much force, you might either have to press really really hard, or not hard at all, depending on the device.
Implementations
sourceimpl Force
impl Force
sourcepub fn normalized(&self) -> f64
pub fn normalized(&self) -> f64
Returns the force normalized to the range between 0.0 and 1.0 inclusive.
Instead of normalizing the force, you should prefer to handle
Force::Calibrated
so that the amount of force the user has to apply is
consistent across devices.
Trait Implementations
impl Copy for Force
impl StructuralPartialEq for Force
Auto Trait Implementations
impl RefUnwindSafe for Force
impl Send for Force
impl Sync for Force
impl Unpin for Force
impl UnwindSafe for Force
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more