mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-12 12:41:30 +03:00
enable conditional compilation for all backends
To reduce binary size one can now enable only specific backends, e.g. wayland or x11 via cargo features Additionally adds stubs for libei and xdg-desktop-portal backends
This commit is contained in:
60
src/backend/consumer/windows.rs
Normal file
60
src/backend/consumer/windows.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
use crate::event::{KeyboardEvent, PointerEvent};
|
||||
use winapi::{
|
||||
self,
|
||||
um::winuser::{INPUT, INPUT_MOUSE, LPINPUT, MOUSEEVENTF_MOVE, MOUSEINPUT},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
client::{Client, ClientHandle},
|
||||
event::Event,
|
||||
};
|
||||
|
||||
fn rel_mouse(dx: i32, dy: i32) {
|
||||
let mi = MOUSEINPUT {
|
||||
dx,
|
||||
dy,
|
||||
mouseData: 0,
|
||||
dwFlags: MOUSEEVENTF_MOVE,
|
||||
time: 0,
|
||||
dwExtraInfo: 0,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut input = INPUT {
|
||||
type_: INPUT_MOUSE,
|
||||
u: std::mem::transmute(mi),
|
||||
};
|
||||
|
||||
winapi::um::winuser::SendInput(
|
||||
1 as u32,
|
||||
&mut input as LPINPUT,
|
||||
std::mem::size_of::<INPUT>() as i32,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(event_rx: Receiver<(Event, ClientHandle)>, _clients: Vec<Client>) {
|
||||
loop {
|
||||
match event_rx.recv().expect("event receiver unavailable").0 {
|
||||
Event::Pointer(pointer_event) => match pointer_event {
|
||||
PointerEvent::Motion {
|
||||
time: _,
|
||||
relative_x,
|
||||
relative_y,
|
||||
} => {
|
||||
rel_mouse(relative_x as i32, relative_y as i32);
|
||||
}
|
||||
PointerEvent::Button { .. } => {}
|
||||
PointerEvent::Axis { .. } => {}
|
||||
PointerEvent::Frame {} => {}
|
||||
},
|
||||
Event::Keyboard(keyboard_event) => match keyboard_event {
|
||||
KeyboardEvent::Key { .. } => {}
|
||||
KeyboardEvent::Modifiers { .. } => {}
|
||||
},
|
||||
Event::Release() => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user