Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiseiYokoyama committed May 6, 2020
1 parent f98356b commit e7dd10c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions examples/rumble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ fn main() -> JoyConResult<()> {

driver.enable_feature(JoyConFeature::Vibration)?;

// let rumble = Rumble::new(80.0,0.2);
let rumble = Rumble::new(300.0,0.9);
driver.rumble((Some(rumble), Some(rumble)))?;

std::thread::sleep(std::time::Duration::from_millis(60));
driver.rumble((None,None))?;

let stop = Rumble::stop();
driver.rumble((Some(stop),Some(stop)))?;

Ok(())
})?;
Expand Down
6 changes: 2 additions & 4 deletions src/joycon/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,11 @@ pub trait JoyConDriver {

// rumble
let (rumble_l, rumble_r) = self.get_rumble_status();
{
let rumble_l = rumble_l.unwrap_or(Rumble::new(40.0, 0.0));
if let Some(rumble_l) = rumble_l {
let rumble_left: [u8; 4] = rumble_l.into();
buf[2..6].copy_from_slice(&rumble_left);
}
{
let rumble_r = rumble_r.unwrap_or(Rumble::new(40.0, 0.0));
if let Some(rumble_r) = rumble_r {
let rumble_right: [u8; 4] = rumble_r.into();
buf[6..10].copy_from_slice(&rumble_right);
}
Expand Down

0 comments on commit e7dd10c

Please sign in to comment.