diff --git a/build b/build new file mode 100755 index 0000000..5e714d1 --- /dev/null +++ b/build @@ -0,0 +1,5 @@ +#!/bin/bash +git add . +git commit -am "$(date +%s)" + +ssh trekstor -c "cd dashboard && git pull && cargo r -r" diff --git a/src/input.rs b/src/input.rs index 814206c..eb92e71 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use evdev::{AbsoluteAxisCode, Device, EventSummary, KeyCode}; +use evdev::{AbsoluteAxisCode, Device, EventSummary, InputEvent, KeyCode}; struct InputState { x: i32, @@ -22,4 +22,21 @@ impl InputState { clear_before_next_event: true, } } + + pub fn handle_event(&mut self, event: &InputEvent) { + match event.destructure() { + EventSummary::AbsoluteAxis(_, AbsoluteAxisCode::ABS_X, value) => { + self.x = (((value - 13) as f32 / 882.) * (screen.width() as f32)) as i32; + } + EventSummary::AbsoluteAxis(_, AbsoluteAxisCode::ABS_Y, value) => { + self.y = (((value - 13) as f32 / 624.) * (screen.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) + } + _ => {} + } + } }