-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCompactScreen.h
More file actions
67 lines (54 loc) · 2.05 KB
/
CompactScreen.h
File metadata and controls
67 lines (54 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <string>
#include <vector>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
struct ScreenInfo {
std::string name; // Friendly display name (e.g., "ASUS VG27AQ")
int native_width; // Actual panel resolution width
int native_height; // Actual panel resolution height
int current_width; // Current Windows desktop resolution width
int current_height; // Current Windows desktop resolution height
int refresh_rate; // Refresh rate in Hz
int scale_percent; // Windows DPI scaling (e.g., 100, 125, 150, 175, 200)
std::string scale_mul; // Formatted scale multiplier (e.g., "1x", "1.75x")
std::string upscale; // GPU upscale info (e.g., "Off", "2x (NVIDIA DSR)", "4x (AMD VSR)")
};
class CompactScreen {
public:
CompactScreen();
// Get all detected screens
std::vector<ScreenInfo> getScreens() const { return screens; }
// Check if NVIDIA GPU is present
static bool isNvidiaPresent();
// Check if AMD GPU is present
static bool isAMDPresent();
// Convert scale percentage to multiplier string (e.g., 150 -> "1.5x")
static std::string scaleMultiplier(int scalePercent);
// Compute upscale factor from current vs native resolution
static int computeUpscaleFactor(int currentWidth, int nativeWidth);
// Refresh screen information
bool refresh();
private:
std::vector<ScreenInfo> screens;
#if defined(_WIN32) || defined(_WIN64)
// Windows-specific population methods
bool populateFromDXGI();
bool enrichWithNVAPI();
bool enrichWithADL();
std::string getFriendlyNameFromEDID(const std::wstring& deviceName);
#else
// POSIX population methods
bool populateFromXrandr();
bool populateFromDRM();
#endif
// Helper to parse EDID for native resolution and name
struct EDIDInfo {
std::string friendlyName;
int nativeWidth;
int nativeHeight;
bool valid;
};
EDIDInfo parseEDID(const unsigned char* edid, size_t size);
};