mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
get display DPI info to scale mouse movement
This commit is contained in:
@@ -7,6 +7,7 @@ include_directories(
|
||||
|
||||
add_library(lg_common_platform_code STATIC
|
||||
crash.c
|
||||
dpi.c
|
||||
sysinfo.c
|
||||
thread.c
|
||||
event.c
|
||||
|
37
common/src/platform/windows/dpi.c
Normal file
37
common/src/platform/windows/dpi.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "common/dpi.h"
|
||||
#include "common/windebug.h"
|
||||
|
||||
typedef enum MONITOR_DPI_TYPE {
|
||||
MDT_EFFECTIVE_DPI,
|
||||
MDT_ANGULAR_DPI,
|
||||
MDT_RAW_DPI,
|
||||
MDT_DEFAULT
|
||||
} MONITOR_DPI_TYPE;
|
||||
typedef HRESULT (WINAPI *GetDpiForMonitor_t)(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT * dpiX, UINT * dpiY);
|
||||
|
||||
UINT monitor_dpi(HMONITOR hMonitor)
|
||||
{
|
||||
HMODULE shcore = LoadLibraryA("shcore.dll");
|
||||
if (!shcore)
|
||||
{
|
||||
DEBUG_ERROR("Could not load shcore.dll");
|
||||
return DPI_100_PERCENT;
|
||||
}
|
||||
|
||||
GetDpiForMonitor_t GetDpiForMonitor = (GetDpiForMonitor_t) GetProcAddress(shcore, "GetDpiForMonitor");
|
||||
if (!GetDpiForMonitor)
|
||||
{
|
||||
DEBUG_ERROR("Could not find GetDpiForMonitor");
|
||||
return DPI_100_PERCENT;
|
||||
}
|
||||
|
||||
UINT dpiX, dpiY;
|
||||
HRESULT status = GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY);
|
||||
if (FAILED(status))
|
||||
{
|
||||
DEBUG_WINERROR("GetDpiForMonitor failed", status);
|
||||
return DPI_100_PERCENT;
|
||||
}
|
||||
|
||||
return dpiX;
|
||||
}
|
Reference in New Issue
Block a user