diff --git a/src/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs b/src/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs index 0cb49ca8ce..a05070ed61 100644 --- a/src/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs +++ b/src/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs @@ -1,6 +1,8 @@ +using System; + namespace Ryujinx.Common.Configuration.Hid { - public class KeyboardHotkeys + public class KeyboardHotkeys : IEquatable { public Key ToggleVsync { get; set; } public Key Screenshot { get; set; } @@ -11,5 +13,65 @@ namespace Ryujinx.Common.Configuration.Hid public Key ResScaleDown { get; set; } public Key VolumeUp { get; set; } public Key VolumeDown { get; set; } + + public bool Equals(KeyboardHotkeys other) + { + if (other == null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return ToggleVsync == other.ToggleVsync && + Screenshot == other.Screenshot && + ShowUI == other.ShowUI && + Pause == other.Pause && + ToggleMute == other.ToggleMute && + ResScaleUp == other.ResScaleUp && + ResScaleDown == other.ResScaleDown && + VolumeUp == other.VolumeUp && + VolumeDown == other.VolumeDown; + } + + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != this.GetType()) + { + return false; + } + + return Equals((KeyboardHotkeys)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = (int)ToggleVsync; + hashCode = (hashCode * 397) ^ (int)Screenshot; + hashCode = (hashCode * 397) ^ (int)ShowUI; + hashCode = (hashCode * 397) ^ (int)Pause; + hashCode = (hashCode * 397) ^ (int)ToggleMute; + hashCode = (hashCode * 397) ^ (int)ResScaleUp; + hashCode = (hashCode * 397) ^ (int)ResScaleDown; + hashCode = (hashCode * 397) ^ (int)VolumeUp; + hashCode = (hashCode * 397) ^ (int)VolumeDown; + return hashCode; + } + } } } diff --git a/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs b/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs index 181ec986c4..18256a401c 100644 --- a/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Settings/SettingsHotkeysViewModel.cs @@ -22,17 +22,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings { bool isDirty = false; - var hotkeys = KeyboardHotkey.GetConfig(); - - isDirty |= config.Hid.Hotkeys.Value.ToggleVsync != hotkeys.ToggleVsync; - isDirty |= config.Hid.Hotkeys.Value.Screenshot != hotkeys.Screenshot; - isDirty |= config.Hid.Hotkeys.Value.ShowUI != hotkeys.ShowUI; - isDirty |= config.Hid.Hotkeys.Value.Pause != hotkeys.Pause; - isDirty |= config.Hid.Hotkeys.Value.ToggleMute != hotkeys.ToggleMute; - isDirty |= config.Hid.Hotkeys.Value.ResScaleUp != hotkeys.ResScaleUp; - isDirty |= config.Hid.Hotkeys.Value.ResScaleDown != hotkeys.ResScaleDown; - isDirty |= config.Hid.Hotkeys.Value.VolumeUp != hotkeys.VolumeUp; - isDirty |= config.Hid.Hotkeys.Value.VolumeDown != hotkeys.VolumeDown; + isDirty |= !config.Hid.Hotkeys.Value.Equals(KeyboardHotkey.GetConfig()); return isDirty; }