From 236deab49b977479c2b0064f09d462e513fcccb3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Mar 2015 11:31:53 -0700 Subject: [PATCH] Fixed relative mouse motion moving farther and farther off screen. --- src/events/SDL_mouse.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 0ce443a3c..326bbbadc 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -293,9 +293,14 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ event.motion.yrel = yrel; posted = (SDL_PushEvent(&event) > 0); } - /* Use unclamped values if we're getting events outside the window */ - mouse->last_x = x; - mouse->last_y = y; + if (relative) { + mouse->last_x = mouse->x; + mouse->last_y = mouse->y; + } else { + /* Use unclamped values if we're getting events outside the window */ + mouse->last_x = x; + mouse->last_y = y; + } return posted; }