diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index ba551c86f..efd42ed7e 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -253,6 +253,7 @@ fn generate_trezorhal_bindings() { .allowlist_function("storage_next_counter") // display .allowlist_function("display_init") + .allowlist_function("display_offset") .allowlist_function("display_refresh") .allowlist_function("display_backlight") .allowlist_function("display_text") diff --git a/core/embed/rust/src/trezorhal/display.rs b/core/embed/rust/src/trezorhal/display.rs index d8bcd8db3..8329e0ffe 100644 --- a/core/embed/rust/src/trezorhal/display.rs +++ b/core/embed/rust/src/trezorhal/display.rs @@ -1,5 +1,6 @@ use super::ffi; use core::ptr; +use cty::c_int; pub struct ToifInfo { pub width: u16, @@ -140,3 +141,12 @@ pub fn set_window(x0: u16, y0: u16, x1: u16, y1: u16) { ffi::display_set_window(x0, y0, x1, y1); } } + +pub fn get_offset() -> (i32, i32) { + unsafe { + let mut x: c_int = 0; + let mut y: c_int = 0; + ffi::display_offset(ptr::null_mut(), &mut x, &mut y); + (x as i32, y as i32) + } +} diff --git a/core/embed/rust/src/ui/display.rs b/core/embed/rust/src/ui/display.rs index 3bcec0764..b372f136c 100644 --- a/core/embed/rust/src/ui/display.rs +++ b/core/embed/rust/src/ui/display.rs @@ -229,6 +229,11 @@ pub fn pixeldata_dirty() { display::pixeldata_dirty(); } +pub fn get_offset() -> Offset { + let offset = display::get_offset(); + Offset::new(offset.0, offset.1) +} + pub fn set_window(window: Rect) { display::set_window( window.x0 as u16,