mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Potential fix for DPI scaling.
This commit is contained in:
parent
c90d1fcb7b
commit
90a3a9f371
2 changed files with 17 additions and 11 deletions
|
|
@ -2344,7 +2344,7 @@ namespace plume {
|
|||
dstWidth = rect.right - rect.left;
|
||||
dstHeight = rect.bottom - rect.top;
|
||||
# elif defined(SDL_VULKAN_ENABLED)
|
||||
SDL_GetWindowSize(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
||||
SDL_GetWindowSizeInPixels(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
||||
# elif defined(__ANDROID__)
|
||||
dstWidth = ANativeWindow_getWidth(renderWindow);
|
||||
dstHeight = ANativeWindow_getHeight(renderWindow);
|
||||
|
|
|
|||
|
|
@ -2415,19 +2415,25 @@ static void DrawImGui()
|
|||
// we can adjust the mouse events before ImGui processes them.
|
||||
uint32_t width = g_swapChain->getWidth();
|
||||
uint32_t height = g_swapChain->getHeight();
|
||||
|
||||
if (width != Video::s_viewportWidth || height != Video::s_viewportHeight)
|
||||
float mousePosScaleX = float(width) / float(GameWindow::s_width);
|
||||
float mousePosScaleY = float(height) / float(GameWindow::s_height);
|
||||
float mousePosOffsetX = (width - Video::s_viewportWidth) / 2.0f;
|
||||
float mousePosOffsetY = (height - Video::s_viewportHeight) / 2.0f;
|
||||
for (int i = 0; i < io.Ctx->InputEventsQueue.Size; i++)
|
||||
{
|
||||
float mousePosOffsetX = (width - Video::s_viewportWidth) / 2.0f;
|
||||
float mousePosOffsetY = (height - Video::s_viewportHeight) / 2.0f;
|
||||
|
||||
for (int i = 0; i < io.Ctx->InputEventsQueue.Size; i++)
|
||||
auto& e = io.Ctx->InputEventsQueue[i];
|
||||
if (e.Type == ImGuiInputEventType_MousePos)
|
||||
{
|
||||
auto& e = io.Ctx->InputEventsQueue[i];
|
||||
if (e.Type == ImGuiInputEventType_MousePos)
|
||||
if (e.MousePos.PosX != -FLT_MAX)
|
||||
{
|
||||
if (e.MousePos.PosX != -FLT_MAX) e.MousePos.PosX -= mousePosOffsetX;
|
||||
if (e.MousePos.PosY != -FLT_MAX) e.MousePos.PosY -= mousePosOffsetY;
|
||||
e.MousePos.PosX *= mousePosScaleX;
|
||||
e.MousePos.PosX -= mousePosOffsetX;
|
||||
}
|
||||
|
||||
if (e.MousePos.PosY != -FLT_MAX)
|
||||
{
|
||||
e.MousePos.PosY *= mousePosScaleY;
|
||||
e.MousePos.PosY -= mousePosOffsetY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue