Skip to content
Snippets Groups Projects
Commit 04ce7fb7 authored by Evan Husted's avatar Evan Husted
Browse files

misc: chore: [ci skip] VSync progression as an extension

parent 359852b5
No related branches found
No related tags found
No related merge requests found
......@@ -6,4 +6,16 @@ namespace Ryujinx.Common.Configuration
Unbounded,
Custom
}
public static class VSyncModeExtensions
{
public static VSyncMode Next(this VSyncMode vsync, bool customEnabled = false) =>
vsync switch
{
VSyncMode.Switch => customEnabled ? VSyncMode.Custom : VSyncMode.Unbounded,
VSyncMode.Unbounded => VSyncMode.Switch,
VSyncMode.Custom => VSyncMode.Unbounded,
_ => VSyncMode.Switch
};
}
}
......@@ -319,25 +319,12 @@ namespace Ryujinx.Ava
public void VSyncModeToggle()
{
VSyncMode oldVSyncMode = Device.VSyncMode;
VSyncMode newVSyncMode = VSyncMode.Switch;
bool customVSyncIntervalEnabled = ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Value;
switch (oldVSyncMode)
{
case VSyncMode.Switch:
newVSyncMode = customVSyncIntervalEnabled
? VSyncMode.Custom
: VSyncMode.Unbounded;
break;
case VSyncMode.Unbounded:
newVSyncMode = VSyncMode.Switch;
break;
case VSyncMode.Custom:
newVSyncMode = VSyncMode.Unbounded;
break;
}
UpdateVSyncMode(this, new ReactiveEventArgs<VSyncMode>(oldVSyncMode, newVSyncMode));
UpdateVSyncMode(this, new ReactiveEventArgs<VSyncMode>(
oldVSyncMode,
oldVSyncMode.Next(customVSyncIntervalEnabled))
);
}
private void UpdateCustomVSyncIntervalValue(object sender, ReactiveEventArgs<int> e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment