From 1aab8a7c299d0ad8ec514c4384876a74bf506c03 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 20 Oct 2022 12:55:52 +0200 Subject: [PATCH] fixup! feat(core/rust): expose touch processing functions to rust --- core/embed/rust/build.rs | 11 ++++++++++- core/embed/rust/src/trezorhal/io.rs | 14 ++++++++++++++ core/embed/rust/trezorhal.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 core/embed/rust/src/trezorhal/io.rs diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index d5a0104a9b..58c50c42b9 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -310,7 +310,16 @@ fn generate_trezorhal_bindings() { .allowlist_function("buffers_get_line_buffer_4bpp") .allowlist_function("buffers_get_text_buffer") .allowlist_var("text_buffer_height") - .allowlist_var("buffer_width"); + .allowlist_var("buffer_width") + // touch + .allowlist_function("touch_read") + // button + .allowlist_function("button_read") + .allowlist_var("BTN_EVT_DOWN") + .allowlist_var("BTN_EVT_UP") + .allowlist_var("BTN_RIGHT") + .allowlist_var("BTN_LEFT"); + // Write the bindings to a file in the OUR_DIR. bindings .generate() diff --git a/core/embed/rust/src/trezorhal/io.rs b/core/embed/rust/src/trezorhal/io.rs new file mode 100644 index 0000000000..d8aa3aa749 --- /dev/null +++ b/core/embed/rust/src/trezorhal/io.rs @@ -0,0 +1,14 @@ +use super::ffi; + +#[cfg(feature = "buttons")] +pub use super::ffi::{BTN_EVT_DOWN, BTN_EVT_UP, BTN_LEFT, BTN_RIGHT}; + +#[cfg(feature = "touch")] +pub fn io_touch_read() -> u32 { + unsafe { ffi::touch_read() } +} + +#[cfg(feature = "buttons")] +pub fn io_button_read() -> u32 { + unsafe { ffi::button_read() } +} diff --git a/core/embed/rust/trezorhal.h b/core/embed/rust/trezorhal.h index 0f474ae0a6..c64b015e1f 100644 --- a/core/embed/rust/trezorhal.h +++ b/core/embed/rust/trezorhal.h @@ -1,4 +1,5 @@ #include "buffers.h" +#include "button.h" #include "common.h" #include "display.h" #include "display_interface.h" @@ -8,6 +9,7 @@ #include "rgb_led.h" #include "secbool.h" #include "storage.h" +#include "touch.h" #include "bip39.h" #include "rand.h"