feat: mobile map mode (#9717)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-10-23 09:28:39 +08:00
committed by GitHub
parent 2cdaca0fa3
commit cc6f919080
5 changed files with 64 additions and 44 deletions

View File

@@ -861,24 +861,13 @@ impl<T: InvokeUiSession> Session<T> {
platform_code,
position_code: position_code as _,
event_type,
usb_hid: 0,
#[cfg(any(target_os = "windows", target_os = "macos"))]
extra_data: 0,
};
keyboard::client::process_event(keyboard_mode, &event, Some(lock_modes));
keyboard::client::process_event_with_session(keyboard_mode, &event, Some(lock_modes), self);
}
#[cfg(any(target_os = "ios"))]
pub fn handle_flutter_key_event(
&self,
_keyboard_mode: &str,
_character: &str,
_usb_hid: i32,
_lock_modes: i32,
_down_or_up: bool,
) {
}
#[cfg(not(any(target_os = "ios")))]
pub fn handle_flutter_key_event(
&self,
keyboard_mode: &str,
@@ -900,7 +889,6 @@ impl<T: InvokeUiSession> Session<T> {
}
}
#[cfg(not(any(target_os = "ios")))]
fn _handle_key_flutter_simulation(
&self,
_keyboard_mode: &str,
@@ -925,7 +913,6 @@ impl<T: InvokeUiSession> Session<T> {
self.send_key_event(&key_event);
}
#[cfg(not(any(target_os = "ios")))]
fn _handle_key_non_flutter_simulation(
&self,
keyboard_mode: &str,
@@ -936,14 +923,24 @@ impl<T: InvokeUiSession> Session<T> {
) {
let key = rdev::usb_hid_key_from_code(usb_hid as _);
#[cfg(any(target_os = "android", target_os = "ios"))]
let position_code: KeyCode = 0;
#[cfg(any(target_os = "android", target_os = "ios"))]
let platform_code: KeyCode = 0;
#[cfg(target_os = "windows")]
let platform_code: u32 = rdev::win_code_from_key(key).unwrap_or(0);
#[cfg(target_os = "windows")]
let position_code: KeyCode = rdev::win_scancode_from_key(key).unwrap_or(0) as _;
#[cfg(not(target_os = "windows"))]
#[cfg(not(any(target_os = "windows", target_os = "android", target_os = "ios")))]
let position_code: KeyCode = rdev::code_from_key(key).unwrap_or(0) as _;
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
#[cfg(not(any(
target_os = "windows",
target_os = "android",
target_os = "ios",
target_os = "linux"
)))]
let platform_code: u32 = position_code as _;
// For translate mode.
// We need to set the platform code (keysym) if is AltGr.
@@ -972,10 +969,14 @@ impl<T: InvokeUiSession> Session<T> {
platform_code,
position_code: position_code as _,
event_type,
#[cfg(any(target_os = "android", target_os = "ios"))]
usb_hid: usb_hid as _,
#[cfg(not(any(target_os = "android", target_os = "ios")))]
usb_hid: 0,
#[cfg(any(target_os = "windows", target_os = "macos"))]
extra_data: 0,
};
keyboard::client::process_event(keyboard_mode, &event, Some(lock_modes));
keyboard::client::process_event_with_session(keyboard_mode, &event, Some(lock_modes), self);
}
// flutter only TODO new input