71 lines
2.3 KiB
Rust
71 lines
2.3 KiB
Rust
mod rgba;
|
|
mod trekstor;
|
|
|
|
use evdev::KeyCode;
|
|
|
|
use crate::trekstor::Trekstor;
|
|
|
|
fn main() {
|
|
let mut trekstor = Trekstor::new(30);
|
|
|
|
trekstor.update(|screen, input| {
|
|
// retuyrningf false will exit loop
|
|
if input.is_just_released(KeyCode::BTN_TOUCH) {
|
|
println!("Released {}x{}", input.x, input.y);
|
|
}
|
|
true
|
|
});
|
|
|
|
// let red = (255, 0, 0, 255);
|
|
// let green = (0, 255, 0, 255);
|
|
// let blue = (0, 0, 255, 255);
|
|
|
|
// // /dev/input/event4: silead_ts
|
|
|
|
// Rectangle::new(Point::new(0, 0), Size::new(trekstor.screen.width(), 1))
|
|
// .into_styled(PrimitiveStyle::with_fill(Rgba::from(red)))
|
|
// .draw(&mut trekstor.screen)
|
|
// .ok();
|
|
|
|
// Rectangle::new(Point::new(0, 1), Size::new(trekstor.screen.width(), 1))
|
|
// .into_styled(PrimitiveStyle::with_fill(Rgba::from(green)))
|
|
// .draw(&mut trekstor.screen)
|
|
// .ok();
|
|
|
|
// Rectangle::new(Point::new(0, 2), Size::new(trekstor.screen.width(), 1))
|
|
// .into_styled(PrimitiveStyle::with_fill(Rgba::from(blue)))
|
|
// .draw(&mut trekstor.screen)
|
|
// .ok();
|
|
|
|
// device.set_nonblocking(true).unwrap();
|
|
|
|
// loop {
|
|
// // println!("dont block");
|
|
|
|
// for event in events {
|
|
// match event.destructure() {
|
|
// EventSummary::AbsoluteAxis(_, AbsoluteAxisCode::ABS_X, value) => {
|
|
// x = (((value - 13) as f32 / 882.) * (trekstor.width() as f32)) as i32;
|
|
// }
|
|
// EventSummary::AbsoluteAxis(_, AbsoluteAxisCode::ABS_Y, value) => {
|
|
// y = (((value - 13) as f32 / 624.) * (trekstor.height() as f32)) as i32;
|
|
// }
|
|
// EventSummary::Key(_, KeyCode::BTN_TOUCH, value) => {
|
|
// // if value is 1, touch is started
|
|
// // if value is 0, touch ended
|
|
// println!("touch: {}", value)
|
|
// }
|
|
// _ => {}
|
|
// }
|
|
// }
|
|
|
|
// println!("{}x{}", x, y);
|
|
|
|
// trekstor.clear(Rgba::from((0, 0, 0, 255))).ok();
|
|
// Rectangle::new(Point::new(x - 50, y - 50), Size::new(100, 100))
|
|
// .into_styled(PrimitiveStyle::with_fill(Rgba::from(blue)))
|
|
// .draw(&mut trekstor)
|
|
// .ok();
|
|
// }
|
|
}
|