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
11 changes: 8 additions & 3 deletions src/proto/console/pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ impl Pointer {

/// Retrieves the pointer device's current state.
///
/// Will return None if the state has not changed since the last query.
///
/// # Errors
/// - `NotReady` is returned if the state hasn't changed since the last call.
/// - `DeviceError` if there was an issue with the pointer device.
pub fn state(&self) -> Result<PointerState> {
pub fn state(&self) -> Result<Option<PointerState>> {
let mut pointer_state = unsafe { mem::uninitialized() };

(self.get_state)(self, &mut pointer_state).into_with(|| pointer_state)
match (self.get_state)(self, &mut pointer_state) {
Status::Success => Ok(Some(pointer_state)),
Status::NotReady => Ok(None),
error => Err(error)
}
}

/// Returns a reference to the pointer device information.
Expand Down
7 changes: 4 additions & 3 deletions uefi-test-runner/src/proto/console/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ pub fn test(bt: &BootServices) {
.reset(false)
.expect("Failed to reset pointer device");

if let Ok(state) = pointer.state() {
info!("Pointer State: {:#?}", state);
let state = pointer.state().expect("Failed to retrieve pointer state");
if let Some(state) = state {
info!("New pointer State: {:#?}", state);
} else {
error!("Failed to retrieve pointer state");
info!("Pointer state has not changed since the last query");
}
} else {
warn!("No pointer device found");
Expand Down