-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstandard_full_report.rs
44 lines (34 loc) · 1.08 KB
/
standard_full_report.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![allow(unused_must_use)]
use joycon_rs::prelude::*;
fn main() -> JoyConResult<()> {
// First, connect your Joy-Cons to your computer!
let (tx, rx) = std::sync::mpsc::channel();
let _output = std::thread::spawn(move || {
// Push buttons or tilt the stick please.
// Stop with `Cmd + C` or `Ctrl + C`
while let Ok(message) = rx.recv() {
dbg!(message);
}
});
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 driver = SimpleJoyConDriver::new(&d)?;
let standard_full_mode = StandardFullMode::new(driver)?;
let tx = tx.clone();
std::thread::spawn( move || {
loop {
tx.send(standard_full_mode.read_input_report()).unwrap();
}
});
Ok(())
})?;
Ok(())
}