android changes taken from ibaryshnikov

This commit is contained in:
Your Name 2025-05-14 23:27:12 +02:00
parent 50cc94d944
commit a6f4b5ac0a
7 changed files with 130 additions and 31 deletions

View file

@ -203,13 +203,19 @@ pub fn window_event(
WindowEvent::KeyboardInput { is_synthetic, .. } if is_synthetic => None,
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
let key = {
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(
target_arch = "wasm32",
target_os = "android",
)))]
{
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
event.key_without_modifiers()
}
#[cfg(target_arch = "wasm32")]
#[cfg(any(
target_arch = "wasm32",
target_os = "android",
))]
{
// TODO: Fix inconsistent API on Wasm
event.logical_key.clone()
@ -217,7 +223,10 @@ pub fn window_event(
};
let text = {
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(
target_arch = "wasm32",
target_os = "android",
)))]
{
use crate::core::SmolStr;
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
@ -225,6 +234,18 @@ pub fn window_event(
event.text_with_all_modifiers().map(SmolStr::new)
}
#[cfg(target_os = "android")]
{
if event.text.is_some() {
event.text
} else {
match &key {
winit::keyboard::Key::Character(c) => Some(c.clone()),
_ => None,
}
}
}
#[cfg(target_arch = "wasm32")]
{
// TODO: Fix inconsistent API on Wasm