Requested renames

This commit is contained in:
Isaac Marovitz 2024-03-25 13:02:40 -04:00
commit a73e0786f1
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
15 changed files with 58 additions and 62 deletions

View file

@ -7,7 +7,7 @@ using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
namespace Ryujinx.UI.Helper namespace Ryujinx.UI.Helper
{ {
public static class ButtonValueHelper public static class ButtonHelper
{ {
private static readonly Dictionary<Key, string> _keysMap = new() private static readonly Dictionary<Key, string> _keysMap = new()
{ {
@ -117,35 +117,35 @@ namespace Ryujinx.UI.Helper
{ StickInputId.Unbound, "Unbound" }, { StickInputId.Unbound, "Unbound" },
}; };
public static string ToString(ButtonValue buttonValue) public static string ToString(Button button)
{ {
string keyString = ""; string keyString = "";
if (buttonValue.Type == ButtonValueType.Key) if (button.Type == ButtonType.Key)
{ {
var key = buttonValue.AsHidType<Key>(); var key = button.AsHidType<Key>();
if (!_keysMap.TryGetValue(buttonValue.AsHidType<Key>(), out keyString)) if (!_keysMap.TryGetValue(button.AsHidType<Key>(), out keyString))
{ {
keyString = key.ToString(); keyString = key.ToString();
} }
} }
if (buttonValue.Type == ButtonValueType.GamepadButtonInputId) if (button.Type == ButtonType.GamepadButtonInputId)
{ {
var gamepadButton = buttonValue.AsHidType<GamepadInputId>(); var gamepadButton = button.AsHidType<GamepadInputId>();
if (!_gamepadInputIdMap.TryGetValue(buttonValue.AsHidType<GamepadInputId>(), out keyString)) if (!_gamepadInputIdMap.TryGetValue(button.AsHidType<GamepadInputId>(), out keyString))
{ {
keyString = gamepadButton.ToString(); keyString = gamepadButton.ToString();
} }
} }
if (buttonValue.Type == ButtonValueType.StickId) if (button.Type == ButtonType.StickId)
{ {
var stickInput = buttonValue.AsHidType<StickInputId>(); var stickInput = button.AsHidType<StickInputId>();
if (!_stickInputIdMap.TryGetValue(buttonValue.AsHidType<StickInputId>(), out keyString)) if (!_stickInputIdMap.TryGetValue(button.AsHidType<StickInputId>(), out keyString))
{ {
keyString = stickInput.ToString(); keyString = stickInput.ToString();
} }

View file

@ -18,6 +18,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using Button = Ryujinx.Input.Button;
using ConfigGamepadInputId = Ryujinx.Common.Configuration.Hid.Controller.GamepadInputId; using ConfigGamepadInputId = Ryujinx.Common.Configuration.Hid.Controller.GamepadInputId;
using ConfigStickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId; using ConfigStickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
using GUI = Gtk.Builder.ObjectAttribute; using GUI = Gtk.Builder.ObjectAttribute;
@ -894,7 +895,7 @@ namespace Ryujinx.UI.Windows
} }
} }
string pressedButton = ButtonValueHelper.ToString(assigner.GetPressedButton() ?? new ButtonValue(Input.Key.Unknown)); string pressedButton = ButtonHelper.ToString(assigner.GetPressedButton() ?? new Button(Input.Key.Unknown));
Application.Invoke(delegate Application.Invoke(delegate
{ {

View file

@ -59,7 +59,7 @@ namespace Ryujinx.Input.Assigner
return _gamepad == null || !_gamepad.IsConnected; return _gamepad == null || !_gamepad.IsConnected;
} }
public ButtonValue? GetPressedButton() public Button? GetPressedButton()
{ {
IEnumerable<GamepadButtonInputId> pressedButtons = _detector.GetPressedButtons(); IEnumerable<GamepadButtonInputId> pressedButtons = _detector.GetPressedButtons();

View file

@ -31,6 +31,6 @@ namespace Ryujinx.Input.Assigner
/// Get the pressed button that was read in <see cref="ReadInput"/> by the button assigner. /// Get the pressed button that was read in <see cref="ReadInput"/> by the button assigner.
/// </summary> /// </summary>
/// <returns>The pressed button that was read</returns> /// <returns>The pressed button that was read</returns>
ButtonValue? GetPressedButton(); Button? GetPressedButton();
} }
} }

View file

@ -31,9 +31,9 @@ namespace Ryujinx.Input.Assigner
return _keyboardState.IsPressed(Key.Escape); return _keyboardState.IsPressed(Key.Escape);
} }
public ButtonValue? GetPressedButton() public Button? GetPressedButton()
{ {
ButtonValue? keyPressed = null; Button? keyPressed = null;
for (Key key = Key.Unknown; key < Key.Count; key++) for (Key key = Key.Unknown; key < Key.Count; key++)
{ {

View file

@ -2,26 +2,26 @@ using System;
namespace Ryujinx.Input namespace Ryujinx.Input
{ {
public readonly struct ButtonValue public readonly struct Button
{ {
public readonly ButtonValueType Type; public readonly ButtonType Type;
private readonly uint _rawValue; private readonly uint _rawValue;
public ButtonValue(Key key) public Button(Key key)
{ {
Type = ButtonValueType.Key; Type = ButtonType.Key;
_rawValue = (uint)key; _rawValue = (uint)key;
} }
public ButtonValue(GamepadButtonInputId gamepad) public Button(GamepadButtonInputId gamepad)
{ {
Type = ButtonValueType.GamepadButtonInputId; Type = ButtonType.GamepadButtonInputId;
_rawValue = (uint)gamepad; _rawValue = (uint)gamepad;
} }
public ButtonValue(StickInputId stick) public Button(StickInputId stick)
{ {
Type = ButtonValueType.StickId; Type = ButtonType.StickId;
_rawValue = (uint)stick; _rawValue = (uint)stick;
} }

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Input namespace Ryujinx.Input
{ {
public enum ButtonValueType public enum ButtonType
{ {
Key, Key,
GamepadButtonInputId, GamepadButtonInputId,

View file

@ -12,9 +12,9 @@ namespace Ryujinx.Ava.UI.Helpers
internal class ButtonAssignedEventArgs : EventArgs internal class ButtonAssignedEventArgs : EventArgs
{ {
public ToggleButton Button { get; } public ToggleButton Button { get; }
public ButtonValue? ButtonValue { get; } public Button? ButtonValue { get; }
public ButtonAssignedEventArgs(ToggleButton button, ButtonValue? buttonValue) public ButtonAssignedEventArgs(ToggleButton button, Button? buttonValue)
{ {
Button = button; Button = button;
ButtonValue = buttonValue; ButtonValue = buttonValue;
@ -75,7 +75,7 @@ namespace Ryujinx.Ava.UI.Helpers
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {
ButtonValue? pressedButton = assigner.GetPressedButton(); Button? pressedButton = assigner.GetPressedButton();
if (_shouldUnbind) if (_shouldUnbind)
{ {

View file

@ -6,7 +6,7 @@ using System;
namespace Ryujinx.Ava.UI.Models.Input namespace Ryujinx.Ava.UI.Models.Input
{ {
public class ControllerInputConfig : BaseModel public class GamepadInputConfig : BaseModel
{ {
public bool EnableCemuHookMotion { get; set; } public bool EnableCemuHookMotion { get; set; }
public string DsuServerHost { get; set; } public string DsuServerHost { get; set; }
@ -409,7 +409,7 @@ namespace Ryujinx.Ava.UI.Models.Input
} }
} }
public ControllerInputConfig(InputConfig config) public GamepadInputConfig(InputConfig config)
{ {
if (config != null) if (config != null)
{ {

View file

@ -3,7 +3,7 @@ using Ryujinx.Common.Configuration.Hid;
namespace Ryujinx.Ava.UI.Models.Input namespace Ryujinx.Ava.UI.Models.Input
{ {
public class HotkeysConfig : BaseModel public class HotkeyConfig : BaseModel
{ {
private Key _toggleVsync; private Key _toggleVsync;
public Key ToggleVsync public Key ToggleVsync
@ -104,7 +104,7 @@ namespace Ryujinx.Ava.UI.Models.Input
} }
} }
public HotkeysConfig(KeyboardHotkeys config) public HotkeyConfig(KeyboardHotkeys config)
{ {
if (config != null) if (config != null)
{ {

View file

@ -6,8 +6,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
public class ControllerInputViewModel : BaseModel public class ControllerInputViewModel : BaseModel
{ {
private ControllerInputConfig _config; private GamepadInputConfig _config;
public ControllerInputConfig Config public GamepadInputConfig Config
{ {
get => _config; get => _config;
set set
@ -56,7 +56,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public InputViewModel parentModel; public InputViewModel parentModel;
public ControllerInputViewModel(InputViewModel model, ControllerInputConfig config) public ControllerInputViewModel(InputViewModel model, GamepadInputConfig config)
{ {
parentModel = model; parentModel = model;
model.NotifyChangesEvent += OnParentModelChanged; model.NotifyChangesEvent += OnParentModelChanged;

View file

@ -288,7 +288,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
if (Config is StandardControllerInputConfig controllerInputConfig) if (Config is StandardControllerInputConfig controllerInputConfig)
{ {
ConfigViewModel = new ControllerInputViewModel(this, new ControllerInputConfig(controllerInputConfig)); ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig));
} }
} }

View file

@ -236,12 +236,7 @@ namespace Ryujinx.Ava.UI.ViewModels
get => new(_networkInterfaces.Keys); get => new(_networkInterfaces.Keys);
} }
public AvaloniaList<string> MultiplayerModes public HotkeyConfig KeyboardHotkey { get; set; }
{
get => new(Enum.GetNames<MultiplayerMode>());
}
public HotkeysConfig KeyboardHotkeys { get; set; }
public int NetworkInterfaceIndex public int NetworkInterfaceIndex
{ {
@ -408,7 +403,7 @@ namespace Ryujinx.Ava.UI.ViewModels
EnableMouse = config.Hid.EnableMouse; EnableMouse = config.Hid.EnableMouse;
// Keyboard Hotkeys // Keyboard Hotkeys
KeyboardHotkeys = new HotkeysConfig(config.Hid.Hotkeys.Value); KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
// System // System
Region = (int)config.System.Region.Value; Region = (int)config.System.Region.Value;
@ -495,7 +490,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.Hid.EnableMouse.Value = EnableMouse; config.Hid.EnableMouse.Value = EnableMouse;
// Keyboard Hotkeys // Keyboard Hotkeys
config.Hid.Hotkeys.Value = KeyboardHotkeys.GetConfig(); config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();
// System // System
config.System.Region.Value = (Region)Region; config.System.Region.Value = (Region)Region;

View file

@ -52,55 +52,55 @@
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysToggleVsyncHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysToggleVsyncHotkey}" />
<ToggleButton Name="ToggleVsync"> <ToggleButton Name="ToggleVsync">
<TextBlock Text="{Binding KeyboardHotkeys.ToggleVsync, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ToggleVsync, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysScreenshotHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysScreenshotHotkey}" />
<ToggleButton Name="Screenshot"> <ToggleButton Name="Screenshot">
<TextBlock Text="{Binding KeyboardHotkeys.Screenshot, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.Screenshot, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysShowUiHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysShowUiHotkey}" />
<ToggleButton Name="ShowUI"> <ToggleButton Name="ShowUI">
<TextBlock Text="{Binding KeyboardHotkeys.ShowUI, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ShowUI, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysPauseHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysPauseHotkey}" />
<ToggleButton Name="Pause"> <ToggleButton Name="Pause">
<TextBlock Text="{Binding KeyboardHotkeys.Pause, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.Pause, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysToggleMuteHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysToggleMuteHotkey}" />
<ToggleButton Name="ToggleMute"> <ToggleButton Name="ToggleMute">
<TextBlock Text="{Binding KeyboardHotkeys.ToggleMute, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ToggleMute, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysResScaleUpHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysResScaleUpHotkey}" />
<ToggleButton Name="ResScaleUp"> <ToggleButton Name="ResScaleUp">
<TextBlock Text="{Binding KeyboardHotkeys.ResScaleUp, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ResScaleUp, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysResScaleDownHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysResScaleDownHotkey}" />
<ToggleButton Name="ResScaleDown"> <ToggleButton Name="ResScaleDown">
<TextBlock Text="{Binding KeyboardHotkeys.ResScaleDown, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ResScaleDown, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysVolumeUpHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysVolumeUpHotkey}" />
<ToggleButton Name="VolumeUp"> <ToggleButton Name="VolumeUp">
<TextBlock Text="{Binding KeyboardHotkeys.VolumeUp, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.VolumeUp, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysVolumeDownHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysVolumeDownHotkey}" />
<ToggleButton Name="VolumeDown"> <ToggleButton Name="VolumeDown">
<TextBlock Text="{Binding KeyboardHotkeys.VolumeDown, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.VolumeDown, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View file

@ -84,31 +84,31 @@ namespace Ryujinx.Ava.UI.Views.Settings
switch (button.Name) switch (button.Name)
{ {
case "ToggleVsync": case "ToggleVsync":
viewModel.KeyboardHotkeys.ToggleVsync = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType<Key>();
break; break;
case "Screenshot": case "Screenshot":
viewModel.KeyboardHotkeys.Screenshot = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
break; break;
case "ShowUI": case "ShowUI":
viewModel.KeyboardHotkeys.ShowUI = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ShowUI = buttonValue.AsHidType<Key>();
break; break;
case "Pause": case "Pause":
viewModel.KeyboardHotkeys.Pause = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.Pause = buttonValue.AsHidType<Key>();
break; break;
case "ToggleMute": case "ToggleMute":
viewModel.KeyboardHotkeys.ToggleMute = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ToggleMute = buttonValue.AsHidType<Key>();
break; break;
case "ResScaleUp": case "ResScaleUp":
viewModel.KeyboardHotkeys.ResScaleUp = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ResScaleUp = buttonValue.AsHidType<Key>();
break; break;
case "ResScaleDown": case "ResScaleDown":
viewModel.KeyboardHotkeys.ResScaleDown = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ResScaleDown = buttonValue.AsHidType<Key>();
break; break;
case "VolumeUp": case "VolumeUp":
viewModel.KeyboardHotkeys.VolumeUp = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.VolumeUp = buttonValue.AsHidType<Key>();
break; break;
case "VolumeDown": case "VolumeDown":
viewModel.KeyboardHotkeys.VolumeDown = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
break; break;
} }
} }