Skip to content

Commit 3d18fe2

Browse files
committed
Added calibration instructions, failure checking in c and corrected axis/abs info
1 parent d886612 commit 3d18fe2

4 files changed

Lines changed: 35 additions & 17 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ Create a file called `/etc/X11/xorg.conf.d/10-evdev.conf` and add [this content]
5858
In order to work in GIMP, the device must get enabled under `Edit -> Input devices`.
5959

6060

61+
# Calibrating
62+
63+
It also is a good idea to calibrate the tablet using xinput_calibrator because the tablet screen will be streched to match your screen. That will result in a wrong aspect ratio.
64+
65+
When calibration using xinput_calibrator use the pdf, open it on the reMarkable and touch the points there.
66+
67+
(I essentially just recorded the calibration screen, took a screenshot, changed the colors, added borders, and created a pdf from it.)
68+
6169
# Credits
6270

6371
Huge thanks to benthor's [HuionKamvasGT191LinuxDriver](https://github.com/benthor/HuionKamvasGT191LinuxDriver) (found

tabletDriver.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ void addAbsCapability(int fd, int code, int32_t value, int32_t min, int32_t max,
5454
abs_setup.code = code;
5555
abs_setup.absinfo = abs_info;
5656

57-
ioctl(fd, UI_ABS_SETUP, &abs_setup); // Set abs data
57+
if(ioctl(fd, UI_ABS_SETUP, &abs_setup) < 0) { // Set abs data
58+
perror("Failed to absolute info to uinput-device (old kernel?)");
59+
exit(1);
60+
}
5861
}
5962

6063
int main(int argc, char** argv)
@@ -83,14 +86,14 @@ int main(int argc, char** argv)
8386

8487
// See https://python-evdev.readthedocs.io/en/latest/apidoc.html#evdev.device.AbsInfo.resolution
8588
// Resolution = max(20967, 15725) / (21*10) # Height of display is 21cm. Format is units/mm. => ca. 100 (99.84285714285714)
86-
// Tilt resolution = 12400 / ((math.pi / 180) * 140 (max angle)) (Format: units/radian) => ca. 5074 (5074.769042587292)
89+
// Tilt resolution = 12600 / ((math.pi / 180) * 140 (max angle)) (Format: units/radian) => ca. 5074 (5074.769042587292)
8790
ioctl(fd, UI_SET_EVBIT, EV_ABS);
88-
addAbsCapability(fd, ABS_PRESSURE, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 4095, /*Resolution:*/ 0, /*Fuzz:*/ 0, /*Flat:*/ 0 );
89-
addAbsCapability(fd, ABS_DISTANCE, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 110, /*Resolution:*/ 0, /*Fuzz:*/ 0, /*Flat:*/ 0 );
90-
addAbsCapability(fd, ABS_TILT_X, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 12400, /*Resolution:*/ 5074, /*Fuzz:*/ 0, /*Flat:*/ 6200);
91-
addAbsCapability(fd, ABS_TILT_Y, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 12400, /*Resolution:*/ 5074, /*Fuzz:*/ 0, /*Flat:*/ 6200);
92-
addAbsCapability(fd, ABS_X, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 20967, /*Resolution:*/ 100, /*Fuzz:*/ 0, /*Flat:*/ 0 );
93-
addAbsCapability(fd, ABS_Y, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 15725, /*Resolution:*/ 100, /*Fuzz:*/ 0, /*Flat:*/ 0 );
91+
addAbsCapability(fd, ABS_PRESSURE, /*Value:*/ 0, /*Min:*/ 0, /*Max:*/ 4095, /*Resolution:*/ 0, /*Fuzz:*/ 0, /*Flat:*/ 0);
92+
addAbsCapability(fd, ABS_DISTANCE, /*Value:*/ 95, /*Min:*/ 0, /*Max:*/ 255, /*Resolution:*/ 0, /*Fuzz:*/ 0, /*Flat:*/ 0);
93+
addAbsCapability(fd, ABS_TILT_X, /*Value:*/ 0, /*Min:*/ -9000, /*Max:*/ 9000, /*Resolution:*/ 5074, /*Fuzz:*/ 0, /*Flat:*/ 0);
94+
addAbsCapability(fd, ABS_TILT_Y, /*Value:*/ 0, /*Min:*/ -9000, /*Max:*/ 9000, /*Resolution:*/ 5074, /*Fuzz:*/ 0, /*Flat:*/ 0);
95+
addAbsCapability(fd, ABS_X, /*Value:*/ 11344, /*Min:*/ 0, /*Max:*/ 20967, /*Resolution:*/ 100, /*Fuzz:*/ 0, /*Flat:*/ 0);
96+
addAbsCapability(fd, ABS_Y, /*Value:*/ 10471, /*Min:*/ 0, /*Max:*/ 15725, /*Resolution:*/ 100, /*Fuzz:*/ 0, /*Flat:*/ 0);
9497

9598
struct uinput_setup usetup;
9699
memset(&usetup, 0, sizeof(usetup));
@@ -99,9 +102,15 @@ int main(int argc, char** argv)
99102
//usetup.id.product = 0x7890; /* sample product */
100103
usetup.id.version = 0x3;
101104
strcpy(usetup.name, "reMarkableTablet-FakePen"); // Has to end with "pen" to work in Krita!!!
102-
ioctl(fd, UI_DEV_SETUP, &usetup);
103-
104-
ioctl(fd, UI_DEV_CREATE);
105+
if(ioctl(fd, UI_DEV_SETUP, &usetup) < 0) {
106+
perror("Failed to setup uinput-device (old kernel?)");
107+
return 1;
108+
}
109+
110+
if(ioctl(fd, UI_DEV_CREATE) < 0) {
111+
perror("Failed to create uinput-device");
112+
return 1;
113+
}
105114

106115
void closeDevice() {
107116
ioctl(fd, UI_DEV_DESTROY);

tabletDriver.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@
4040
# BTN_TOOL_PEN == 1 means that the pen is hovering over the tablet
4141
# BTN_TOUCH == 1 means that the pen is touching the tablet
4242

43-
# This WONT'T WORK with libinput since the resolution is never actually set.
43+
# This WONT'T WORK with libinput since the resolution is never actually set
44+
# and pydev uses an old method for creating the uinput-device which can't set the resolution.
4445
# This is fixed in the c-version but doesn't quite work yet, too.
4546
capabilities = {
4647
ecodes.EV_KEY: [ecodes.BTN_TOOL_PEN, ecodes.BTN_TOUCH],
4748
EV_ABS: [
4849
(WACOM_EVCODE_PRESSURE, AbsInfo(value=0, min=0, max=4095, fuzz=0, flat=0, resolution=0)),
49-
(WACOM_EVCODE_DISTANCE, AbsInfo(value=0, min=0, max=110, fuzz=0, flat=0, resolution=0)),
50-
(WACOM_EVCODE_XTILT, AbsInfo(value=0, min=0, max=12400, fuzz=0, flat=6200, resolution=5074)),
51-
(WACOM_EVCODE_YTILT, AbsInfo(value=0, min=0, max=12400, fuzz=0, flat=6200, resolution=5074)),
52-
(WACOM_EVCODE_XPOS, AbsInfo(value=0, min=0, max=WACOM_HEIGHT, fuzz=0, flat=0, resolution=100)),
53-
(WACOM_EVCODE_YPOS, AbsInfo(value=0, min=0, max=WACOM_WIDTH, fuzz=0, flat=0, resolution=100))
50+
(WACOM_EVCODE_DISTANCE, AbsInfo(value=95, min=0, max=255, fuzz=0, flat=0, resolution=0)),
51+
(WACOM_EVCODE_XTILT, AbsInfo(value=0, min=-9000, max=9000, fuzz=0, flat=0, resolution=5074)),
52+
(WACOM_EVCODE_YTILT, AbsInfo(value=0, min=-9000, max=9000, fuzz=0, flat=0, resolution=5074)),
53+
(WACOM_EVCODE_XPOS, AbsInfo(value=11344, min=0, max=WACOM_HEIGHT, fuzz=0, flat=0, resolution=100)),
54+
(WACOM_EVCODE_YPOS, AbsInfo(value=10471, min=0, max=WACOM_WIDTH, fuzz=0, flat=0, resolution=100))
5455
]
5556
}
5657

4.65 KB
Binary file not shown.

0 commit comments

Comments
 (0)