translate mode, mac --> win, debug 2
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
7dfcc401e5
commit
b2d13647be
@ -39,7 +39,7 @@ fn mouse_event(flags: u32, data: u32, dx: i32, dy: i32) -> DWORD {
|
||||
unsafe { SendInput(1, &mut input as LPINPUT, size_of::<INPUT>() as c_int) }
|
||||
}
|
||||
|
||||
fn keybd_event(flags: u32, vk: u16, scan: u16) -> DWORD {
|
||||
fn keybd_event(mut flags: u32, vk: u16, scan: u16) -> DWORD {
|
||||
let mut scan = scan;
|
||||
unsafe {
|
||||
// https://github.com/rustdesk/rustdesk/issues/366
|
||||
@ -52,35 +52,33 @@ fn keybd_event(flags: u32, vk: u16, scan: u16) -> DWORD {
|
||||
scan = MapVirtualKeyExW(vk as _, 0, LAYOUT) as _;
|
||||
}
|
||||
}
|
||||
let mut input: INPUT = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
|
||||
input.type_ = INPUT_KEYBOARD;
|
||||
unsafe {
|
||||
let dst_ptr = (&mut input.u as *mut _) as *mut u8;
|
||||
let flags = match vk as _ {
|
||||
winapi::um::winuser::VK_HOME |
|
||||
winapi::um::winuser::VK_UP |
|
||||
winapi::um::winuser::VK_PRIOR |
|
||||
winapi::um::winuser::VK_LEFT |
|
||||
winapi::um::winuser::VK_RIGHT |
|
||||
winapi::um::winuser::VK_END |
|
||||
winapi::um::winuser::VK_DOWN |
|
||||
winapi::um::winuser::VK_NEXT |
|
||||
winapi::um::winuser::VK_INSERT |
|
||||
winapi::um::winuser::VK_DELETE => flags | winapi::um::winuser::KEYEVENTF_EXTENDEDKEY,
|
||||
_ => flags,
|
||||
};
|
||||
|
||||
let k = KEYBDINPUT {
|
||||
if flags & KEYEVENTF_UNICODE == 0 {
|
||||
if scan >> 8 == 0xE0 || scan >> 8 == 0xE1 {
|
||||
flags |= winapi::um::winuser::KEYEVENTF_EXTENDEDKEY;
|
||||
}
|
||||
}
|
||||
let mut union: INPUT_u = unsafe { std::mem::zeroed() };
|
||||
unsafe {
|
||||
*union.ki_mut() = KEYBDINPUT {
|
||||
wVk: vk,
|
||||
wScan: scan,
|
||||
dwFlags: flags,
|
||||
time: 0,
|
||||
dwExtraInfo: ENIGO_INPUT_EXTRA_VALUE,
|
||||
};
|
||||
let src_ptr = (&k as *const _) as *const u8;
|
||||
std::ptr::copy_nonoverlapping(src_ptr, dst_ptr, size_of::<KEYBDINPUT>());
|
||||
}
|
||||
unsafe { SendInput(1, &mut input as LPINPUT, size_of::<INPUT>() as c_int) }
|
||||
let mut inputs = [INPUT {
|
||||
type_: INPUT_KEYBOARD,
|
||||
u: union,
|
||||
}; 1];
|
||||
unsafe {
|
||||
SendInput(
|
||||
inputs.len() as UINT,
|
||||
inputs.as_mut_ptr(),
|
||||
size_of::<INPUT>() as c_int,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_error() -> String {
|
||||
|
@ -806,8 +806,8 @@ fn is_hot_key_modifiers_down() -> bool {
|
||||
|
||||
#[inline]
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn translate_key_code(event: &Event, mut key_event: KeyEvent) -> Option<KeyEvent> {
|
||||
let mut key_event = map_keyboard_mode(event, key_event)?;
|
||||
pub fn translate_key_code(peer: &str, event: &Event, key_event: KeyEvent) -> Option<KeyEvent> {
|
||||
let mut key_event = map_keyboard_mode(peer, event, key_event)?;
|
||||
key_event.set_chr((key_event.chr() & 0x0000FFFF) | ((event.code as u32) << 16));
|
||||
Some(key_event)
|
||||
}
|
||||
|
@ -1084,8 +1084,6 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
|
||||
#[cfg(target_os = "windows")]
|
||||
fn translate_process_code(code: u32, down: bool) {
|
||||
crate::platform::windows::try_change_desktop();
|
||||
let vk_code =
|
||||
|
||||
match code >> 16 {
|
||||
0 => sim_rdev_rawkey_position(code, down),
|
||||
vk_code => sim_rdev_rawkey_virtual(vk_code, down),
|
||||
|
Loading…
Reference in New Issue
Block a user