From 2372c194f10d8f9ef7ea2dc415aa1613fbfc078a Mon Sep 17 00:00:00 2001 From: Ac_K Date: Tue, 6 Dec 2022 16:32:14 +0100 Subject: ava: Cleanup Input classes (#4042) * ava: Cleanup Input classes This PR just cleanup all Input classes for consistencies. * Addresses TSRBerry's feedback --- Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs | 34 +++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs') diff --git a/Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs b/Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs index 910de186..31a53c32 100644 --- a/Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs +++ b/Ryujinx.Ava/Input/AvaloniaKeyboardDriver.cs @@ -4,7 +4,6 @@ using Ryujinx.Ava.Common.Locale; using Ryujinx.Input; using System; using System.Collections.Generic; - using AvaKey = Avalonia.Input.Key; using Key = Ryujinx.Input.Key; @@ -13,24 +12,23 @@ namespace Ryujinx.Ava.Input internal class AvaloniaKeyboardDriver : IGamepadDriver { private static readonly string[] _keyboardIdentifers = new string[1] { "0" }; - private readonly Control _control; + private readonly Control _control; private readonly HashSet _pressedKeys; public event EventHandler KeyPressed; public event EventHandler KeyRelease; - public event EventHandler TextInput; - - public string DriverName => "Avalonia"; + public event EventHandler TextInput; + public string DriverName => "AvaloniaKeyboardDriver"; public ReadOnlySpan GamepadsIds => _keyboardIdentifers; public AvaloniaKeyboardDriver(Control control) { - _control = control; + _control = control; _pressedKeys = new HashSet(); - _control.KeyDown += OnKeyPress; - _control.KeyUp += OnKeyRelease; + _control.KeyDown += OnKeyPress; + _control.KeyUp += OnKeyRelease; _control.TextInput += Control_TextInput; } @@ -41,21 +39,16 @@ namespace Ryujinx.Ava.Input public event Action OnGamepadConnected { - add { } + add { } remove { } } public event Action OnGamepadDisconnected { - add { } + add { } remove { } } - public void Dispose() - { - Dispose(true); - } - public IGamepad GetGamepad(string id) { if (!_keyboardIdentifers[0].Equals(id)) @@ -70,15 +63,13 @@ namespace Ryujinx.Ava.Input { if (disposing) { - _control.KeyUp -= OnKeyPress; + _control.KeyUp -= OnKeyPress; _control.KeyDown -= OnKeyRelease; } } protected void OnKeyPress(object sender, KeyEventArgs args) { - AvaKey key = args.Key; - _pressedKeys.Add(args.Key); KeyPressed?.Invoke(this, args); @@ -98,7 +89,7 @@ namespace Ryujinx.Ava.Input return false; } - AvaloniaMappingHelper.TryGetAvaKey(key, out var nativeKey); + AvaloniaKeyboardMappingHelper.TryGetAvaKey(key, out var nativeKey); return _pressedKeys.Contains(nativeKey); } @@ -107,5 +98,10 @@ namespace Ryujinx.Ava.Input { _pressedKeys.Clear(); } + + public void Dispose() + { + Dispose(true); + } } } \ No newline at end of file -- cgit v1.2.3