mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-27 14:49:05 +00:00
Overall Code Cleanup
This commit is contained in:
@@ -153,7 +153,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
|
||||
break;
|
||||
case PhysicalKey physicalKey:
|
||||
keyString = PhysicalKeyLabelHelper.GetString(physicalKey);
|
||||
keyString = PhysicalKeyLabelHelper.GetDisplayString(physicalKey);
|
||||
break;
|
||||
case GamepadInputId gamepadInputId:
|
||||
if (_gamepadInputIdMap.TryGetValue(gamepadInputId, out localeKey))
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
[ConfigPhysicalKey.Unbound] = LocaleKeys.KeyboardLayout_KeyUnbound,
|
||||
};
|
||||
|
||||
public static string GetString(ConfigPhysicalKey key)
|
||||
public static string GetDisplayString(ConfigPhysicalKey key)
|
||||
{
|
||||
if (_localizedKeysMap.TryGetValue(key, out LocaleKeys localeKey))
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
return observedLabel;
|
||||
}
|
||||
|
||||
if (TryGetPrintableKeySymbol(key, out string label))
|
||||
if (TryGetFallbackPrintableKeyLabel(key, out string label))
|
||||
{
|
||||
return label;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
return key.ToString();
|
||||
}
|
||||
|
||||
public static void UpdateFromEvent(KeyEventArgs args)
|
||||
public static void ObserveKeyPress(object sender, KeyEventArgs args)
|
||||
{
|
||||
if (args.KeyModifiers != KeyModifiers.None)
|
||||
{
|
||||
@@ -99,13 +99,13 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryNormalizePrintableSymbol(args.KeySymbol, out string label))
|
||||
if (TryNormalizeObservedPrintableLabel(args.KeySymbol, out string label))
|
||||
{
|
||||
_observedLayoutLabels[physicalKey] = label;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetPrintableKeySymbol(ConfigPhysicalKey key, out string label)
|
||||
private static bool TryGetFallbackPrintableKeyLabel(ConfigPhysicalKey key, out string label)
|
||||
{
|
||||
// The legacy enum name for the ISO extra key is misleading, so give it a distinct physical label.
|
||||
if (key == ConfigPhysicalKey.Grave)
|
||||
@@ -136,7 +136,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool TryNormalizePrintableSymbol(string keySymbol, out string label)
|
||||
private static bool TryNormalizeObservedPrintableLabel(string keySymbol, out string label)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keySymbol) || keySymbol.Length != 1 || char.IsControl(keySymbol[0]))
|
||||
{
|
||||
|
||||
@@ -291,6 +291,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
_mainWindow = RyujinxApp.MainWindow;
|
||||
|
||||
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner, KeyboardInputMode.Physical);
|
||||
AvaloniaKeyboardDriver.KeyPressed += PhysicalKeyLabelHelper.ObserveKeyPress;
|
||||
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||
}
|
||||
|
||||
_avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this, KeyboardInputMode.Semantic);
|
||||
_avaloniaKeyboardDriver.KeyPressed += PhysicalKeyLabelHelper.ObserveKeyPress;
|
||||
}
|
||||
|
||||
protected override void OnPointerReleased(PointerReleasedEventArgs e)
|
||||
|
||||
@@ -106,7 +106,9 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
InputManager = new InputManager(new AvaloniaKeyboardDriver(this, KeyboardInputMode.Semantic), new SDL3GamepadDriver());
|
||||
AvaloniaKeyboardDriver keyboardDriver = new(this, KeyboardInputMode.Semantic);
|
||||
keyboardDriver.KeyPressed += PhysicalKeyLabelHelper.ObserveKeyPress;
|
||||
InputManager = new InputManager(keyboardDriver, new SDL3GamepadDriver());
|
||||
|
||||
_ = this.GetObservable(IsActiveProperty).Subscribe(it => ViewModel.IsActive = it);
|
||||
this.ScalingChanged += OnScalingChanged;
|
||||
|
||||
Reference in New Issue
Block a user