Enum input_device::event::Force[][src]

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

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.

Fields of Calibrated

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.

altitude_angle: Option<f64>

The altitude (in radians) of the stylus.

A value of 0 radians indicates that the stylus is parallel to the surface. The value of this property is Pi/2 when the stylus is perpendicular to the surface.

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.

Tuple Fields of Normalized

0: f64

Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.