From b7e8d7d04437e536d3fb2f9a79cfd2ac5d4ff788 Mon Sep 17 00:00:00 2001
From: Ronald Kinard <ronkinard93@gmail.com>
Date: Thu, 13 Nov 2014 01:04:17 -0600
Subject: [PATCH] Fix -nomouse

---
 src/sdl/i_video.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c
index a59db26cc5..fd24c430a1 100644
--- a/src/sdl/i_video.c
+++ b/src/sdl/i_video.c
@@ -818,30 +818,33 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
 	event_t event;
 	int wwidth, wheight;
 
-	SDL_GetWindowSize(window, &wwidth, &wheight);
-
-	if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
+	if (USE_MOUSEINPUT)
 	{
-		SDLdoUngrabMouse();
-		return;
-	}
+		SDL_GetWindowSize(window, &wwidth, &wheight);
 
-	if ((evt.x == realwidth/2) && (evt.y == realheight/2))
-	{
-		return;
-	}
-	else
-	{
-		event.data2 = (evt.xrel) * (wwidth / realwidth);
-		event.data3 = -evt.yrel * (wheight / realheight);
-	}
+		if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
+		{
+			SDLdoUngrabMouse();
+			return;
+		}
 
-	event.type = ev_mouse;
+		if ((evt.x == realwidth/2) && (evt.y == realheight/2))
+		{
+			return;
+		}
+		else
+		{
+			event.data2 = (int)round((evt.xrel) * ((float)wwidth / (float)realwidth));
+			event.data3 = (int)round(-evt.yrel * ((float)wheight / (float)realheight));
+		}
 
-	if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
-	{
-		D_PostEvent(&event);
-		HalfWarpMouse(wwidth, wheight);
+		event.type = ev_mouse;
+
+		if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
+		{
+			D_PostEvent(&event);
+			HalfWarpMouse(wwidth, wheight);
+		}
 	}
 }
 
-- 
GitLab