Skip to content

How to associate touch coordinates with components in an MCU? #5099

Answered by ogoffart
Song-aff asked this question in Q&A
Discussion options

You must be logged in to vote

You ask the touch driver.

There are some example in the repository for a few different touch screens:

// handle touch event
let button = PointerEventButton::Left;
if let Some(event) = self
.touch
.borrow_mut()
.read()
.map_err(|_| ())
.unwrap()
.map(|point| {
let position = slint::PhysicalPosition::new(
(point.x * DISPLAY_SIZE.width as f32) as _,
(point.y * DISPLAY_SIZE.height as f32) as _,
)
.to_logical(window.scale_factor());
match last_touch.replace(position) {
Some(_) => WindowEvent::PointerMoved { position },
None => W…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Song-aff
Comment options

@ogoffart
Comment options

Answer selected by Song-aff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants