mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 23:19:02 +08:00
Merge pull request #3119 from fufesou/feat/keyboard_translate_mode3
Feat/keyboard translate mode
This commit is contained in:
commit
d26da28218
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4405,7 +4405,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rdev"
|
||||
version = "0.5.0-2"
|
||||
source = "git+https://github.com/fufesou/rdev#4d8231f05e14c5a04cd7d2c1288e87ad52d39e4c"
|
||||
source = "git+https://github.com/fufesou/rdev#cedc4e62744566775026af4b434ef799804c1130"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"core-foundation 0.9.3",
|
||||
|
@ -1,6 +1,9 @@
|
||||
use std::{collections::HashMap, ffi::{CStr, CString}, os::raw::c_char, thread};
|
||||
use std::{collections::HashMap, ffi::{CStr, CString}, os::raw::c_char};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use std::thread;
|
||||
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use serde_json::json;
|
||||
|
||||
@ -928,7 +931,7 @@ pub fn main_start_dbus_server() {
|
||||
{
|
||||
use crate::dbus::start_dbus_server;
|
||||
// spawn new thread to start dbus server
|
||||
std::thread::spawn(|| {
|
||||
thread::spawn(|| {
|
||||
let _ = start_dbus_server();
|
||||
});
|
||||
}
|
||||
@ -1275,7 +1278,7 @@ pub fn main_is_login_wayland() -> SyncReturn<bool> {
|
||||
|
||||
pub fn main_start_pa() {
|
||||
#[cfg(target_os = "linux")]
|
||||
std::thread::spawn(crate::ipc::start_pa);
|
||||
thread::spawn(crate::ipc::start_pa);
|
||||
}
|
||||
|
||||
pub fn main_hide_docker() -> SyncReturn<bool> {
|
||||
@ -1302,9 +1305,9 @@ pub fn main_start_ipc_url_server() {
|
||||
///
|
||||
/// * macOS only
|
||||
#[allow(unused_variables)]
|
||||
pub fn send_url_scheme(url: String) {
|
||||
pub fn send_url_scheme(_url: String) {
|
||||
#[cfg(target_os = "macos")]
|
||||
thread::spawn(move || crate::ui::macos::handle_url_scheme(url));
|
||||
thread::spawn(move || crate::ui::macos::handle_url_scheme(_url));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
@ -1324,7 +1327,7 @@ pub mod server_side {
|
||||
_class: JClass,
|
||||
) {
|
||||
log::debug!("startServer from java");
|
||||
std::thread::spawn(move || start_server(true));
|
||||
thread::spawn(move || start_server(true));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -193,8 +193,8 @@ pub mod client {
|
||||
#[cfg(windows)]
|
||||
pub fn update_grab_get_key_name() {
|
||||
match get_keyboard_mode_enum() {
|
||||
KeyboardMode::Map => rdev::set_get_key_name(false),
|
||||
KeyboardMode::Translate => rdev::set_get_key_name(true),
|
||||
KeyboardMode::Map => rdev::set_get_key_unicode(false),
|
||||
KeyboardMode::Translate => rdev::set_get_key_unicode(true),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
@ -256,6 +256,7 @@ pub fn start_grab_loop() {
|
||||
if let Err(error) = rdev::grab(func) {
|
||||
log::error!("rdev Error: {:?}", error)
|
||||
}
|
||||
rdev::set_event_popup(false);
|
||||
});
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@ -757,12 +758,10 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option<KeyEv
|
||||
fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec<KeyEvent>) {
|
||||
match &event.unicode {
|
||||
Some(unicode_info) => {
|
||||
if !unicode_info.is_dead {
|
||||
for code in &unicode_info.unicode {
|
||||
let mut evt = key_event.clone();
|
||||
evt.set_unicode(*code as _);
|
||||
events.push(evt);
|
||||
}
|
||||
for code in &unicode_info.unicode {
|
||||
let mut evt = key_event.clone();
|
||||
evt.set_unicode(*code as _);
|
||||
events.push(evt);
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
@ -816,6 +815,12 @@ pub fn translate_virtual_keycode(event: &Event, mut key_event: KeyEvent) -> Opti
|
||||
|
||||
pub fn translate_keyboard_mode(event: &Event, key_event: KeyEvent) -> Vec<KeyEvent> {
|
||||
let mut events: Vec<KeyEvent> = Vec::new();
|
||||
if let Some(unicode_info) = &event.unicode {
|
||||
if unicode_info.is_dead {
|
||||
return events;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
unsafe {
|
||||
if event.scan_code == 0x021D {
|
||||
|
@ -368,8 +368,8 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
match &self.lc.read().unwrap().keyboard_mode as _ {
|
||||
"legacy" => rdev::set_get_key_name(true),
|
||||
"translate" => rdev::set_get_key_name(true),
|
||||
"legacy" => rdev::set_get_key_unicode(true),
|
||||
"translate" => rdev::set_get_key_unicode(true),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -381,7 +381,7 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
pub fn leave(&self) {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
rdev::set_get_key_name(false);
|
||||
rdev::set_get_key_unicode(false);
|
||||
}
|
||||
IS_IN.store(false, Ordering::SeqCst);
|
||||
keyboard::client::change_grab_status(GrabState::Wait);
|
||||
|
Loading…
Reference in New Issue
Block a user