Skip to content

Commit

Permalink
better resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
darvin committed May 20, 2018
1 parent d586569 commit cdc2610
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
5 changes: 4 additions & 1 deletion build-run-remarkable.sh
@@ -1,4 +1,7 @@
dockcross-linux-armv7-rust ./build.sh && \
#!/bin/bash
set -ex

dockcross-linux-armv7-rust ./build.sh
dockcross-linux-armv7-rust ./dist.sh

DEVICE_IP="10.11.99.1"
Expand Down
27 changes: 24 additions & 3 deletions src/device.rs
@@ -1,5 +1,4 @@
extern crate libc;

use std::env;
use std::fmt;
use std::collections::HashMap;
Expand Down Expand Up @@ -140,8 +139,30 @@ lazy_static! {
model: Model::Remarkable,
proto: TouchProto::MultiB,
mirrored_x: true,
dims: (758, 1024),
dpi: 212,
dims: (1404, 1872),
dpi: 300, //todo fixme actual 226, but it crashes weirdly without stacktrace:
//thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
//Error: could not get list of modules: No such file or directory
//stack backtrace:
// 0: <unknown>
// 1: <unknown>
// 2: <unknown>
// 3: <unknown>
// 4: <unknown>
// 5: <unknown>
// 6: <unknown>
// 7: <unknown>
// 8: <unknown>
// 9: <unknown>
// 10: <unknown>
// 11: <unknown>
// 12: <unknown>
// 13: <unknown>
// 14: <unknown>
// 15: <unknown>
// 16: main
// 17: __libc_start_main

},
"kraken" => Device {
model: Model::Glo,
Expand Down
2 changes: 2 additions & 0 deletions src/input/mod.rs
Expand Up @@ -238,6 +238,8 @@ fn parse_usb_events(tx: &Sender<DeviceEvent>) {
}
}



pub fn device_events(rx: Receiver<InputEvent>, dims: (u32, u32)) -> Receiver<DeviceEvent> {
let (ty, ry) = mpsc::channel();
thread::spawn(move || CURRENT_DEVICE.parse_device_events(&rx, &ty, dims));
Expand Down
14 changes: 6 additions & 8 deletions src/input/remarkable.rs
Expand Up @@ -5,7 +5,8 @@ use geom::Point;
use std::mem;
use input::*;
use std::sync::mpsc::{self, Sender, Receiver};

extern crate libremarkable;
use self::libremarkable::framebuffer::common::{MTWIDTH, MTHEIGHT};

struct TouchState {
position: Point,
Expand All @@ -27,9 +28,6 @@ impl Default for TouchState {


pub fn remarkable_parse_device_events(rx: &Receiver<InputEvent>, ty: &Sender<DeviceEvent>, dims: (u32, u32)) {
static touchscreen_dims: (u32, u32) = (767, 1023);

let (tc_width, tc_height) = touchscreen_dims;
let (scr_width, scr_height) = dims;
let mut slot = 0;
let mut fingers: FnvHashMap<i32, TouchState> = FnvHashMap::default();
Expand All @@ -55,13 +53,13 @@ pub fn remarkable_parse_device_events(rx: &Receiver<InputEvent>, ty: &Sender<Dev
}
} else if evt.code == tc.x {
if let Some(ts) = fingers.get_mut(&slot) {
let pos = tc_width as i32 - 1 - evt.value;
ts.position.x = (pos as f32 / tc_width as f32 * scr_width as f32) as i32;
let pos = MTWIDTH as i32 - 1 - evt.value;
ts.position.x = (pos as f32 / MTWIDTH as f32 * scr_width as f32) as i32;
}
} else if evt.code == tc.y {
if let Some(ts) = fingers.get_mut(&slot) {
let pos = tc_height as i32 - 1 - evt.value;
ts.position.y = (pos as f32 / tc_height as f32 * scr_height as f32) as i32;
let pos = MTHEIGHT as i32 - 1 - evt.value;
ts.position.y = (pos as f32 / MTHEIGHT as f32 * scr_height as f32) as i32;
}
} else if evt.code == tc.pressure {
if let Some(ts) = fingers.get_mut(&slot) {
Expand Down

0 comments on commit cdc2610

Please sign in to comment.