From 66de3e3cbc2f8e6013db8c6bc189bb6b4e7e15a7 Mon Sep 17 00:00:00 2001 From: Ferdinand Schober Date: Mon, 18 Dec 2023 21:38:12 +0100 Subject: [PATCH] fix remaining clippy lints --- src/backend/consumer/macos.rs | 2 +- src/backend/consumer/windows.rs | 4 ++-- src/backend/producer/macos.rs | 5 +++-- src/producer.rs | 5 ++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/backend/consumer/macos.rs b/src/backend/consumer/macos.rs index a4dbfc29..9001e24b 100644 --- a/src/backend/consumer/macos.rs +++ b/src/backend/consumer/macos.rs @@ -140,7 +140,7 @@ impl EventConsumer for MacOSConsumer { } }; // store button state - self.button_state[mouse_button] = if state == 1 { true } else { false }; + self.button_state[mouse_button] = state == 1; let location = self.get_mouse_location().unwrap(); let event = match CGEvent::new_mouse_event( diff --git a/src/backend/consumer/windows.rs b/src/backend/consumer/windows.rs index 1d96e633..c3333f9a 100644 --- a/src/backend/consumer/windows.rs +++ b/src/backend/consumer/windows.rs @@ -80,7 +80,7 @@ fn send_mouse_input(mi: MOUSEINPUT) { }; SendInput( - 1 as u32, + 1_u32, &mut input as LPINPUT, std::mem::size_of::() as i32, ); @@ -173,7 +173,7 @@ fn send_keyboard_input(ki: KEYBDINPUT) { u: std::mem::zeroed(), }; *input.u.ki_mut() = ki; - SendInput(1 as u32, &mut input, std::mem::size_of::() as i32); + SendInput(1_u32, &mut input, std::mem::size_of::() as i32); } } diff --git a/src/backend/producer/macos.rs b/src/backend/producer/macos.rs index 1f9e5ce4..89341eb7 100644 --- a/src/backend/producer/macos.rs +++ b/src/backend/producer/macos.rs @@ -1,3 +1,4 @@ +use anyhow::{anyhow, Result}; use crate::client::{ClientEvent, ClientHandle}; use crate::event::Event; use crate::producer::EventProducer; @@ -8,8 +9,8 @@ use std::{io, pin::Pin}; pub struct MacOSProducer; impl MacOSProducer { - pub fn new() -> Self { - Self {} + pub fn new() -> Result { + Err(anyhow!("not yet implemented")) } } diff --git a/src/producer.rs b/src/producer.rs index def6fef9..1c6acf2c 100644 --- a/src/producer.rs +++ b/src/producer.rs @@ -10,7 +10,10 @@ use crate::{ pub async fn create() -> Box { #[cfg(target_os = "macos")] - return Box::new(producer::macos::MacOSProducer::new()); + match producer::macos::MacOSProducer::new() { + Ok(p) => return Box::new(p), + Err(e) => log::info!("macos event producer not available: {e}"), + } #[cfg(windows)] match producer::windows::WindowsProducer::new() {