diff --git a/Ryujinx.Ava/AppHost.cs b/Ryujinx.Ava/AppHost.cs
index 320efeb5e..d039ded79 100644
--- a/Ryujinx.Ava/AppHost.cs
+++ b/Ryujinx.Ava/AppHost.cs
@@ -58,6 +58,8 @@ namespace Ryujinx.Ava
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
private const int TargetFps = 60;
+ private const float VolumeDelta = 0.05f;
+
private static readonly Cursor InvisibleCursor = new Cursor(StandardCursorType.None);
private readonly long _ticksPerFrame;
@@ -73,6 +75,7 @@ namespace Ryujinx.Ava
private bool _isStopped;
private bool _isActive;
private long _lastCursorMoveTime;
+ private float _newVolume;
private long _ticks = 0;
private KeyboardHotkeyState _prevHotkeyState;
@@ -1003,6 +1006,18 @@ namespace Ryujinx.Ava
GraphicsConfig.ResScale =
(MaxResolutionScale + GraphicsConfig.ResScale - 2) % MaxResolutionScale + 1;
break;
+ case KeyboardHotkeyState.VolumeUp:
+ _newVolume = MathF.Round((Device.GetVolume() + VolumeDelta), 2);
+ Device.SetVolume(_newVolume);
+
+ _parent.ViewModel.Volume = Device.GetVolume();
+ break;
+ case KeyboardHotkeyState.VolumeDown:
+ _newVolume = MathF.Round((Device.GetVolume() - VolumeDelta), 2);
+ Device.SetVolume(_newVolume);
+
+ _parent.ViewModel.Volume = Device.GetVolume();
+ break;
case KeyboardHotkeyState.None:
(_keyboardInterface as AvaloniaKeyboard).Clear();
break;
@@ -1068,6 +1083,14 @@ namespace Ryujinx.Ava
{
state = KeyboardHotkeyState.ResScaleDown;
}
+ else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeUp))
+ {
+ state = KeyboardHotkeyState.VolumeUp;
+ }
+ else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeDown))
+ {
+ state = KeyboardHotkeyState.VolumeDown;
+ }
return state;
}
diff --git a/Ryujinx.Ava/Assets/Locales/en_US.json b/Ryujinx.Ava/Assets/Locales/en_US.json
index a6641a028..95f663aa6 100644
--- a/Ryujinx.Ava/Assets/Locales/en_US.json
+++ b/Ryujinx.Ava/Assets/Locales/en_US.json
@@ -589,5 +589,7 @@
"SettingsAppRequiredRestartMessage": "Ryujinx Restart Required",
"SettingsGpuBackendRestartMessage": "Graphics Backend or Gpu settings have been modified. This will require a restart to be applied",
"SettingsGpuBackendRestartSubMessage": "Do you want to restart now?",
+ "SettingsTabHotkeysVolumeUpHotkey": "Increase Volume:",
+ "SettingsTabHotkeysVolumeDownHotkey": "Decrease Volume:",
"VolumeShort": "Vol"
}
diff --git a/Ryujinx.Ava/Common/KeyboardHotkeyState.cs b/Ryujinx.Ava/Common/KeyboardHotkeyState.cs
index a4e9c5550..e85bdf341 100644
--- a/Ryujinx.Ava/Common/KeyboardHotkeyState.cs
+++ b/Ryujinx.Ava/Common/KeyboardHotkeyState.cs
@@ -9,6 +9,8 @@
Pause,
ToggleMute,
ResScaleUp,
- ResScaleDown
+ ResScaleDown,
+ VolumeUp,
+ VolumeDown
}
}
\ No newline at end of file
diff --git a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
index 43cef98cd..55fe83656 100644
--- a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
+++ b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
@@ -257,6 +257,22 @@
TextAlignment="Center" />
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs b/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs
index a6f69e8d1..45217e02f 100644
--- a/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs
+++ b/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs
@@ -9,5 +9,7 @@
public Key ToggleMute { get; set; }
public Key ResScaleUp { get; set; }
public Key ResScaleDown { get; set; }
+ public Key VolumeUp { get; set; }
+ public Key VolumeDown { get; set; }
}
}
diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs
index 4bd1fe397..de0f98e46 100644
--- a/Ryujinx.HLE/Switch.cs
+++ b/Ryujinx.HLE/Switch.cs
@@ -124,7 +124,7 @@ namespace Ryujinx.HLE
public void SetVolume(float volume)
{
- System.SetVolume(volume);
+ System.SetVolume(Math.Clamp(volume, 0, 1));
}
public float GetVolume()
diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs
index fbac88908..f27116574 100644
--- a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs
+++ b/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs
@@ -14,7 +14,7 @@ namespace Ryujinx.Ui.Common.Configuration
///
/// The current version of the file format
///
- public const int CurrentVersion = 40;
+ public const int CurrentVersion = 41;
///
/// Version of the configuration file format
diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
index b8c174da2..3dbbb3dd3 100644
--- a/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
+++ b/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs
@@ -677,7 +677,9 @@ namespace Ryujinx.Ui.Common.Configuration
ShowUi = Key.F4,
Pause = Key.F5,
ResScaleUp = Key.Unbound,
- ResScaleDown = Key.Unbound
+ ResScaleDown = Key.Unbound,
+ VolumeUp = Key.Unbound,
+ VolumeDown = Key.Unbound
};
Hid.InputConfig.Value = new List
{
@@ -1156,6 +1158,24 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileUpdated = true;
}
+ if (configurationFileFormat.Version < 41)
+ {
+ Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 41.");
+
+ configurationFileFormat.Hotkeys = new KeyboardHotkeys
+ {
+ ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
+ Screenshot = configurationFileFormat.Hotkeys.Screenshot,
+ ShowUi = configurationFileFormat.Hotkeys.ShowUi,
+ Pause = configurationFileFormat.Hotkeys.Pause,
+ ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
+ ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
+ ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
+ VolumeUp = Key.Unbound,
+ VolumeDown = Key.Unbound
+ };
+ }
+
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
diff --git a/Ryujinx/Ui/RendererWidgetBase.cs b/Ryujinx/Ui/RendererWidgetBase.cs
index 6a728a26d..7e25ba2d9 100644
--- a/Ryujinx/Ui/RendererWidgetBase.cs
+++ b/Ryujinx/Ui/RendererWidgetBase.cs
@@ -35,6 +35,7 @@ namespace Ryujinx.Ui
private const int SwitchPanelHeight = 720;
private const int TargetFps = 60;
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
+ private const float VolumeDelta = 0.05f;
public ManualResetEvent WaitEvent { get; set; }
public NpadManager NpadManager { get; }
@@ -57,6 +58,7 @@ namespace Ryujinx.Ui
private readonly long _ticksPerFrame;
private long _ticks = 0;
+ private float _newVolume;
private readonly Stopwatch _chrono;
@@ -643,6 +645,20 @@ namespace Ryujinx.Ui
(MaxResolutionScale + GraphicsConfig.ResScale - 2) % MaxResolutionScale + 1;
}
+ if (currentHotkeyState.HasFlag(KeyboardHotkeyState.VolumeUp) &&
+ !_prevHotkeyState.HasFlag(KeyboardHotkeyState.VolumeUp))
+ {
+ _newVolume = MathF.Round((Device.GetVolume() + VolumeDelta), 2);
+ Device.SetVolume(_newVolume);
+ }
+
+ if (currentHotkeyState.HasFlag(KeyboardHotkeyState.VolumeDown) &&
+ !_prevHotkeyState.HasFlag(KeyboardHotkeyState.VolumeDown))
+ {
+ _newVolume = MathF.Round((Device.GetVolume() - VolumeDelta), 2);
+ Device.SetVolume(_newVolume);
+ }
+
_prevHotkeyState = currentHotkeyState;
}
@@ -675,7 +691,9 @@ namespace Ryujinx.Ui
Pause = 1 << 3,
ToggleMute = 1 << 4,
ResScaleUp = 1 << 5,
- ResScaleDown = 1 << 6
+ ResScaleDown = 1 << 6,
+ VolumeUp = 1 << 7,
+ VolumeDown = 1 << 8
}
private KeyboardHotkeyState GetHotkeyState()
@@ -717,6 +735,16 @@ namespace Ryujinx.Ui
state |= KeyboardHotkeyState.ResScaleDown;
}
+ if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeUp))
+ {
+ state |= KeyboardHotkeyState.VolumeUp;
+ }
+
+ if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeDown))
+ {
+ state |= KeyboardHotkeyState.VolumeDown;
+ }
+
return state;
}
}