Skip to content
Merged
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: 1 addition & 1 deletion ndk-examples/examples/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn main() {
ndk_glue::NDK_GLUE_LOOPER_INPUT_QUEUE_IDENT => {
let input_queue = ndk_glue::input_queue();
let input_queue = input_queue.as_ref().expect("Input queue not attached");
assert!(input_queue.has_events().unwrap());
assert!(input_queue.has_events());
// Consume as many events as possible
while let Some(event) = input_queue.get_event().unwrap() {
// Pass the event by a possible IME (Input Method Editor, ie. an open keyboard) first
Expand Down
3 changes: 2 additions & 1 deletion ndk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
- native_activity: Add `set_window_flags()` to change window behavior. (#278)
- Add `SurfaceTexture` bindings. (#267)
- Improve library and structure documentation, linking back to the NDK docs more rigorously. (#290)
- **Breaking:** input_queue: `InputQueue::{get_event,has_events}()` now return a `Result` with `std::io::Error`; `InputQueueError` has been removed. (#292)
- **Breaking:** input_queue: `get_event()` now returns a `Result` with `std::io::Error`; `InputQueueError` has been removed. (#292)
- **Breaking:** input_queue: `has_events()` now returns a `bool` directly without being wrapped in `Result`. (#294)
- **Breaking:** Update `jni` crate (used in public API) from `0.18` to `0.19`. (#300)

# 0.6.0 (2022-01-05)
Expand Down
7 changes: 3 additions & 4 deletions ndk/src/input_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ impl InputQueue {
}

/// Returns [`true`] if there are one or more events available in the input queue.
pub fn has_events(&self) -> Result<bool> {
pub fn has_events(&self) -> bool {
match unsafe { ffi::AInputQueue_hasEvents(self.ptr.as_ptr()) } {
0 => Ok(false),
1 => Ok(true),
r if r < 0 => Err(Error::from_raw_os_error(-r)),
0 => false,
1 => true,
r => unreachable!("AInputQueue_hasEvents returned non-boolean {}", r),
}
}
Expand Down