1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(unused)]
pub struct VirtualTouchScreen {
pub filename: String,
queue: Vec<String>,
}
impl VirtualTouchScreen {
pub fn new() -> VirtualTouchScreen {
VirtualTouchScreen {
filename: "/dev/virtual_touchscreen".to_string(),
queue: Vec::new(),
}
}
pub fn new_with_path(path: String) -> VirtualTouchScreen {
VirtualTouchScreen {
filename: path,
queue: Vec::new(),
}
}
pub fn clear_queue(&mut self) {
self.queue.clear();
}
pub fn pop_queue(&mut self) {
self.queue.pop();
}
pub fn submit_queue(&mut self) {
let mut full_command = String::new();
for s in self.queue.clone() {
full_command += &s;
}
full_command += "S 0\n";
use std::fs;
use std::io::prelude::*;
fs::write(&self.filename, full_command).expect("Unable to write to module entrypoint.");
self.clear_queue();
}
pub fn set_pointer(&mut self, pointer: u32) {
self.queue.push(format!("s {}\na {}\n", pointer, pointer));
}
pub fn set_position(&mut self, x: u32, y: u32) {
self.set_x(x);
self.set_y(y);
}
pub fn set_x(&mut self, x: u32) {
self.queue.push(format!("X {}\nx {}\n", x, x));
}
pub fn set_y(&mut self, y: u32) {
self.queue.push(format!("Y {}\ny {}\n", y, y));
}
}