Commit 9fc2742d authored by abmyii's avatar abmyii
Browse files

Fix absolute mouse motion by sending events to touchscreen input

parent cff470f9
......@@ -50,6 +50,9 @@
#include <libevdev/libevdev.h>
#include <libevdev/libevdev-uinput.h>
#include <fcntl.h> /* For O_RDWR */
#include <unistd.h> /* For open(), creat() */
namespace po = boost::program_options;
......@@ -69,6 +72,7 @@ thread_local int dummy_tls[2];
struct libevdev *dev;
struct libevdev_uinput *uidev;
struct libevdev_uinput *uidev2;
void shutdown(int)
{
......@@ -457,12 +461,18 @@ int last_x, last_y;
static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
{
printf("%d (%dx%d)\n", buttonMask, x, y);
libevdev_uinput_write_event(uidev, EV_REL, REL_X, x-last_x);
libevdev_uinput_write_event(uidev, EV_REL, REL_Y, y-last_y);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
last_x = x;
last_y = y;
int left_w = buttonMask & 0x1;
printf("%d (%dx%d)\n", left_w, x, y);
libevdev_uinput_write_event(uidev2, EV_ABS, ABS_MT_TRACKING_ID, 10);
libevdev_uinput_write_event(uidev2, EV_ABS, ABS_MT_POSITION_X, x*2.5);
libevdev_uinput_write_event(uidev2, EV_ABS, ABS_MT_POSITION_Y, y*2.5);
libevdev_uinput_write_event(uidev2, EV_KEY, BTN_TOUCH, left_w);
libevdev_uinput_write_event(uidev2, EV_SYN, SYN_REPORT, 0);
/* libevdev_uinput_write_event(uidev, EV_REL, REL_X, x-last_x); */
/* libevdev_uinput_write_event(uidev, EV_REL, REL_Y, y-last_y); */
/* libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); */
/* last_x = x; */
/* last_y = y; */
}
......@@ -552,6 +562,18 @@ try
LIBEVDEV_UINPUT_OPEN_MANAGED,
&uidev);
// Touch event
int rc;
int fd;
const char *path;
struct libevdev *dev2;
fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
libevdev_new_from_fd(fd, &dev2);
libevdev_uinput_create_from_device(dev2,
LIBEVDEV_UINPUT_OPEN_MANAGED,
&uidev2);
//avoid unused warning/error
dummy_tls[0] = 0;
......@@ -686,7 +708,10 @@ try
do_screencast(egl_setup, screencast_size, number_of_captures, capture_fps, file_stream);
}
// Clear libevdev devices
libevdev_uinput_destroy(uidev);
libevdev_free(dev2);
close(fd);
return EXIT_SUCCESS;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment