Union sdl2_sys::SDL_HapticEffect

source ·
#[repr(C)]
pub union SDL_HapticEffect {
    pub type_: Uint16,
    pub constant: SDL_HapticConstant,
    pub periodic: SDL_HapticPeriodic,
    pub condition: SDL_HapticCondition,
    pub ramp: SDL_HapticRamp,
    pub leftright: SDL_HapticLeftRight,
    pub custom: SDL_HapticCustom,
}
Expand description

\brief The generic template for any haptic effect.

All values max at 32767 (0x7FFF). Signed values also can be negative. Time values unless specified otherwise are in milliseconds.

You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 value. Neither delay, interval, attack_length nor fade_length support ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.

Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of ::SDL_HAPTIC_INFINITY.

Button triggers may not be supported on all devices, it is advised to not use them if possible. Buttons start at index 1 instead of index 0 like the joystick.

If both attack_length and fade_level are 0, the envelope is not used, otherwise both values are used.

Common parts: \code // Replay - All effects have this Uint32 length; // Duration of effect (ms). Uint16 delay; // Delay before starting effect.

// Trigger - All effects have this Uint16 button; // Button that triggers effect. Uint16 interval; // How soon before effect can be triggered again.

// Envelope - All effects except condition effects have this Uint16 attack_length; // Duration of the attack (ms). Uint16 attack_level; // Level at the start of the attack. Uint16 fade_length; // Duration of the fade out (ms). Uint16 fade_level; // Level at the end of the fade. \endcode

Here we have an example of a constant effect evolution in time: \verbatim Strength ^ | | effect level –> _________________ | /
| /
| /
| /
| attack_level –> |
| | | <— fade_level | +–––––––––––––––––––––––––> Time [–] [—] attack_length fade_length

[——————][———————–] delay length \endverbatim

Note either the attack_level or the fade_level may be above the actual effect level.

\sa SDL_HapticConstant \sa SDL_HapticPeriodic \sa SDL_HapticCondition \sa SDL_HapticRamp \sa SDL_HapticLeftRight \sa SDL_HapticCustom

Fields§

§type_: Uint16

< Effect type.

§constant: SDL_HapticConstant

< Constant effect.

§periodic: SDL_HapticPeriodic

< Periodic effect.

§condition: SDL_HapticCondition

< Condition effect.

§ramp: SDL_HapticRamp

< Ramp effect.

§leftright: SDL_HapticLeftRight

< Left/Right effect.

§custom: SDL_HapticCustom

< Custom effect.

Trait Implementations§

source§

impl Clone for SDL_HapticEffect

source§

fn clone(&self) -> SDL_HapticEffect

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Copy for SDL_HapticEffect

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<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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.