mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 21:01:37 +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;
|
dstWidth = rect.right - rect.left;
|
||||||
dstHeight = rect.bottom - rect.top;
|
dstHeight = rect.bottom - rect.top;
|
||||||
# elif defined(SDL_VULKAN_ENABLED)
|
# elif defined(SDL_VULKAN_ENABLED)
|
||||||
SDL_GetWindowSize(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
SDL_GetWindowSizeInPixels(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
||||||
# elif defined(__ANDROID__)
|
# elif defined(__ANDROID__)
|
||||||
dstWidth = ANativeWindow_getWidth(renderWindow);
|
dstWidth = ANativeWindow_getWidth(renderWindow);
|
||||||
dstHeight = ANativeWindow_getHeight(renderWindow);
|
dstHeight = ANativeWindow_getHeight(renderWindow);
|
||||||
|
|
|
||||||
|
|
@ -2415,19 +2415,25 @@ static void DrawImGui()
|
||||||
// we can adjust the mouse events before ImGui processes them.
|
// we can adjust the mouse events before ImGui processes them.
|
||||||
uint32_t width = g_swapChain->getWidth();
|
uint32_t width = g_swapChain->getWidth();
|
||||||
uint32_t height = g_swapChain->getHeight();
|
uint32_t height = g_swapChain->getHeight();
|
||||||
|
float mousePosScaleX = float(width) / float(GameWindow::s_width);
|
||||||
if (width != Video::s_viewportWidth || height != Video::s_viewportHeight)
|
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;
|
auto& e = io.Ctx->InputEventsQueue[i];
|
||||||
float mousePosOffsetY = (height - Video::s_viewportHeight) / 2.0f;
|
if (e.Type == ImGuiInputEventType_MousePos)
|
||||||
|
|
||||||
for (int i = 0; i < io.Ctx->InputEventsQueue.Size; i++)
|
|
||||||
{
|
{
|
||||||
auto& e = io.Ctx->InputEventsQueue[i];
|
if (e.MousePos.PosX != -FLT_MAX)
|
||||||
if (e.Type == ImGuiInputEventType_MousePos)
|
|
||||||
{
|
{
|
||||||
if (e.MousePos.PosX != -FLT_MAX) e.MousePos.PosX -= mousePosOffsetX;
|
e.MousePos.PosX *= mousePosScaleX;
|
||||||
if (e.MousePos.PosY != -FLT_MAX) e.MousePos.PosY -= mousePosOffsetY;
|
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