diff --git a/Src/Mouse.cpp b/Src/Mouse.cpp index 61f71822..93293dc0 100644 --- a/Src/Mouse.cpp +++ b/Src/Mouse.cpp @@ -527,13 +527,16 @@ void Mouse::SetWindow(HWND window) #include +// This symbol is defined for Win32 desktop applications, but not for UWP +constexpr float USER_DEFAULT_SCREEN_DPI = 96.f; + class Mouse::Impl { public: explicit Impl(Mouse* owner) noexcept(false) : mState{}, mOwner(owner), - mDPI(96.f), + mDPI(USER_DEFAULT_SCREEN_DPI), mMode(MODE_ABSOLUTE), mAutoReset(true), mLastX(0), @@ -906,8 +909,8 @@ class Mouse::Impl const float dpi = s_mouse->mDPI; - s_mouse->mState.x = static_cast(pos.X * dpi / 96.f + 0.5f); - s_mouse->mState.y = static_cast(pos.Y * dpi / 96.f + 0.5f); + s_mouse->mState.x = static_cast(pos.X * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f); + s_mouse->mState.y = static_cast(pos.Y * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f); } return S_OK; @@ -970,8 +973,8 @@ class Mouse::Impl float dpi = s_mouse->mDPI; - s_mouse->mState.x = static_cast(pos.X * dpi / 96.f + 0.5f); - s_mouse->mState.y = static_cast(pos.Y * dpi / 96.f + 0.5f); + s_mouse->mState.x = static_cast(pos.X * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f); + s_mouse->mState.y = static_cast(pos.Y * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f); } }