Skip to content

shim quirks #33

@HookedBehemoth

Description

@HookedBehemoth

I've been trying to get my sudoku running and encountered a few issues between libremarkable being pedantic and the shim being a bit flaky.

This is a list of issues I've encountered and I'm uncertain what the action for each of these should be. I'd like to fix as much as possible with your input.

Partial update broken

The integer division floors, breaking partial updates. Easy fix.

diff --git a/src/qtfb/FBController.cpp b/src/qtfb/FBController.cpp
index 8653892..efe2bd0 100644
--- a/src/qtfb/FBController.cpp
+++ b/src/qtfb/FBController.cpp
@@ -73,11 +73,14 @@ void FBController::associateSHM(QImage *image) {
 void FBController::markedUpdate(const QRect &rect) {
     isMidPaint = true;
     if(_allowScaling && image) {
+        double sx = double(this->width())  / image->width();
+        double sy = double(this->height()) / image->height();
+
         update(QRect(
-           (rect.x() / image->width()) * this->width(),
-           (rect.y() / image->height()) * this->height(),
-           (rect.width() / image->width()) * this->width(),
-           (rect.height() / image->height()) * this->height()
+            int(rect.x()      * sx),
+            int(rect.y()      * sy),
+            int(rect.width()  * sx),
+            int(rect.height() * sy)
         ));
     } else {
         update(rect);

Broken up partial refresh

After fixing the above I get a dash pattern while writing. Unclear.
Image

Rubber not working

Already a TODO in the code. I'd have to investigate further.

TOUCH_QUEUE sends EV_KEY

While not advertised earlier, EV_KEY BTN_TOUCH 1/0 is set.

unsigned long *bits = (unsigned long*) ptr;
SETBIT(EV_ABS, bits);
SETBIT(EV_REL, bits);

switch(message.userInput.inputType) {
case INPUT_TOUCH_PRESS:
state_a = 1;
pushToAll(QUEUE_TOUCH, evt(EV_ABS, ABS_MT_SLOT, 1));
pushToAll(QUEUE_TOUCH, evt(EV_ABS, ABS_MT_TRACKING_ID, 50));
goto sendpos;
case INPUT_TOUCH_RELEASE:
state_a = 0;
pushToAll(QUEUE_TOUCH, evt(EV_ABS, ABS_MT_TRACKING_ID, -1));
sendpos:
if(state_a != 0) {
pushToAll(QUEUE_TOUCH, evt(EV_ABS, ABS_MT_POSITION_X, xTranslate));
pushToAll(QUEUE_TOUCH, evt(EV_ABS, ABS_MT_POSITION_Y, yTranslate));
}
if(state_a == 1 || state_a == 0) {
pushToAll(QUEUE_TOUCH, evt(EV_KEY, BTN_TOUCH, state_a));
}
pushToAll(QUEUE_TOUCH, evt(EV_SYN, SYN_REPORT, 0));
break;
case INPUT_TOUCH_UPDATE:{
state_a = 2;
goto sendpos;
break;
}

libremarkable doesn't check this value but the evdev library aborts because it wasn't advertised.
Unclear fix. Either don't send the event or advertise it.
Regardless, those weird goto's make it harder to read the code than it should.

Touch Identifier is static

libremarkable seems to only consider the first touch. Randomizing this value works.

Symlink causes weird mixups

The symlink from touchscreen0 -> eventX causes two devices to share the same ident.
Coincidentally RM2 on RM2 works:

Ident dig: 4000000000000d41
Ident touch: 4000000000000d41
Ident touch: 4000000000000d42
Ident btn: 4000000000000d40

mode RM1 on RM2 doesn't

Ident dig: 4000000000000d40
Ident touch: 4000000000000d41
Ident touch: 4000000000000d42
Ident btn: 4000000000000d41

I have no idea what to do here.

Touch-X coordinates are flipped with RM2 on RM2

The many layers rotate and flip the coordinates enough times to make my brain hurt and sudoku/libremarkable to have X flipped while it's fine in Koreader.

18:37:01.192 default                  [QTFB]: Touch x:  52  y:  26  state:  QEventPoint::Pressed
[QTFB SHIM INPUT]: 16, 52, 26 (Translated to 51, 1846)
Press { finger: Finger { tracking_id: 50, pos: Point2 [1352, 25], pos_updated: true, last_pressed: true, pressed: true } }
18:37:01.297 default                  [QTFB]: Touch x:  52  y:  26  state:  QEventPoint::Released
[QTFB SHIM INPUT]: 17, 52, 26 (Translated to 51, 1846)
Release { finger: Finger { tracking_id: 50, pos: Point2 [1352, 25], pos_updated: false, last_pressed: false, pressed: false } }

Unclear. Caused by the shimming input but not the device type. Setting mode to RM1 with the symlinks fixed should fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions