Browse Source

Correct DPI on devices that apply extra scaling

pull/3681/head
Anders Jenbo 4 years ago committed by GitHub
parent
commit
d3a7c36d1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Source/controls/touch/gamepad.cpp

6
Source/controls/touch/gamepad.cpp

@ -62,7 +62,11 @@ void InitializeVirtualGamepad()
if (SDL_GetDisplayDPI(displayIndex, nullptr, &hdpi, &vdpi) == 0) {
int clientWidth;
int clientHeight;
SDL_GetWindowSize(ghMainWnd, &clientWidth, &clientHeight);
if (renderer != nullptr)
SDL_GetRendererOutputSize(renderer, &clientWidth, &clientHeight);
else
SDL_GetWindowSize(ghMainWnd, &clientWidth, &clientHeight);
hdpi *= static_cast<float>(gnScreenWidth) / clientWidth;
vdpi *= static_cast<float>(gnScreenHeight) / clientHeight;

Loading…
Cancel
Save