这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/linux/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ pub fn convert_event(code: c_uchar, type_: c_int, x: f64, y: f64) -> Option<Even
delta_y: -1,
delta_x: 0,
}),
#[allow(clippy::identity_conversion)]
code => Some(EventType::ButtonPress(Button::Unknown(code))),
},
xlib::ButtonRelease => match code {
1 => Some(EventType::ButtonRelease(Button::Left)),
2 => Some(EventType::ButtonRelease(Button::Middle)),
3 => Some(EventType::ButtonRelease(Button::Right)),
4 | 5 => None,
#[allow(clippy::identity_conversion)]
_ => Some(EventType::ButtonRelease(Button::Unknown(code))),
},
xlib::MotionNotify => Some(EventType::MouseMove { x, y }),
Expand Down
8 changes: 4 additions & 4 deletions src/linux/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ fn evdev_event_to_rdev_event(
) -> Option<EventType> {
match &event.event_code {
EventCode::EV_KEY(key) => {
if let Some(button) = evdev_key_to_rdev_button(&key) {
if let Some(button) = evdev_key_to_rdev_button(key) {
// first check if pressed key is a mouse button
match event.value {
0 => Some(EventType::ButtonRelease(button)),
_ => Some(EventType::ButtonPress(button)),
}
} else if let Some(key) = evdev_key_to_rdev_key(&key) {
} else if let Some(key) = evdev_key_to_rdev_key(key) {
// check if pressed key is a keyboard key
match event.value {
0 => Some(EventType::KeyRelease(key)),
Expand Down Expand Up @@ -345,7 +345,7 @@ where
let mut inotify = setup_inotify(epoll_fd, &devices)?;

//grab devices
let _grab = devices
devices
.iter_mut()
.try_for_each(|device| device.grab(evdev_rs::GrabMode::Grab))?;

Expand Down Expand Up @@ -505,7 +505,7 @@ fn setup_devices() -> io::Result<(RawFd, Vec<Device>, Vec<UInputDevice>)> {
.collect::<io::Result<Vec<Device>>>()?;
let output_devices = devices
.iter()
.map(|device| UInputDevice::create_from_device(device))
.map(UInputDevice::create_from_device)
.collect::<io::Result<Vec<UInputDevice>>>()?;
Ok((epoll_fd, devices, output_devices))
}
Expand Down
4 changes: 3 additions & 1 deletion src/macos/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use std::os::raw::c_void;

static mut GLOBAL_CALLBACK: Option<Box<dyn FnMut(Event) -> Option<Event>>> = None;

#[link(name = "Cocoa", kind = "framework")]
extern "C" {}

unsafe extern "C" fn raw_callback(
_proxy: CGEventTapProxy,
_type: CGEventType,
Expand All @@ -29,7 +32,6 @@ unsafe extern "C" fn raw_callback(
cg_event
}

#[link(name = "Cocoa", kind = "framework")]
pub fn grab<T>(callback: T) -> Result<(), GrabError>
where
T: FnMut(Event) -> Option<Event> + 'static,
Expand Down
4 changes: 3 additions & 1 deletion src/macos/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use std::os::raw::c_void;

static mut GLOBAL_CALLBACK: Option<Box<dyn FnMut(Event)>> = None;

#[link(name = "Cocoa", kind = "framework")]
extern "C" {}

unsafe extern "C" fn raw_callback(
_proxy: CGEventTapProxy,
_type: CGEventType,
Expand All @@ -29,7 +32,6 @@ unsafe extern "C" fn raw_callback(
cg_event
}

#[link(name = "Cocoa", kind = "framework")]
pub fn listen<T>(callback: T) -> Result<(), ListenError>
where
T: FnMut(Event) + 'static,
Expand Down
2 changes: 2 additions & 0 deletions src/macos/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ unsafe fn get_current_mouse_location() -> Option<CGPoint> {
}

#[link(name = "Cocoa", kind = "framework")]
extern "C" {}

pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> {
unsafe {
if let Some(cg_event) = convert_native(event_type) {
Expand Down