mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 22:38:41 -06:00
support keyboard input on wayland and android properly
This commit is contained in:
parent
097bdc29ff
commit
bb4d2a80bf
|
@ -48,8 +48,9 @@ ndk = "0.9"
|
||||||
winapi = { version = "0.3", features = ["wincon"] }
|
winapi = { version = "0.3", features = ["wincon"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["raw-evt"]
|
default = ["raw-evt-mouse"]
|
||||||
raw-evt = [] #required for mouse input, but breaks keyboard on android
|
raw-evt-keyboard = [] # use raw input for keyboard. works on x11 and windows, breaks keyboard on android and wayland
|
||||||
|
raw-evt-mouse = [] # required for mouse input
|
||||||
generate_visualizer_data = ["dep:serde_json", "shipyard/serde1"]
|
generate_visualizer_data = ["dep:serde_json", "shipyard/serde1"]
|
||||||
safe_lz4 = ["lz4_flex/safe-encode", "lz4_flex/safe-decode"]
|
safe_lz4 = ["lz4_flex/safe-encode", "lz4_flex/safe-decode"]
|
||||||
parallel = ["shipyard/parallel"] # causes some serious issues!
|
parallel = ["shipyard/parallel"] # causes some serious issues!
|
||||||
|
|
|
@ -34,8 +34,12 @@ pub fn process_winit_events(world: &mut World, event: &Event<()>) {
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "raw-evt"))]
|
#[cfg(not(feature = "raw-evt-keyboard"))]
|
||||||
WindowEvent::KeyboardInput { device_id, event, .. } => {
|
WindowEvent::KeyboardInput { device_id, event, .. } => {
|
||||||
|
// HACK: translate KeyboardInput events to raw device events
|
||||||
|
if event.repeat {
|
||||||
|
return;
|
||||||
|
}
|
||||||
world.add_entity((
|
world.add_entity((
|
||||||
EventComponent,
|
EventComponent,
|
||||||
InputDeviceEvent {
|
InputDeviceEvent {
|
||||||
|
@ -63,8 +67,21 @@ pub fn process_winit_events(world: &mut World, event: &Event<()>) {
|
||||||
_ => ()
|
_ => ()
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(feature = "raw-evt")]
|
#[cfg(any(
|
||||||
|
feature = "raw-evt-keyboard",
|
||||||
|
feature = "raw-evt-mouse",
|
||||||
|
))]
|
||||||
Event::DeviceEvent { device_id, event } => {
|
Event::DeviceEvent { device_id, event } => {
|
||||||
|
// Filter out events we don't care about
|
||||||
|
match event {
|
||||||
|
#[cfg(feature = "raw-evt-keyboard")]
|
||||||
|
DeviceEvent::Key(_) => (),
|
||||||
|
|
||||||
|
#[cfg(feature = "raw-evt-mouse")]
|
||||||
|
DeviceEvent::MouseMotion { .. } | DeviceEvent::Button { .. } => (),
|
||||||
|
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
world.add_entity((
|
world.add_entity((
|
||||||
EventComponent,
|
EventComponent,
|
||||||
InputDeviceEvent {
|
InputDeviceEvent {
|
||||||
|
|
Loading…
Reference in a new issue