diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 6c01b3b37daef03dc5ada2665120763f02e657f7..0000000000000000000000000000000000000000 --- a/.cargo/config +++ /dev/null @@ -1,5 +0,0 @@ -[build] -# Set the default --target flag -target = "armv7-unknown-linux-gnueabihf" - - diff --git a/.gitignore b/.gitignore index 992c4be0bd14afced6c70456cb7ef613c42c16c2..99d8631045aeadb04286a2262dad8e147d20f0b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target *.swp Cargo.lock +*.debug +*.release +.gdb* diff --git a/Cargo.toml b/Cargo.toml index c97e1d5e273bf628558d158e396d430cf24d4fc0..a34b2f29afa753d37886969da236665c60a8bc25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rm2canvas" version = "0.1.0" -authors = ["Florian Unger <florian.unger@posteo.net>"] +authors = ["Florian Unger <florian.unger@posteo.net>", "Jonathan Krebs <jonathan.krebs@rm2canvas-2020.bruckbu.de>"] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..0b75561f587fe86d3eb0b2b0233fcdc47e73c7a0 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +TARGET ?= armv7-unknown-linux-gnueabihf +STRIP = arm-linux-gnueabihf-strip +#PROFILE ?= release + +SSH_HOST ?= remarkable + +.PHONY: clean all + +all: tipa.debug screenshot.release + +clean: + rm -rf target *.release *.debug Cargo.lock + +%.release: target/$(TARGET)/release/% + cp --reflink=auto $< $@ + $(STRIP) $@ + +%.debug: target/$(TARGET)/debug/% + cp --reflink=auto $< $@ + +%.remotedebug: %.debug + scp $< $(SSH_HOST): + ssh $(SSH_HOST) -L 1234:127.0.0.1:1234 ./gdbserver 127.0.0.1:1234 $(basename $<) & + gdb-multiarch -ex 'target remote localhost:1234' + +%.install: %.release + scp $< $(SSH_HOST): + +target/$(TARGET)/release/%: FORCE + cross build --target $(TARGET) --release --bin $* + #$(STRIP) target/$(TARGET)/$(PROFILE)/tipa + #ls -lh target/$(TARGET)/$(PROFILE)/tipa + +target/$(TARGET)/debug/%: FORCE + cross build --target $(TARGET) --bin $* + +FORCE: diff --git a/src/tipa.rs b/src/tipa.rs index 0882a18796e638d768c2745fb4fd2ad5000181e9..ec13b1f146f6c4f849ef8e40c90ff37f927d5f71 100644 --- a/src/tipa.rs +++ b/src/tipa.rs @@ -1,5 +1,5 @@ -use std::io::BufReader; -use std::fs::File; +use tokio::io::AsyncReadExt; +use tokio::fs::File; use structure::{structure, structure_impl}; @@ -25,8 +25,7 @@ const MAX_PRESSURE:u32 = 4095; fn input_stream_parser() -> impl Stream<Item = std::io::Result<CanvasInputEvent>> { let mut state = ParserState{x:0, y:0, pressure:0, tool:2}; try_stream! { - let f = File::open("/dev/input/event1")?; - let mut reader = BufReader::with_capacity(16, f); + let mut f = File::open("/dev/input/event1").await?; loop { // See https://github.com/canselcik/libremarkable/wiki/Reading-from-Wacom-I2C-Digitizer @@ -36,7 +35,9 @@ fn input_stream_parser() -> impl Stream<Item = std::io::Result<CanvasInputEvent> // 2 byte unsigned int for code, // 4 byte unsigned int for value. - let (s, us, typ, code, val) = structure!("<IIHHI").unpack_from(&mut reader)?; + let mut event_buf = [0u8; 16]; + f.read_exact(&mut event_buf).await?; + let (s, us, typ, code, val) = structure!("<IIHHI").unpack(&mut event_buf)?; // absolute position if typ == 3 { if code == 0 {