Skip to content

Expose underlying mobile support from winit via cfg changes #2952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ x11 = ["winit/x11"]
wayland = ["winit/wayland"]
wayland-dlopen = ["winit/wayland-dlopen"]
wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
android-native-activity = ["winit/android-native-activity"]
android-game-activity = ["winit/android-game-activity"]
unconditional-rendering = []

[dependencies]
Expand Down
32 changes: 28 additions & 4 deletions winit/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,29 +203,53 @@ 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(any(
target_os="windows",
target_os="macos",
all(feature = "x11", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
all(feature = "wayland", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
target_os="redox",
))]
{
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
event.key_without_modifiers()
}

#[cfg(target_arch = "wasm32")]
#[cfg(not(any(
target_os="windows",
target_os="macos",
all(feature = "x11", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
all(feature = "wayland", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
target_os="redox",
)))]
{
// TODO: Fix inconsistent API on Wasm
event.logical_key.clone()
}
};

let text = {
#[cfg(not(target_arch = "wasm32"))]
#[cfg(any(
target_os="windows",
target_os="macos",
all(feature = "x11", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
all(feature = "wayland", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
target_os="redox",
))]
{
use crate::core::SmolStr;
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;

event.text_with_all_modifiers().map(SmolStr::new)
}

#[cfg(target_arch = "wasm32")]
#[cfg(not(any(
target_os="windows",
target_os="macos",
all(feature = "x11", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
all(feature = "wayland", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
target_os="redox",
)))]
{
// TODO: Fix inconsistent API on Wasm
event.text
Expand Down