This commit is contained in:
JerryXiao 2023-04-26 01:00:37 +08:00
parent 222b8fbdc4
commit a5fbfa7a59
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -228,57 +228,57 @@ static void rfb_ptr_hook(int mask, int screen_x, int screen_y, rfbClientPtr cl)
int touch_x = round(global_x / resolution.x * UINPUT_ABS_MAX);
int touch_y = round(global_y / resolution.y * UINPUT_ABS_MAX);
struct input_event ies1[] = {
{
.type = EV_ABS,
.code = ABS_X,
.value = touch_x,
},
{
.type = EV_ABS,
.code = ABS_Y,
.value = touch_y,
},
{
.type = EV_KEY,
.code = BTN_LEFT,
.value = !! (mask & 0b1)
},
{
.type = EV_KEY,
.code = BTN_MIDDLE,
.value = !! (mask & 0b10)
},
{
.type = EV_KEY,
.code = BTN_RIGHT,
.value = !! (mask & 0b100)
},
{
.type = EV_SYN,
.code = SYN_REPORT,
.value = 0,
},
{
.type = EV_ABS,
.code = ABS_X,
.value = touch_x,
},
{
.type = EV_ABS,
.code = ABS_Y,
.value = touch_y,
},
{
.type = EV_KEY,
.code = BTN_LEFT,
.value = !! (mask & 0b1)
},
{
.type = EV_KEY,
.code = BTN_MIDDLE,
.value = !! (mask & 0b10)
},
{
.type = EV_KEY,
.code = BTN_RIGHT,
.value = !! (mask & 0b100)
},
{
.type = EV_SYN,
.code = SYN_REPORT,
.value = 0,
},
};
for (int i = 0; i < ARRAY_SIZE(ies1); i++) {
write(uinput_fd, &ies1[i], sizeof(ies1[0]));
}
if (mask & 0b11000) {
struct input_event ies2[] = {
{
.type = EV_REL,
.code = REL_WHEEL,
.value = mask & 0b1000 ? 1 : -1,
},
{
.type = EV_SYN,
.code = SYN_REPORT,
.value = 0,
},
{
.type = EV_REL,
.code = REL_WHEEL,
.value = mask & 0b1000 ? 1 : -1,
},
{
.type = EV_SYN,
.code = SYN_REPORT,
.value = 0,
},
};
for (int i = 0; i < ARRAY_SIZE(ies2); i++) {
write(uinput_fd, &ies2[i], sizeof(ies2[0]));
}
}
}
}