choose keyboard layout type, mid commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-12-27 16:45:13 +08:00
parent 5b3b7bd3c0
commit 48e684335e
11 changed files with 345 additions and 10 deletions

View File

@@ -181,6 +181,14 @@ pub fn set_local_flutter_config(k: String, v: String) {
ui_interface::set_local_flutter_config(k, v);
}
pub fn get_local_kb_layout_type() -> SyncReturn<String> {
SyncReturn(ui_interface::get_kb_layout_type())
}
pub fn set_local_kb_layout_type(kb_layout_type: String) {
ui_interface::set_kb_layout_type(kb_layout_type)
}
pub fn session_get_view_style(id: String) -> Option<String> {
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
Some(session.get_view_style())

View File

@@ -6,7 +6,7 @@ use crate::flutter::FlutterHandler;
#[cfg(not(feature = "flutter"))]
use crate::ui::remote::SciterHandler;
use crate::ui_session_interface::Session;
use hbb_common::{log, message_proto::*};
use hbb_common::{log, message_proto::*, config::LocalConfig};
use rdev::{Event, EventType, Key};
#[cfg(any(target_os = "windows", target_os = "macos"))]
use std::sync::atomic::{AtomicBool, Ordering};
@@ -620,7 +620,13 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option<KeyEv
#[cfg(target_os = "windows")]
let keycode = match peer.as_str() {
"windows" => event.scan_code,
"macos" => rdev::win_scancode_to_macos_code(event.scan_code)?,
"macos" => {
if LocalConfig::get_kb_layout_type() == "ISO" {
rdev::win_scancode_to_macos_iso_code(event.scan_code)?
} else {
rdev::win_scancode_to_macos_code(event.scan_code)?
}
},
_ => rdev::win_scancode_to_linux_code(event.scan_code)?,
};
#[cfg(target_os = "macos")]
@@ -632,7 +638,13 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option<KeyEv
#[cfg(target_os = "linux")]
let keycode = match peer.as_str() {
"windows" => rdev::linux_code_to_win_scancode(event.code as _)?,
"macos" => rdev::linux_code_to_macos_code(event.code as _)?,
"macos" => {
if LocalConfig::get_kb_layout_type() == "ISO" {
rdev::linux_code_to_macos_iso_code(event.scan_code)?
} else {
rdev::linux_code_to_macos_code(event.code as _)?
}
},
_ => event.code as _,
};
#[cfg(any(target_os = "android", target_os = "ios"))]

View File

@@ -407,5 +407,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Group", "小组"),
("Search", "搜索"),
("Closed manually by the web console", "被web控制台手动关闭"),
("Local keyboard type", "本地键盘类型"),
("Select local keyboard type", "请选择本地键盘类型"),
].iter().cloned().collect();
}

View File

@@ -406,5 +406,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Group", "小組"),
("Search", "搜索"),
("Closed manually by the web console", "被web控制台手動關閉"),
("Local keyboard type", "本地鍵盤類型"),
("Select local keyboard type", "請選擇本地鍵盤類型"),
].iter().cloned().collect();
}

View File

@@ -202,6 +202,16 @@ pub fn set_local_flutter_config(key: String, value: String) {
LocalConfig::set_flutter_config(key, value);
}
#[inline]
pub fn get_kb_layout_type() -> String {
LocalConfig::get_kb_layout_type()
}
#[inline]
pub fn set_kb_layout_type(kb_layout_type: String) {
LocalConfig::set_kb_layout_type(kb_layout_type);
}
#[inline]
pub fn peer_has_password(id: String) -> bool {
!PeerConfig::load(&id).password.is_empty()