Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
WindowsDisplayUtilities.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <Windows.h>
13#include <SetupAPI.h>
14#include <tuple>
15#include <vector>
16#include <set>
17#include <string>
18#include <fstream>
19#include <map>
20#include <physicalmonitorEnumerationapi.h>
21
22#include "sr/types.h"
23
24#ifdef WIN32
25# ifdef COMPILING_DLL_SimulatedRealityDisplays
26# define DIMENCOSR_API __declspec(dllexport)
27# else
28# define DIMENCOSR_API __declspec(dllimport)
29# endif
30#else
31# define DIMENCOSR_API
32#endif
33
34namespace SR {
35 union EdidData {
36 unsigned char buffer[128];
37 struct {
38 unsigned char pad[8];
39 unsigned char manufacturerId[2];
40 unsigned char productId[2]; //10-11
41 unsigned char serialNumber[4]; //12-15
42 };
43 };
44
45 struct Resolution {
46 int height;
47 int width;
48 };
49
55 unsigned char memoryAddress;
56 unsigned long disableFiltersValue;
57 unsigned long enableFiltersValue;
58 };
59
60 struct MonitorData {
61 HMONITOR monitorHandle;
67 };
68
76 DIMENCOSR_API bool isProductCodeSupported(std::string productCode);
77
87 DIMENCOSR_API bool getNativeResolution(const LUID adapterLuid, const UINT32 targetId, DISPLAYCONFIG_TARGET_PREFERRED_MODE& PreferredMode);
88
97 DIMENCOSR_API HRESULT GetPathInfo(HMONITOR hMonitor, _Out_ DISPLAYCONFIG_PATH_INFO* pPathInfo);
98
106 DIMENCOSR_API bool getDisplayResolution(LPCSTR deviceName, int& height, int& width);
107
115 DIMENCOSR_API bool getMonitorList(std::vector<MonitorData>& monitors);
116
126 DIMENCOSR_API bool getEdidData(const HKEY& hDevRegKey, EdidData& edid);
127
134 DIMENCOSR_API void logSrMonitor(MonitorData data, bool srDisplay);
135
141 DIMENCOSR_API void printMonitorList(std::vector<MonitorData> monitors);
142
152 DIMENCOSR_API bool getKnownMonitors(const std::vector<MonitorData>& monitors, std::vector<MonitorData>& knownMonitors);
153
163 DIMENCOSR_API bool getDDCCISupportedMonitors(const std::vector<MonitorData>& monitors, std::vector<DDCCISettings>& DDCCISupportedMonitors);
164
175
185 DIMENCOSR_API bool matchProductId(const std::string productCode, const MonitorData& monitorData);
186
192 DIMENCOSR_API void addPreferredResolution(std::vector<MonitorData>& externalMonitors);
193
199 DIMENCOSR_API void addCloneStatus(std::vector<MonitorData>& externalMonitors);
200
209 DIMENCOSR_API bool monitorEquals(const SR::MonitorData& monitorA, const SR::MonitorData& monitorB);
210
221
230
234 DIMENCOSR_API std::vector<RECT> getMonitorRectangles(const std::vector<MonitorData>& monitors);
235
243 DIMENCOSR_API void waitForChangeMonitorRectangles(std::vector<RECT>& monitorRectangles, unsigned int timeBetweenChecks, bool& active);
244
253 DIMENCOSR_API double getMonitorRefreshRate(HMONITOR monitorHandle);
254}
255
256#undef DIMENCOSR_API
#define DIMENCOSR_API
Definition: WindowsDisplayUtilities.h:31
Namespace containing all C++ Simulated Reality classes.
Definition: srconfiguration.h:25
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:53
unsigned long disableFiltersValue
Definition: WindowsDisplayUtilities.h:56
HANDLE physicalMonitorHandle
Definition: WindowsDisplayUtilities.h:54
unsigned long enableFiltersValue
Definition: WindowsDisplayUtilities.h:57
unsigned char memoryAddress
Definition: WindowsDisplayUtilities.h:55
Definition: WindowsDisplayUtilities.h:60
SR_recti rectangle
Definition: WindowsDisplayUtilities.h:62
bool isDuplicated
Definition: WindowsDisplayUtilities.h:66
HMONITOR monitorHandle
Definition: WindowsDisplayUtilities.h:61
EdidData edid
Definition: WindowsDisplayUtilities.h:63
Resolution nativeResolution
Definition: WindowsDisplayUtilities.h:65
Resolution displayResolution
Definition: WindowsDisplayUtilities.h:64
Definition: WindowsDisplayUtilities.h:45
int width
Definition: WindowsDisplayUtilities.h:47
int height
Definition: WindowsDisplayUtilities.h:46
Definition: WindowsDisplayUtilities.h:35
unsigned char productId[2]
Definition: WindowsDisplayUtilities.h:40
unsigned char buffer[128]
Definition: WindowsDisplayUtilities.h:36
unsigned char manufacturerId[2]
Definition: WindowsDisplayUtilities.h:39
unsigned char serialNumber[4]
Definition: WindowsDisplayUtilities.h:41
unsigned char pad[8]
Definition: WindowsDisplayUtilities.h:38
C-compatible integer rectangle representation.
Definition: types.h:115