BLAM!
Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
At a very, very, very, very, very quick glance, one *might* try to leverage tslib to do some of the heavy lifting.
The calibration tool appeared to manage to make sense of what my H2O spouts, for instance. (Calibration best done over USBNet w/ Nickel killed, to avoid spurious refreshes & touch responses).
Quick'n (very) dirty patch to make it very minimally behave on Kobo:
Code:
diff --git a/src/ts_setup.c b/src/ts_setup.c
index e11db0e..d52a7a3 100644
--- a/src/ts_setup.c
+++ b/src/ts_setup.c
@@ -48,6 +48,10 @@
#define BITS_PER_LONG (sizeof(long) * BITS_PER_BYTE)
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+#ifndef EVIOCGPROP
+#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */
+#endif
+
static int is_event_device(const struct dirent *dir)
{
return strncmp(EVENT_DEV_NAME, dir->d_name, 5) == 0;
@@ -78,9 +82,7 @@ static char *scan_devices(void)
if (fd < 0)
continue;
- if ((ioctl(fd, EVIOCGPROP(sizeof(propbit)), propbit) < 0) ||
- !(propbit[BIT_WORD(INPUT_PROP_DIRECT)] &
- BIT_MASK(INPUT_PROP_DIRECT))) {
+ if (strcmp(fname, "/dev/input/event1")) {
close(fd);
continue;
} else {
diff --git a/tests/fbutils-linux.c b/tests/fbutils-linux.c
index 660e63f..b9cd501 100644
--- a/tests/fbutils-linux.c
+++ b/tests/fbutils-linux.c
@@ -29,6 +29,8 @@
#include "font.h"
#include "fbutils.h"
+#include <fbink.h>
+
union multiptr {
uint8_t *p8;
uint16_t *p16;
@@ -222,6 +224,10 @@ void put_cross(int32_t x, int32_t y, uint32_t colidx)
line(x + 4, y - 4, x + 7, y - 7, colidx + 1);
line(x + 4, y + 4, x + 7, y + 7, colidx + 1);
}
+
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
}
static void put_char(int32_t x, int32_t y, int32_t c, int32_t colidx)
diff --git a/tests/ts_calibrate.c b/tests/ts_calibrate.c
index 5b540f3..6655b70 100644
--- a/tests/ts_calibrate.c
+++ b/tests/ts_calibrate.c
@@ -32,6 +32,8 @@
#include "testutils.h"
#include "ts_calibrate.h"
+#include <fbink.h>
+
#define CROSS_BOUND_DIST 50
#define VALIDATE_BOUNDARY_MIN 10
#define VALIDATE_LOOPS_DEFAULT 3
@@ -168,6 +170,9 @@ static int ts_validate(struct tsdev *ts, int boundary, unsigned int loops, int t
put_string_center(xres / 2, yres / 4, textbuf, 1);
put_string_center(xres / 2, yres / 4 + 20,
"Touch crosshair to validate", 2);
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
for (i = 0; i < loops; i++) {
srand(time(NULL));
@@ -181,6 +186,7 @@ static int ts_validate(struct tsdev *ts, int boundary, unsigned int loops, int t
done:
fillrect(0, 0, xres - 1, yres - 1, 0);
put_string_center(xres / 2, yres / 4, textbuf, 1);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
if (timeout == 0) {
close_framebuffer();
@@ -197,6 +203,7 @@ done:
put_string_center(xres / 2, yres / 4 + 20,
"Validation failed", 4);
}
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
if (timeout > 0) {
sleep(timeout);
@@ -404,6 +411,9 @@ int main(int argc, char **argv)
"Touchscreen calibration utility", 1);
put_string_center(xres / 2, yres / 4 + 20,
"Touch crosshair to calibrate", 2);
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
printf("xres = %d, yres = %d\n", xres, yres);
diff --git a/tests/ts_test.c b/tests/ts_test.c
index c9ced73..8eb4718 100644
--- a/tests/ts_test.c
+++ b/tests/ts_test.c
@@ -22,6 +22,8 @@
#include "fbutils.h"
#include "testutils.h"
+#include <fbink.h>
+
static int palette[] = {
0x000000, 0xffe080, 0xffffff, 0xe0c0a0, 0x304050, 0x80b8c0
};
@@ -50,6 +52,10 @@ static void refresh_screen(void)
for (i = 0; i < NR_BUTTONS; i++)
button_draw(&buttons[i]);
+
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
}
static void help(void)
diff --git a/tests/ts_test_mt.c b/tests/ts_test_mt.c
index 7337f1e..f0f3b68 100644
--- a/tests/ts_test_mt.c
+++ b/tests/ts_test_mt.c
@@ -55,6 +55,8 @@
#include "fbutils.h"
#include "testutils.h"
+#include <fbink.h>
+
#ifndef ABS_MT_SLOT /* < 2.6.36 kernel headers */
# define ABS_MT_SLOT 0x2f /* MT slot being modified */
#endif
@@ -87,6 +89,10 @@ static void refresh_screen(void)
for (i = 0; i < NR_BUTTONS; i++)
button_draw(&buttons[i]);
+
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
}
static void help(void)
@@ -127,6 +133,10 @@ void print_slot_info(char *slot_info, size_t len, int32_t max_slots,
"%d touch contacts supported (%s)",
max_slots, user_slots ? "user" : "driver");
put_string(2, yres - 14, slot_info, 2);
+
+ FBInkConfig fbink_cfg = { 0 };
+ fbink_init(FBFD_AUTO, &fbink_cfg);
+ fbink_refresh(FBFD_AUTO, 0, 0, 0, 0, HWD_PASSTHROUGH, &fbink_cfg);
}
#define CROSS_VISIBLE 0x00001000
Don't use FBInk like that at home, kids, this was just to get it running quickly ;p.
Last edited by NiLuJe; 05-25-2019 at 07:53 PM.
|