Crates.io | dualshock4 |
lib.rs | dualshock4 |
version | 0.1.1 |
source | src |
created_at | 2018-02-28 18:03:01.933993 |
updated_at | 2018-03-20 06:33:19.489943 |
description | Read Dualshock4 controller data by using hidapi |
homepage | https://bitbucket.org/unessa/dualshock4-rust |
repository | https://bitbucket.org/unessa/dualshock4-rust.git |
max_upload_size | |
id | 53212 |
size | 26,824 |
This library is used to read dualshock4 controller data.
Dualshock4 event data documentation: http://www.psdevwiki.com/ps4/DS4-USB
Connect dualshock4 controller to your computer by using USB or bluetooth connection.
Add the following dependencies:
[dependencies]
hidapi = "0.4.1"
dualshock4 = "0.1.0"
Start reading device data:
extern crate hidapi;
extern crate dualshock4;
use hidapi::{HidApi};
fn main() {
let api = HidApi::new().expect("Failed to create HID API instance.");
let controller = dualshock4::get_device(&api).expect("Failed to open device");
loop {
let data = dualshock4::read(&controller)
.expect("Failed to read data");
println!("{:?}", data);
}
}