Commit 80a38062 authored by abmyii's avatar abmyii
Browse files

Add RMB, middle click and absolute cursor position

parent 64b93423
......@@ -74,6 +74,8 @@ struct libevdev *dev;
struct libevdev_uinput *uidev;
bool lmb;
bool rmb;
bool mmb;
void shutdown(int)
......@@ -463,7 +465,18 @@ static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
{
int left_down = buttonMask & 0x1;
int right_down = buttonMask & 0x4;
int middle_down = buttonMask & 0x2;
/* printf("%d %d %d %d\n", buttonMask, left_down, right_down, right_down >> 2); */
libevdev_uinput_write_event(uidev, EV_ABS, ABS_X, x*2.5);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_Y, y*2.5);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
if (left_down) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_LEFT, 1);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_TRACKING_ID, 10);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOUCH, 1);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOOL_FINGER, 1);
......@@ -473,12 +486,27 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
lmb = true;
}
else if (lmb) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_LEFT, 0);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_TRACKING_ID, -1);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOUCH, 0);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOOL_FINGER, 0);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
lmb = false;
}
if (right_down || rmb) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_RIGHT, right_down >> 2);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
rmb ^= true;
}
if (middle_down || mmb) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_MIDDLE, middle_down >> 1);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
mmb ^= true;
}
}
......@@ -572,13 +600,18 @@ try
libevdev_enable_event_code(dev, EV_ABS, ABS_MT_TRACKING_ID, &abs);
abs.maximum = 1080;
libevdev_enable_event_code(dev, EV_ABS, ABS_X, &abs);
libevdev_enable_event_code(dev, EV_ABS, ABS_MT_POSITION_X, &abs);
abs.maximum = 1920;
libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &abs);
libevdev_enable_event_code(dev, EV_ABS, ABS_MT_POSITION_Y, &abs);
// Keyboard input
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);
libevdev_enable_event_code(dev, EV_KEY, BTN_MIDDLE, NULL);
libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL);
for (int i = 0; i < KEY_MAX; i++)
......
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