Skip to content

Commit 5cbc857

Browse files
committed
Handle DualShock3 in controllers()
Also dedup hidapi.device_list() using device serial_number in controllers() because in my tests the DualShock 3 controller was showing up twice.
1 parent b05b85b commit 5cbc857

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

backend/src/api.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,20 @@ pub fn controllers() -> Result<Vec<Controller>> {
100100
}
101101
}
102102

103-
for device_info in hidapi.device_list() {
103+
let mut unique_devices: Vec<_> = hidapi.device_list().collect();
104+
unique_devices.dedup_by(|a, b| a.serial_number() == b.serial_number());
105+
for device_info in unique_devices {
104106
match (device_info.vendor_id(), device_info.product_id()) {
107+
(playstation::DS_VENDOR_ID, playstation::DS3_PRODUCT_ID) => {
108+
debug!("Found DualShock3 controller: {:?}", device_info);
109+
let controller = playstation::parse_dualshock3_controller_data(
110+
device_info,
111+
&hidapi,
112+
"DualShock3",
113+
)?;
114+
115+
controllers.push(controller);
116+
}
105117
(playstation::DS_VENDOR_ID, playstation::DS_PRODUCT_ID) => {
106118
debug!("Found DualSense controller: {:?}", device_info);
107119
let controller = playstation::parse_dualsense_controller_data(

0 commit comments

Comments
 (0)