Rumble

Struct Rumble 

Source
pub struct Rumble { /* private fields */ }
Expand description

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();

Implementations§

Source§

impl Rumble

Source

pub fn frequency(self) -> f32

Source

pub fn amplitude(self) -> f32

Source

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

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

Source

pub fn is_safe(self) -> bool

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

Source

pub fn stop() -> Self

Generates stopper of rumbling.

§Example
// Make JoyCon stop rambling.
rumbling_controller_driver.rumble((Some(Rumble::stop()),Some(Rumble::stop()))).unwrap();

Trait Implementations§

Source§

impl Clone for Rumble

Source§

fn clone(&self) -> Rumble

Returns a duplicate 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 Debug for Rumble

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Into<[u8; 4]> for Rumble

Source§

fn into(self) -> [u8; 4]

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for Rumble

Source§

fn eq(&self, other: &Rumble) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Rumble

Source§

impl StructuralPartialEq for Rumble

Auto Trait Implementations§

§

impl Freeze for Rumble

§

impl RefUnwindSafe for Rumble

§

impl Send for Rumble

§

impl Sync for Rumble

§

impl Unpin for Rumble

§

impl UnwindSafe for Rumble

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

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>,

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.