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§
Calibrated
Fields
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.
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§
source§impl 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.