From 2eaa0c7abe8a0b80aa15bbd42f4336859fb2430d Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:55:32 +0100 Subject: [PATCH 01/13] Multimedia keys (1.2 revision) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/rdev.rs | 4 ++++ src/windows/keycodes.rs | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d83e2f96..b6596e51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "rdev" -version = "0.6.3" +version = "0.7.0" dependencies = [ "cocoa", "core-foundation", diff --git a/Cargo.toml b/Cargo.toml index dfd8c221..c962400f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rdev" -version = "0.6.3" +version = "0.7.0" authors = ["Nicolas Patry ", "David M "] edition = "2021" publish = false diff --git a/src/rdev.rs b/src/rdev.rs index 96c47b68..fbc54534 100644 --- a/src/rdev.rs +++ b/src/rdev.rs @@ -138,6 +138,10 @@ pub enum Key { VolumeMute, VolumeDown, VolumeUp, + NextTrack, + PrevTrack, + StopTrack, + PlayPauseTrack, Home, LeftArrow, /// also known as "windows", "super", and "command" diff --git a/src/windows/keycodes.rs b/src/windows/keycodes.rs index e4ca4918..ca73aa61 100644 --- a/src/windows/keycodes.rs +++ b/src/windows/keycodes.rs @@ -78,6 +78,10 @@ decl_keycodes! { VolumeMute, 173, VolumeDown, 174, VolumeUp, 175, + NextTrack, 0xB0, + PrevTrack, 0xB1, + StopTrack, 0xB2, + PlayPauseTrack, 0xB3, Home, 36, LeftArrow, 37, MetaLeft, 91, From da4f5ce0a37ac4afbc94d39d2e1ce719b3ff99c5 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:18:45 +0100 Subject: [PATCH 02/13] Add a different flag to simulated events --- src/linux/simulate.rs | 8 ++++---- src/windows/common.rs | 1 + src/windows/keyboard.rs | 10 ++++++---- src/windows/simulate.rs | 25 +++++++++++++++---------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/linux/simulate.rs b/src/linux/simulate.rs index ea3d6121..090d9828 100644 --- a/src/linux/simulate.rs +++ b/src/linux/simulate.rs @@ -21,8 +21,8 @@ unsafe fn send_native(event_type: &EventType, display: *mut xlib::Display) -> Op Button::Left => xtest::XTestFakeButtonEvent(display, 1, TRUE, 0), Button::Middle => xtest::XTestFakeButtonEvent(display, 2, TRUE, 0), Button::Right => xtest::XTestFakeButtonEvent(display, 3, TRUE, 0), - Button::Forward => xtest::XTestFakeButtonEvent(display, 4 , TRUE, 0), - Button::Backward => xtest::XTestFakeButtonEvent(display, 5 , TRUE, 0), + Button::Forward => xtest::XTestFakeButtonEvent(display, 4, TRUE, 0), + Button::Backward => xtest::XTestFakeButtonEvent(display, 5, TRUE, 0), Button::Unknown(code) => { xtest::XTestFakeButtonEvent(display, (*code).try_into().ok()?, TRUE, 0) } @@ -31,8 +31,8 @@ unsafe fn send_native(event_type: &EventType, display: *mut xlib::Display) -> Op Button::Left => xtest::XTestFakeButtonEvent(display, 1, FALSE, 0), Button::Middle => xtest::XTestFakeButtonEvent(display, 2, FALSE, 0), Button::Right => xtest::XTestFakeButtonEvent(display, 3, FALSE, 0), - Button::Forward => xtest::XTestFakeButtonEvent(display, 4 , FALSE, 0), - Button::Backward => xtest::XTestFakeButtonEvent(display, 5 , FALSE, 0), + Button::Forward => xtest::XTestFakeButtonEvent(display, 4, FALSE, 0), + Button::Backward => xtest::XTestFakeButtonEvent(display, 5, FALSE, 0), Button::Unknown(code) => { xtest::XTestFakeButtonEvent(display, (*code).try_into().ok()?, FALSE, 0) } diff --git a/src/windows/common.rs b/src/windows/common.rs index 2675cb8a..71a01fd0 100644 --- a/src/windows/common.rs +++ b/src/windows/common.rs @@ -18,6 +18,7 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{ pub const TRUE: i32 = 1; pub const FALSE: i32 = 0; +pub const KEYBOARDMANAGER_INJECTED_FLAG: usize = 0x1; #[inline] fn hiword(l: u32) -> u16 { ((l >> 16) & 0xffff) as u16 diff --git a/src/windows/keyboard.rs b/src/windows/keyboard.rs index 554ddf1e..dc0786b5 100644 --- a/src/windows/keyboard.rs +++ b/src/windows/keyboard.rs @@ -1,16 +1,18 @@ -use crate::rdev::{EventType, Key, KeyboardState}; -use crate::windows::common::{get_code, get_scan_code, FALSE, TRUE}; -use crate::windows::keycodes::code_from_key; use std::ptr::null_mut; + use windows_sys::Win32::Foundation::LPARAM; use windows_sys::Win32::System::Threading::{AttachThreadInput, GetCurrentThreadId}; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - GetKeyState, GetKeyboardLayout, GetKeyboardState, ToUnicodeEx, VK_CAPITAL, VK_LSHIFT, + GetKeyboardLayout, GetKeyboardState, GetKeyState, ToUnicodeEx, VK_CAPITAL, VK_LSHIFT, VK_RSHIFT, VK_SHIFT, }; use windows_sys::Win32::UI::TextServices::HKL; use windows_sys::Win32::UI::WindowsAndMessaging::{GetForegroundWindow, GetWindowThreadProcessId}; +use crate::rdev::{EventType, Key, KeyboardState}; +use crate::windows::common::{FALSE, get_code, get_scan_code, TRUE}; +use crate::windows::keycodes::code_from_key; + const VK_SHIFT_: usize = VK_SHIFT as usize; const VK_CAPITAL_: usize = VK_CAPITAL as usize; const VK_LSHIFT_: usize = VK_LSHIFT as usize; diff --git a/src/windows/simulate.rs b/src/windows/simulate.rs index f7e55c6b..effbeeb1 100644 --- a/src/windows/simulate.rs +++ b/src/windows/simulate.rs @@ -1,20 +1,24 @@ -use crate::rdev::{Button, EventType, SimulateError}; -use crate::windows::keyboard::UINT; -use crate::windows::keycodes::{code_from_key, scan_from_code}; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; use std::convert::TryFrom; use std::ffi::c_int; use std::mem::size_of; + use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - SendInput, INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, - MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, - MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, - MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, - MOUSEEVENTF_XUP, MOUSEINPUT, + INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, MOUSEEVENTF_ABSOLUTE, + MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, + MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, + MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, MOUSEEVENTF_XUP, + MOUSEINPUT, SendInput, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ GetSystemMetrics, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, WHEEL_DELTA, }; + +use crate::rdev::{Button, EventType, SimulateError}; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; +use crate::windows::common::KEYBOARDMANAGER_INJECTED_FLAG; +use crate::windows::keyboard::UINT; +use crate::windows::keycodes::{code_from_key, scan_from_code}; + /// Not defined in win32 but define here for clarity static KEYEVENTF_KEYDOWN: u32 = 0; @@ -27,7 +31,7 @@ fn sim_mouse_event(flags: DWORD, data: LONG, dx: LONG, dy: LONG) -> Result<(), S mouseData: data, dwFlags: flags, time: 0, - dwExtraInfo: 0, + dwExtraInfo: KEYBOARDMANAGER_INJECTED_FLAG, }; let mut input = [INPUT { r#type: INPUT_MOUSE, @@ -80,6 +84,7 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { EventType::KeyPress(key) => { let code = code_from_key(*key).ok_or(SimulateError)?; let scan = scan_from_code(code).ok_or(SimulateError)?; + sim_keyboard_event(KEYEVENTF_KEYDOWN, code, scan) } EventType::KeyRelease(key) => { From 7357816053f434f1b4efbb858618b78395a97008 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:20:07 +0100 Subject: [PATCH 03/13] Feature version bump 0.8 - added simulated flag --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6596e51..44c6e9bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -482,7 +482,7 @@ dependencies = [ [[package]] name = "rdev" -version = "0.7.0" +version = "0.8.0" dependencies = [ "cocoa", "core-foundation", diff --git a/Cargo.toml b/Cargo.toml index c962400f..7d17504f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rdev" -version = "0.7.0" +version = "0.8.0" authors = ["Nicolas Patry ", "David M "] edition = "2021" publish = false From 35de2d82197c931981c115c6105885fa8610b9d4 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:01:33 +0100 Subject: [PATCH 04/13] library update --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44c6e9bb..a5c2bf23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -595,9 +595,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "syn" From 5b9df07a031354b3e9a9fee7259d5f69b34427a1 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:11:58 +0100 Subject: [PATCH 05/13] Migrate to newer version of windows-sys crate --- Cargo.lock | 87 ++++++++++++++++++++++++++++++++++------- Cargo.toml | 7 ++-- src/windows/common.rs | 8 ++-- src/windows/keyboard.rs | 4 +- src/windows/simulate.rs | 14 +++---- 5 files changed, 89 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5c2bf23..c78e6dc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,7 +441,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" +checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" dependencies = [ "dashmap", "futures", @@ -575,9 +575,9 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" +checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", @@ -641,11 +641,11 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -654,13 +654,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -669,42 +684,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "x11" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 7d17504f..72261006 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ license = "MIT" [dependencies] serde = {version = "1.0", features = ["derive"], optional=true} lazy_static = "1.4" +tokio = "1.35" [features] serialize = ["serde"] @@ -37,7 +38,7 @@ epoll = {version = "4.3", optional=true} inotify = {version = "0.10", default-features=false, optional=true} [target.'cfg(target_os = "windows")'.dependencies] -windows-sys = { version = "0.48.0", features = [ +windows-sys = { version = "0.52.0", features = [ "Win32_UI_WindowsAndMessaging", "Win32_Foundation", "Win32_System_Threading", @@ -50,8 +51,8 @@ serde_json = "1.0" # Some tests interact with the real OS. We can't hit the OS in parallel # because that leads to unexpected behavior and flaky tests, so we need # to run thoses tests in sequence instead. -serial_test = "2.0" -tokio = {version = "1.5", features=["sync", "macros", "rt-multi-thread"]} +serial_test = "3.0" +tokio = {version = "1.35", features=["sync", "macros", "rt-multi-thread"]} [[example]] name = "serialize" diff --git a/src/windows/common.rs b/src/windows/common.rs index 71a01fd0..99371e2d 100644 --- a/src/windows/common.rs +++ b/src/windows/common.rs @@ -122,8 +122,8 @@ pub enum HookError { } pub unsafe fn set_key_hook(callback: RawCallback) -> Result<(), HookError> { - let hmod: HLOCAL = 0; - let hook = SetWindowsHookExA(WH_KEYBOARD_LL, Some(callback), hmod, 0); + let hmod: HLOCAL = std::ptr::null_mut(); + let hook = SetWindowsHookExA(WH_KEYBOARD_LL, Some(callback), hmod as isize, 0); if hook == 0 { let error = GetLastError(); @@ -134,8 +134,8 @@ pub unsafe fn set_key_hook(callback: RawCallback) -> Result<(), HookError> { } pub unsafe fn set_mouse_hook(callback: RawCallback) -> Result<(), HookError> { - let hmod: HLOCAL = 0; - let hook = SetWindowsHookExA(WH_MOUSE_LL, Some(callback), hmod, 0); + let hmod: HLOCAL = std::ptr::null_mut(); + let hook = SetWindowsHookExA(WH_MOUSE_LL, Some(callback), hmod as isize, 0); if hook == 0 { let error = GetLastError(); return Err(HookError::Mouse(error)); diff --git a/src/windows/keyboard.rs b/src/windows/keyboard.rs index dc0786b5..ff64448c 100644 --- a/src/windows/keyboard.rs +++ b/src/windows/keyboard.rs @@ -3,14 +3,14 @@ use std::ptr::null_mut; use windows_sys::Win32::Foundation::LPARAM; use windows_sys::Win32::System::Threading::{AttachThreadInput, GetCurrentThreadId}; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - GetKeyboardLayout, GetKeyboardState, GetKeyState, ToUnicodeEx, VK_CAPITAL, VK_LSHIFT, + GetKeyState, GetKeyboardLayout, GetKeyboardState, ToUnicodeEx, VK_CAPITAL, VK_LSHIFT, VK_RSHIFT, VK_SHIFT, }; use windows_sys::Win32::UI::TextServices::HKL; use windows_sys::Win32::UI::WindowsAndMessaging::{GetForegroundWindow, GetWindowThreadProcessId}; use crate::rdev::{EventType, Key, KeyboardState}; -use crate::windows::common::{FALSE, get_code, get_scan_code, TRUE}; +use crate::windows::common::{get_code, get_scan_code, FALSE, TRUE}; use crate::windows::keycodes::code_from_key; const VK_SHIFT_: usize = VK_SHIFT as usize; diff --git a/src/windows/simulate.rs b/src/windows/simulate.rs index effbeeb1..29ee97c0 100644 --- a/src/windows/simulate.rs +++ b/src/windows/simulate.rs @@ -3,21 +3,21 @@ use std::ffi::c_int; use std::mem::size_of; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, MOUSEEVENTF_ABSOLUTE, - MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, - MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, - MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, MOUSEEVENTF_XUP, - MOUSEINPUT, SendInput, + SendInput, INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, + MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, + MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, + MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, + MOUSEEVENTF_XUP, MOUSEINPUT, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ GetSystemMetrics, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, WHEEL_DELTA, }; use crate::rdev::{Button, EventType, SimulateError}; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; use crate::windows::common::KEYBOARDMANAGER_INJECTED_FLAG; use crate::windows::keyboard::UINT; use crate::windows::keycodes::{code_from_key, scan_from_code}; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; /// Not defined in win32 but define here for clarity static KEYEVENTF_KEYDOWN: u32 = 0; @@ -28,7 +28,7 @@ fn sim_mouse_event(flags: DWORD, data: LONG, dx: LONG, dy: LONG) -> Result<(), S *inner_union = MOUSEINPUT { dx, dy, - mouseData: data, + mouseData: data.try_into().unwrap(), dwFlags: flags, time: 0, dwExtraInfo: KEYBOARDMANAGER_INJECTED_FLAG, From 7068da8cfe6f5d3979975e88f77be2bb1d2a2733 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:18:58 +0100 Subject: [PATCH 06/13] WIP Simulated key mode --- src/rdev.rs | 12 +++++++ src/windows/common.rs | 75 ++++++++++++++++++++++++++++++++++++----- src/windows/simulate.rs | 31 +++++++++-------- 3 files changed, 95 insertions(+), 23 deletions(-) diff --git a/src/rdev.rs b/src/rdev.rs index fbc54534..8129e05f 100644 --- a/src/rdev.rs +++ b/src/rdev.rs @@ -253,15 +253,23 @@ pub enum EventType { /// To the actual letter a user would use, that requires some layout logic to be added. KeyPress(Key), KeyRelease(Key), + SimulatedKeyPress(Key), + SimulatedKeyRelease(Key), /// Mouse Button ButtonPress(Button), ButtonRelease(Button), + SimulatedButtonPress(Button), + SimulatedButtonRelease(Button), /// Values in pixels. `EventType::MouseMove{x: 0, y: 0}` corresponds to the /// top left corner, with x increasing downward and y increasing rightward MouseMove { x: f64, y: f64, }, + SimulatedMouseMove { + x: f64, + y: f64, + }, /// `delta_y` represents vertical scroll and `delta_x` represents horizontal scroll. /// Positive values correspond to scrolling up or right and negative values /// correspond to scrolling down or left @@ -269,6 +277,10 @@ pub enum EventType { delta_x: i64, delta_y: i64, }, + SimulatedWheel { + delta_x: i64, + delta_y: i64, + }, } /// When events arrive from the OS they get some additional information added from diff --git a/src/windows/common.rs b/src/windows/common.rs index 99371e2d..004758ed 100644 --- a/src/windows/common.rs +++ b/src/windows/common.rs @@ -1,20 +1,24 @@ -use crate::rdev::{Button, EventType}; -use crate::windows::keyboard::Keyboard; -use crate::windows::keycodes::key_from_code; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; -use lazy_static::lazy_static; use std::convert::TryInto; use std::os::raw::c_int; use std::sync::Mutex; + +use lazy_static::lazy_static; use windows_sys::Win32::Foundation::{GetLastError, WPARAM}; use windows_sys::Win32::Foundation::{HLOCAL, LPARAM, LRESULT}; -use windows_sys::Win32::UI::WindowsAndMessaging::HHOOK; +use windows_sys::Win32::UI::Input::KeyboardAndMouse::KEYBDINPUT; use windows_sys::Win32::UI::WindowsAndMessaging::{ - SetWindowsHookExA, KBDLLHOOKSTRUCT, MSLLHOOKSTRUCT, WHEEL_DELTA, WH_KEYBOARD_LL, WH_MOUSE_LL, + KBDLLHOOKSTRUCT, MSLLHOOKSTRUCT, SetWindowsHookExA, WH_KEYBOARD_LL, WH_MOUSE_LL, WHEEL_DELTA, WM_KEYDOWN, WM_KEYUP, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_XBUTTONDOWN, WM_XBUTTONUP, }; +use windows_sys::Win32::UI::WindowsAndMessaging::HHOOK; + +use crate::rdev::{Button, EventType}; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; +use crate::windows::keyboard::Keyboard; +use crate::windows::keycodes::key_from_code; + pub const TRUE: i32 = 1; pub const FALSE: i32 = 0; @@ -34,6 +38,38 @@ pub unsafe fn get_code(lpdata: LPARAM) -> DWORD { kb.vkCode } +#[cfg(debug_assertions)] +pub unsafe fn analyse_simulate(key_union: &mut KEYBDINPUT) { + println!("SIMULATION ANALYSIS"); + println!("Event vkCode: {}", key_union.wVk); + println!("Event scanCode: {}", key_union.wScan); + println!("Event flags: {}", key_union.dwFlags); + println!("Event time: {}", key_union.time); + println!("Event simulated?: {}", key_union.dwExtraInfo); + println!("--------"); +} +#[cfg(debug_assertions)] +pub unsafe fn analyse_listen(lpdata: LPARAM) { + let kb = *(lpdata as *const KBDLLHOOKSTRUCT); + println!("LISTEN ANALYSIS"); + println!("Event vkCode: {}", kb.vkCode); + println!("Event scanCode: {}", kb.scanCode); + println!("Event flags: {}", kb.flags); + println!("Event time: {}", kb.time); + println!("Event simulated?: {}", kb.dwExtraInfo); + println!("--------"); +} + +/// Returns whether the input received was made by the rdev simulate command, or the user pressing keys. +pub unsafe fn get_simulated(lpdata: LPARAM) -> bool { + let kb = *(lpdata as *const KBDLLHOOKSTRUCT); + + if kb.dwExtraInfo == KEYBOARDMANAGER_INJECTED_FLAG { + true + } else { + false + } +} pub unsafe fn get_scan_code(lpdata: LPARAM) -> DWORD { let kb = *(lpdata as *const KBDLLHOOKSTRUCT); kb.scanCode @@ -61,12 +97,28 @@ pub unsafe fn convert(param: WPARAM, lpdata: LPARAM) -> Option { Ok(WM_KEYDOWN) | Ok(WM_SYSKEYDOWN) => { let code = get_code(lpdata); let key = key_from_code(code as u16); - Some(EventType::KeyPress(key)) + let simulated = get_simulated(lpdata); + + #[cfg(debug_assertions)] + println!("Simulated: {}", simulated); + + match simulated { + true => Some(EventType::SimulatedKeyPress(key)), + false => Some(EventType::KeyPress(key)), + } } Ok(WM_KEYUP) | Ok(WM_SYSKEYUP) => { let code = get_code(lpdata); let key = key_from_code(code as u16); - Some(EventType::KeyRelease(key)) + let simulated = get_simulated(lpdata); + + #[cfg(debug_assertions)] + println!("Simulated: {}", simulated); + + match simulated { + true => Some(EventType::SimulatedKeyRelease(key)), + false => Some(EventType::KeyRelease(key)), + } } Ok(WM_LBUTTONDOWN) => Some(EventType::ButtonPress(Button::Left)), Ok(WM_LBUTTONUP) => Some(EventType::ButtonRelease(Button::Left)), @@ -76,6 +128,11 @@ pub unsafe fn convert(param: WPARAM, lpdata: LPARAM) -> Option { Ok(WM_RBUTTONUP) => Some(EventType::ButtonRelease(Button::Right)), Ok(WM_XBUTTONDOWN) => { let code = get_button_code(lpdata) as u8; + let simulated = get_simulated(lpdata); + + #[cfg(debug_assertions)] + println!("Simulated: {}", simulated); + match code { num if num == MOUSE_FORWARD => Some(EventType::ButtonPress(Button::Forward)), num if num == MOUSE_BACKWARD => Some(EventType::ButtonPress(Button::Backward)), diff --git a/src/windows/simulate.rs b/src/windows/simulate.rs index 29ee97c0..d55812b4 100644 --- a/src/windows/simulate.rs +++ b/src/windows/simulate.rs @@ -3,21 +3,21 @@ use std::ffi::c_int; use std::mem::size_of; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - SendInput, INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, - MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, - MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, - MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, - MOUSEEVENTF_XUP, MOUSEINPUT, + INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, MOUSEEVENTF_ABSOLUTE, + MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, + MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, + MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, MOUSEEVENTF_XUP, + MOUSEINPUT, SendInput, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ GetSystemMetrics, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, WHEEL_DELTA, }; use crate::rdev::{Button, EventType, SimulateError}; -use crate::windows::common::KEYBOARDMANAGER_INJECTED_FLAG; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; +use crate::windows::common::{analyse_simulate, KEYBOARDMANAGER_INJECTED_FLAG}; use crate::windows::keyboard::UINT; use crate::windows::keycodes::{code_from_key, scan_from_code}; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; /// Not defined in win32 but define here for clarity static KEYEVENTF_KEYDOWN: u32 = 0; @@ -54,13 +54,16 @@ fn sim_mouse_event(flags: DWORD, data: LONG, dx: LONG, dy: LONG) -> Result<(), S fn sim_keyboard_event(flags: DWORD, vk: WORD, scan: WORD) -> Result<(), SimulateError> { let mut union: INPUT_0 = unsafe { std::mem::zeroed() }; let inner_union = unsafe { &mut union.ki }; + + *inner_union = KEYBDINPUT { wVk: vk, wScan: scan, dwFlags: flags, time: 0, - dwExtraInfo: 0, + dwExtraInfo: KEYBOARDMANAGER_INJECTED_FLAG, }; + let mut input = [INPUT { r#type: INPUT_KEYBOARD, Anonymous: union, @@ -81,18 +84,18 @@ fn sim_keyboard_event(flags: DWORD, vk: WORD, scan: WORD) -> Result<(), Simulate pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { match event_type { - EventType::KeyPress(key) => { + EventType::KeyPress(key) | EventType::SimulatedKeyPress(key) => { let code = code_from_key(*key).ok_or(SimulateError)?; let scan = scan_from_code(code).ok_or(SimulateError)?; sim_keyboard_event(KEYEVENTF_KEYDOWN, code, scan) } - EventType::KeyRelease(key) => { + EventType::KeyRelease(key) | EventType::SimulatedKeyRelease(key) => { let code = code_from_key(*key).ok_or(SimulateError)?; let scan = scan_from_code(code).ok_or(SimulateError)?; sim_keyboard_event(KEYEVENTF_KEYUP, code, scan) } - EventType::ButtonPress(button) => match button { + EventType::ButtonPress(button) | EventType::SimulatedButtonPress(button) => match button { Button::Left => sim_mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0), Button::Middle => sim_mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0), Button::Right => sim_mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0), @@ -100,7 +103,7 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { Button::Backward => sim_mouse_event(MOUSEEVENTF_XDOWN, MOUSE_BACKWARD.into(), 0, 0), Button::Unknown(code) => sim_mouse_event(MOUSEEVENTF_XDOWN, (*code).into(), 0, 0), }, - EventType::ButtonRelease(button) => match button { + EventType::ButtonRelease(button) | EventType::SimulatedButtonRelease(button) => match button { Button::Left => sim_mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0), Button::Middle => sim_mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0), Button::Right => sim_mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0), @@ -108,7 +111,7 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { Button::Backward => sim_mouse_event(MOUSEEVENTF_XUP, MOUSE_BACKWARD.into(), 0, 0), Button::Unknown(code) => sim_mouse_event(MOUSEEVENTF_XUP, (*code).into(), 0, 0), }, - EventType::Wheel { delta_x, delta_y } => { + EventType::Wheel { delta_x, delta_y } | EventType::SimulatedWheel {delta_x, delta_y} => { if *delta_x != 0 { sim_mouse_event( MOUSEEVENTF_HWHEEL, @@ -128,7 +131,7 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { } Ok(()) } - EventType::MouseMove { x, y } => { + EventType::MouseMove { x, y } | EventType::SimulatedMouseMove {x, y} => { let width = unsafe { GetSystemMetrics(SM_CXVIRTUALSCREEN) }; let height = unsafe { GetSystemMetrics(SM_CYVIRTUALSCREEN) }; if width == 0 || height == 0 { From 3a8519eda13c12e831fe4ea2d86b22d3879cfdaf Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:24:11 +0100 Subject: [PATCH 07/13] Added simulate response to all events --- src/windows/common.rs | 179 ++++++++++++++++++++++++---------------- src/windows/simulate.rs | 3 +- 2 files changed, 112 insertions(+), 70 deletions(-) diff --git a/src/windows/common.rs b/src/windows/common.rs index 004758ed..114cff16 100644 --- a/src/windows/common.rs +++ b/src/windows/common.rs @@ -5,19 +5,18 @@ use std::sync::Mutex; use lazy_static::lazy_static; use windows_sys::Win32::Foundation::{GetLastError, WPARAM}; use windows_sys::Win32::Foundation::{HLOCAL, LPARAM, LRESULT}; -use windows_sys::Win32::UI::Input::KeyboardAndMouse::KEYBDINPUT; +use windows_sys::Win32::UI::WindowsAndMessaging::HHOOK; use windows_sys::Win32::UI::WindowsAndMessaging::{ - KBDLLHOOKSTRUCT, MSLLHOOKSTRUCT, SetWindowsHookExA, WH_KEYBOARD_LL, WH_MOUSE_LL, WHEEL_DELTA, + SetWindowsHookExA, KBDLLHOOKSTRUCT, MSLLHOOKSTRUCT, WHEEL_DELTA, WH_KEYBOARD_LL, WH_MOUSE_LL, WM_KEYDOWN, WM_KEYUP, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_XBUTTONDOWN, WM_XBUTTONUP, }; -use windows_sys::Win32::UI::WindowsAndMessaging::HHOOK; use crate::rdev::{Button, EventType}; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; use crate::windows::keyboard::Keyboard; use crate::windows::keycodes::key_from_code; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; pub const TRUE: i32 = 1; pub const FALSE: i32 = 0; @@ -38,37 +37,34 @@ pub unsafe fn get_code(lpdata: LPARAM) -> DWORD { kb.vkCode } -#[cfg(debug_assertions)] -pub unsafe fn analyse_simulate(key_union: &mut KEYBDINPUT) { - println!("SIMULATION ANALYSIS"); - println!("Event vkCode: {}", key_union.wVk); - println!("Event scanCode: {}", key_union.wScan); - println!("Event flags: {}", key_union.dwFlags); - println!("Event time: {}", key_union.time); - println!("Event simulated?: {}", key_union.dwExtraInfo); - println!("--------"); -} -#[cfg(debug_assertions)] -pub unsafe fn analyse_listen(lpdata: LPARAM) { - let kb = *(lpdata as *const KBDLLHOOKSTRUCT); - println!("LISTEN ANALYSIS"); - println!("Event vkCode: {}", kb.vkCode); - println!("Event scanCode: {}", kb.scanCode); - println!("Event flags: {}", kb.flags); - println!("Event time: {}", kb.time); - println!("Event simulated?: {}", kb.dwExtraInfo); - println!("--------"); -} +// #[cfg(debug_assertions)] +// pub unsafe fn analyse_simulate(key_union: &mut KEYBDINPUT) { +// println!("SIMULATION ANALYSIS"); +// println!("Event vkCode: {}", key_union.wVk); +// println!("Event scanCode: {}", key_union.wScan); +// println!("Event flags: {}", key_union.dwFlags); +// println!("Event time: {}", key_union.time); +// println!("Event simulated?: {}", key_union.dwExtraInfo); +// println!("--------"); +// } +// #[cfg(debug_assertions)] +// pub unsafe fn analyse_listen(lpdata: LPARAM) { +// let kb = *(lpdata as *const KBDLLHOOKSTRUCT); +// println!("LISTEN ANALYSIS"); +// println!("Event vkCode: {}", kb.vkCode); +// println!("Event scanCode: {}", kb.scanCode); +// println!("Event flags: {}", kb.flags); +// println!("Event time: {}", kb.time); +// println!("Event simulated?: {}", kb.dwExtraInfo); +// println!("--------"); +// } /// Returns whether the input received was made by the rdev simulate command, or the user pressing keys. pub unsafe fn get_simulated(lpdata: LPARAM) -> bool { let kb = *(lpdata as *const KBDLLHOOKSTRUCT); - if kb.dwExtraInfo == KEYBOARDMANAGER_INJECTED_FLAG { - true - } else { - false - } + // Rust clippy insisted - this returns true if it equals, otherwise it returns false + kb.dwExtraInfo == KEYBOARDMANAGER_INJECTED_FLAG } pub unsafe fn get_scan_code(lpdata: LPARAM) -> DWORD { let kb = *(lpdata as *const KBDLLHOOKSTRUCT); @@ -97,12 +93,8 @@ pub unsafe fn convert(param: WPARAM, lpdata: LPARAM) -> Option { Ok(WM_KEYDOWN) | Ok(WM_SYSKEYDOWN) => { let code = get_code(lpdata); let key = key_from_code(code as u16); - let simulated = get_simulated(lpdata); - - #[cfg(debug_assertions)] - println!("Simulated: {}", simulated); - match simulated { + match get_simulated(lpdata) { true => Some(EventType::SimulatedKeyPress(key)), false => Some(EventType::KeyPress(key)), } @@ -110,64 +102,113 @@ pub unsafe fn convert(param: WPARAM, lpdata: LPARAM) -> Option { Ok(WM_KEYUP) | Ok(WM_SYSKEYUP) => { let code = get_code(lpdata); let key = key_from_code(code as u16); - let simulated = get_simulated(lpdata); - #[cfg(debug_assertions)] - println!("Simulated: {}", simulated); - - match simulated { + match get_simulated(lpdata) { true => Some(EventType::SimulatedKeyRelease(key)), false => Some(EventType::KeyRelease(key)), } } - Ok(WM_LBUTTONDOWN) => Some(EventType::ButtonPress(Button::Left)), - Ok(WM_LBUTTONUP) => Some(EventType::ButtonRelease(Button::Left)), - Ok(WM_MBUTTONDOWN) => Some(EventType::ButtonPress(Button::Middle)), - Ok(WM_MBUTTONUP) => Some(EventType::ButtonRelease(Button::Middle)), - Ok(WM_RBUTTONDOWN) => Some(EventType::ButtonPress(Button::Right)), - Ok(WM_RBUTTONUP) => Some(EventType::ButtonRelease(Button::Right)), + Ok(WM_LBUTTONDOWN) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Left)), + false => Some(EventType::ButtonPress(Button::Left)), + }, + Ok(WM_LBUTTONUP) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Left)), + false => Some(EventType::ButtonRelease(Button::Left)), + }, + Ok(WM_MBUTTONDOWN) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Middle)), + false => Some(EventType::ButtonRelease(Button::Middle)), + }, + Ok(WM_MBUTTONUP) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Middle)), + false => Some(EventType::ButtonRelease(Button::Middle)), + }, + Ok(WM_RBUTTONDOWN) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Right)), + false => Some(EventType::ButtonPress(Button::Right)), + }, + Ok(WM_RBUTTONUP) => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Right)), + false => Some(EventType::ButtonRelease(Button::Right)), + }, Ok(WM_XBUTTONDOWN) => { let code = get_button_code(lpdata) as u8; - let simulated = get_simulated(lpdata); - - #[cfg(debug_assertions)] - println!("Simulated: {}", simulated); - match code { - num if num == MOUSE_FORWARD => Some(EventType::ButtonPress(Button::Forward)), - num if num == MOUSE_BACKWARD => Some(EventType::ButtonPress(Button::Backward)), - num => Some(EventType::ButtonPress(Button::Unknown(num))), + num if num == MOUSE_FORWARD => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Forward)), + false => Some(EventType::ButtonPress(Button::Forward)), + }, + num if num == MOUSE_BACKWARD => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Backward)), + false => Some(EventType::ButtonPress(Button::Backward)), + }, + num => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonPress(Button::Unknown(num))), + false => Some(EventType::ButtonPress(Button::Unknown(num))), + }, } } + Ok(WM_XBUTTONUP) => { let code = get_button_code(lpdata) as u8; match code { - num if num == MOUSE_FORWARD => Some(EventType::ButtonRelease(Button::Forward)), - num if num == MOUSE_BACKWARD => Some(EventType::ButtonRelease(Button::Backward)), - num => Some(EventType::ButtonRelease(Button::Unknown(num))), + num if num == MOUSE_FORWARD => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Forward)), + false => Some(EventType::ButtonRelease(Button::Forward)), + }, + num if num == MOUSE_BACKWARD => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Backward)), + false => Some(EventType::ButtonRelease(Button::Backward)), + }, + num => match get_simulated(lpdata) { + true => Some(EventType::SimulatedButtonRelease(Button::Unknown(num))), + false => Some(EventType::ButtonRelease(Button::Unknown(num))), + }, } } Ok(WM_MOUSEMOVE) => { let (x, y) = get_point(lpdata); - Some(EventType::MouseMove { - x: x as f64, - y: y as f64, - }) + match get_simulated(lpdata) { + true => Some(EventType::SimulatedMouseMove { + x: x as f64, + y: y as f64, + }), + false => Some(EventType::MouseMove { + x: x as f64, + y: y as f64, + }), + } } Ok(WM_MOUSEWHEEL) => { let delta = get_delta(lpdata); - Some(EventType::Wheel { - delta_x: 0, - delta_y: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, - }) + match get_simulated(lpdata) { + true => Some(EventType::SimulatedWheel { + delta_x: 0, + delta_y: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, + }), + false => Some(EventType::Wheel { + delta_x: 0, + delta_y: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, + }), + } } + Ok(WM_MOUSEHWHEEL) => { let delta = get_delta(lpdata); - Some(EventType::Wheel { - delta_x: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, - delta_y: 0, - }) + match get_simulated(lpdata) { + true => Some(EventType::SimulatedWheel { + delta_x: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, + delta_y: 0, + }), + + false => Some(EventType::Wheel { + delta_x: (delta.checked_div(hiword(WHEEL_DELTA)).unwrap_or_default()) as i64, + delta_y: 0, + }), + } } + _ => None, } } diff --git a/src/windows/simulate.rs b/src/windows/simulate.rs index d55812b4..56d7bcbf 100644 --- a/src/windows/simulate.rs +++ b/src/windows/simulate.rs @@ -15,7 +15,7 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{ use crate::rdev::{Button, EventType, SimulateError}; use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; -use crate::windows::common::{analyse_simulate, KEYBOARDMANAGER_INJECTED_FLAG}; +use crate::windows::common::KEYBOARDMANAGER_INJECTED_FLAG; use crate::windows::keyboard::UINT; use crate::windows::keycodes::{code_from_key, scan_from_code}; @@ -83,6 +83,7 @@ fn sim_keyboard_event(flags: DWORD, vk: WORD, scan: WORD) -> Result<(), Simulate } pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { + // TODO: Maybe there is a use for a separate Simulated Key press? Explore match event_type { EventType::KeyPress(key) | EventType::SimulatedKeyPress(key) => { let code = code_from_key(*key).ok_or(SimulateError)?; From ef3768d8852b09c1a7fd0f5af899a4d308da3744 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:38:35 +0100 Subject: [PATCH 08/13] Updated grab to showcase simulate events --- examples/grab.rs | 19 ++++++++++++++++--- src/windows/simulate.rs | 35 ++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/examples/grab.rs b/examples/grab.rs index 6f7f04ad..a1bed957 100644 --- a/examples/grab.rs +++ b/examples/grab.rs @@ -1,4 +1,4 @@ -use rdev::{grab, Event, EventType, Key}; +use rdev::{grab, simulate, Event, EventType, Key}; fn main() { // This will block. @@ -8,12 +8,25 @@ fn main() { } fn callback(event: Event) -> Option { - println!("My callback {:?}", event); match event.event_type { + EventType::SimulatedKeyRelease(_) | EventType::SimulatedKeyPress(_) => { + println!("{:?}", event.event_type); + Some(event) + } + EventType::KeyPress(Key::Tab) => { - println!("Cancelling tab !"); + println!("Pressed TAB: {:?}", event.name.unwrap_or_default()); + + simulate(&EventType::KeyPress(Key::KeyA)).unwrap(); + std::thread::sleep(std::time::Duration::from_millis(20)); + simulate(&EventType::KeyRelease(Key::KeyA)).unwrap(); None } + EventType::KeyRelease(_) | EventType::KeyPress(_) => { + println!("{:?}", event.event_type); + Some(event) + } + _ => Some(event), } } diff --git a/src/windows/simulate.rs b/src/windows/simulate.rs index 56d7bcbf..f5669647 100644 --- a/src/windows/simulate.rs +++ b/src/windows/simulate.rs @@ -3,21 +3,21 @@ use std::ffi::c_int; use std::mem::size_of; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, MOUSEEVENTF_ABSOLUTE, - MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_MIDDLEDOWN, - MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, - MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, MOUSEEVENTF_XUP, - MOUSEINPUT, SendInput, + SendInput, INPUT, INPUT_0, INPUT_KEYBOARD, INPUT_MOUSE, KEYBDINPUT, KEYEVENTF_KEYUP, + MOUSEEVENTF_ABSOLUTE, MOUSEEVENTF_HWHEEL, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, + MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MOUSEEVENTF_MOVE, MOUSEEVENTF_RIGHTDOWN, + MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_VIRTUALDESK, MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, + MOUSEEVENTF_XUP, MOUSEINPUT, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ GetSystemMetrics, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, WHEEL_DELTA, }; use crate::rdev::{Button, EventType, SimulateError}; -use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; use crate::windows::common::KEYBOARDMANAGER_INJECTED_FLAG; use crate::windows::keyboard::UINT; use crate::windows::keycodes::{code_from_key, scan_from_code}; +use crate::windows::{DWORD, LONG, MOUSE_BACKWARD, MOUSE_FORWARD, WORD}; /// Not defined in win32 but define here for clarity static KEYEVENTF_KEYDOWN: u32 = 0; @@ -55,7 +55,6 @@ fn sim_keyboard_event(flags: DWORD, vk: WORD, scan: WORD) -> Result<(), Simulate let mut union: INPUT_0 = unsafe { std::mem::zeroed() }; let inner_union = unsafe { &mut union.ki }; - *inner_union = KEYBDINPUT { wVk: vk, wScan: scan, @@ -104,15 +103,17 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { Button::Backward => sim_mouse_event(MOUSEEVENTF_XDOWN, MOUSE_BACKWARD.into(), 0, 0), Button::Unknown(code) => sim_mouse_event(MOUSEEVENTF_XDOWN, (*code).into(), 0, 0), }, - EventType::ButtonRelease(button) | EventType::SimulatedButtonRelease(button) => match button { - Button::Left => sim_mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0), - Button::Middle => sim_mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0), - Button::Right => sim_mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0), - Button::Forward => sim_mouse_event(MOUSEEVENTF_XUP, MOUSE_FORWARD.into(), 0, 0), - Button::Backward => sim_mouse_event(MOUSEEVENTF_XUP, MOUSE_BACKWARD.into(), 0, 0), - Button::Unknown(code) => sim_mouse_event(MOUSEEVENTF_XUP, (*code).into(), 0, 0), - }, - EventType::Wheel { delta_x, delta_y } | EventType::SimulatedWheel {delta_x, delta_y} => { + EventType::ButtonRelease(button) | EventType::SimulatedButtonRelease(button) => { + match button { + Button::Left => sim_mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0), + Button::Middle => sim_mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0), + Button::Right => sim_mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0), + Button::Forward => sim_mouse_event(MOUSEEVENTF_XUP, MOUSE_FORWARD.into(), 0, 0), + Button::Backward => sim_mouse_event(MOUSEEVENTF_XUP, MOUSE_BACKWARD.into(), 0, 0), + Button::Unknown(code) => sim_mouse_event(MOUSEEVENTF_XUP, (*code).into(), 0, 0), + } + } + EventType::Wheel { delta_x, delta_y } | EventType::SimulatedWheel { delta_x, delta_y } => { if *delta_x != 0 { sim_mouse_event( MOUSEEVENTF_HWHEEL, @@ -132,7 +133,7 @@ pub fn simulate(event_type: &EventType) -> Result<(), SimulateError> { } Ok(()) } - EventType::MouseMove { x, y } | EventType::SimulatedMouseMove {x, y} => { + EventType::MouseMove { x, y } | EventType::SimulatedMouseMove { x, y } => { let width = unsafe { GetSystemMetrics(SM_CXVIRTUALSCREEN) }; let height = unsafe { GetSystemMetrics(SM_CYVIRTUALSCREEN) }; if width == 0 || height == 0 { From 11029d0c8c2f41b26d803d8808bfd6140e9ac56e Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:52:28 +0200 Subject: [PATCH 09/13] update libraries --- Cargo.lock | 133 ++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c78e6dc4..25301b95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,15 +19,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -46,9 +46,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block" @@ -58,12 +58,9 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -160,7 +157,7 @@ version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74351c3392ea1ff6cd2628e0042d268ac2371cb613252ff383b6dfa50d22fa79" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "libc", ] @@ -305,9 +302,9 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "inotify" @@ -331,9 +328,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" @@ -343,9 +340,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lock_api" @@ -359,9 +356,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "malloc_buf" @@ -374,15 +371,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -446,9 +443,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -458,15 +455,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -518,9 +515,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "scopeguard" @@ -530,18 +527,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", @@ -550,9 +547,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -595,15 +592,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" dependencies = [ "proc-macro2", "quote", @@ -612,9 +609,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.35.1" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "num_cpus", @@ -645,7 +642,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -665,17 +662,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -686,9 +683,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -698,9 +695,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -710,9 +707,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -722,9 +719,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -734,9 +731,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -746,9 +743,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -758,9 +755,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "x11" From f8df4050936391b4f91edb37a07253a75ff9ae36 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:52:54 +0200 Subject: [PATCH 10/13] remove dead code --- src/windows/common.rs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/windows/common.rs b/src/windows/common.rs index 114cff16..9d999386 100644 --- a/src/windows/common.rs +++ b/src/windows/common.rs @@ -37,28 +37,6 @@ pub unsafe fn get_code(lpdata: LPARAM) -> DWORD { kb.vkCode } -// #[cfg(debug_assertions)] -// pub unsafe fn analyse_simulate(key_union: &mut KEYBDINPUT) { -// println!("SIMULATION ANALYSIS"); -// println!("Event vkCode: {}", key_union.wVk); -// println!("Event scanCode: {}", key_union.wScan); -// println!("Event flags: {}", key_union.dwFlags); -// println!("Event time: {}", key_union.time); -// println!("Event simulated?: {}", key_union.dwExtraInfo); -// println!("--------"); -// } -// #[cfg(debug_assertions)] -// pub unsafe fn analyse_listen(lpdata: LPARAM) { -// let kb = *(lpdata as *const KBDLLHOOKSTRUCT); -// println!("LISTEN ANALYSIS"); -// println!("Event vkCode: {}", kb.vkCode); -// println!("Event scanCode: {}", kb.scanCode); -// println!("Event flags: {}", kb.flags); -// println!("Event time: {}", kb.time); -// println!("Event simulated?: {}", kb.dwExtraInfo); -// println!("--------"); -// } - /// Returns whether the input received was made by the rdev simulate command, or the user pressing keys. pub unsafe fn get_simulated(lpdata: LPARAM) -> bool { let kb = *(lpdata as *const KBDLLHOOKSTRUCT); From e7905613092c3ba302c1efb5e496c98488c61555 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:53:01 +0200 Subject: [PATCH 11/13] fix for rust 2024 edition --- src/windows/listen.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/windows/listen.rs b/src/windows/listen.rs index e240c684..eab478da 100644 --- a/src/windows/listen.rs +++ b/src/windows/listen.rs @@ -1,7 +1,7 @@ use crate::rdev::{Event, EventType, ListenError}; use crate::windows::common::{convert, set_key_hook, set_mouse_hook, HookError, HOOK, KEYBOARD}; use std::os::raw::c_int; -use std::ptr::null_mut; +use std::ptr::{self, null_mut}; use std::time::SystemTime; use windows_sys::Win32::Foundation::{LPARAM, LRESULT, WPARAM}; use windows_sys::Win32::UI::WindowsAndMessaging::{CallNextHookEx, GetMessageA, HC_ACTION}; @@ -33,8 +33,11 @@ unsafe extern "system" fn raw_callback(code: c_int, param: WPARAM, lpdata: LPARA time: SystemTime::now(), name, }; - if let Some(callback) = &mut GLOBAL_CALLBACK { - callback(event); + + let callback = ptr::addr_of_mut!(GLOBAL_CALLBACK); + + if (*callback).is_some() { + (*callback).as_mut().unwrap()(event) } } } From 7fa430bdcef701a580430f476db958195ae37156 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Thu, 9 May 2024 16:46:18 +0200 Subject: [PATCH 12/13] update libraries --- Cargo.lock | 220 ++++++++++++++++++++--------------------------------- Cargo.toml | 2 +- 2 files changed, 84 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25301b95..65968288 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" @@ -58,9 +58,9 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cfg-if" @@ -116,9 +116,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-graphics" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -138,19 +138,6 @@ dependencies = [ "libc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "epoll" version = "4.3.3" @@ -294,12 +281,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hermit-abi" version = "0.3.9" @@ -340,15 +321,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -420,9 +401,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -430,15 +411,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -461,18 +442,18 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -500,24 +481,33 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scc" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" +dependencies = [ + "sdd", +] [[package]] name = "scopeguard" @@ -525,20 +515,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sdd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" + [[package]] name = "serde" -version = "1.0.197" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", @@ -547,9 +543,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -558,23 +554,23 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" dependencies = [ - "dashmap", "futures", - "lazy_static", "log", + "once_cell", "parking_lot", + "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", @@ -598,9 +594,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.57" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", @@ -642,122 +638,72 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_msvc" -version = "0.48.5" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "x11" diff --git a/Cargo.toml b/Cargo.toml index 72261006..21a6a44e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ license = "MIT" [dependencies] serde = {version = "1.0", features = ["derive"], optional=true} lazy_static = "1.4" -tokio = "1.35" +tokio = "1.37" [features] serialize = ["serde"] From c25768293eca13afbb7136455c42ff3e830b7b1a Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Thu, 16 May 2024 13:29:40 +0200 Subject: [PATCH 13/13] update libraries --- Cargo.lock | 12 ++++++------ Cargo.toml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65968288..eeb58ecc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -523,18 +523,18 @@ checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", @@ -594,9 +594,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.61" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 21a6a44e..fd9098ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,8 +51,8 @@ serde_json = "1.0" # Some tests interact with the real OS. We can't hit the OS in parallel # because that leads to unexpected behavior and flaky tests, so we need # to run thoses tests in sequence instead. -serial_test = "3.0" -tokio = {version = "1.35", features=["sync", "macros", "rt-multi-thread"]} +serial_test = "3.1" +tokio = {version = "1.37", features=["sync", "macros", "rt-multi-thread"]} [[example]] name = "serialize"