Fixed bug 1813 - MouseMotion relative values do not respect renderer LogicalSize
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 12:54:27 -0700
changeset 7496 13dfa871f0af
parent 7495 c4ba5e5c2765
child 7497 109f37bca7cc
Fixed bug 1813 - MouseMotion relative values do not respect renderer LogicalSize driedfruit A trivial issue, the xrel and yrel values of MouseMotion event struct are not adjusted to renderer logical size.
src/render/SDL_render.c
--- a/src/render/SDL_render.c	Sun Jul 21 12:47:47 2013 -0700
+++ b/src/render/SDL_render.c	Sun Jul 21 12:54:27 2013 -0700
@@ -151,6 +151,16 @@
             event->motion.y -= renderer->viewport.y;
             event->motion.x = (int)(event->motion.x / renderer->scale.x);
             event->motion.y = (int)(event->motion.y / renderer->scale.y);
+            if (event->motion.xrel > 0) {
+                event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / renderer->scale.x));
+            } else if (event->motion.xrel < 0) {
+                event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / renderer->scale.x));
+            }
+            if (event->motion.yrel > 0) {
+                event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / renderer->scale.y));
+            } else if (event->motion.yrel < 0) {
+                event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / renderer->scale.y));
+            }
         }
     } else if (event->type == SDL_MOUSEBUTTONDOWN ||
                event->type == SDL_MOUSEBUTTONUP) {