mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-02-04 15:46:34 +11:00
Android: Add KeyEvent handling (#1839)
This commit is contained in:
parent
10a94c0794
commit
952edcb804
2 changed files with 27 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On Android, `InputEvent::KeyEvent` is partially implemented providing the key scancode.
|
||||||
- Added `is_maximized` method to `Window`.
|
- Added `is_maximized` method to `Window`.
|
||||||
- On Windows, fix bug where clicking the decoration bar would make the cursor blink.
|
- On Windows, fix bug where clicking the decoration bar would make the cursor blink.
|
||||||
- On Windows, fix bug causing newly created windows to erroneously display the "wait" (spinning) cursor.
|
- On Windows, fix bug causing newly created windows to erroneously display the "wait" (spinning) cursor.
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use ndk::{
|
use ndk::{
|
||||||
configuration::Configuration,
|
configuration::Configuration,
|
||||||
event::{InputEvent, MotionAction},
|
event::{InputEvent, KeyAction, MotionAction},
|
||||||
looper::{ForeignLooper, Poll, ThreadLooper},
|
looper::{ForeignLooper, Poll, ThreadLooper},
|
||||||
};
|
};
|
||||||
use ndk_glue::{Event, Rect};
|
use ndk_glue::{Event, Rect};
|
||||||
|
@ -239,9 +239,31 @@ impl<T: 'static> EventLoop<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InputEvent::KeyEvent(_) => {
|
InputEvent::KeyEvent(key) => {
|
||||||
// TODO
|
let state = match key.action() {
|
||||||
handled = false;
|
KeyAction::Down => event::ElementState::Pressed,
|
||||||
|
KeyAction::Up => event::ElementState::Released,
|
||||||
|
_ => event::ElementState::Released,
|
||||||
|
};
|
||||||
|
let event = event::Event::WindowEvent {
|
||||||
|
window_id,
|
||||||
|
event: event::WindowEvent::KeyboardInput {
|
||||||
|
device_id,
|
||||||
|
input: event::KeyboardInput {
|
||||||
|
scancode: key.scan_code() as u32,
|
||||||
|
state,
|
||||||
|
virtual_keycode: None,
|
||||||
|
modifiers: event::ModifiersState::default(),
|
||||||
|
},
|
||||||
|
is_synthetic: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
call_event_handler!(
|
||||||
|
event_handler,
|
||||||
|
self.window_target(),
|
||||||
|
control_flow,
|
||||||
|
event
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
input_queue.finish_event(event, handled);
|
input_queue.finish_event(event, handled);
|
||||||
|
|
Loading…
Add table
Reference in a new issue