diff --git a/input.c b/input.c index 6a77b4e..9f9f257 100644 --- a/input.c +++ b/input.c @@ -140,10 +140,10 @@ void rfb_key_hook(rfbBool down, rfbKeySym keysym, rfbClientPtr cl) void rfb_ptr_hook(int mask, int screen_x, int screen_y, rfbClientPtr cl) { // printf("pointer to %d, %d\n", screen_x, screen_y); - float global_x = (float)screen_x; - float global_y = (float)screen_y; - int touch_x = round(global_x / kmsvnc->drm->mfb->width * UINPUT_ABS_MAX); - int touch_y = round(global_y / kmsvnc->drm->mfb->height * UINPUT_ABS_MAX); + float global_x = (float)(screen_x + kmsvnc->input_offx); + float global_y = (float)(screen_y + kmsvnc->input_offy); + int touch_x = round(global_x / (kmsvnc->input_width ?: kmsvnc->drm->mfb->width) * UINPUT_ABS_MAX); + int touch_y = round(global_y / (kmsvnc->input_height ?: kmsvnc->drm->mfb->height) * UINPUT_ABS_MAX); struct input_event ies1[] = { { .type = EV_ABS, diff --git a/kmsvnc.c b/kmsvnc.c index 04aa87c..daf1fca 100644 --- a/kmsvnc.c +++ b/kmsvnc.c @@ -144,7 +144,11 @@ static struct argp_option kmsvnc_main_options[] = { {"disable-compare-fb", 0xff02, 0, OPTION_ARG_OPTIONAL, "Do not compare pixels"}, {"capture-raw-fb", 0xff03, "/tmp/rawfb.bin", 0, "Capture RAW framebuffer instead of starting the vnc server (for debugging)"}, {"va-derive", 0xff04, "off", 0, "Enable derive with vaapi"}, - {"va-print-format", 0xff05, 0, OPTION_ARG_OPTIONAL, "Print supported vaImage format"}, + {"va-debug", 0xff05, 0, OPTION_ARG_OPTIONAL, "Print va debug message"}, + {"input-width", 0xff06, "0", 0, "Explicitly set input width, normally this is inferred from screen width on a single display system"}, + {"input-height", 0xff07, "0", 0, "Explicitly set input height"}, + {"input-offx", 0xff08, "0", 0, "Set input offset of x axis on a multi display system"}, + {"input-offy", 0xff09, "0", 0, "Set input offset of y axis on a multi display system"}, {"wakeup", 'w', 0, OPTION_ARG_OPTIONAL, "Move mouse to wake the system up before start"}, {"disable-input", 'i', 0, OPTION_ARG_OPTIONAL, "Disable uinput"}, {"desktop-name", 'n', "kmsvnc", 0, "Specify vnc desktop name"}, @@ -215,7 +219,31 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { } break; case 0xff05: - kmsvnc->va_print_fmt = 1; + kmsvnc->va_debug = 1; + break; + case 0xff06: + int width = atoi(arg); + if (width > 0) { + kmsvnc->input_width = width; + } + break; + case 0xff07: + int height = atoi(arg); + if (height > 0) { + kmsvnc->input_height = height; + } + break; + case 0xff08: + int offset_x = atoi(arg); + if (offset_x > 0) { + kmsvnc->input_offx = offset_x; + } + break; + case 0xff09: + int offset_y = atoi(arg); + if (offset_y > 0) { + kmsvnc->input_offy = offset_y; + } break; case 'w': kmsvnc->input_wakeup = 1; diff --git a/kmsvnc.h b/kmsvnc.h index 4dae072..27970dc 100644 --- a/kmsvnc.h +++ b/kmsvnc.h @@ -34,9 +34,13 @@ struct kmsvnc_data char input_wakeup; char disable_input; int va_derive_enabled; - int va_print_fmt; + int va_debug; int source_plane; int source_crtc; + int input_width; + int input_height; + int input_offx; + int input_offy; struct kmsvnc_drm_data *drm; struct kmsvnc_input_data *input; struct kmsvnc_keymap_data *keymap; diff --git a/va.c b/va.c index 4543798..20990fc 100644 --- a/va.c +++ b/va.c @@ -39,7 +39,7 @@ void va_cleanup() { } static void va_msg_callback(void *user_context, const char *message) { - if (kmsvnc->va_print_fmt) { + if (kmsvnc->va_debug) { printf("va msg: %s", message); } } @@ -158,7 +158,7 @@ int va_init() { if (!rt_format) { KMSVNC_FATAL("Unsupported pixfmt %s for vaapi, please create an issue with your pixfmt.", kmsvnc->drm->pixfmt_name); } - if (kmsvnc->va_print_fmt) { + if (kmsvnc->va_debug) { printf("selected rt_format %u, alpha %d\n", rt_format, is_alpha); } prime_desc.width = kmsvnc->drm->mfb->width; @@ -249,7 +249,7 @@ int va_init() { } } - if (kmsvnc->va_print_fmt) { + if (kmsvnc->va_debug) { for (int i = 0; i < va->img_fmt_count; i++) { print_va_image_fmt(va->img_fmts + i); } @@ -318,7 +318,7 @@ int va_init() { char success = 0; for (int i = 0; i < KMSVNC_ARRAY_ELEMENTS(format_to_try); i++) { if (format_to_try[i].fmt == NULL) continue; - if (!kmsvnc->va_print_fmt && rt_format != format_to_try[i].va_rt_format) continue; + if (!kmsvnc->va_debug && rt_format != format_to_try[i].va_rt_format) continue; if (is_alpha != format_to_try[i].is_alpha) continue; VAImageFormat *fmt = format_to_try[i].fmt;