]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix virtual mouse driver native/host mouse positioning.
authorToni Wilen <twilen@winuae.net>
Wed, 9 Jul 2025 15:51:39 +0000 (18:51 +0300)
committerToni Wilen <twilen@winuae.net>
Wed, 9 Jul 2025 15:51:39 +0000 (18:51 +0300)
drawing.cpp
inputdevice.cpp
od-win32/win32gfx.cpp

index dbcd324c1b1f2ed6a44d606e5d7da765201729a6..66c5510bac65dd306badd52dff827444ac3de259 100644 (file)
@@ -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;
 }
 
index 58c8a528af58046d9731d1b05aae989c0bd678f8..130a08cbb8a897c802d8a4a46e09c56e1f422898 100644 (file)
@@ -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;
index c4f8290d14c5db27bdfae0d9aab99a48633dd54f..239a4b133395ba7360ef10f8ca552df36f87c627 100644 (file)
@@ -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)