Crates.io | dualsense-rs |
lib.rs | dualsense-rs |
version | 0.6.0 |
source | src |
created_at | 2023-12-18 23:46:24.017041 |
updated_at | 2024-03-23 19:47:32.854484 |
description | Rust programmatic wrapper over HID messages sent and received by the PS5 DualSense controller. |
homepage | |
repository | https://github.com/radu781/dualsense-rs |
max_upload_size | |
id | 1073777 |
size | 69,937 |
Rust programmatic wrapper over HID messages sent and received by the PS5 DualSense controller. Allows support for simultaneous key presses or combos that require consecutive presses in a given time interval(wip).
Add callback functions to detect when properties change.
Log details about the left and right sticks' positions:
use dualsense_rs::DualSense;
fn main() {
let mut controller = DualSense::new();
controller.on_left_pad_x_changed(&|lpx| println!("left pad x: {lpx}"));
controller.on_left_pad_x_changed(&|lpx| {
if lpx > 127 {
println!("left pad x in right region: {lpx}")
}
});
controller.on_left_pad_y_changed(&|lpy| println!("left pad y: {lpy}"));
controller.on_right_pad_x_changed(&|rpx| println!("right pad x: {rpx}"));
let handle = controller.run();
// can also add after the `.run()` call
controller.on_right_pad_y_changed(&|rpy| println!("right pad y: {rpy}"));
// make sure to join the thread so the program doesn't stop immediately
handle.join().ok();
}
Output values are stored in an internal cache and will be sent in the following read/write cycle. Packets will not be sent if nothing changed.
use dualsense_rs::DualSense;
fn main() {
let mut controller = DualSense::new();
controller.set_left_trigger_effect(TriggerEffect::Mode1);
let handle = controller.run();
controller.set_light_red(255);
handle.join().ok();
}
Try examples for:
cargo run --example <example>
Currently the following features are of priority: