added function to update the mouse position when changing window size
[rocksndiamonds.git] / src / libgame / system.c
index 7fcb784d66c9f7608f00dad238a52b76cc0ce464..8c8b7d5ac8515121bc647aec0ecb59b71c14924e 100644 (file)
@@ -1576,6 +1576,28 @@ void SetMouseCursor(int mode)
   gfx.cursor_mode_final = mode_final;
 }
 
+void UpdateRawMousePosition(int mouse_x, int mouse_y)
+{
+  // mouse events do not contain logical screen size corrections yet
+  SDLCorrectRawMousePosition(&mouse_x, &mouse_y);
+
+  mouse_x -= video.screen_xoffset;
+  mouse_y -= video.screen_yoffset;
+
+  gfx.mouse_x = mouse_x;
+  gfx.mouse_y = mouse_y;
+}
+
+void UpdateMousePosition(void)
+{
+  int mouse_x, mouse_y;
+
+  SDL_PumpEvents();
+  SDL_GetMouseState(&mouse_x, &mouse_y);
+
+  UpdateRawMousePosition(mouse_x, mouse_y);
+}
+
 
 // ============================================================================
 // audio functions