Skip to content

Commit 3aab49c

Browse files
committed
1.5.0
Fixed multi monitor compatibility New status tab Fixed some ui glitches
1 parent c524c1b commit 3aab49c

22 files changed

+246
-109
lines changed

Photoshop/Logo_Git.png

50.6 KB
Loading

Photoshop/Logo_Git.psd

423 KB
Binary file not shown.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@ Running mode works the same, but as the name says, it is not neccessary for the
1212

1313
For the moment, the tool is only looking for the process name and not the location of the file.
1414

15-
~~I disabled the Auto-Start feature for now, as this doesn't work, if the tool requires administrative priviliges and I found no other possibility to monitor the proccesses.~~
16-
Auto-Start setting will create a scheduled task to run this application when the currently logged on user gets logged on.
15+
**Features:**
16+
17+
**Auto-Start:** This setting will create a scheduled task to run this application when the currently logged on user gets logged on.
18+
**HDR-Mode** Select at which condition of one of the added applications HDR should be activated automatically.
19+
**Restart on first start:** In some games, e.g. Cyberpunk 2077, you don't see any HDR options in settings, when HDR was not enabled in Windows before the game was launched. Therefore, the application kills the process on the first occurence, activates hdr and restarts the process.
20+
**Start in HDR-Mode:** You can use HDRProfile as a launcher by selecting the application and clicking Start in HDR-Mode. This will enable HDR before starting the application, which is necessary for some applications, e.g. Cyberpunk 2077.
21+
22+
Screenshots:
23+
![ScreenShot](https://raw.github.com/Codectory/HDR-Profile/main/Screenshots/Status_1-5-0.png)
24+
![ScreenShot](https://raw.github.com/Codectory/HDR-Profile/main/Screenshots/Applications_1-5-0.png)
25+
![ScreenShot](https://raw.github.com/Codectory/HDR-Profile/main/Screenshots/Settings_1-5-0.png)

Screenshots/Applications_1-5-0.png

16.7 KB
Loading
File renamed without changes.

Screenshots/Settings_1-5-0.png

8.85 KB
Loading

Screenshots/Status_1-5-0.png

16.7 KB
Loading

Source/HDRController/HDRController/HDRController.cpp

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <stdio.h>
1010
#include <winerror.h>
1111
#include <wingdi.h>
12-
12+
#include <stdexcept>
1313

1414

1515
#include <stdint.h>
@@ -50,13 +50,15 @@ static void SetHDR(bool enabled)
5050
pathsArray = static_cast<DISPLAYCONFIG_PATH_INFO*>(std::malloc(sizePathsArray));
5151
modesArray = static_cast<DISPLAYCONFIG_MODE_INFO*>(std::malloc(sizeModesArray));
5252

53+
5354
if (pathsArray != nullptr && modesArray != nullptr)
5455
{
5556
std::memset(pathsArray, 0, sizePathsArray);
5657
std::memset(modesArray, 0, sizeModesArray);
5758

58-
if (ERROR_SUCCESS == QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, pathsArray,
59-
&modeCount, modesArray, 0))
59+
LONG queryRet = QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, pathsArray,
60+
&modeCount, modesArray, 0);
61+
if (ERROR_SUCCESS == queryRet)
6062
{
6163
DISPLAYCONFIG_DEVICE_INFO_HEADER* setPacket =
6264
reinterpret_cast<DISPLAYCONFIG_DEVICE_INFO_HEADER*>(set);
@@ -65,35 +67,48 @@ static void SetHDR(bool enabled)
6567

6668
for (int i = 0; i < modeCount; i++)
6769
{
68-
if (modesArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
69-
{
70-
setPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
71-
setPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
72-
setPacket->id = modesArray[i].id;
73-
74-
requestPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
75-
requestPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
76-
requestPacket->id = modesArray[i].id;
77-
}
78-
}
79-
80-
if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(requestPacket))
81-
{
82-
if (enabled == true)
70+
try
8371
{
84-
set[20] = 1;
85-
DisplayConfigSetDeviceInfo(setPacket);
72+
if (modesArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
73+
{
74+
setPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
75+
setPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
76+
setPacket->id = modesArray[i].id;
77+
78+
requestPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
79+
requestPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
80+
requestPacket->id = modesArray[i].id;
81+
82+
if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(requestPacket))
83+
{
84+
if (enabled == true)
85+
{
86+
set[20] = 1;
87+
DisplayConfigSetDeviceInfo(setPacket);
88+
}
89+
else if (enabled == false)
90+
{
91+
set[20] = 0;
92+
DisplayConfigSetDeviceInfo(setPacket);
93+
}
94+
}
95+
}
8696
}
87-
else if (enabled == false)
97+
catch (const std::exception&)
8898
{
89-
set[20] = 0;
90-
DisplayConfigSetDeviceInfo(setPacket);
99+
91100
}
92101
}
102+
93103
}
104+
94105
std::free(pathsArray);
95106
std::free(modesArray);
96107
}
108+
else
109+
{
110+
throw std::invalid_argument("No monitor found.");
111+
}
97112
}
98113
}
99114

@@ -134,30 +149,36 @@ static bool HDRIsOn()
134149
DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket =
135150
reinterpret_cast<DISPLAYCONFIG_DEVICE_INFO_HEADER*>(request);
136151

152+
//HDR is off
153+
returnValue = false;
137154
for (int i = 0; i < modeCount; i++)
138155
{
139-
if (modesArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
156+
try
140157
{
141-
setPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
142-
setPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
143-
setPacket->id = modesArray[i].id;
144-
145-
requestPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
146-
requestPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
147-
requestPacket->id = modesArray[i].id;
158+
if (modesArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
159+
{
160+
setPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
161+
setPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
162+
setPacket->id = modesArray[i].id;
163+
164+
requestPacket->adapterId.HighPart = modesArray[i].adapterId.HighPart;
165+
requestPacket->adapterId.LowPart = modesArray[i].adapterId.LowPart;
166+
requestPacket->id = modesArray[i].id;
167+
}
168+
if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(requestPacket))
169+
{
170+
if (request[20] == 0xD3) // HDR is ON
171+
{
172+
returnValue = true;
173+
break;
174+
}
175+
}
148176
}
149-
}
150-
151-
if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(requestPacket))
152-
{
153-
if (request[20] == 0xD1) // HDR is OFF
154-
{
155-
returnValue = false;
156-
}
157-
else if (request[20] == 0xD3) // HDR is ON
177+
catch (const std::exception&)
158178
{
159-
returnValue = true;
179+
160180
}
181+
161182
}
162183
}
163184
std::free(pathsArray);
2.5 KB
Binary file not shown.

Source/HDRProfile/App.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Application.Resources>
1313

1414
<system:String x:Key="DonateLink">https://paypal.me/pools/c/8vksshrMln</system:String>
15-
<system:String x:Key="InfoLink">https://sourceforge.net/projects/hdr-profile</system:String>
15+
<system:String x:Key="InfoLink">https://github.com/Codectory/HDR-Profile</system:String>
1616
<Color x:Key="AccentColor">#5d9ac7</Color>
1717
<Color x:Key="HighlightedColor">#6fb3e3</Color>
1818
<Color x:Key="ButtonClickedColor">#396585</Color>
@@ -41,7 +41,7 @@
4141
<Setter.Value>
4242
<ControlTemplate TargetType="Button">
4343
<Border Height="Auto" Width="Auto" BorderBrush="{TemplateBinding Background}" Background="{TemplateBinding Background}" BorderThickness="1" CornerRadius="{StaticResource CornerRadius}">
44-
<TextBlock Background="Transparent" Padding="5,4,5,5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
44+
<TextBlock Background="Transparent" Margin="5" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
4545
</Border>
4646
</ControlTemplate>
4747
</Setter.Value>

0 commit comments

Comments
 (0)