[][src]Struct joycon_rs::joycon::Rumble

pub struct Rumble { /* fields omitted */ }

Rumble data for vibration.

Notice

Constraints exist.

  • frequency - 0.0 < freq < 1252.0
  • amplitude - 0.0 < amp < 1.799.0

Example

use joycon_rs::prelude::{*, joycon_features::JoyConFeature};

let manager = JoyConManager::get_instance();
let devices = {
    let lock = manager.lock();
    match lock {
        Ok(manager) => manager.new_devices(),
        Err(_) => unreachable!(),
    }
};

devices.iter()
    .try_for_each::<_, JoyConResult<()>>(|d| {
        let mut driver = SimpleJoyConDriver::new(&d)?;

        driver.enable_feature(JoyConFeature::Vibration)?;

        let rumble = Rumble::new(300.0,0.9);
        // ₍₍(ง˘ω˘)ว⁾⁾ Rumble! ₍₍(ง˘ω˘)ว⁾⁾
        driver.rumble((Some(rumble), Some(rumble)))?;

        Ok(())
    })
    .unwrap();

Methods

impl Rumble[src]

pub fn frequency(&self) -> f32[src]

pub fn amplitude(&self) -> f32[src]

pub fn new(freq: f32, amp: f32) -> Self[src]

Constructor of Rumble. If arguments not in line with constraints, args will be saturated.

pub fn is_safe(&self) -> bool[src]

The amplitudes over 1.003 are not safe for the integrity of the linear resonant actuators.

pub fn stop() -> Self[src]

Generates stopper of rumbling.

Example

This example is not tested
// Make JoyCon stop rambling.
rumbling_controller_driver.rumble((Some(Rumble::stop()),Some(Rumble::stop()))).unwrap();

Trait Implementations

impl Clone for Rumble[src]

impl Copy for Rumble[src]

impl Debug for Rumble[src]

impl Into<[u8; 4]> for Rumble[src]

impl PartialEq<Rumble> for Rumble[src]

impl StructuralPartialEq for Rumble[src]

Auto Trait Implementations

impl RefUnwindSafe for Rumble

impl Send for Rumble

impl Sync for Rumble

impl Unpin for Rumble

impl UnwindSafe for Rumble

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.