LeiaSR SDK 720218b2 v1.32.7.6322 2025-02-13T14:55:38Z
Stable
WindowsDisplayUtilities.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <Windows.h>
8#include <SetupAPI.h>
9#include <tuple>
10#include <vector>
11#include <set>
12#include <string>
13#include <fstream>
14#include <map>
15#include <physicalmonitorEnumerationapi.h>
16
17#include "sr/types.h"
18
19#ifdef WIN32
20# ifdef COMPILING_DLL_SimulatedRealityDisplays
21# define DIMENCOSR_API __declspec(dllexport)
22# else
23# define DIMENCOSR_API __declspec(dllimport)
24# endif
25#else
26# define DIMENCOSR_API
27#endif
28
29namespace SR {
30 union EdidData {
31 unsigned char buffer[128];
32 struct {
33 unsigned char pad[8];
34 unsigned char manufacturerId[2];
35 unsigned char productId[2]; //10-11
36 unsigned char serialNumber[4]; //12-15
37 };
38 };
39
40 struct Resolution {
41 int height;
42 int width;
43 };
44
50 unsigned char memoryAddress;
51 unsigned long disableFiltersValue;
52 unsigned long enableFiltersValue;
53 };
54
55 struct MonitorData {
56 HMONITOR monitorHandle;
62 };
63
71 DIMENCOSR_API bool isProductCodeSupported(std::string productCode);
72
82 DIMENCOSR_API bool getNativeResolution(const LUID adapterLuid, const UINT32 targetId, DISPLAYCONFIG_TARGET_PREFERRED_MODE& PreferredMode);
83
92 DIMENCOSR_API HRESULT GetPathInfo(HMONITOR hMonitor, _Out_ DISPLAYCONFIG_PATH_INFO* pPathInfo);
93
101 DIMENCOSR_API bool getDisplayResolution(LPCSTR deviceName, int& height, int& width);
102
110 DIMENCOSR_API bool getMonitorList(std::vector<MonitorData>& monitors);
111
121 DIMENCOSR_API bool getEdidData(const HKEY& hDevRegKey, EdidData& edid);
122
129 DIMENCOSR_API void logSrMonitor(MonitorData data, bool srDisplay);
130
136 DIMENCOSR_API void printMonitorList(std::vector<MonitorData> monitors);
137
147 DIMENCOSR_API bool getKnownMonitors(const std::vector<MonitorData>& monitors, std::vector<MonitorData>& knownMonitors);
148
158 DIMENCOSR_API bool getDDCCISupportedMonitors(const std::vector<MonitorData>& monitors, std::vector<DDCCISettings>& DDCCISupportedMonitors);
159
170
180 DIMENCOSR_API bool matchProductId(const std::string productCode, const MonitorData& monitorData);
181
187 DIMENCOSR_API void addPreferredResolution(std::vector<MonitorData>& externalMonitors);
188
194 DIMENCOSR_API void addCloneStatus(std::vector<MonitorData>& externalMonitors);
195
204 DIMENCOSR_API bool monitorEquals(const SR::MonitorData& monitorA, const SR::MonitorData& monitorB);
205
216
225
229 DIMENCOSR_API std::vector<RECT> getMonitorRectangles(const std::vector<MonitorData>& monitors);
230
238 DIMENCOSR_API void waitForChangeMonitorRectangles(std::vector<RECT>& monitorRectangles, unsigned int timeBetweenChecks, bool& active);
239
248 DIMENCOSR_API double getMonitorRefreshRate(HMONITOR monitorHandle);
249}
250
251#undef DIMENCOSR_API
#define DIMENCOSR_API
Definition: WindowsDisplayUtilities.h:26
Namespace containing all C++ Simulated Reality classes.
Definition: srconfiguration.h:20
DIMENCOSR_API void addCloneStatus(std::vector< MonitorData > &externalMonitors)
add clone or duplicate status of connected monitors
DIMENCOSR_API bool isProductCodeSupported(std::string productCode)
checks if the given productCode is supported
DIMENCOSR_API double getMonitorRefreshRate(HMONITOR monitorHandle)
Return the refresh rate in hertz of the monitor that is represented by the given monitorHandle If the...
DIMENCOSR_API bool getKnownMonitors(const std::vector< MonitorData > &monitors, std::vector< MonitorData > &knownMonitors)
Gets a list of SR displays from a list of displays. Clears knownMonitors and appends SR monitors foun...
DIMENCOSR_API bool getMonitorList(std::vector< MonitorData > &monitors)
Gets all active monitor handles and EDID information.
DIMENCOSR_API bool disableAttachDetachNotifications()
returns true if attach/detach notifications should be disabled for the currently attached monitors....
DIMENCOSR_API bool matchProductId(const std::string productCode, const MonitorData &monitorData)
Check expected EDID productId for a given product code.
DIMENCOSR_API HRESULT GetPathInfo(HMONITOR hMonitor, _Out_ DISPLAYCONFIG_PATH_INFO *pPathInfo)
Gets path of the given monitor handler.
DIMENCOSR_API bool getDDCCISupportedMonitors(const std::vector< MonitorData > &monitors, std::vector< DDCCISettings > &DDCCISupportedMonitors)
gets a list of SR displays that support DDC/CI. Clears DDCCISupportedMonitors and appends the DDC/CI ...
DIMENCOSR_API bool monitorConfigurationEquals(const SR::MonitorData &monitorA, const SR::MonitorData &monitorB)
Compare two given monitors and see if they are the equal based on the resolution and duplication valu...
DIMENCOSR_API void waitForChangeMonitorRectangles(std::vector< RECT > &monitorRectangles, unsigned int timeBetweenChecks, bool &active)
Updates monitorRectangles with the rectangles of the monitors currently returned by getMonitorList() ...
DIMENCOSR_API void printMonitorList(std::vector< MonitorData > monitors)
logs all members for a given list of MonitorData
DIMENCOSR_API void logSrMonitor(MonitorData data, bool srDisplay)
logs the virtual rectangle, virtual position and the srDisplay boolean
DIMENCOSR_API bool monitorEquals(const SR::MonitorData &monitorA, const SR::MonitorData &monitorB)
Compare two given monitors and see if they are the equal based on the EDID data in MonitorData.
DIMENCOSR_API bool getDisplayResolution(LPCSTR deviceName, int &height, int &width)
Get display resolution of the given monitor.
DIMENCOSR_API bool getNativeResolution(const LUID adapterLuid, const UINT32 targetId, DISPLAYCONFIG_TARGET_PREFERRED_MODE &PreferredMode)
Gets preferred or recommended resolutions of the monitor.
DIMENCOSR_API bool getEdidData(const HKEY &hDevRegKey, EdidData &edid)
Gets edid data given a key from the registry and parses the data.
DIMENCOSR_API void addPreferredResolution(std::vector< MonitorData > &externalMonitors)
add preferred resolution of the given monitors
DIMENCOSR_API bool hasNonNativeResolution(const SR::MonitorData &monitor)
Compare the displayResolution and the nativeResolution of the given monitor.
DIMENCOSR_API std::vector< RECT > getMonitorRectangles(const std::vector< MonitorData > &monitors)
Extract RECT rectangles from a list of MonitorData monitors.
Holds all data required to set the DDC/CI settings of the display.
Definition: WindowsDisplayUtilities.h:48
unsigned long disableFiltersValue
Definition: WindowsDisplayUtilities.h:51
HANDLE physicalMonitorHandle
Definition: WindowsDisplayUtilities.h:49
unsigned long enableFiltersValue
Definition: WindowsDisplayUtilities.h:52
unsigned char memoryAddress
Definition: WindowsDisplayUtilities.h:50
Definition: WindowsDisplayUtilities.h:55
SR_recti rectangle
Definition: WindowsDisplayUtilities.h:57
bool isDuplicated
Definition: WindowsDisplayUtilities.h:61
HMONITOR monitorHandle
Definition: WindowsDisplayUtilities.h:56
EdidData edid
Definition: WindowsDisplayUtilities.h:58
Resolution nativeResolution
Definition: WindowsDisplayUtilities.h:60
Resolution displayResolution
Definition: WindowsDisplayUtilities.h:59
Definition: WindowsDisplayUtilities.h:40
int width
Definition: WindowsDisplayUtilities.h:42
int height
Definition: WindowsDisplayUtilities.h:41
Definition: WindowsDisplayUtilities.h:30
unsigned char productId[2]
Definition: WindowsDisplayUtilities.h:35
unsigned char buffer[128]
Definition: WindowsDisplayUtilities.h:31
unsigned char manufacturerId[2]
Definition: WindowsDisplayUtilities.h:34
unsigned char serialNumber[4]
Definition: WindowsDisplayUtilities.h:36
unsigned char pad[8]
Definition: WindowsDisplayUtilities.h:33
C-compatible integer rectangle representation.
Definition: types.h:107