Skip to main content

HapticFeedback

Struct HapticFeedback 

Source
pub struct HapticFeedback;
Expand description

Allows access to the haptic feedback interface on the device.

This API is intentionally terse since it calls default platform behavior. It is not suitable for precise control of the system’s haptic feedback module.

See also:

Implementations§

Source§

impl HapticFeedback

Source

pub fn vibrate(app: &App)

Provides vibration haptic feedback to the user for a short duration.

On iOS devices that support haptic feedback, this uses the default system vibration value (kSystemSoundID_Vibrate).

On Android, this uses the platform haptic feedback API to simulate a response to a long press (HapticFeedbackConstants.LONG_PRESS).

Source

pub fn light_impact(app: &App)

Provides a haptic feedback corresponding a collision impact with a light mass.

On iOS versions 10 and above, this uses a UIImpactFeedbackGenerator with UIImpactFeedbackStyleLight. This call has no effects on iOS versions below 10.

On Android, this uses HapticFeedbackConstants.VIRTUAL_KEY.

See also:

Source

pub fn medium_impact(app: &App)

Provides a haptic feedback corresponding a collision impact with a medium mass.

On iOS versions 10 and above, this uses a UIImpactFeedbackGenerator with UIImpactFeedbackStyleMedium. This call has no effects on iOS versions below 10.

On Android, this uses HapticFeedbackConstants.KEYBOARD_TAP.

Source

pub fn heavy_impact(app: &App)

Provides a haptic feedback corresponding a collision impact with a heavy mass.

On iOS versions 10 and above, this uses a UIImpactFeedbackGenerator with UIImpactFeedbackStyleHeavy. This call has no effects on iOS versions below 10.

On Android, this uses HapticFeedbackConstants.CONTEXT_CLICK on API levels 23 and above. This call has no effects on Android API levels below 23.

Source

pub fn selection_click(app: &App)

Provides a haptic feedback indication selection changing through discrete values.

On iOS versions 10 and above, this uses a UISelectionFeedbackGenerator. This call has no effects on iOS versions below 10.

On Android, this uses HapticFeedbackConstants.CLOCK_TICK.

See also:

Source

pub fn success_notification(app: &App)

Provides a haptic feedback indicating that a task or action has completed successfully.

On iOS, this uses a UINotificationFeedbackGenerator with UINotificationFeedbackTypeSuccess.

On Android, this uses HapticFeedbackConstants.CONFIRM on API levels 30 and above. This call has no effects on Android API levels below 30.

See also:

Source

pub fn warning_notification(app: &App)

Provides a haptic feedback indicating that a task or action has produced a warning.

On iOS, this uses a UINotificationFeedbackGenerator with UINotificationFeedbackTypeWarning.

On Android, this uses HapticFeedbackConstants.KEYBOARD_TAP on API levels 30 and above. This call has no effects on Android API levels below 30.

Source

pub fn error_notification(app: &App)

Provides a haptic feedback indicating that a task or action has failed.

On iOS, this uses a UINotificationFeedbackGenerator with UINotificationFeedbackTypeError.

On Android, this uses HapticFeedbackConstants.REJECT on API levels 30 and above. This call has no effects on Android API levels below 30.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,