2022-12-19 22:47:10 +01:00
|
|
|
using PowerControl.Helpers;
|
|
|
|
|
using PowerControl.Helpers.AMD;
|
|
|
|
|
|
|
|
|
|
namespace PowerControl.Options
|
|
|
|
|
{
|
|
|
|
|
public static class Resolution
|
|
|
|
|
{
|
|
|
|
|
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
|
|
|
|
{
|
|
|
|
|
Name = "Resolution",
|
2023-01-05 23:52:23 +01:00
|
|
|
PersistentKey = "Resolution",
|
2022-12-19 22:47:10 +01:00
|
|
|
ApplyDelay = 1000,
|
|
|
|
|
ResetValue = () =>
|
|
|
|
|
{
|
|
|
|
|
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
|
|
|
|
|
return null;
|
2022-12-19 23:36:22 +01:00
|
|
|
return DisplayResolutionController.GetAllResolutions().Last().ToString();
|
2022-12-19 22:47:10 +01:00
|
|
|
},
|
|
|
|
|
OptionsValues = delegate ()
|
|
|
|
|
{
|
2023-02-09 11:03:41 +01:00
|
|
|
var resolutions = DisplayResolutionController.GetAllResolutions().ToList();
|
|
|
|
|
|
|
|
|
|
var currentResolution = DisplayResolutionController.GetResolution();
|
2023-02-09 11:42:50 +01:00
|
|
|
if (currentResolution is not null)
|
2023-02-09 11:03:41 +01:00
|
|
|
resolutions.Add(currentResolution.Value);
|
2023-02-09 11:42:50 +01:00
|
|
|
|
|
|
|
|
if (ExternalHelpers.DisplayConfig.IsInternalConnected == true)
|
|
|
|
|
{
|
|
|
|
|
foreach (var displayModeInfo in ModeTiming.AllDetailedTimings())
|
|
|
|
|
{
|
|
|
|
|
if (currentResolution?.Rotated == true)
|
|
|
|
|
{
|
|
|
|
|
resolutions.Add(new DisplayResolutionController.DisplayResolution(
|
|
|
|
|
displayModeInfo.iPelsHeight, displayModeInfo.iPelsWidth));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
resolutions.Add(new DisplayResolutionController.DisplayResolution(
|
|
|
|
|
displayModeInfo.iPelsWidth, displayModeInfo.iPelsHeight));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-09 11:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-09 11:42:50 +01:00
|
|
|
resolutions = resolutions.Distinct().ToList();
|
|
|
|
|
resolutions.Sort();
|
|
|
|
|
|
2022-12-19 22:47:10 +01:00
|
|
|
if (resolutions.Count() > 1)
|
2022-12-19 23:36:22 +01:00
|
|
|
return resolutions.Select(item => item.ToString()).ToArray();
|
2023-02-09 11:03:41 +01:00
|
|
|
|
2022-12-19 22:47:10 +01:00
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
CurrentValue = delegate ()
|
|
|
|
|
{
|
|
|
|
|
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
|
|
|
|
|
return null;
|
2022-12-19 23:36:22 +01:00
|
|
|
return DisplayResolutionController.GetResolution().ToString();
|
2022-12-19 22:47:10 +01:00
|
|
|
},
|
2022-12-19 23:36:22 +01:00
|
|
|
ApplyValue = (selected) =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
2022-12-19 23:36:22 +01:00
|
|
|
var selectedResolution = new DisplayResolutionController.DisplayResolution(selected);
|
2023-02-09 11:42:50 +01:00
|
|
|
selectedResolution.Rotated = DisplayResolutionController.GetResolution()?.Rotated;
|
2023-02-08 23:41:08 +01:00
|
|
|
|
|
|
|
|
if (ExternalHelpers.DisplayConfig.IsInternalConnected == true)
|
|
|
|
|
{
|
2023-02-09 11:42:50 +01:00
|
|
|
var normalizedResolution = selectedResolution.Normalize();
|
|
|
|
|
|
|
|
|
|
bool result = ModeTiming.AddTiming(new Helpers.AMD.ADLDisplayModeX2()
|
2023-02-08 23:41:08 +01:00
|
|
|
{
|
2023-02-09 11:42:50 +01:00
|
|
|
PelsWidth = normalizedResolution.Width,
|
|
|
|
|
PelsHeight = normalizedResolution.Height,
|
2023-02-08 23:41:08 +01:00
|
|
|
RefreshRate = DisplayResolutionController.GetRefreshRate(),
|
2023-02-09 11:42:50 +01:00
|
|
|
TimingStandard = Helpers.AMD.ADL.ADL_DL_MODETIMING_STANDARD_CUSTOM,
|
2023-02-08 23:41:08 +01:00
|
|
|
});
|
2023-02-09 11:42:50 +01:00
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
Thread.Sleep(500);
|
2023-02-08 23:41:08 +01:00
|
|
|
}
|
2023-02-09 00:24:32 +01:00
|
|
|
|
|
|
|
|
DisplayResolutionController.SetResolution(selectedResolution);
|
2023-01-10 11:12:31 +01:00
|
|
|
return DisplayResolutionController.GetResolution().ToString();
|
|
|
|
|
},
|
|
|
|
|
Impacts =
|
|
|
|
|
{
|
|
|
|
|
RefreshRate.Instance,
|
|
|
|
|
FPSLimit.Instance
|
2022-12-19 22:47:10 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|