int FilterMouseMotionEvents(void *userdata, Event *event)
{
- if (event->type != EVENT_MOTIONNOTIFY)
- return 1;
-
- int mouse_x = ((MotionEvent *)event)->x;
- int mouse_y = ((MotionEvent *)event)->y;
-
- // mouse events do not contain logical screen size corrections at this stage
- SDLCorrectMouseEventXY(&mouse_x, &mouse_y);
-
- mouse_x -= video.screen_xoffset;
- mouse_y -= video.screen_yoffset;
+ if (event->type == EVENT_MOTIONNOTIFY)
+ {
+ int mouse_x = ((MotionEvent *)event)->x;
+ int mouse_y = ((MotionEvent *)event)->y;
- gfx.mouse_x = mouse_x;
- gfx.mouse_y = mouse_y;
+ UpdateRawMousePosition(mouse_x, mouse_y);
+ }
return 1;
}
if (game_status == GAME_MODE_SETUP)
RedrawSetupScreenAfterFullscreenToggle();
+ UpdateMousePosition();
+
SetWindowTitle();
}
}
if (game_status == GAME_MODE_SETUP)
RedrawSetupScreenAfterFullscreenToggle();
+ UpdateMousePosition();
+
// set flag to ignore repeated "key pressed" events
ignore_repeated_key = TRUE;
if (game_status == GAME_MODE_SETUP)
RedrawSetupScreenAfterFullscreenToggle();
+ UpdateMousePosition();
+
return;
}
SDL_WaitEvent(event);
}
-void SDLCorrectMouseEventXY(int *x, int *y)
+void SDLCorrectRawMousePosition(int *x, int *y)
{
if (sdl_renderer == NULL)
return;
void SDLCloseAudio(void);
void SDLWaitEvent(Event *);
-void SDLCorrectMouseEventXY(int *, int *);
+void SDLCorrectRawMousePosition(int *, int *);
void HandleJoystickEvent(Event *);
void SDLInitJoysticks(void);
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
void ScaleBitmap(Bitmap **, int);
void SetMouseCursor(int);
+void UpdateRawMousePosition(int, int);
+void UpdateMousePosition(void);
void OpenAudio(void);
void CloseAudio(void);