diff --git a/Cargo.lock b/Cargo.lock index 35d87cbd7..96ff5a811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3985,7 +3985,7 @@ dependencies = [ "libc", "widestring 1.0.2", "winapi 0.3.9", - "x11", + "x11 2.20.0", ] [[package]] @@ -4993,11 +4993,12 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "tfc" version = "0.6.1" -source = "git+https://github.com/asur4s/The-Fat-Controller#25bfa7ef1cb0bd0b522cc4155dea6b99673bcfd4" +source = "git+https://github.com/asur4s/The-Fat-Controller#8ef82be83d8d941f08bdb84e77bea52290f92050" dependencies = [ "core-graphics 0.22.3", "unicode-segmentation", "winapi 0.3.9", + "x11 2.19.0", ] [[package]] @@ -5931,6 +5932,15 @@ dependencies = [ "tap", ] +[[package]] +name = "x11" +version = "2.19.0" +source = "git+https://github.com/bjornsnoen/x11-rs#c2e9bfaa7b196938f8700245564d8ac5d447786a" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "x11" version = "2.20.0" diff --git a/DEBIAN/postinst b/DEBIAN/postinst index 1c7697acc..d643c5caf 100755 --- a/DEBIAN/postinst +++ b/DEBIAN/postinst @@ -12,9 +12,6 @@ if [ "$1" = configure ]; then fi version=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)') parsedVersion=$(echo "${version//./}") - if [[ "$parsedVersion" -gt "360" ]]; then - sudo -H pip3 install pynput - fi cp /usr/share/rustdesk/files/systemd/rustdesk.service /usr/lib/systemd/system/rustdesk.service systemctl daemon-reload systemctl enable rustdesk diff --git a/PKGBUILD b/PKGBUILD index 6fb65d48b..1d1956ede 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -26,6 +26,5 @@ package() { install -Dm 644 ${HBB}/libsciter-gtk.so -t "${pkgdir}/usr/lib/rustdesk" install -Dm 644 $HBB/rustdesk.service -t "${pkgdir}/usr/share/rustdesk/files" install -Dm 644 $HBB/rustdesk.desktop -t "${pkgdir}/usr/share/rustdesk/files" - install -Dm 644 $HBB/pynput_service.py -t "${pkgdir}/usr/share/rustdesk/files" install -Dm 644 $HBB/128x128@2x.png "${pkgdir}/usr/share/rustdesk/files/rustdesk.png" } diff --git a/README-AR.md b/README-AR.md index 2deb4914b..c0186037e 100644 --- a/README-AR.md +++ b/README-AR.md @@ -80,11 +80,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### pynput package تثبيت - -```sh -pip3 install pynput -``` ### vcpkg تثبيت diff --git a/README-CS.md b/README-CS.md index 4f2c0e80f..7ad86e08b 100644 --- a/README-CS.md +++ b/README-CS.md @@ -75,12 +75,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Instalace balíčku pynput - -```sh -pip3 install pynput -``` - ### Instalace vcpkg ```sh diff --git a/README-FA.md b/README-FA.md index 5fd3c0d03..f7de9aa87 100644 --- a/README-FA.md +++ b/README-FA.md @@ -78,12 +78,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### بسته pynput را نصب کنید - -```sh -pip3 install pynput -``` - ### نرم افزار vcpkg را نصب کنید ```sh diff --git a/README-HU.md b/README-HU.md index 3960d8b40..cfc6c793d 100644 --- a/README-HU.md +++ b/README-HU.md @@ -81,12 +81,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Telepítsd a pynput csomagot - -```sh -pip3 install pynput -``` - ### Telepítsd a vcpkg-t ```sh diff --git a/README-JP.md b/README-JP.md index c1722a90f..394fbc52a 100644 --- a/README-JP.md +++ b/README-JP.md @@ -80,12 +80,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Install pynput package - -```sh -pip3 install pynput -``` - ### Install vcpkg ```sh diff --git a/README-KR.md b/README-KR.md index c7cf423da..9a87d8ab1 100644 --- a/README-KR.md +++ b/README-KR.md @@ -78,12 +78,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Install pynput package - -```sh -pip3 install pynput -``` - ### Install vcpkg ```sh diff --git a/README-VN.md b/README-VN.md index 641b80ebd..b7b683e4f 100644 --- a/README-VN.md +++ b/README-VN.md @@ -82,12 +82,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Cách tải về gói hàng pynput - -```sh -pip3 install pynput -``` - ### Cách cài vcpkg ```sh diff --git a/README.md b/README.md index 456862af5..fbbc1b60b 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,6 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb- sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pulseaudio ``` -### Install pynput package - -```sh -pip3 install pynput -``` - ### Install vcpkg ```sh diff --git a/appimage/AppImageBuilder.yml b/appimage/AppImageBuilder.yml index 08a4f0786..cdaead908 100644 --- a/appimage/AppImageBuilder.yml +++ b/appimage/AppImageBuilder.yml @@ -9,8 +9,6 @@ script: # Download sciter.so - mkdir -p AppDir/usr/lib/rustdesk/ - pushd AppDir/usr/lib/rustdesk && wget https://github.com/c-smile/sciter-sdk/raw/29a598b6d20220b93848b5e8abab704619296857/bin.lnx/x64/libsciter-gtk.so && popd - # pynput_service.py - - cp ../pynput_service.py ./AppDir/usr/lib/rustdesk # Build rustdesk - pushd .. && python3 inline-sciter.py && cargo build --features inline,appimage --release && popd - mkdir -p AppDir/usr/bin diff --git a/appimage/requirements.txt b/appimage/requirements.txt deleted file mode 100644 index d632797e5..000000000 --- a/appimage/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pynput \ No newline at end of file diff --git a/build.py b/build.py index 6b03cb57b..095f8b7f1 100755 --- a/build.py +++ b/build.py @@ -140,8 +140,6 @@ def build_flutter_deb(version): 'cp rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') os.system( 'cp rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') - os.system( - 'cp ../pynput_service.py tmpdeb/usr/share/rustdesk/files/') os.system( 'cp ../128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') os.system( @@ -150,7 +148,6 @@ def build_flutter_deb(version): os.system('cp -a ../DEBIAN/* tmpdeb/DEBIAN/') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service.user') - md5_file('usr/share/rustdesk/files/pynput_service.py') os.system('dpkg-deb -b tmpdeb rustdesk.deb; /bin/rm -rf tmpdeb/') os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version) os.chdir("..") @@ -285,15 +282,12 @@ def main(): 'cp rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') os.system( 'cp rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') - os.system( - 'cp pynput_service.py tmpdeb/usr/share/rustdesk/files/') os.system('cp -a DEBIAN/* tmpdeb/DEBIAN/') os.system('strip tmpdeb/usr/bin/rustdesk') os.system('mkdir -p tmpdeb/usr/lib/rustdesk') os.system('cp libsciter-gtk.so tmpdeb/usr/lib/rustdesk/') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service.user') - md5_file('usr/share/rustdesk/files/pynput_service.py') md5_file('usr/lib/rustdesk/libsciter-gtk.so') os.system('dpkg-deb -b tmpdeb rustdesk.deb; /bin/rm -rf tmpdeb/') os.rename('rustdesk.deb', 'rustdesk-%s.deb' % version) diff --git a/libs/enigo/src/linux/mod.rs b/libs/enigo/src/linux/mod.rs index 42e1dfebf..1f73004ad 100644 --- a/libs/enigo/src/linux/mod.rs +++ b/libs/enigo/src/linux/mod.rs @@ -1,5 +1,4 @@ mod nix_impl; -mod pynput; mod xdo; pub use self::nix_impl::Enigo; diff --git a/libs/enigo/src/linux/nix_impl.rs b/libs/enigo/src/linux/nix_impl.rs index 7a8f6668e..0c9b30eff 100644 --- a/libs/enigo/src/linux/nix_impl.rs +++ b/libs/enigo/src/linux/nix_impl.rs @@ -1,11 +1,10 @@ -use super::{pynput::EnigoPynput, xdo::EnigoXdo}; +use super::{xdo::EnigoXdo}; use crate::{Key, KeyboardControllable, MouseButton, MouseControllable}; /// The main struct for handling the event emitting // #[derive(Default)] pub struct Enigo { xdo: EnigoXdo, - pynput: EnigoPynput, is_x11: bool, uinput_keyboard: Option>, uinput_mouse: Option>, @@ -20,9 +19,9 @@ impl Enigo { pub fn set_delay(&mut self, delay: u64) { self.xdo.set_delay(delay) } - /// Reset pynput. + /// Reset pynput?. pub fn reset(&mut self) { - self.pynput.reset(); + todo!() } /// Set uinput keyboard. pub fn set_uinput_keyboard( @@ -44,7 +43,6 @@ impl Default for Enigo { uinput_keyboard: None, uinput_mouse: None, xdo: EnigoXdo::default(), - pynput: EnigoPynput::default(), } } } @@ -142,9 +140,6 @@ impl KeyboardControllable for Enigo { fn key_down(&mut self, key: Key) -> crate::ResultType { if self.is_x11 { - if self.pynput.send_pynput(&key, true) { - return Ok(()); - } self.xdo.key_down(key) } else { if let Some(keyboard) = &mut self.uinput_keyboard { @@ -156,9 +151,6 @@ impl KeyboardControllable for Enigo { } fn key_up(&mut self, key: Key) { if self.is_x11 { - if self.pynput.send_pynput(&key, false) { - return; - } self.xdo.key_up(key) } else { if let Some(keyboard) = &mut self.uinput_keyboard { diff --git a/libs/enigo/src/linux/pynput.rs b/libs/enigo/src/linux/pynput.rs deleted file mode 100644 index 836c645fe..000000000 --- a/libs/enigo/src/linux/pynput.rs +++ /dev/null @@ -1,279 +0,0 @@ -use crate::Key; -use std::{io::prelude::*, sync::mpsc}; - -enum PyMsg { - Char(char), - Str(&'static str), -} - -/// The main struct for handling the event emitting -pub(super) struct EnigoPynput { - tx: mpsc::Sender<(PyMsg, bool)>, -} - -impl Default for EnigoPynput { - fn default() -> Self { - let (tx, rx) = mpsc::channel(); - start_pynput_service(rx); - Self { tx } - } -} -impl EnigoPynput { - pub(super) fn reset(&mut self) { - self.tx.send((PyMsg::Char('\0'), true)).ok(); - } - - #[inline] - pub(super) fn send_pynput(&mut self, key: &Key, is_press: bool) -> bool { - if unsafe { PYNPUT_EXIT || !PYNPUT_REDAY } { - return false; - } - if let Key::Layout(c) = key { - return self.tx.send((PyMsg::Char(*c), is_press)).is_ok(); - } - if let Key::Raw(_) = key { - return false; - } - #[allow(deprecated)] - let s = match key { - Key::Alt => "Alt_L", - Key::Backspace => "BackSpace", - Key::CapsLock => "Caps_Lock", - Key::Control => "Control_L", - Key::Delete => "Delete", - Key::DownArrow => "Down", - Key::End => "End", - Key::Escape => "Escape", - Key::F1 => "F1", - Key::F10 => "F10", - Key::F11 => "F11", - Key::F12 => "F12", - Key::F2 => "F2", - Key::F3 => "F3", - Key::F4 => "F4", - Key::F5 => "F5", - Key::F6 => "F6", - Key::F7 => "F7", - Key::F8 => "F8", - Key::F9 => "F9", - Key::Home => "Home", - Key::LeftArrow => "Left", - Key::Option => "Option", - Key::PageDown => "Page_Down", - Key::PageUp => "Page_Up", - Key::Return => "Return", - Key::RightArrow => "Right", - Key::Shift => "Shift_L", - Key::Space => "space", - Key::Tab => "Tab", - Key::UpArrow => "Up", - Key::Numpad0 => "KP_0", - Key::Numpad1 => "KP_1", - Key::Numpad2 => "KP_2", - Key::Numpad3 => "KP_3", - Key::Numpad4 => "KP_4", - Key::Numpad5 => "KP_5", - Key::Numpad6 => "KP_6", - Key::Numpad7 => "KP_7", - Key::Numpad8 => "KP_8", - Key::Numpad9 => "KP_9", - Key::Decimal => "KP_Decimal", - Key::Cancel => "Cancel", - Key::Clear => "Clear", - Key::Pause => "Pause", - Key::Kana => "Kana", - Key::Hangul => "Hangul", - Key::Hanja => "Hanja", - Key::Kanji => "Kanji", - Key::Select => "Select", - Key::Print => "Print", - Key::Execute => "Execute", - Key::Snapshot => "3270_PrintScreen", - Key::Insert => "Insert", - Key::Help => "Help", - Key::Separator => "KP_Separator", - Key::Scroll => "Scroll_Lock", - Key::NumLock => "Num_Lock", - Key::RWin => "Super_R", - Key::Apps => "Menu", - Key::Multiply => "KP_Multiply", - Key::Add => "KP_Add", - Key::Subtract => "KP_Subtract", - Key::Divide => "KP_Divide", - Key::Equals => "KP_Equal", - Key::NumpadEnter => "KP_Enter", - Key::RightShift => "Shift_R", - Key::RightControl => "Control_R", - Key::RightAlt => "Mode_switch", - Key::Command | Key::Super | Key::Windows | Key::Meta => "Super_L", - _ => { - return true; - } - }; - return self.tx.send((PyMsg::Str(s), is_press)).is_ok(); - } -} - -// impl MouseControllable for EnigoPynput { -// fn mouse_move_to(&mut self, _x: i32, _y: i32) { -// unimplemented!() -// } -// fn mouse_move_relative(&mut self, _x: i32, _y: i32) { -// unimplemented!() -// } -// fn mouse_down(&mut self, _button: MouseButton) -> crate::ResultType { -// unimplemented!() -// } -// fn mouse_up(&mut self, _button: MouseButton) { -// unimplemented!() -// } -// fn mouse_click(&mut self, _button: MouseButton) { -// unimplemented!() -// } -// fn mouse_scroll_x(&mut self, _length: i32) { -// unimplemented!() -// } -// fn mouse_scroll_y(&mut self, _length: i32) { -// unimplemented!() -// } -// } - -// impl KeyboardControllable for EnigoPynput { -// fn get_key_state(&mut self, _key: Key) -> bool { -// unimplemented!() -// } - -// fn key_sequence(&mut self, _sequence: &str) { -// unimplemented!() -// } -// fn key_down(&mut self, key: Key) -> crate::ResultType { -// let _ = self.send_pynput(&key, true); -// Ok(()) -// } -// fn key_up(&mut self, key: Key) { -// let _ = self.send_pynput(&key, false); -// } -// fn key_click(&mut self, _key: Key) { -// unimplemented!() -// } -// } - -static mut PYNPUT_EXIT: bool = false; -static mut PYNPUT_REDAY: bool = false; -static IPC_FILE: &'static str = "/tmp/RustDesk/pynput_service"; - -fn start_pynput_service(rx: mpsc::Receiver<(PyMsg, bool)>) { - let mut py = "./pynput_service.py".to_owned(); - if !std::path::Path::new(&py).exists() { - py = "/usr/share/rustdesk/files/pynput_service.py".to_owned(); - if !std::path::Path::new(&py).exists() { - py = "/usr/lib/rustdesk/pynput_service.py".to_owned(); - if !std::path::Path::new(&py).exists() { - log::error!("{} not exits", py); - } - } - } - log::info!("pynput service: {}", py); - std::thread::spawn(move || { - let username = std::env::var("PYNPUT_USERNAME").unwrap_or("".to_owned()); - let userid = std::env::var("PYNPUT_USERID").unwrap_or("".to_owned()); - let status = if username.is_empty() { - std::process::Command::new("python3") - .arg(&py) - .arg(IPC_FILE) - .status() - .map(|x| x.success()) - } else { - let mut status = Ok(true); - for i in 0..100 { - if i % 10 == 0 { - log::info!("#{} try to start pynput server", i); - } - status = std::process::Command::new("sudo") - .args(vec![ - "-E", - &format!("XDG_RUNTIME_DIR=/run/user/{}", userid) as &str, - "-u", - &username, - "python3", - &py, - IPC_FILE, - ]) - .status() - .map(|x| x.success()); - match status { - Ok(true) => break, - _ => {} - } - std::thread::sleep(std::time::Duration::from_millis(100)); - } - status - }; - log::info!( - "pynput server exit with username/id {}/{}: {:?}", - username, - userid, - status - ); - unsafe { - PYNPUT_EXIT = true; - } - }); - std::thread::spawn(move || { - for i in 0..300 { - std::thread::sleep(std::time::Duration::from_millis(100)); - let mut conn = match std::os::unix::net::UnixStream::connect(IPC_FILE) { - Ok(conn) => conn, - Err(err) => { - if i % 15 == 0 { - log::warn!("Failed to connect to {}: {}", IPC_FILE, err); - } - continue; - } - }; - if let Err(err) = conn.set_nonblocking(true) { - log::error!("Failed to set ipc nonblocking: {}", err); - return; - } - log::info!("Conntected to pynput server"); - let d = std::time::Duration::from_millis(30); - unsafe { - PYNPUT_REDAY = true; - } - let mut buf = [0u8; 1024]; - loop { - if unsafe { PYNPUT_EXIT } { - break; - } - match rx.recv_timeout(d) { - Ok((msg, is_press)) => { - let msg = match msg { - PyMsg::Char(chr) => { - format!("{}{}", if is_press { 'p' } else { 'r' }, chr) - } - PyMsg::Str(s) => format!("{}{}", if is_press { 'p' } else { 'r' }, s), - }; - let n = msg.len(); - buf[0] = n as _; - buf[1..(n + 1)].copy_from_slice(msg.as_bytes()); - if let Err(err) = conn.write_all(&buf[..n + 1]) { - log::error!("Failed to write to ipc: {}", err); - break; - } - } - Err(err) => match err { - mpsc::RecvTimeoutError::Disconnected => { - log::error!("pynput sender disconnecte"); - break; - } - _ => {} - }, - } - } - unsafe { - PYNPUT_REDAY = false; - } - break; - } - }); -} diff --git a/pacman_install b/pacman_install index d22423574..cfd3bdd60 100644 --- a/pacman_install +++ b/pacman_install @@ -7,7 +7,7 @@ post_install() { # do something here cp /usr/share/rustdesk/files/rustdesk.service /etc/systemd/system/rustdesk.service cp /usr/share/rustdesk/files/rustdesk.desktop /usr/share/applications/ - sudo -H pip3 install pynput + sudo -H pip3 install systemctl daemon-reload systemctl enable rustdesk systemctl start rustdesk diff --git a/pynput_service.py b/pynput_service.py deleted file mode 100644 index 5aca57986..000000000 --- a/pynput_service.py +++ /dev/null @@ -1,240 +0,0 @@ -from pynput.keyboard import Key, Controller -from pynput.keyboard._xorg import KeyCode -from pynput._util.xorg import display_manager -import Xlib -from pynput._util.xorg import * -import Xlib -import os -import sys -import socket - -KeyCode._from_symbol("\0") # test - -DEAD_KEYS = { - '`': 65104, - '´': 65105, - '^': 65106, - '~': 65107, - '¯': 65108, - '˘': 65109, - '˙': 65110, - '¨': 65111, - '˚': 65112, - '˝': 65113, - 'ˇ': 65114, - '¸': 65115, - '˛': 65116, - '℩': 65117, # ? - '゛': 65118, # ? - '゚ ': 65119, - 'ٜ': 65120, - '↪': 65121, - ' ̛': 65122, -} - - - -def my_keyboard_mapping(display): - """Generates a mapping from *keysyms* to *key codes* and required - modifier shift states. - - :param Xlib.display.Display display: The display for which to retrieve the - keyboard mapping. - - :return: the keyboard mapping - """ - mapping = {} - - shift_mask = 1 << 0 - group_mask = alt_gr_mask(display) - - # Iterate over all keysym lists in the keyboard mapping - min_keycode = display.display.info.min_keycode - keycode_count = display.display.info.max_keycode - min_keycode + 1 - for index, keysyms in enumerate(display.get_keyboard_mapping( - min_keycode, keycode_count)): - key_code = index + min_keycode - - # Normalise the keysym list to yield a tuple containing the two groups - normalized = keysym_normalize(keysyms) - if not normalized: - continue - - # Iterate over the groups to extract the shift and modifier state - for groups, group in zip(normalized, (False, True)): - for keysym, shift in zip(groups, (False, True)): - - if not keysym: - continue - shift_state = 0 \ - | (shift_mask if shift else 0) \ - | (group_mask if group else 0) - - # !!!: Save all keycode combinations of keysym - if keysym in mapping: - mapping[keysym].append((key_code, shift_state)) - else: - mapping[keysym] = [(key_code, shift_state)] - return mapping - - -class MyController(Controller): - def _update_keyboard_mapping(self): - """Updates the keyboard mapping. - """ - with display_manager(self._display) as dm: - self._keyboard_mapping = my_keyboard_mapping(dm) - - def send_event(self, event, keycode, shift_state): - with display_manager(self._display) as dm, self.modifiers as modifiers: - # Under certain cimcumstances, such as when running under Xephyr, - # the value returned by dm.get_input_focus is an int - window = dm.get_input_focus().focus - send_event = getattr( - window, - 'send_event', - lambda event: dm.send_event(window, event)) - send_event(event( - detail=keycode, - state=shift_state | self._shift_mask(modifiers), - time=0, - root=dm.screen().root, - window=window, - same_screen=0, - child=Xlib.X.NONE, - root_x=0, root_y=0, event_x=0, event_y=0)) - - def fake_input(self, keycode, is_press): - with display_manager(self._display) as dm: - Xlib.ext.xtest.fake_input( - dm, - Xlib.X.KeyPress if is_press else Xlib.X.KeyRelease, - keycode) - - def _handle(self, key, is_press): - """Resolves a key identifier and sends a keyboard event. - :param event: The *X* keyboard event. - :param int keysym: The keysym to handle. - """ - event = Xlib.display.event.KeyPress if is_press \ - else Xlib.display.event.KeyRelease - keysym = self._keysym(key) - - if key.vk is not None: - keycode = self._display.keysym_to_keycode(key.vk) - self.fake_input(keycode, is_press) - # Otherwise use XSendEvent; we need to use this in the general case to - # work around problems with keyboard layouts - self._emit('_on_fake_event', key, is_press) - return - - # Make sure to verify that the key was resolved - if keysym is None: - raise self.InvalidKeyException(key) - - # There may be multiple keycodes for keysym in keyboard_mapping - keycode_flag = len(self.keyboard_mapping[keysym]) == 1 - if keycode_flag: - keycode, shift_state = self.keyboard_mapping[keysym][0] - else: - keycode, shift_state = self._display.keysym_to_keycode(keysym), 0 - - keycode_set = set(map(lambda x: x[0], self.keyboard_mapping[keysym])) - # The keycode of the dead key is inconsistent, The keysym has multiple combinations of a keycode. - if keycode != self._display.keysym_to_keycode(keysym) \ - or (keycode_flag == False and keycode == list(keycode_set)[0] and len(keycode_set) == 1): - deakkey_chr = str(key).replace("'", '') - keysym = DEAD_KEYS[deakkey_chr] - # shift_state = 0 - keycode, shift_state = list( - filter(lambda x: x[1] == 0, - self.keyboard_mapping[keysym]) - )[0] - - # If the key has a virtual key code, use that immediately with - # fake_input; fake input,being an X server extension, has access to - # more internal state that we do - - try: - with self.modifiers as modifiers: - alt_gr = Key.alt_gr in modifiers - # !!!: Send_event can't support lock screen, this condition cann't be modified - if alt_gr: - self.send_event( - event, keycode, shift_state) - else: - self.fake_input(keycode, is_press) - except KeyError: - with self._borrow_lock: - keycode, index, count = self._borrows[keysym] - self._send_key( - event, - keycode, - index_to_shift(self._display, index)) - count += 1 if is_press else -1 - self._borrows[keysym] = (keycode, index, count) - - # Notify any running listeners - self._emit('_on_fake_event', key, is_press) - - -keyboard = MyController() - -server_address = sys.argv[1] -if not os.path.exists(os.path.dirname(server_address)): - os.makedirs(os.path.dirname(server_address)) - -try: - os.unlink(server_address) -except OSError: - if os.path.exists(server_address): - raise - -server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) -server.bind(server_address) -server.listen(1) -clientsocket, address = server.accept() -os.system('chmod a+rw %s' % server_address) -print("Got pynput connection") - - -def loop(): - global keyboard - buf = [] - while True: - data = clientsocket.recv(1024) - if not data: - print("Connection broken") - break - buf.extend(data) - while buf: - n = buf[0] - n = n + 1 - if len(buf) < n: - break - msg = bytearray(buf[1:n]).decode("utf-8") - buf = buf[n:] - if len(msg) < 2: - continue - if msg[1] == "\0": - keyboard = MyController() - print("Keyboard reset") - continue - if len(msg) == 2: - name = msg[1] - else: - name = KeyCode._from_symbol(msg[1:]) - if str(name) == "<0>": - continue - try: - if msg[0] == "p": - keyboard.press(name) - else: - keyboard.release(name) - except Exception as e: - print('[x] error key',e) - - -loop() -clientsocket.close() -server.close() diff --git a/rpm-suse.spec b/rpm-suse.spec index 73a610c11..db4bfe66f 100644 --- a/rpm-suse.spec +++ b/rpm-suse.spec @@ -25,7 +25,6 @@ install $HBB/libsciter-gtk.so %{buildroot}/usr/lib/rustdesk/libsciter-gtk.so install $HBB/rustdesk.service %{buildroot}/usr/share/rustdesk/files/ install $HBB/128x128@2x.png %{buildroot}/usr/share/rustdesk/files/rustdesk.png install $HBB/rustdesk.desktop %{buildroot}/usr/share/rustdesk/files/ -install $HBB/pynput_service.py %{buildroot}/usr/share/rustdesk/files/ %files /usr/bin/rustdesk @@ -33,7 +32,6 @@ install $HBB/pynput_service.py %{buildroot}/usr/share/rustdesk/files/ /usr/share/rustdesk/files/rustdesk.service /usr/share/rustdesk/files/rustdesk.png /usr/share/rustdesk/files/rustdesk.desktop -/usr/share/rustdesk/files/pynput_service.py %changelog # let's skip this for now @@ -54,7 +52,6 @@ esac %post cp /usr/share/rustdesk/files/rustdesk.service /etc/systemd/system/rustdesk.service cp /usr/share/rustdesk/files/rustdesk.desktop /usr/share/applications/ -sudo -H pip3 install pynput systemctl daemon-reload systemctl enable rustdesk systemctl start rustdesk diff --git a/rpm.spec b/rpm.spec index c61db5d0b..37e8ea4cc 100644 --- a/rpm.spec +++ b/rpm.spec @@ -25,7 +25,6 @@ install $HBB/libsciter-gtk.so %{buildroot}/usr/lib/rustdesk/libsciter-gtk.so install $HBB/rustdesk.service %{buildroot}/usr/share/rustdesk/files/ install $HBB/128x128@2x.png %{buildroot}/usr/share/rustdesk/files/rustdesk.png install $HBB/rustdesk.desktop %{buildroot}/usr/share/rustdesk/files/ -install $HBB/pynput_service.py %{buildroot}/usr/share/rustdesk/files/ %files /usr/bin/rustdesk @@ -33,7 +32,6 @@ install $HBB/pynput_service.py %{buildroot}/usr/share/rustdesk/files/ /usr/share/rustdesk/files/rustdesk.service /usr/share/rustdesk/files/rustdesk.png /usr/share/rustdesk/files/rustdesk.desktop -/usr/share/rustdesk/files/pynput_service.py /usr/share/rustdesk/files/__pycache__/* %changelog @@ -55,7 +53,6 @@ esac %post cp /usr/share/rustdesk/files/rustdesk.service /etc/systemd/system/rustdesk.service cp /usr/share/rustdesk/files/rustdesk.desktop /usr/share/applications/ -sudo -H pip3 install pynput systemctl daemon-reload systemctl enable rustdesk systemctl start rustdesk diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 310c6f3f6..24882ce4f 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -108,13 +108,7 @@ parts: plugin: nil override-pull: | mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/share/rustdesk/files/systemd/ - cp ${SNAPCRAFT_PART_SRC}/../../rustdesk/src/pynput_service.py ${SNAPCRAFT_PART_INSTALL}/usr/share/rustdesk/files/ cp ${SNAPCRAFT_PART_SRC}/../../rustdesk/src/rustdesk.service ${SNAPCRAFT_PART_INSTALL}/usr/share/rustdesk/files/systemd/ - - python3-deps: - plugin: python - python-packages: - - pynput == 1.7.6 layout: /usr/share/rustdesk: diff --git a/src/flutter.rs b/src/flutter.rs index 9c5dd319d..6653f96f3 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -226,7 +226,6 @@ impl Session { pub fn send_key_event(&self, mut evt: KeyEvent, keyboard_mode: KeyboardMode) { // mode: legacy(0), map(1), translate(2), auto(3) evt.mode = keyboard_mode.into(); - dbg!(&evt); let mut msg_out = Message::new(); msg_out.set_key_event(evt); self.send(Data::Message(msg_out)); diff --git a/src/server/input_service.rs b/src/server/input_service.rs index eddfa3c73..1e6a10613 100644 --- a/src/server/input_service.rs +++ b/src/server/input_service.rs @@ -169,13 +169,6 @@ fn run_cursor(sp: MouseCursorService, state: &mut StateCursor) -> ResultType<()> lazy_static::lazy_static! { static ref ENIGO: Arc> = { - #[cfg(target_os = "linux")] - { - if crate::platform::is_root() { - std::env::set_var("PYNPUT_USERNAME", crate::platform::linux::get_active_username()); - std::env::set_var("PYNPUT_USERID", crate::platform::linux::get_active_userid()); - } - } Arc::new(Mutex::new(Enigo::new())) }; static ref KEYS_DOWN: Arc>> = Default::default(); @@ -680,7 +673,6 @@ fn map_keyboard_mode(evt: &KeyEvent) { fn tfc_key_down_or_up(key: Key, down: bool, up: bool) { if let Key::Layout(chr) = key { - log::info!("tfc_key_down_or_up: {:?}", chr); if down { TFC_CONTEXT.lock().unwrap().unicode_char_down(chr); } @@ -766,7 +758,6 @@ fn tfc_key_down_or_up(key: Key, down: bool, up: bool) { } }; - log::info!("tfc_key_down_or_up: {:?}", key); if down { TFC_CONTEXT.lock().unwrap().key_down(key); } diff --git a/src/ui/remote.rs b/src/ui/remote.rs index 34d4251fa..6100c8b87 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -1106,8 +1106,6 @@ impl Handler { if let Some(chars) = chars { for chr in chars { - dbg!(chr); - let mut key_event = KeyEvent::new(); key_event.set_chr(chr as _); key_event.down = true;