-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from KaiseiYokoyama/dev/0.2.0
Dev/0.2.0
- Loading branch information
Showing
13 changed files
with
1,083 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "joycon-rs" | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
authors = ["Kaisei Yokoyama <[email protected]>"] | ||
edition = "2018" | ||
description = " a framework for dealing with Nintendo Switch Joy-Con on Rust easily and efficiently" | ||
|
@@ -11,7 +11,11 @@ license = "Apache-2.0" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
hidapi = "1.2.1" | ||
hidapi = { git = "https://github.com/KaiseiYokoyama/hidapi-rs" } | ||
crossbeam-channel = "0.4.2" | ||
|
||
[dev-dependencies] | ||
doc-comment = "0.3.3" | ||
|
||
[[example]] | ||
name = "scan_for_joycons" | ||
|
@@ -23,4 +27,7 @@ name = "player_lights" | |
name = "standard_full_report" | ||
|
||
[[example]] | ||
name = "simple_hid_report" | ||
name = "simple_hid_report" | ||
|
||
[[example]] | ||
name = "rumble" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use joycon_rs::prelude::*; | ||
use std::convert::TryInto; | ||
use std::ops::Deref; | ||
use joycon_rs::joycon::joycon_features::JoyConFeature; | ||
|
||
fn main() -> JoyConResult<()> { | ||
// First, connect your Joy-Cons to your computer! | ||
|
||
let manager = | ||
JoyConManager::new()?; | ||
let (managed_devices, new_devices) = { | ||
let lock = manager.lock(); | ||
match lock { | ||
Ok(manager) => | ||
(manager.managed_devices(), manager.new_devices()), | ||
Err(_) => unreachable!(), | ||
} | ||
}; | ||
|
||
managed_devices.into_iter() | ||
.chain(new_devices) | ||
.inspect(|d| { | ||
let lock = d.lock(); | ||
let device = match lock { | ||
Ok(device) => device, | ||
Err(e) => e.into_inner(), | ||
}; | ||
let hid_device: JoyConResult<&HidDevice> = device.deref().try_into(); | ||
if let Ok(hid_device) = hid_device { | ||
println!("{:?}", hid_device.get_product_string()) | ||
} | ||
}) | ||
.try_for_each::<_, JoyConResult<()>>(|d| { | ||
let mut driver = SimpleJoyConDriver::new(&d)?; | ||
|
||
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)))?; | ||
|
||
Ok(()) | ||
})?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.