Commit cff470f9 authored by abmyii's avatar abmyii
Browse files

Get relative mouse motion working

parent 759c17c8
......@@ -444,20 +444,28 @@ static int keysym2scancode(rfbKeySym key)
// vnc key event function, escape to quit
static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
{
if(down) {
if(key==XK_Escape) {
/* close down server, disconnecting clients */
rfbShutdownServer(cl->screen,TRUE);
running = 0;
}
printf("%d Down\n", key);
printf("%d Down\n", KEY_A);
}
/* if(down && key==XK_Escape) { */
/* /1* close down server, disconnecting clients *1/ */
/* rfbShutdownServer(cl->screen,TRUE); */
/* running = 0; */
/* } */
libevdev_uinput_write_event(uidev, EV_KEY, keysym2scancode(key), down);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
}
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;
}
void do_screencast(EGLSetup const& egl_setup,
mir::geometry::Size const& size,
int32_t number_of_captures,
......@@ -484,6 +492,7 @@ void do_screencast(EGLSetup const& egl_setup,
rfbScreen->frameBuffer = frame_data.data();
rfbScreen->alwaysShared = TRUE;
rfbScreen->kbdAddEvent = dokey;
rfbScreen->ptrAddEvent = doptr;
rfbInitServer(rfbScreen);
rfbRunEventLoop(rfbScreen,-1,TRUE);
fprintf(stderr, "Running vnc background loop...\n");
......@@ -526,16 +535,20 @@ try
bool query_params_only = false;
int capture_interval = 1;
// Fake keyboard device
int err;
// Fake keyboard device (https://stackoverflow.com/q/23092855)
dev = libevdev_new();
libevdev_set_name(dev, "fake keyboard device");
libevdev_enable_event_type(dev, EV_REL);
libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
libevdev_enable_event_type(dev, EV_KEY);
libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
for (int i = 0; i < KEY_MAX; i++)
libevdev_enable_event_code(dev, EV_KEY, i, NULL);
err = libevdev_uinput_create_from_device(dev,
libevdev_uinput_create_from_device(dev,
LIBEVDEV_UINPUT_OPEN_MANAGED,
&uidev);
......
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