Skip to content

Commit 0512fd9

Browse files
committed
Fix formatting and clippy warnings for CI
1 parent 03071a5 commit 0512fd9

6 files changed

Lines changed: 24 additions & 40 deletions

File tree

crates/hidpp-daemon/src/daemon.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ async fn connect_and_listen(
220220
wake_rx: &mut tokio::sync::mpsc::Receiver<()>,
221221
) -> anyhow::Result<bool> {
222222
// Prevent system idle sleep during device setup (connect, discover, divert).
223-
let _power_guard =
224-
crate::platform::PowerAssertion::prevent_idle_sleep("HID++ device setup");
223+
let _power_guard = crate::platform::PowerAssertion::prevent_idle_sleep("HID++ device setup");
225224

226225
let device = connect_device(index_override).await?;
227226
let name = device.name().to_string();
@@ -351,9 +350,7 @@ async fn connect_and_listen(
351350
}
352351

353352
/// Headless connect_and_listen — no diversion, no actions, just log.
354-
async fn connect_and_listen_headless(
355-
index_override: Option<DeviceIndex>,
356-
) -> anyhow::Result<()> {
353+
async fn connect_and_listen_headless(index_override: Option<DeviceIndex>) -> anyhow::Result<()> {
357354
let device = connect_device(index_override).await?;
358355

359356
let mut rx = device.subscribe();
@@ -448,9 +445,7 @@ fn handle_notification(
448445
gesture::GestureDirection::Up => gesture_cfg.up.as_ref(),
449446
gesture::GestureDirection::Down => gesture_cfg.down.as_ref(),
450447
gesture::GestureDirection::Left => gesture_cfg.left.as_ref(),
451-
gesture::GestureDirection::Right => {
452-
gesture_cfg.right.as_ref()
453-
}
448+
gesture::GestureDirection::Right => gesture_cfg.right.as_ref(),
454449
};
455450
(format!("swipe {dir_name}"), a)
456451
}
@@ -479,11 +474,7 @@ fn handle_notification(
479474
gestures.button_pressed(cid);
480475
} else if let Some(action) = cfg.buttons.get(&cid) {
481476
let desc = action_description(action);
482-
execute_and_notify(
483-
action,
484-
&format!("button CID {cid}: {desc}"),
485-
proxy,
486-
);
477+
execute_and_notify(action, &format!("button CID {cid}: {desc}"), proxy);
487478
}
488479
}
489480
}

crates/hidpp-daemon/src/main.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ fn run_tray_app(
182182
rt.block_on(async {
183183
#[cfg(unix)]
184184
{
185-
let mut sigterm =
186-
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
187-
.expect("SIGTERM handler");
185+
let mut sigterm = tokio::signal::unix::signal(
186+
tokio::signal::unix::SignalKind::terminate(),
187+
)
188+
.expect("SIGTERM handler");
188189
sigterm.recv().await;
189190
}
190191
#[cfg(not(unix))]
@@ -204,7 +205,12 @@ fn run_tray_app(
204205
// Spawn background daemon thread.
205206
std::thread::spawn(move || {
206207
let rt = tokio::runtime::Runtime::new().expect("tokio runtime");
207-
rt.block_on(daemon::run(&config_path, device_index, proxy.clone(), cmd_rx));
208+
rt.block_on(daemon::run(
209+
&config_path,
210+
device_index,
211+
proxy.clone(),
212+
cmd_rx,
213+
));
208214
// Daemon exited (shutdown command or signal) — tell the event loop to quit.
209215
let _ = proxy.send_event(DaemonEvent::Shutdown);
210216
});
@@ -438,8 +444,8 @@ fn init_logging(log_level: &str) {
438444
#[cfg(not(target_os = "macos"))]
439445
{
440446
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
441-
let state_dir = std::env::var("XDG_STATE_HOME")
442-
.unwrap_or_else(|_| format!("{home}/.local/state"));
447+
let state_dir =
448+
std::env::var("XDG_STATE_HOME").unwrap_or_else(|_| format!("{home}/.local/state"));
443449
let log_path = std::path::Path::new(&state_dir).join("hidpp/hidppd.log");
444450

445451
if let Some(parent) = log_path.parent() {

crates/hidpp-daemon/src/platform.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#[cfg(target_os = "macos")]
88
#[allow(unsafe_code)]
99
mod imp {
10-
use std::ffi::c_void;
1110
use std::ffi::CString;
11+
use std::ffi::c_void;
1212
use std::io::Read;
1313
use std::os::fd::FromRawFd;
1414

@@ -44,9 +44,7 @@ mod imp {
4444
unsafe { notify_register_file_descriptor(name.as_ptr(), &mut fd, 0, &mut token) };
4545

4646
if status != 0 || fd < 0 {
47-
tracing::warn!(
48-
"failed to register for power state notifications (status={status})"
49-
);
47+
tracing::warn!("failed to register for power state notifications (status={status})");
5048
return;
5149
}
5250

@@ -80,14 +78,8 @@ mod imp {
8078
const K_CF_NUMBER_INT_TYPE: u64 = 9; // kCFNumberIntType
8179

8280
unsafe extern "C" {
83-
fn IOHIDManagerCreate(
84-
allocator: *const c_void,
85-
options: u32,
86-
) -> *mut c_void;
87-
fn IOHIDManagerSetDeviceMatching(
88-
manager: *mut c_void,
89-
matching: *const c_void,
90-
);
81+
fn IOHIDManagerCreate(allocator: *const c_void, options: u32) -> *mut c_void;
82+
fn IOHIDManagerSetDeviceMatching(manager: *mut c_void, matching: *const c_void);
9183
fn IOHIDManagerRegisterDeviceMatchingCallback(
9284
manager: *mut c_void,
9385
callback: unsafe extern "C" fn(*mut c_void, i32, *mut c_void, *mut c_void),
@@ -332,6 +324,6 @@ mod imp {
332324
}
333325
}
334326

327+
pub use imp::PowerAssertion;
335328
pub use imp::spawn_hid_watcher;
336329
pub use imp::spawn_wake_watcher;
337-
pub use imp::PowerAssertion;

crates/hidpp-device/tests/integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async fn dpi_read() {
9595

9696
let dpi = device.dpi_get().await.expect("DPI read failed");
9797

98-
assert!(dpi >= 200 && dpi <= 8000, "DPI out of range: {dpi}");
98+
assert!((200..=8000).contains(&dpi), "DPI out of range: {dpi}");
9999
println!("DPI: {dpi}");
100100
}
101101

@@ -221,7 +221,7 @@ async fn config_export() {
221221
println!("{toml}");
222222

223223
// Should contain device name.
224-
assert!(toml.contains("MX Master") || toml.contains(&device.name()));
224+
assert!(toml.contains("MX Master") || toml.contains(device.name()));
225225

226226
// Round-trip: parse the TOML back.
227227
let parsed = hidpp_device::DeviceConfig::from_toml(&toml).expect("TOML parse failed");

crates/hidpp-transport/src/native.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,7 @@ impl HidapiTransport {
249249
self.send(report).await?;
250250

251251
// Wait for response with timeout.
252-
match tokio::time::timeout(
253-
Duration::from_millis(RESPONSE_TIMEOUT_MS),
254-
response_rx,
255-
)
256-
.await
257-
{
252+
match tokio::time::timeout(Duration::from_millis(RESPONSE_TIMEOUT_MS), response_rx).await {
258253
Ok(Ok(response)) => Ok(response),
259254
Ok(Err(_)) => Err(TransportError::Disconnected),
260255
Err(_) => Err(TransportError::Timeout),

web/docs/device.png

11.6 KB
Loading

0 commit comments

Comments
 (0)