From 7ae09e1ee671d2c231f9e5cb4b8598a7412553d4 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 9 Jul 2025 18:51:39 +0300 Subject: [PATCH] Fix virtual mouse driver native/host mouse positioning. --- drawing.cpp | 14 +++++++++----- inputdevice.cpp | 23 ++++++++++++++++++----- od-win32/win32gfx.cpp | 12 ++++++++++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index dbcd324c..66c5510b 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -552,7 +552,7 @@ static void count_frame(int monid) ad->framecnt = 1; } -STATIC_INLINE int xshift (int x, int shift) +STATIC_INLINE int xshift(int x, int shift) { if (shift < 0) return x >> (-shift); @@ -560,16 +560,20 @@ STATIC_INLINE int xshift (int x, int shift) return x << shift; } -int coord_native_to_amiga_x (int x) +int coord_native_to_amiga_x(int x) { x += visible_left_border; return x; } -int coord_native_to_amiga_y (int y) +int coord_native_to_amiga_y(int y) { - if (!native2amiga_line_map || y < 0 || y >= native2amiga_line_map_height) - return -1; + if (!native2amiga_line_map || y < 0) { + return 0; + } + if (y >= native2amiga_line_map_height) { + y = native2amiga_line_map_height - 1; + } return native2amiga_line_map[y] + thisframe_y_adjust - minfirstline; } diff --git a/inputdevice.cpp b/inputdevice.cpp index 58c8a528..130a08cb 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -2676,15 +2676,28 @@ static bool get_mouse_position(int *xp, int *yp, int inx, int iny) } x = (int)(x * fmx); y = (int)(y * fmy); - x -= (int)(fdx * fmx) - 1; - y -= (int)(fdy * fmy) - 2; + x -= (int)(fdx * 1.0) - 0; + y -= (int)(fdy * 1.0) - 2; + if (x < 0) { + ob = true; + x = 0; + } + if (x * fmx >= vidinfo->outbuffer->outwidth) { + ob = true; + x = vidinfo->outbuffer->outwidth - 1; + } + if (y < 0) { + ob = true; + y = 0; + } + if (y * fmy >= vidinfo->outbuffer->outheight) { + ob = true; + y = vidinfo->outbuffer->outheight - 1; + } x = coord_native_to_amiga_x(x); if (y >= 0) { y = coord_native_to_amiga_y(y) * 2; } - if (x < 0 || y < 0 || x >= vidinfo->outbuffer->outwidth || y >= vidinfo->outbuffer->outheight) { - ob = true; - } } *xp = x; *yp = y; diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index c4f8290d..239a4b13 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -1490,6 +1490,8 @@ void getrtgfilterdata(int monid, struct displayscale *ds) int srcratio, dstratio; int srcwidth, srcheight; + int outwidth, outheight; + srcwidth = state->Width; srcheight = state->Height; if (!srcwidth || !srcheight) @@ -1518,6 +1520,8 @@ void getrtgfilterdata(int monid, struct displayscale *ds) picasso_offset_y = -yy; mx = mul; my = mul; + outwidth = srcwidth; + outheight = srcheight; ds->mode = 1; } else if (mon->scalepicasso == RTG_MODE_CENTER) { int xx = (mon->currentmode.native_width - srcwidth) / 2; @@ -1526,6 +1530,8 @@ void getrtgfilterdata(int monid, struct displayscale *ds) picasso_offset_y = -yy; ds->outwidth = mon->currentmode.native_width; ds->outheight = mon->currentmode.native_height; + outwidth = ds->outwidth; + outheight = ds->outheight; mx = my = 1.0; } else { if (currprefs.win32_rtgscaleaspectratio < 0) { @@ -1555,6 +1561,8 @@ void getrtgfilterdata(int monid, struct displayscale *ds) ds->outheight = srcheight; picasso_offset_x = (state->Width - xx) / 2; } + outwidth = ds->outwidth; + outheight = ds->outheight; } ds->xoffset += picasso_offset_x; @@ -1563,8 +1571,8 @@ void getrtgfilterdata(int monid, struct displayscale *ds) picasso_offset_x /= state->HLineDBL; picasso_offset_y /= state->VLineDBL; - picasso_offset_mx = (float)(srcwidth * mx * state->HLineDBL) / ds->dstwidth; - picasso_offset_my = (float)(srcheight * my * state->VLineDBL) / ds->dstheight; + picasso_offset_mx = (float)(srcwidth * mx * state->HLineDBL) / outwidth; + picasso_offset_my = (float)(srcheight * my * state->VLineDBL) / outheight; } static uae_u8 *gfx_lock_picasso2(int monid, bool fullupdate) -- 2.47.3