mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-10-05 05:17:58 +03:00
Fix mouse cursor movement in fullscreen mode
Ported from kichikuou/xsystem35-sdl2@91d30c9.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "ags.h"
|
||||
#include <string.h>
|
||||
|
||||
extern SDL_Window* g_window;
|
||||
|
||||
void AGS::load_cursor(int page)
|
||||
{
|
||||
// カーソルCGをロードする
|
||||
@@ -91,3 +93,29 @@ void AGS::select_cursor()
|
||||
}
|
||||
}
|
||||
|
||||
void AGS::translate_mouse_coords(int* x, int* y)
|
||||
{
|
||||
// scale mouse x and y
|
||||
float scalex, scaley;
|
||||
SDL_RenderGetScale(sdlRenderer, &scalex, &scaley);
|
||||
*x *= scalex;
|
||||
*y *= scaley;
|
||||
|
||||
// calculate window borders
|
||||
int logw, logh;
|
||||
SDL_RenderGetLogicalSize(sdlRenderer, &logw, &logh);
|
||||
|
||||
float scalew, scaleh;
|
||||
scalew = logw * scalex;
|
||||
scaleh = logh * scaley;
|
||||
|
||||
int winw, winh;
|
||||
SDL_GetWindowSize(g_window, &winw, &winh);
|
||||
|
||||
float border_left = (winw - scalew) / 2;
|
||||
float border_top = (winh - scaleh) / 2;
|
||||
|
||||
// offset x and y by window borders
|
||||
*x += border_left;
|
||||
*y += border_top;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user