Crates.io | dual-shock4-controller |
lib.rs | dual-shock4-controller |
version | 0.1.1 |
source | src |
created_at | 2020-08-19 05:29:17.792782 |
updated_at | 2020-08-19 06:05:01.054618 |
description | Sony DualShock 4 Controller for Rust |
homepage | https://github.com/ookicent/dual-shock4-controller |
repository | https://github.com/ookicent/dual-shock4-controller.git |
max_upload_size | |
id | 278113 |
size | 7,843 |
Getting Started| Documentation | | Blog
Sony DualShock 4 Controller for Rust
Add this to your Cargo.toml
:
dual-shock4-controller = "0.1.0"
use dual_shock4_controller::joystick::{DeviceInfo,Joystick};
let joystick = Joystick::new();
let device_info = DeviceInfo{vid:0x054c,pid:0x05c4};//HID\VID_054C&PID_05C4\7&3869AC07&0&0000
let device = joystick.connect(device_info).expect("can't find device!");//
loop {
let mut buf = [0u8;64];
device.read_timeout(&mut buf[..], 1000).unwrap();
let gamepad = joystick.get_gamepad().get_state(&buf);
if gamepad.x_button.pressed {
println!("× button is pressed");
break;
}
}
This repository is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.