mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-25 06:00:54 +03:00
Compare commits
3 Commits
fix-usize-
...
fix-UB-tra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc17f7033f | ||
|
|
1c37579ae5 | ||
|
|
460bacade5 |
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1292,6 +1292,7 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"clap",
|
"clap",
|
||||||
"core-graphics",
|
"core-graphics",
|
||||||
|
"endi",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ once_cell = "1.19.0"
|
|||||||
num_enum = "0.7.2"
|
num_enum = "0.7.2"
|
||||||
hostname = "0.4.0"
|
hostname = "0.4.0"
|
||||||
slab = "0.4.9"
|
slab = "0.4.9"
|
||||||
|
endi = "1.1.0"
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
libc = "0.2.148"
|
libc = "0.2.148"
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -69,7 +69,15 @@ Precompiled release binaries for Windows, MacOS and Linux are available in the [
|
|||||||
For Windows, the depenedencies are included in the .zip file, for other operating systems see [Installing Dependencies](#installing-dependencies).
|
For Windows, the depenedencies are included in the .zip file, for other operating systems see [Installing Dependencies](#installing-dependencies).
|
||||||
|
|
||||||
### Arch Linux
|
### Arch Linux
|
||||||
Lan Mouse is available on the AUR:
|
|
||||||
|
Lan Mouse can be installed from the [official repositories](https://archlinux.org/packages/extra/x86_64/lan-mouse/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pacman -S lan-mouse
|
||||||
|
```
|
||||||
|
|
||||||
|
It is also available on the AUR:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# git version (includes latest changes)
|
# git version (includes latest changes)
|
||||||
paru -S lan-mouse-git
|
paru -S lan-mouse-git
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ unsafe fn get_event_tid() -> Option<u32> {
|
|||||||
static mut ENTRY_POINT: (i32, i32) = (0, 0);
|
static mut ENTRY_POINT: (i32, i32) = (0, 0);
|
||||||
|
|
||||||
fn to_mouse_event(wparam: WPARAM, lparam: LPARAM) -> Option<PointerEvent> {
|
fn to_mouse_event(wparam: WPARAM, lparam: LPARAM) -> Option<PointerEvent> {
|
||||||
let mouse_low_level: MSLLHOOKSTRUCT =
|
let mouse_low_level: MSLLHOOKSTRUCT = unsafe { *(lparam.0 as *const MSLLHOOKSTRUCT) };
|
||||||
unsafe { *std::mem::transmute::<LPARAM, *const MSLLHOOKSTRUCT>(lparam) };
|
|
||||||
match wparam {
|
match wparam {
|
||||||
WPARAM(p) if p == WM_LBUTTONDOWN as usize => Some(PointerEvent::Button {
|
WPARAM(p) if p == WM_LBUTTONDOWN as usize => Some(PointerEvent::Button {
|
||||||
time: 0,
|
time: 0,
|
||||||
@@ -167,8 +166,7 @@ fn to_mouse_event(wparam: WPARAM, lparam: LPARAM) -> Option<PointerEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn to_key_event(wparam: WPARAM, lparam: LPARAM) -> Option<KeyboardEvent> {
|
unsafe fn to_key_event(wparam: WPARAM, lparam: LPARAM) -> Option<KeyboardEvent> {
|
||||||
let kybrdllhookstruct: KBDLLHOOKSTRUCT =
|
let kybrdllhookstruct: KBDLLHOOKSTRUCT = *(lparam.0 as *const KBDLLHOOKSTRUCT);
|
||||||
*std::mem::transmute::<LPARAM, *const KBDLLHOOKSTRUCT>(lparam);
|
|
||||||
let mut scan_code = kybrdllhookstruct.scanCode;
|
let mut scan_code = kybrdllhookstruct.scanCode;
|
||||||
log::trace!("scan_code: {scan_code}");
|
log::trace!("scan_code: {scan_code}");
|
||||||
if kybrdllhookstruct.flags.contains(LLKHF_EXTENDED) {
|
if kybrdllhookstruct.flags.contains(LLKHF_EXTENDED) {
|
||||||
@@ -247,8 +245,7 @@ unsafe fn check_client_activation(wparam: WPARAM, lparam: LPARAM) -> bool {
|
|||||||
if wparam.0 != WM_MOUSEMOVE as usize {
|
if wparam.0 != WM_MOUSEMOVE as usize {
|
||||||
return ACTIVE_CLIENT.is_some();
|
return ACTIVE_CLIENT.is_some();
|
||||||
}
|
}
|
||||||
let mouse_low_level: MSLLHOOKSTRUCT =
|
let mouse_low_level: MSLLHOOKSTRUCT = *(lparam.0 as *const MSLLHOOKSTRUCT);
|
||||||
unsafe { *std::mem::transmute::<LPARAM, *const MSLLHOOKSTRUCT>(lparam) };
|
|
||||||
static mut PREV_POS: Option<(i32, i32)> = None;
|
static mut PREV_POS: Option<(i32, i32)> = None;
|
||||||
let curr_pos = (mouse_low_level.pt.x, mouse_low_level.pt.y);
|
let curr_pos = (mouse_low_level.pt.x, mouse_low_level.pt.y);
|
||||||
let prev_pos = PREV_POS.unwrap_or(curr_pos);
|
let prev_pos = PREV_POS.unwrap_or(curr_pos);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use std::{
|
|||||||
use crate::frontend::{gtk::window::Window, FrontendRequest};
|
use crate::frontend::{gtk::window::Window, FrontendRequest};
|
||||||
|
|
||||||
use adw::Application;
|
use adw::Application;
|
||||||
|
use endi::{Endian, ReadBytes};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gdk::Display, glib::clone, prelude::*, subclass::prelude::ObjectSubclassIsExt, IconTheme,
|
gdk::Display, glib::clone, prelude::*, subclass::prelude::ObjectSubclassIsExt, IconTheme,
|
||||||
};
|
};
|
||||||
@@ -85,16 +86,14 @@ fn build_ui(app: &Application) {
|
|||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
match loop {
|
match loop {
|
||||||
// read length
|
// read length
|
||||||
let mut len = [0u8; 8];
|
let len = match rx.read_u64(Endian::Big) {
|
||||||
match rx.read_exact(&mut len) {
|
Ok(l) => l,
|
||||||
Ok(_) => (),
|
|
||||||
Err(e) if e.kind() == ErrorKind::UnexpectedEof => break Ok(()),
|
Err(e) if e.kind() == ErrorKind::UnexpectedEof => break Ok(()),
|
||||||
Err(e) => break Err(e),
|
Err(e) => break Err(e),
|
||||||
};
|
};
|
||||||
let len = usize::from_be_bytes(len);
|
|
||||||
|
|
||||||
// read payload
|
// read payload
|
||||||
let mut buf = vec![0u8; len];
|
let mut buf = vec![0u8; len as usize];
|
||||||
match rx.read_exact(&mut buf) {
|
match rx.read_exact(&mut buf) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) if e.kind() == ErrorKind::UnexpectedEof => break Ok(()),
|
Err(e) if e.kind() == ErrorKind::UnexpectedEof => break Ok(()),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use std::net::TcpStream;
|
|||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
|
use endi::{Endian, WriteBytes};
|
||||||
use glib::{clone, Object};
|
use glib::{clone, Object};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio,
|
gio,
|
||||||
@@ -265,8 +266,7 @@ impl Window {
|
|||||||
let mut stream = self.imp().stream.borrow_mut();
|
let mut stream = self.imp().stream.borrow_mut();
|
||||||
let stream = stream.as_mut().unwrap();
|
let stream = stream.as_mut().unwrap();
|
||||||
let bytes = json.as_bytes();
|
let bytes = json.as_bytes();
|
||||||
let len = bytes.len().to_be_bytes();
|
if let Err(e) = stream.write_u64(Endian::Big, bytes.len() as u64) {
|
||||||
if let Err(e) = stream.write(&len) {
|
|
||||||
log::error!("error sending message: {e}");
|
log::error!("error sending message: {e}");
|
||||||
};
|
};
|
||||||
if let Err(e) = stream.write(bytes) {
|
if let Err(e) = stream.write(bytes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user