Skip to content

Commit b90c8ec

Browse files
committed
bflibrary: Fix mouse warping mode
The mode was damaged for some time, returning strange relative positions. Now it should work as good as the direct coords mode. The SDL2 also has a build-in relative mode, which allows to achieve similar results without warping mouse; but that is also capturing the mouse, while auto reset mode allows to escape with fast mouse move.
1 parent 3b603e5 commit b90c8ec

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bflibrary/src/x86-win-sdl/smouse.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,11 @@ void MouseToScreen(struct TbPoint *pos)
270270
orig.x = pos->x;
271271
orig.y = pos->y;
272272
#if defined(LB_ENABLE_MOUSE_MOVE_RATIO)
273-
pos->x = mx + ((pos->x - mx) * (long)lbDisplay.MouseMoveRatioX)/256;
274-
pos->y = my + ((pos->y - my) * (long)lbDisplay.MouseMoveRatioY)/256;
273+
pos->x = lbDisplay.MMouseX + ((pos->x - mx) * (long)lbDisplay.MouseMoveRatioX)/256;
274+
pos->y = lbDisplay.MMouseY + ((pos->y - my) * (long)lbDisplay.MouseMoveRatioY)/256;
275+
#else
276+
pos->x = lbDisplay.MMouseX + (pos->x - mx);
277+
pos->y = lbDisplay.MMouseY + (pos->y - my);
275278
#endif
276279
mx = orig.x;
277280
my = orig.y;

bflibrary/src/x86-win-sdl2/smouse.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,11 @@ void MouseToScreen(struct TbPoint *pos)
271271
orig.x = pos->x;
272272
orig.y = pos->y;
273273
#if defined(LB_ENABLE_MOUSE_MOVE_RATIO)
274-
pos->x = mx + ((pos->x - mx) * (long)lbDisplay.MouseMoveRatioX)/256;
275-
pos->y = my + ((pos->y - my) * (long)lbDisplay.MouseMoveRatioY)/256;
274+
pos->x = lbDisplay.MMouseX + ((pos->x - mx) * (long)lbDisplay.MouseMoveRatioX)/256;
275+
pos->y = lbDisplay.MMouseY + ((pos->y - my) * (long)lbDisplay.MouseMoveRatioY)/256;
276+
#else
277+
pos->x = lbDisplay.MMouseX + (pos->x - mx);
278+
pos->y = lbDisplay.MMouseY + (pos->y - my);
276279
#endif
277280
mx = orig.x;
278281
my = orig.y;

0 commit comments

Comments
 (0)