enigo-rs / enigo

Cross platform input simulation in Rust
MIT License
1.03k stars 102 forks source link

Collection of differences between Rustdesks version and our version #167

Open pentamassiv opened 1 year ago

pentamassiv commented 1 year ago

I am trying to analyze and list the differences between Rustdesks version (as of https://github.com/rustdesk/rustdesk/commit/81bc362b2b414414b58360f87040749dab8465ab) and our version (commit 5bb84e938009385987875472adafaa45613b3534) so we can implement the missing features/fix bugs that they already fixed and maybe allow them to use our upstream version again to not duplicate the development effort.

Here is a list that I will continue to edit and probably open individual issues for:

They added a bunch of keys (I have yet to check if some/all of them were added by now on the master branch)

They marked a lot of the functions with #[inline] (https://matklad.github.io/2021/07/09/inline-in-rust.html)

Cargo.toml

They added hbb_common just to find out if the application runs under X11 or Wayland on Linux

let is_x11 = "x11" == hbb_common::platform::linux::get_display_server();

and they also use some of its types (I don't know why, we use the same types, but directly from libc)

use hbb_common::libc::{c_char, c_int, c_void, useconds_t};

They added log as a dependency

log = "0.4"

They added rdev as a dependency -> I still have to check what for

They added tfc as a dependency -> I still have to check what for

lib.rs

They also import this:

#[cfg(target_os = "windows")]
pub use win::ENIGO_INPUT_EXTRA_VALUE;

The mouse_down and key_down functions return a ResultType:

pub type ResultType = std::result::Result<(), Box<dyn std::error::Error>>;

They allow some casting and added it to the MouseControllable and KeyboardControllable traits:

    // https://stackoverflow.com/a/33687996
    /// Offer the ability to confer concrete type.
    fn as_any(&self) -> &dyn std::any::Any;

    /// Offer the ability to confer concrete type.
    fn as_mut_any(&mut self) -> &mut dyn std::any::Any;

They reverted the deprecation of keys

key_sequence_parse does not panic but prints an error if it fails

They added a fn to check the state of a key to the KeyboardControllable fn get_key_state(&mut self, key: Key) -> bool; And a test to see if it works

They added a dummy Enigo struct for Android and iOS, which does nothing?

linux.rs (they moved it to linux/xdo.rs

In each fn they first check if self.xdo is not NULL

if self.xdo.is_null() {
  return;
}

They added a fn to check the state of a key

They added as_any(&self) and as_mut_any functions

they added key_sequence_parse and key_sequence_parse_try to the KeyboardControllable impl of Enigo

pentamassiv commented 1 year ago

There are a few more files I haven't compared yet

pentamassiv commented 5 months ago

They added some special cases for shift + . on Italian keyboards (e.g https://github.com/rustdesk/rustdesk/commit/7dfa038c6d714607307fca485896d6d12a0b6e28)

pentamassiv commented 5 months ago

They added the ability to get an LED state: https://github.com/rustdesk/rustdesk/commit/72d357e14b305e9186eb1a6c371a6899b50b9d22

They added TFC to simulate input via uinput: https://github.com/indianakernick/The-Fat-Controller

They added rdev, but it looks like it is unused

They are using Pixels as the scroll unit when the touchpad was used on macOS (but they don't check if it was actually the touchpad. They assume it was when it was a horizontal scroll): https://github.com/rustdesk/rustdesk/commit/260c924010361137dd67be145e9d5c0850804768

They added as_any() methods: https://github.com/rustdesk/rustdesk/commit/9dfa02a702277238dcd66afe696d5cf0e9ca3b8f It looks like the method is never used??

There can be sticky Fn keys on macOS and they added a workaround for it: https://github.com/rustdesk/rustdesk/commit/01ade733049c456c0603476c0afb8b8db657d713#diff-964aff976dd9c54ee14fa883d75b78bd4fe601ce12c7a00633033fa26dc21ecf

VK_NUMLOCK, VK_DIVIDE, VK_RCONTROL, VK_RMENU, VK_SNAPSHOT are not considered Extended_keys on windows (https://github.com/rustdesk/rustdesk/commit/c5e39f4bbbc9be670b793fb3dd01e68c87dd44ad)

They do something I haven't fully understood yet: https://github.com/rustdesk/rustdesk/commit/ac74ed1914dbdbf0566673bb7aeeacfc6387c8a2

They do something with the Back and Forward mouse buttons on Windows: https://github.com/rustdesk/rustdesk/commit/c4f9650d7fe2bc1f4116fb124a21c0aeaeba9d67#diff-8735351d4ec65cd079150df61bb6b77a650e4a8f746bfb2634593cdb6fc803ba

Stankye commented 4 months ago

They do something I haven't fully understood yet: https://github.com/rustdesk/rustdesk/commit/ac74ed1914dbdbf0566673bb7aeeacfc6387c8a2

From looking over the code, I believe this started back at this commit https://github.com/rustdesk/rustdesk/commit/3aebc43111f78e361c8e6265b7186fb6b9a529ef

I think this is to support Windows being able to use a different keyboard layouts per application.