Update keyboard localisation refactor snapshot

This commit is contained in:
Babib3l
2026-03-18 21:10:28 +01:00
parent 2fe5e8c40d
commit 84f3ce2ca5
22 changed files with 708 additions and 325 deletions

View File

@@ -1,4 +1,4 @@
namespace Ryujinx.Common.Configuration.Hid.Keyboard namespace Ryujinx.Common.Configuration.Hid.Keyboard
{ {
public class StandardKeyboardInputConfig : GenericKeyboardInputConfig<Key> { } public class StandardKeyboardInputConfig : GenericKeyboardInputConfig<PhysicalKey> { }
} }

View File

@@ -0,0 +1,19 @@
namespace Ryujinx.Common.Configuration.Hid
{
public static class KeyboardKeyExtensions
{
public static Key ToKey(this PhysicalKey key)
{
return key is >= PhysicalKey.Unknown and < PhysicalKey.Count
? (Key)(int)key
: Key.Unknown;
}
public static PhysicalKey ToPhysicalKey(this Key key)
{
return key is >= Key.Unknown and < Key.Count
? (PhysicalKey)(int)key
: PhysicalKey.Unknown;
}
}
}

View File

@@ -0,0 +1,142 @@
using System.Text.Json.Serialization;
namespace Ryujinx.Common.Configuration.Hid
{
[JsonConverter(typeof(JsonStringEnumConverter<PhysicalKey>))]
public enum PhysicalKey
{
Unknown,
ShiftLeft,
ShiftRight,
ControlLeft,
ControlRight,
AltLeft,
AltRight,
WinLeft,
WinRight,
Menu,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21,
F22,
F23,
F24,
F25,
F26,
F27,
F28,
F29,
F30,
F31,
F32,
F33,
F34,
F35,
Up,
Down,
Left,
Right,
Enter,
Escape,
Space,
Tab,
BackSpace,
Insert,
Delete,
PageUp,
PageDown,
Home,
End,
CapsLock,
ScrollLock,
PrintScreen,
Pause,
NumLock,
Clear,
Keypad0,
Keypad1,
Keypad2,
Keypad3,
Keypad4,
Keypad5,
Keypad6,
Keypad7,
Keypad8,
Keypad9,
KeypadDivide,
KeypadMultiply,
KeypadSubtract,
KeypadAdd,
KeypadDecimal,
KeypadEnter,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Number0,
Number1,
Number2,
Number3,
Number4,
Number5,
Number6,
Number7,
Number8,
Number9,
Tilde,
Grave,
Minus,
Plus,
BracketLeft,
BracketRight,
Semicolon,
Quote,
Comma,
Period,
Slash,
BackSlash,
Unbound,
Count,
}
}

View File

@@ -9,7 +9,7 @@ using System.Threading;
using SDL; using SDL;
using static SDL.SDL3; using static SDL.SDL3;
using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using ConfigPhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Input.SDL3 namespace Ryujinx.Input.SDL3
{ {
@@ -264,27 +264,27 @@ namespace Ryujinx.Input.SDL3
return value * ConvertRate; return value * ConvertRate;
} }
private static (short, short) GetStickValues(ref KeyboardStateSnapshot snapshot, JoyconConfigKeyboardStick<ConfigKey> stickConfig) private static (short, short) GetStickValues(ref KeyboardStateSnapshot snapshot, JoyconConfigKeyboardStick<ConfigPhysicalKey> stickConfig)
{ {
short stickX = 0; short stickX = 0;
short stickY = 0; short stickY = 0;
if (snapshot.IsPressed((Key)stickConfig.StickUp)) if (snapshot.IsPressed(stickConfig.StickUp.ToInputKey()))
{ {
stickY += 1; stickY += 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickDown)) if (snapshot.IsPressed(stickConfig.StickDown.ToInputKey()))
{ {
stickY -= 1; stickY -= 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickRight)) if (snapshot.IsPressed(stickConfig.StickRight.ToInputKey()))
{ {
stickX += 1; stickX += 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickLeft)) if (snapshot.IsPressed(stickConfig.StickLeft.ToInputKey()))
{ {
stickX -= 1; stickX -= 1;
} }
@@ -361,28 +361,28 @@ namespace Ryujinx.Input.SDL3
_buttonsUserMapping.Clear(); _buttonsUserMapping.Clear();
// Then configure left joycon // Then configure left joycon
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftStick, (Key)_configuration.LeftJoyconStick.StickButton)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftStick, _configuration.LeftJoyconStick.StickButton.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadUp, (Key)_configuration.LeftJoycon.DpadUp)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadUp, _configuration.LeftJoycon.DpadUp.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadDown, (Key)_configuration.LeftJoycon.DpadDown)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadDown, _configuration.LeftJoycon.DpadDown.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadLeft, (Key)_configuration.LeftJoycon.DpadLeft)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadLeft, _configuration.LeftJoycon.DpadLeft.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadRight, (Key)_configuration.LeftJoycon.DpadRight)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadRight, _configuration.LeftJoycon.DpadRight.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Minus, (Key)_configuration.LeftJoycon.ButtonMinus)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Minus, _configuration.LeftJoycon.ButtonMinus.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftShoulder, (Key)_configuration.LeftJoycon.ButtonL)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftShoulder, _configuration.LeftJoycon.ButtonL.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftTrigger, (Key)_configuration.LeftJoycon.ButtonZl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftTrigger, _configuration.LeftJoycon.ButtonZl.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger0, (Key)_configuration.LeftJoycon.ButtonSr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger0, _configuration.LeftJoycon.ButtonSr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger0, (Key)_configuration.LeftJoycon.ButtonSl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger0, _configuration.LeftJoycon.ButtonSl.ToInputKey()));
// Finally configure right joycon // Finally configure right joycon
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightStick, (Key)_configuration.RightJoyconStick.StickButton)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightStick, _configuration.RightJoyconStick.StickButton.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.A, (Key)_configuration.RightJoycon.ButtonA)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.A, _configuration.RightJoycon.ButtonA.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.B, (Key)_configuration.RightJoycon.ButtonB)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.B, _configuration.RightJoycon.ButtonB.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.X, (Key)_configuration.RightJoycon.ButtonX)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.X, _configuration.RightJoycon.ButtonX.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Y, (Key)_configuration.RightJoycon.ButtonY)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Y, _configuration.RightJoycon.ButtonY.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Plus, (Key)_configuration.RightJoycon.ButtonPlus)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Plus, _configuration.RightJoycon.ButtonPlus.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightShoulder, (Key)_configuration.RightJoycon.ButtonR)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightShoulder, _configuration.RightJoycon.ButtonR.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightTrigger, (Key)_configuration.RightJoycon.ButtonZr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightTrigger, _configuration.RightJoycon.ButtonZr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger1, (Key)_configuration.RightJoycon.ButtonSr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger1, _configuration.RightJoycon.ButtonSr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger1, (Key)_configuration.RightJoycon.ButtonSl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger1, _configuration.RightJoycon.ButtonSl.ToInputKey()));
} }
} }

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Ryujinx.Input.SDL3 namespace Ryujinx.Input.SDL3
{ {
public class SDL3KeyboardDriver : IGamepadDriver public class SDL3KeyboardDriver : IKeyboardModeDriver
{ {
public SDL3KeyboardDriver() public SDL3KeyboardDriver()
{ {
@@ -44,6 +44,11 @@ namespace Ryujinx.Input.SDL3
} }
public IGamepad GetGamepad(string id) public IGamepad GetGamepad(string id)
{
return GetKeyboard(id, KeyboardInputMode.Semantic);
}
public IKeyboard GetKeyboard(string id, KeyboardInputMode mode)
{ {
if (!_keyboardIdentifers[0].Equals(id)) if (!_keyboardIdentifers[0].Equals(id))
{ {

View File

@@ -2,6 +2,7 @@ using Ryujinx.Common;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Controller.Motion; using Ryujinx.Common.Configuration.Hid.Controller.Motion;
using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Hid; using Ryujinx.HLE.HOS.Services.Hid;
using System; using System;
@@ -234,7 +235,9 @@ namespace Ryujinx.Input.HLE
_gamepad?.Dispose(); _gamepad?.Dispose();
Id = config.Id; Id = config.Id;
_gamepad = GamepadDriver.GetGamepad(Id); _gamepad = config is StandardKeyboardInputConfig && GamepadDriver is IKeyboardModeDriver keyboardModeDriver
? keyboardModeDriver.GetKeyboard(Id, KeyboardInputMode.Physical)
: GamepadDriver.GetGamepad(Id);
UpdateUserConfiguration(config); UpdateUserConfiguration(config);

View File

@@ -0,0 +1,7 @@
namespace Ryujinx.Input
{
public interface IKeyboardModeDriver : IGamepadDriver
{
IKeyboard GetKeyboard(string id, KeyboardInputMode mode);
}
}

View File

@@ -0,0 +1,8 @@
namespace Ryujinx.Input
{
public enum KeyboardInputMode
{
Semantic,
Physical,
}
}

View File

@@ -0,0 +1,14 @@
using ConfigPhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Input
{
public static class PhysicalKeyExtensions
{
public static Key ToInputKey(this ConfigPhysicalKey key)
{
return key is >= ConfigPhysicalKey.Unknown and < ConfigPhysicalKey.Count
? (Key)(int)key
: Key.Unknown;
}
}
}

View File

@@ -24,7 +24,7 @@ using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
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 Key = Ryujinx.Common.Configuration.Hid.Key; using PhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Headless namespace Ryujinx.Headless
{ {
@@ -105,48 +105,48 @@ namespace Ryujinx.Headless
Backend = InputBackendType.WindowKeyboard, Backend = InputBackendType.WindowKeyboard,
Id = null, Id = null,
ControllerType = ControllerType.JoyconPair, ControllerType = ControllerType.JoyconPair,
LeftJoycon = new LeftJoyconCommonConfig<Key> LeftJoycon = new LeftJoyconCommonConfig<PhysicalKey>
{ {
DpadUp = Key.Up, DpadUp = PhysicalKey.Up,
DpadDown = Key.Down, DpadDown = PhysicalKey.Down,
DpadLeft = Key.Left, DpadLeft = PhysicalKey.Left,
DpadRight = Key.Right, DpadRight = PhysicalKey.Right,
ButtonMinus = Key.Minus, ButtonMinus = PhysicalKey.Minus,
ButtonL = Key.E, ButtonL = PhysicalKey.E,
ButtonZl = Key.Q, ButtonZl = PhysicalKey.Q,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.W, StickUp = PhysicalKey.W,
StickDown = Key.S, StickDown = PhysicalKey.S,
StickLeft = Key.A, StickLeft = PhysicalKey.A,
StickRight = Key.D, StickRight = PhysicalKey.D,
StickButton = Key.F, StickButton = PhysicalKey.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<PhysicalKey>
{ {
ButtonA = Key.Z, ButtonA = PhysicalKey.Z,
ButtonB = Key.X, ButtonB = PhysicalKey.X,
ButtonX = Key.C, ButtonX = PhysicalKey.C,
ButtonY = Key.V, ButtonY = PhysicalKey.V,
ButtonPlus = Key.Plus, ButtonPlus = PhysicalKey.Plus,
ButtonR = Key.U, ButtonR = PhysicalKey.U,
ButtonZr = Key.O, ButtonZr = PhysicalKey.O,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.I, StickUp = PhysicalKey.I,
StickDown = Key.K, StickDown = PhysicalKey.K,
StickLeft = Key.J, StickLeft = PhysicalKey.J,
StickRight = Key.L, StickRight = PhysicalKey.L,
StickButton = Key.H, StickButton = PhysicalKey.H,
}, },
}; };
} }

View File

@@ -6,7 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Threading; using System.Threading;
using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using ConfigPhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
using Key = Ryujinx.Input.Key; using Key = Ryujinx.Input.Key;
namespace Ryujinx.Ava.Input namespace Ryujinx.Ava.Input
@@ -15,6 +15,7 @@ namespace Ryujinx.Ava.Input
{ {
private readonly List<ButtonMappingEntry> _buttonsUserMapping; private readonly List<ButtonMappingEntry> _buttonsUserMapping;
private readonly AvaloniaKeyboardDriver _driver; private readonly AvaloniaKeyboardDriver _driver;
private readonly KeyboardInputMode _mode;
private StandardKeyboardInputConfig _configuration; private StandardKeyboardInputConfig _configuration;
private uint _ledValue; private uint _ledValue;
@@ -32,11 +33,12 @@ namespace Ryujinx.Ava.Input
public readonly Key From = from; public readonly Key From = from;
} }
public AvaloniaKeyboard(AvaloniaKeyboardDriver driver, string id, string name) public AvaloniaKeyboard(AvaloniaKeyboardDriver driver, string id, string name, KeyboardInputMode mode)
{ {
_buttonsUserMapping = []; _buttonsUserMapping = [];
_driver = driver; _driver = driver;
_mode = mode;
Id = id; Id = id;
Name = name; Name = name;
} }
@@ -101,7 +103,7 @@ namespace Ryujinx.Ava.Input
{ {
try try
{ {
return _driver.IsPressed(key); return _driver.IsPressed(key, _mode);
} }
catch catch
{ {
@@ -119,28 +121,28 @@ namespace Ryujinx.Ava.Input
#pragma warning disable IDE0055 // Disable formatting #pragma warning disable IDE0055 // Disable formatting
// Left JoyCon // Left JoyCon
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftStick, (Key)_configuration.LeftJoyconStick.StickButton)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftStick, _configuration.LeftJoyconStick.StickButton.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadUp, (Key)_configuration.LeftJoycon.DpadUp)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadUp, _configuration.LeftJoycon.DpadUp.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadDown, (Key)_configuration.LeftJoycon.DpadDown)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadDown, _configuration.LeftJoycon.DpadDown.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadLeft, (Key)_configuration.LeftJoycon.DpadLeft)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadLeft, _configuration.LeftJoycon.DpadLeft.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadRight, (Key)_configuration.LeftJoycon.DpadRight)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadRight, _configuration.LeftJoycon.DpadRight.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Minus, (Key)_configuration.LeftJoycon.ButtonMinus)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Minus, _configuration.LeftJoycon.ButtonMinus.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftShoulder, (Key)_configuration.LeftJoycon.ButtonL)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftShoulder, _configuration.LeftJoycon.ButtonL.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftTrigger, (Key)_configuration.LeftJoycon.ButtonZl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftTrigger, _configuration.LeftJoycon.ButtonZl.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger0, (Key)_configuration.LeftJoycon.ButtonSr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger0, _configuration.LeftJoycon.ButtonSr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger0, (Key)_configuration.LeftJoycon.ButtonSl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger0, _configuration.LeftJoycon.ButtonSl.ToInputKey()));
// Right JoyCon // Right JoyCon
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightStick, (Key)_configuration.RightJoyconStick.StickButton)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightStick, _configuration.RightJoyconStick.StickButton.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.A, (Key)_configuration.RightJoycon.ButtonA)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.A, _configuration.RightJoycon.ButtonA.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.B, (Key)_configuration.RightJoycon.ButtonB)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.B, _configuration.RightJoycon.ButtonB.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.X, (Key)_configuration.RightJoycon.ButtonX)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.X, _configuration.RightJoycon.ButtonX.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Y, (Key)_configuration.RightJoycon.ButtonY)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Y, _configuration.RightJoycon.ButtonY.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Plus, (Key)_configuration.RightJoycon.ButtonPlus)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Plus, _configuration.RightJoycon.ButtonPlus.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightShoulder, (Key)_configuration.RightJoycon.ButtonR)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightShoulder, _configuration.RightJoycon.ButtonR.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightTrigger, (Key)_configuration.RightJoycon.ButtonZr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightTrigger, _configuration.RightJoycon.ButtonZr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger1, (Key)_configuration.RightJoycon.ButtonSr)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger1, _configuration.RightJoycon.ButtonSr.ToInputKey()));
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger1, (Key)_configuration.RightJoycon.ButtonSl)); _buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger1, _configuration.RightJoycon.ButtonSl.ToInputKey()));
#pragma warning restore IDE0055 #pragma warning restore IDE0055
} }
} }
@@ -172,27 +174,27 @@ namespace Ryujinx.Ava.Input
return value * ConvertRate; return value * ConvertRate;
} }
private static (short, short) GetStickValues(ref KeyboardStateSnapshot snapshot, JoyconConfigKeyboardStick<ConfigKey> stickConfig) private static (short, short) GetStickValues(ref KeyboardStateSnapshot snapshot, JoyconConfigKeyboardStick<ConfigPhysicalKey> stickConfig)
{ {
short stickX = 0; short stickX = 0;
short stickY = 0; short stickY = 0;
if (snapshot.IsPressed((Key)stickConfig.StickUp)) if (snapshot.IsPressed(stickConfig.StickUp.ToInputKey()))
{ {
stickY += 1; stickY += 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickDown)) if (snapshot.IsPressed(stickConfig.StickDown.ToInputKey()))
{ {
stickY -= 1; stickY -= 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickRight)) if (snapshot.IsPressed(stickConfig.StickRight.ToInputKey()))
{ {
stickX += 1; stickX += 1;
} }
if (snapshot.IsPressed((Key)stickConfig.StickLeft)) if (snapshot.IsPressed(stickConfig.StickLeft.ToInputKey()))
{ {
stickX -= 1; stickX -= 1;
} }
@@ -206,7 +208,7 @@ namespace Ryujinx.Ava.Input
public void Clear() public void Clear()
{ {
_driver?.Clear(); _driver?.Clear(_mode);
} }
public void Dispose() { } public void Dispose() { }

View File

@@ -8,11 +8,13 @@ using Key = Ryujinx.Input.Key;
namespace Ryujinx.Ava.Input namespace Ryujinx.Ava.Input
{ {
internal class AvaloniaKeyboardDriver : IGamepadDriver internal class AvaloniaKeyboardDriver : IKeyboardModeDriver
{ {
private static readonly string[] _keyboardIdentifers = ["0"]; private static readonly string[] _keyboardIdentifers = ["0"];
private readonly Control _control; private readonly Control _control;
private readonly Dictionary<Key, int> _pressedKeys; private readonly Dictionary<Key, int> _semanticPressedKeys;
private readonly Dictionary<Key, int> _physicalPressedKeys;
private readonly KeyboardInputMode _defaultMode;
public event EventHandler<KeyEventArgs> KeyPressed; public event EventHandler<KeyEventArgs> KeyPressed;
public event EventHandler<KeyEventArgs> KeyRelease; public event EventHandler<KeyEventArgs> KeyRelease;
@@ -21,10 +23,12 @@ namespace Ryujinx.Ava.Input
public string DriverName => "AvaloniaKeyboardDriver"; public string DriverName => "AvaloniaKeyboardDriver";
public ReadOnlySpan<string> GamepadsIds => _keyboardIdentifers; public ReadOnlySpan<string> GamepadsIds => _keyboardIdentifers;
public AvaloniaKeyboardDriver(Control control) public AvaloniaKeyboardDriver(Control control, KeyboardInputMode defaultMode = KeyboardInputMode.Semantic)
{ {
_control = control; _control = control;
_pressedKeys = []; _semanticPressedKeys = [];
_physicalPressedKeys = [];
_defaultMode = defaultMode;
_control.KeyDown += OnKeyPress; _control.KeyDown += OnKeyPress;
_control.KeyUp += OnKeyRelease; _control.KeyUp += OnKeyRelease;
@@ -49,13 +53,18 @@ namespace Ryujinx.Ava.Input
} }
public IGamepad GetGamepad(string id) public IGamepad GetGamepad(string id)
{
return GetKeyboard(id, _defaultMode);
}
public IKeyboard GetKeyboard(string id, KeyboardInputMode mode)
{ {
if (!_keyboardIdentifers[0].Equals(id)) if (!_keyboardIdentifers[0].Equals(id))
{ {
return null; return null;
} }
return new AvaloniaKeyboard(this, _keyboardIdentifers[0], LocaleManager.Instance[LocaleKeys.KeyboardLayout_AllKeyboards]); return new AvaloniaKeyboard(this, _keyboardIdentifers[0], LocaleManager.Instance[LocaleKeys.KeyboardLayout_AllKeyboards], mode);
} }
public IEnumerable<IGamepad> GetGamepads() => [GetGamepad("0")]; public IEnumerable<IGamepad> GetGamepads() => [GetGamepad("0")];
@@ -66,63 +75,98 @@ namespace Ryujinx.Ava.Input
{ {
_control.KeyDown -= OnKeyPress; _control.KeyDown -= OnKeyPress;
_control.KeyUp -= OnKeyRelease; _control.KeyUp -= OnKeyRelease;
_control.TextInput -= Control_TextInput;
} }
} }
protected void OnKeyPress(object sender, KeyEventArgs args) protected void OnKeyPress(object sender, KeyEventArgs args)
{ {
Key key = AvaloniaKeyboardMappingHelper.ToInputKey(args.PhysicalKey, args.Key); UpdateKeyState(_semanticPressedKeys, GetInputKey(args, KeyboardInputMode.Semantic), true);
UpdateKeyState(_physicalPressedKeys, GetInputKey(args, KeyboardInputMode.Physical), true);
if (key != Key.Unknown)
{
if (_pressedKeys.TryGetValue(key, out int count))
{
_pressedKeys[key] = count + 1;
}
else
{
_pressedKeys[key] = 1;
}
}
KeyPressed?.Invoke(this, args); KeyPressed?.Invoke(this, args);
} }
protected void OnKeyRelease(object sender, KeyEventArgs args) protected void OnKeyRelease(object sender, KeyEventArgs args)
{ {
Key key = AvaloniaKeyboardMappingHelper.ToInputKey(args.PhysicalKey, args.Key); UpdateKeyState(_semanticPressedKeys, GetInputKey(args, KeyboardInputMode.Semantic), false);
UpdateKeyState(_physicalPressedKeys, GetInputKey(args, KeyboardInputMode.Physical), false);
if (key != Key.Unknown)
{
if (_pressedKeys.TryGetValue(key, out int count))
{
if (count <= 1)
{
_pressedKeys.Remove(key);
}
else
{
_pressedKeys[key] = count - 1;
}
}
}
KeyRelease?.Invoke(this, args); KeyRelease?.Invoke(this, args);
} }
internal bool IsPressed(Key key) internal bool IsPressed(Key key, KeyboardInputMode mode)
{ {
if (key is Key.Unbound or Key.Unknown) if (key is Key.Unbound or Key.Unknown)
{ {
return false; return false;
} }
return _pressedKeys.ContainsKey(key); return GetPressedKeys(mode).ContainsKey(key);
}
internal void Clear(KeyboardInputMode mode)
{
GetPressedKeys(mode).Clear();
} }
public void Clear() public void Clear()
{ {
_pressedKeys.Clear(); _semanticPressedKeys.Clear();
_physicalPressedKeys.Clear();
}
private Dictionary<Key, int> GetPressedKeys(KeyboardInputMode mode)
{
return mode == KeyboardInputMode.Physical ? _physicalPressedKeys : _semanticPressedKeys;
}
private static void UpdateKeyState(Dictionary<Key, int> pressedKeys, Key key, bool isPressed)
{
if (key is Key.Unknown or Key.Unbound)
{
return;
}
if (isPressed)
{
if (pressedKeys.TryGetValue(key, out int count))
{
pressedKeys[key] = count + 1;
}
else
{
pressedKeys[key] = 1;
}
return;
}
if (pressedKeys.TryGetValue(key, out int currentCount))
{
if (currentCount <= 1)
{
pressedKeys.Remove(key);
}
else
{
pressedKeys[key] = currentCount - 1;
}
}
}
private static Key GetInputKey(KeyEventArgs args, KeyboardInputMode mode)
{
if (mode == KeyboardInputMode.Physical)
{
Key physicalKey = AvaloniaKeyboardMappingHelper.ToInputKey(args.PhysicalKey);
return physicalKey != Key.Unknown
? physicalKey
: AvaloniaKeyboardMappingHelper.ToInputKey(args.Key);
}
return AvaloniaKeyboardMappingHelper.ToInputKey(args.PhysicalKey, args.Key);
} }
public void Dispose() public void Dispose()

View File

@@ -13,6 +13,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Key = Ryujinx.Common.Configuration.Hid.Key;
using PhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
using RyuLogger = Ryujinx.Common.Logging.Logger; using RyuLogger = Ryujinx.Common.Logging.Logger;
namespace Ryujinx.Ava.Systems.Configuration namespace Ryujinx.Ava.Systems.Configuration
@@ -269,45 +271,45 @@ namespace Ryujinx.Ava.Systems.Configuration
Id = "0", Id = "0",
PlayerIndex = PlayerIndex.Player1, PlayerIndex = PlayerIndex.Player1,
ControllerType = ControllerType.ProController, ControllerType = ControllerType.ProController,
LeftJoycon = new LeftJoyconCommonConfig<Key> LeftJoycon = new LeftJoyconCommonConfig<PhysicalKey>
{ {
DpadUp = Key.Up, DpadUp = PhysicalKey.Up,
DpadDown = Key.Down, DpadDown = PhysicalKey.Down,
DpadLeft = Key.Left, DpadLeft = PhysicalKey.Left,
DpadRight = Key.Right, DpadRight = PhysicalKey.Right,
ButtonMinus = Key.Minus, ButtonMinus = PhysicalKey.Minus,
ButtonL = Key.E, ButtonL = PhysicalKey.E,
ButtonZl = Key.Q, ButtonZl = PhysicalKey.Q,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.W, StickUp = PhysicalKey.W,
StickDown = Key.S, StickDown = PhysicalKey.S,
StickLeft = Key.A, StickLeft = PhysicalKey.A,
StickRight = Key.D, StickRight = PhysicalKey.D,
StickButton = Key.F, StickButton = PhysicalKey.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<PhysicalKey>
{ {
ButtonA = Key.Z, ButtonA = PhysicalKey.Z,
ButtonB = Key.X, ButtonB = PhysicalKey.X,
ButtonX = Key.C, ButtonX = PhysicalKey.C,
ButtonY = Key.V, ButtonY = PhysicalKey.V,
ButtonPlus = Key.Plus, ButtonPlus = PhysicalKey.Plus,
ButtonR = Key.U, ButtonR = PhysicalKey.U,
ButtonZr = Key.O, ButtonZr = PhysicalKey.O,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.I, StickUp = PhysicalKey.I,
StickDown = Key.K, StickDown = PhysicalKey.K,
StickLeft = Key.J, StickLeft = PhysicalKey.J,
StickRight = Key.L, StickRight = PhysicalKey.L,
StickButton = Key.H, StickButton = PhysicalKey.H,
}, },
} }
]; ];

View File

@@ -8,6 +8,8 @@ using Ryujinx.Graphics.Vulkan;
using Ryujinx.HLE; using Ryujinx.HLE;
using System; using System;
using System.Linq; using System.Linq;
using Key = Ryujinx.Common.Configuration.Hid.Key;
using PhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Ava.Systems.Configuration namespace Ryujinx.Ava.Systems.Configuration
{ {
@@ -285,45 +287,45 @@ namespace Ryujinx.Ava.Systems.Configuration
Name = "Keyboard", Name = "Keyboard",
PlayerIndex = PlayerIndex.Player1, PlayerIndex = PlayerIndex.Player1,
ControllerType = ControllerType.ProController, ControllerType = ControllerType.ProController,
LeftJoycon = new LeftJoyconCommonConfig<Key> LeftJoycon = new LeftJoyconCommonConfig<PhysicalKey>
{ {
DpadUp = Key.Up, DpadUp = PhysicalKey.Up,
DpadDown = Key.Down, DpadDown = PhysicalKey.Down,
DpadLeft = Key.Left, DpadLeft = PhysicalKey.Left,
DpadRight = Key.Right, DpadRight = PhysicalKey.Right,
ButtonMinus = Key.Minus, ButtonMinus = PhysicalKey.Minus,
ButtonL = Key.E, ButtonL = PhysicalKey.E,
ButtonZl = Key.Q, ButtonZl = PhysicalKey.Q,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.W, StickUp = PhysicalKey.W,
StickDown = Key.S, StickDown = PhysicalKey.S,
StickLeft = Key.A, StickLeft = PhysicalKey.A,
StickRight = Key.D, StickRight = PhysicalKey.D,
StickButton = Key.F, StickButton = PhysicalKey.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<PhysicalKey>
{ {
ButtonA = Key.Z, ButtonA = PhysicalKey.Z,
ButtonB = Key.X, ButtonB = PhysicalKey.X,
ButtonX = Key.C, ButtonX = PhysicalKey.C,
ButtonY = Key.V, ButtonY = PhysicalKey.V,
ButtonPlus = Key.Plus, ButtonPlus = PhysicalKey.Plus,
ButtonR = Key.U, ButtonR = PhysicalKey.U,
ButtonZr = Key.O, ButtonZr = PhysicalKey.O,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.I, StickUp = PhysicalKey.I,
StickDown = Key.K, StickDown = PhysicalKey.K,
StickLeft = Key.J, StickLeft = PhysicalKey.J,
StickRight = Key.L, StickRight = PhysicalKey.L,
StickButton = Key.H, StickButton = PhysicalKey.H,
}, },
} }
]; ];

View File

@@ -151,6 +151,9 @@ namespace Ryujinx.Ava.UI.Helpers
keyString = key.ToString(); keyString = key.ToString();
} }
break;
case PhysicalKey physicalKey:
keyString = PhysicalKeyLabelHelper.GetString(physicalKey);
break; break;
case GamepadInputId gamepadInputId: case GamepadInputId gamepadInputId:
if (_gamepadInputIdMap.TryGetValue(gamepadInputId, out localeKey)) if (_gamepadInputIdMap.TryGetValue(gamepadInputId, out localeKey))

View File

@@ -0,0 +1,131 @@
using Avalonia.Input;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Input;
using Ryujinx.Common.Configuration.Hid;
using System;
using System.Collections.Generic;
using AvaPhysicalKey = Avalonia.Input.PhysicalKey;
using ConfigPhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
using InputKey = Ryujinx.Input.Key;
namespace Ryujinx.Ava.UI.Helpers
{
internal static class PhysicalKeyLabelHelper
{
private static readonly Dictionary<ConfigPhysicalKey, LocaleKeys> _localizedKeysMap = new()
{
[ConfigPhysicalKey.Unknown] = LocaleKeys.KeyboardLayout_KeyUnknown,
[ConfigPhysicalKey.ShiftLeft] = LocaleKeys.KeyboardLayout_KeyShiftLeft,
[ConfigPhysicalKey.ShiftRight] = LocaleKeys.KeyboardLayout_KeyShiftRight,
[ConfigPhysicalKey.ControlLeft] = LocaleKeys.KeyboardLayout_KeyControlLeft,
[ConfigPhysicalKey.ControlRight] = LocaleKeys.KeyboardLayout_KeyControlRight,
[ConfigPhysicalKey.AltLeft] = LocaleKeys.KeyboardLayout_KeyAltLeft,
[ConfigPhysicalKey.AltRight] = LocaleKeys.KeyboardLayout_KeyAltRight,
[ConfigPhysicalKey.WinLeft] = LocaleKeys.KeyboardLayout_KeyWinLeft,
[ConfigPhysicalKey.WinRight] = LocaleKeys.KeyboardLayout_KeyWinRight,
[ConfigPhysicalKey.Up] = LocaleKeys.KeyboardLayout_KeyUp,
[ConfigPhysicalKey.Down] = LocaleKeys.KeyboardLayout_KeyDown,
[ConfigPhysicalKey.Left] = LocaleKeys.KeyboardLayout_KeyLeft,
[ConfigPhysicalKey.Right] = LocaleKeys.KeyboardLayout_KeyRight,
[ConfigPhysicalKey.Enter] = LocaleKeys.KeyboardLayout_KeyEnter,
[ConfigPhysicalKey.Escape] = LocaleKeys.KeyboardLayout_KeyEscape,
[ConfigPhysicalKey.Space] = LocaleKeys.KeyboardLayout_KeySpace,
[ConfigPhysicalKey.Tab] = LocaleKeys.KeyboardLayout_KeyTab,
[ConfigPhysicalKey.BackSpace] = LocaleKeys.KeyboardLayout_KeyBackSpace,
[ConfigPhysicalKey.Insert] = LocaleKeys.KeyboardLayout_KeyInsert,
[ConfigPhysicalKey.Delete] = LocaleKeys.KeyboardLayout_KeyDelete,
[ConfigPhysicalKey.PageUp] = LocaleKeys.KeyboardLayout_KeyPageUp,
[ConfigPhysicalKey.PageDown] = LocaleKeys.KeyboardLayout_KeyPageDown,
[ConfigPhysicalKey.Home] = LocaleKeys.KeyboardLayout_KeyHome,
[ConfigPhysicalKey.End] = LocaleKeys.KeyboardLayout_KeyEnd,
[ConfigPhysicalKey.CapsLock] = LocaleKeys.KeyboardLayout_KeyCapsLock,
[ConfigPhysicalKey.ScrollLock] = LocaleKeys.KeyboardLayout_KeyScrollLock,
[ConfigPhysicalKey.PrintScreen] = LocaleKeys.KeyboardLayout_KeyPrintScreen,
[ConfigPhysicalKey.Pause] = LocaleKeys.KeyboardLayout_KeyPause,
[ConfigPhysicalKey.NumLock] = LocaleKeys.KeyboardLayout_KeyNumLock,
[ConfigPhysicalKey.Clear] = LocaleKeys.KeyboardLayout_KeyClear,
[ConfigPhysicalKey.Keypad0] = LocaleKeys.KeyboardLayout_KeyKeypad0,
[ConfigPhysicalKey.Keypad1] = LocaleKeys.KeyboardLayout_KeyKeypad1,
[ConfigPhysicalKey.Keypad2] = LocaleKeys.KeyboardLayout_KeyKeypad2,
[ConfigPhysicalKey.Keypad3] = LocaleKeys.KeyboardLayout_KeyKeypad3,
[ConfigPhysicalKey.Keypad4] = LocaleKeys.KeyboardLayout_KeyKeypad4,
[ConfigPhysicalKey.Keypad5] = LocaleKeys.KeyboardLayout_KeyKeypad5,
[ConfigPhysicalKey.Keypad6] = LocaleKeys.KeyboardLayout_KeyKeypad6,
[ConfigPhysicalKey.Keypad7] = LocaleKeys.KeyboardLayout_KeyKeypad7,
[ConfigPhysicalKey.Keypad8] = LocaleKeys.KeyboardLayout_KeyKeypad8,
[ConfigPhysicalKey.Keypad9] = LocaleKeys.KeyboardLayout_KeyKeypad9,
[ConfigPhysicalKey.KeypadDivide] = LocaleKeys.KeyboardLayout_KeyKeypadDivide,
[ConfigPhysicalKey.KeypadMultiply] = LocaleKeys.KeyboardLayout_KeyKeypadMultiply,
[ConfigPhysicalKey.KeypadSubtract] = LocaleKeys.KeyboardLayout_KeyKeypadSubtract,
[ConfigPhysicalKey.KeypadAdd] = LocaleKeys.KeyboardLayout_KeyKeypadAdd,
[ConfigPhysicalKey.KeypadDecimal] = LocaleKeys.KeyboardLayout_KeyKeypadDecimal,
[ConfigPhysicalKey.KeypadEnter] = LocaleKeys.KeyboardLayout_KeyKeypadEnter,
[ConfigPhysicalKey.Unbound] = LocaleKeys.KeyboardLayout_KeyUnbound,
};
public static string GetString(ConfigPhysicalKey key)
{
if (_localizedKeysMap.TryGetValue(key, out LocaleKeys localeKey))
{
return GetLocalizedString(localeKey);
}
if (TryGetPrintableKeySymbol(key, out string label))
{
return label;
}
return key.ToString();
}
private static bool TryGetPrintableKeySymbol(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)
{
label = "<>";
return true;
}
if (!AvaloniaKeyboardMappingHelper.TryGetAvaPhysicalKey((InputKey)(int)key, out AvaPhysicalKey avaPhysicalKey))
{
label = string.Empty;
return false;
}
label = PhysicalKeyExtensions.ToQwertyKeySymbol(avaPhysicalKey, false);
if (string.IsNullOrEmpty(label) || label.Length != 1 || char.IsControl(label[0]))
{
label = string.Empty;
return false;
}
if (char.IsLetter(label[0]))
{
label = char.ToUpperInvariant(label[0]).ToString();
}
return true;
}
private static string GetLocalizedString(LocaleKeys localeKey)
{
if (OperatingSystem.IsMacOS())
{
localeKey = localeKey switch
{
LocaleKeys.KeyboardLayout_KeyControlLeft => LocaleKeys.KeyboardLayout_KeyMacControlLeft,
LocaleKeys.KeyboardLayout_KeyControlRight => LocaleKeys.KeyboardLayout_KeyMacControlRight,
LocaleKeys.KeyboardLayout_KeyAltLeft => LocaleKeys.KeyboardLayout_KeyMacAltLeft,
LocaleKeys.KeyboardLayout_KeyAltRight => LocaleKeys.KeyboardLayout_KeyMacAltRight,
LocaleKeys.KeyboardLayout_KeyWinLeft => LocaleKeys.KeyboardLayout_KeyMacWinLeft,
LocaleKeys.KeyboardLayout_KeyWinRight => LocaleKeys.KeyboardLayout_KeyMacWinRight,
_ => localeKey
};
}
return LocaleManager.Instance[localeKey];
}
}
}

View File

@@ -13,88 +13,88 @@ namespace Ryujinx.Ava.UI.Models.Input
public PlayerIndex PlayerIndex { get; set; } public PlayerIndex PlayerIndex { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftStickUp { get; set; } public partial PhysicalKey LeftStickUp { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftStickDown { get; set; } public partial PhysicalKey LeftStickDown { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftStickLeft { get; set; } public partial PhysicalKey LeftStickLeft { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftStickRight { get; set; } public partial PhysicalKey LeftStickRight { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftStickButton { get; set; } public partial PhysicalKey LeftStickButton { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightStickUp { get; set; } public partial PhysicalKey RightStickUp { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightStickDown { get; set; } public partial PhysicalKey RightStickDown { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightStickLeft { get; set; } public partial PhysicalKey RightStickLeft { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightStickRight { get; set; } public partial PhysicalKey RightStickRight { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightStickButton { get; set; } public partial PhysicalKey RightStickButton { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key DpadUp { get; set; } public partial PhysicalKey DpadUp { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key DpadDown { get; set; } public partial PhysicalKey DpadDown { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key DpadLeft { get; set; } public partial PhysicalKey DpadLeft { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key DpadRight { get; set; } public partial PhysicalKey DpadRight { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonMinus { get; set; } public partial PhysicalKey ButtonMinus { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonPlus { get; set; } public partial PhysicalKey ButtonPlus { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonA { get; set; } public partial PhysicalKey ButtonA { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonB { get; set; } public partial PhysicalKey ButtonB { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonX { get; set; } public partial PhysicalKey ButtonX { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonY { get; set; } public partial PhysicalKey ButtonY { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonL { get; set; } public partial PhysicalKey ButtonL { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonR { get; set; } public partial PhysicalKey ButtonR { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonZl { get; set; } public partial PhysicalKey ButtonZl { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key ButtonZr { get; set; } public partial PhysicalKey ButtonZr { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftButtonSl { get; set; } public partial PhysicalKey LeftButtonSl { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key LeftButtonSr { get; set; } public partial PhysicalKey LeftButtonSr { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightButtonSl { get; set; } public partial PhysicalKey RightButtonSl { get; set; }
[ObservableProperty] [ObservableProperty]
public partial Key RightButtonSr { get; set; } public partial PhysicalKey RightButtonSr { get; set; }
public KeyboardInputConfig(InputConfig config) public KeyboardInputConfig(InputConfig config)
{ {
@@ -153,7 +153,7 @@ namespace Ryujinx.Ava.UI.Models.Input
Backend = InputBackendType.WindowKeyboard, Backend = InputBackendType.WindowKeyboard,
PlayerIndex = PlayerIndex, PlayerIndex = PlayerIndex,
ControllerType = ControllerType, ControllerType = ControllerType,
LeftJoycon = new LeftJoyconCommonConfig<Key> LeftJoycon = new LeftJoyconCommonConfig<PhysicalKey>
{ {
DpadUp = DpadUp, DpadUp = DpadUp,
DpadDown = DpadDown, DpadDown = DpadDown,
@@ -165,7 +165,7 @@ namespace Ryujinx.Ava.UI.Models.Input
ButtonSl = LeftButtonSl, ButtonSl = LeftButtonSl,
ButtonSr = LeftButtonSr, ButtonSr = LeftButtonSr,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<PhysicalKey>
{ {
ButtonA = ButtonA, ButtonA = ButtonA,
ButtonB = ButtonB, ButtonB = ButtonB,
@@ -177,7 +177,7 @@ namespace Ryujinx.Ava.UI.Models.Input
ButtonR = ButtonR, ButtonR = ButtonR,
ButtonZr = ButtonZr, ButtonZr = ButtonZr,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = LeftStickUp, StickUp = LeftStickUp,
StickDown = LeftStickDown, StickDown = LeftStickDown,
@@ -185,7 +185,7 @@ namespace Ryujinx.Ava.UI.Models.Input
StickLeft = LeftStickLeft, StickLeft = LeftStickLeft,
StickButton = LeftStickButton, StickButton = LeftStickButton,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = RightStickUp, StickUp = RightStickUp,
StickDown = RightStickDown, StickDown = RightStickDown,

View File

@@ -154,42 +154,42 @@ namespace Ryujinx.Ava.UI.Models.Input
{ {
KeyboardStateSnapshot snapshot = keyboard.GetKeyboardStateSnapshot(); KeyboardStateSnapshot snapshot = keyboard.GetKeyboardStateSnapshot();
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickRight)) if (snapshot.IsPressed(KeyboardConfig.LeftStickRight.ToInputKey()))
{ {
leftBuffer.Item1 += 1; leftBuffer.Item1 += 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickLeft)) if (snapshot.IsPressed(KeyboardConfig.LeftStickLeft.ToInputKey()))
{ {
leftBuffer.Item1 -= 1; leftBuffer.Item1 -= 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickUp)) if (snapshot.IsPressed(KeyboardConfig.LeftStickUp.ToInputKey()))
{ {
leftBuffer.Item2 += 1; leftBuffer.Item2 += 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickDown)) if (snapshot.IsPressed(KeyboardConfig.LeftStickDown.ToInputKey()))
{ {
leftBuffer.Item2 -= 1; leftBuffer.Item2 -= 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickRight)) if (snapshot.IsPressed(KeyboardConfig.RightStickRight.ToInputKey()))
{ {
rightBuffer.Item1 += 1; rightBuffer.Item1 += 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickLeft)) if (snapshot.IsPressed(KeyboardConfig.RightStickLeft.ToInputKey()))
{ {
rightBuffer.Item1 -= 1; rightBuffer.Item1 -= 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickUp)) if (snapshot.IsPressed(KeyboardConfig.RightStickUp.ToInputKey()))
{ {
rightBuffer.Item2 += 1; rightBuffer.Item2 += 1;
} }
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickDown)) if (snapshot.IsPressed(KeyboardConfig.RightStickDown.ToInputKey()))
{ {
rightBuffer.Item2 -= 1; rightBuffer.Item2 -= 1;
} }

View File

@@ -28,7 +28,7 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
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 Key = Ryujinx.Common.Configuration.Hid.Key; using PhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Ava.UI.ViewModels.Input namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
@@ -290,7 +290,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
_mainWindow = RyujinxApp.MainWindow; _mainWindow = RyujinxApp.MainWindow;
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner); AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner, KeyboardInputMode.Physical);
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected; _mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected; _mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
@@ -677,46 +677,46 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
Id = id, Id = id,
Name = name, Name = name,
ControllerType = ControllerType.ProController, ControllerType = ControllerType.ProController,
LeftJoycon = new LeftJoyconCommonConfig<Key> LeftJoycon = new LeftJoyconCommonConfig<PhysicalKey>
{ {
DpadUp = Key.Up, DpadUp = PhysicalKey.Up,
DpadDown = Key.Down, DpadDown = PhysicalKey.Down,
DpadLeft = Key.Left, DpadLeft = PhysicalKey.Left,
DpadRight = Key.Right, DpadRight = PhysicalKey.Right,
ButtonMinus = Key.Minus, ButtonMinus = PhysicalKey.Minus,
ButtonL = Key.E, ButtonL = PhysicalKey.E,
ButtonZl = Key.Q, ButtonZl = PhysicalKey.Q,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
LeftJoyconStick = LeftJoyconStick =
new JoyconConfigKeyboardStick<Key> new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.W, StickUp = PhysicalKey.W,
StickDown = Key.S, StickDown = PhysicalKey.S,
StickLeft = Key.A, StickLeft = PhysicalKey.A,
StickRight = Key.D, StickRight = PhysicalKey.D,
StickButton = Key.F, StickButton = PhysicalKey.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<PhysicalKey>
{ {
ButtonA = Key.Z, ButtonA = PhysicalKey.Z,
ButtonB = Key.X, ButtonB = PhysicalKey.X,
ButtonX = Key.C, ButtonX = PhysicalKey.C,
ButtonY = Key.V, ButtonY = PhysicalKey.V,
ButtonPlus = Key.Plus, ButtonPlus = PhysicalKey.Plus,
ButtonR = Key.U, ButtonR = PhysicalKey.U,
ButtonZr = Key.O, ButtonZr = PhysicalKey.O,
ButtonSl = Key.Unbound, ButtonSl = PhysicalKey.Unbound,
ButtonSr = Key.Unbound, ButtonSr = PhysicalKey.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<PhysicalKey>
{ {
StickUp = Key.I, StickUp = PhysicalKey.I,
StickDown = Key.K, StickDown = PhysicalKey.K,
StickLeft = Key.J, StickLeft = PhysicalKey.J,
StickRight = Key.L, StickRight = PhysicalKey.L,
StickButton = Key.H, StickButton = PhysicalKey.H,
}, },
}; };
} }

View File

@@ -12,7 +12,7 @@ using Ryujinx.Input.Assigner;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Button = Ryujinx.Input.Button; using Button = Ryujinx.Input.Button;
using Key = Ryujinx.Common.Configuration.Hid.Key; using PhysicalKey = Ryujinx.Common.Configuration.Hid.PhysicalKey;
namespace Ryujinx.Ava.UI.Views.Input namespace Ryujinx.Ava.UI.Views.Input
{ {
@@ -78,88 +78,88 @@ namespace Ryujinx.Ava.UI.Views.Input
switch (button.Name) switch (button.Name)
{ {
case "ButtonZl": case "ButtonZl":
ViewModel.Config.ButtonZl = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonZl = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonL": case "ButtonL":
ViewModel.Config.ButtonL = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonL = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonMinus": case "ButtonMinus":
ViewModel.Config.ButtonMinus = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonMinus = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftStickButton": case "LeftStickButton":
ViewModel.Config.LeftStickButton = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftStickButton = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftStickUp": case "LeftStickUp":
ViewModel.Config.LeftStickUp = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftStickUp = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftStickDown": case "LeftStickDown":
ViewModel.Config.LeftStickDown = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftStickDown = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftStickRight": case "LeftStickRight":
ViewModel.Config.LeftStickRight = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftStickRight = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftStickLeft": case "LeftStickLeft":
ViewModel.Config.LeftStickLeft = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftStickLeft = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "DpadUp": case "DpadUp":
ViewModel.Config.DpadUp = buttonValue.AsHidType<Key>(); ViewModel.Config.DpadUp = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "DpadDown": case "DpadDown":
ViewModel.Config.DpadDown = buttonValue.AsHidType<Key>(); ViewModel.Config.DpadDown = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "DpadLeft": case "DpadLeft":
ViewModel.Config.DpadLeft = buttonValue.AsHidType<Key>(); ViewModel.Config.DpadLeft = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "DpadRight": case "DpadRight":
ViewModel.Config.DpadRight = buttonValue.AsHidType<Key>(); ViewModel.Config.DpadRight = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftButtonSr": case "LeftButtonSr":
ViewModel.Config.LeftButtonSr = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftButtonSr = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "LeftButtonSl": case "LeftButtonSl":
ViewModel.Config.LeftButtonSl = buttonValue.AsHidType<Key>(); ViewModel.Config.LeftButtonSl = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightButtonSr": case "RightButtonSr":
ViewModel.Config.RightButtonSr = buttonValue.AsHidType<Key>(); ViewModel.Config.RightButtonSr = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightButtonSl": case "RightButtonSl":
ViewModel.Config.RightButtonSl = buttonValue.AsHidType<Key>(); ViewModel.Config.RightButtonSl = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonZr": case "ButtonZr":
ViewModel.Config.ButtonZr = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonZr = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonR": case "ButtonR":
ViewModel.Config.ButtonR = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonR = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonPlus": case "ButtonPlus":
ViewModel.Config.ButtonPlus = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonPlus = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonA": case "ButtonA":
ViewModel.Config.ButtonA = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonA = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonB": case "ButtonB":
ViewModel.Config.ButtonB = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonB = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonX": case "ButtonX":
ViewModel.Config.ButtonX = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonX = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "ButtonY": case "ButtonY":
ViewModel.Config.ButtonY = buttonValue.AsHidType<Key>(); ViewModel.Config.ButtonY = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightStickButton": case "RightStickButton":
ViewModel.Config.RightStickButton = buttonValue.AsHidType<Key>(); ViewModel.Config.RightStickButton = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightStickUp": case "RightStickUp":
ViewModel.Config.RightStickUp = buttonValue.AsHidType<Key>(); ViewModel.Config.RightStickUp = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightStickDown": case "RightStickDown":
ViewModel.Config.RightStickDown = buttonValue.AsHidType<Key>(); ViewModel.Config.RightStickDown = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightStickRight": case "RightStickRight":
ViewModel.Config.RightStickRight = buttonValue.AsHidType<Key>(); ViewModel.Config.RightStickRight = buttonValue.AsHidType<PhysicalKey>();
break; break;
case "RightStickLeft": case "RightStickLeft":
ViewModel.Config.RightStickLeft = buttonValue.AsHidType<Key>(); ViewModel.Config.RightStickLeft = buttonValue.AsHidType<PhysicalKey>();
break; break;
} }
} }
@@ -207,34 +207,34 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
Dictionary<string, Action> buttonActions = new() Dictionary<string, Action> buttonActions = new()
{ {
{ "ButtonZl", () => ViewModel.Config.ButtonZl = Key.Unbound }, { "ButtonZl", () => ViewModel.Config.ButtonZl = PhysicalKey.Unbound },
{ "ButtonL", () => ViewModel.Config.ButtonL = Key.Unbound }, { "ButtonL", () => ViewModel.Config.ButtonL = PhysicalKey.Unbound },
{ "ButtonMinus", () => ViewModel.Config.ButtonMinus = Key.Unbound }, { "ButtonMinus", () => ViewModel.Config.ButtonMinus = PhysicalKey.Unbound },
{ "LeftStickButton", () => ViewModel.Config.LeftStickButton = Key.Unbound }, { "LeftStickButton", () => ViewModel.Config.LeftStickButton = PhysicalKey.Unbound },
{ "LeftStickUp", () => ViewModel.Config.LeftStickUp = Key.Unbound }, { "LeftStickUp", () => ViewModel.Config.LeftStickUp = PhysicalKey.Unbound },
{ "LeftStickDown", () => ViewModel.Config.LeftStickDown = Key.Unbound }, { "LeftStickDown", () => ViewModel.Config.LeftStickDown = PhysicalKey.Unbound },
{ "LeftStickRight", () => ViewModel.Config.LeftStickRight = Key.Unbound }, { "LeftStickRight", () => ViewModel.Config.LeftStickRight = PhysicalKey.Unbound },
{ "LeftStickLeft", () => ViewModel.Config.LeftStickLeft = Key.Unbound }, { "LeftStickLeft", () => ViewModel.Config.LeftStickLeft = PhysicalKey.Unbound },
{ "DpadUp", () => ViewModel.Config.DpadUp = Key.Unbound }, { "DpadUp", () => ViewModel.Config.DpadUp = PhysicalKey.Unbound },
{ "DpadDown", () => ViewModel.Config.DpadDown = Key.Unbound }, { "DpadDown", () => ViewModel.Config.DpadDown = PhysicalKey.Unbound },
{ "DpadLeft", () => ViewModel.Config.DpadLeft = Key.Unbound }, { "DpadLeft", () => ViewModel.Config.DpadLeft = PhysicalKey.Unbound },
{ "DpadRight", () => ViewModel.Config.DpadRight = Key.Unbound }, { "DpadRight", () => ViewModel.Config.DpadRight = PhysicalKey.Unbound },
{ "LeftButtonSr", () => ViewModel.Config.LeftButtonSr = Key.Unbound }, { "LeftButtonSr", () => ViewModel.Config.LeftButtonSr = PhysicalKey.Unbound },
{ "LeftButtonSl", () => ViewModel.Config.LeftButtonSl = Key.Unbound }, { "LeftButtonSl", () => ViewModel.Config.LeftButtonSl = PhysicalKey.Unbound },
{ "RightButtonSr", () => ViewModel.Config.RightButtonSr = Key.Unbound }, { "RightButtonSr", () => ViewModel.Config.RightButtonSr = PhysicalKey.Unbound },
{ "RightButtonSl", () => ViewModel.Config.RightButtonSl = Key.Unbound }, { "RightButtonSl", () => ViewModel.Config.RightButtonSl = PhysicalKey.Unbound },
{ "ButtonZr", () => ViewModel.Config.ButtonZr = Key.Unbound }, { "ButtonZr", () => ViewModel.Config.ButtonZr = PhysicalKey.Unbound },
{ "ButtonR", () => ViewModel.Config.ButtonR = Key.Unbound }, { "ButtonR", () => ViewModel.Config.ButtonR = PhysicalKey.Unbound },
{ "ButtonPlus", () => ViewModel.Config.ButtonPlus = Key.Unbound }, { "ButtonPlus", () => ViewModel.Config.ButtonPlus = PhysicalKey.Unbound },
{ "ButtonA", () => ViewModel.Config.ButtonA = Key.Unbound }, { "ButtonA", () => ViewModel.Config.ButtonA = PhysicalKey.Unbound },
{ "ButtonB", () => ViewModel.Config.ButtonB = Key.Unbound }, { "ButtonB", () => ViewModel.Config.ButtonB = PhysicalKey.Unbound },
{ "ButtonX", () => ViewModel.Config.ButtonX = Key.Unbound }, { "ButtonX", () => ViewModel.Config.ButtonX = PhysicalKey.Unbound },
{ "ButtonY", () => ViewModel.Config.ButtonY = Key.Unbound }, { "ButtonY", () => ViewModel.Config.ButtonY = PhysicalKey.Unbound },
{ "RightStickButton", () => ViewModel.Config.RightStickButton = Key.Unbound }, { "RightStickButton", () => ViewModel.Config.RightStickButton = PhysicalKey.Unbound },
{ "RightStickUp", () => ViewModel.Config.RightStickUp = Key.Unbound }, { "RightStickUp", () => ViewModel.Config.RightStickUp = PhysicalKey.Unbound },
{ "RightStickDown", () => ViewModel.Config.RightStickDown = Key.Unbound }, { "RightStickDown", () => ViewModel.Config.RightStickDown = PhysicalKey.Unbound },
{ "RightStickRight", () => ViewModel.Config.RightStickRight = Key.Unbound }, { "RightStickRight", () => ViewModel.Config.RightStickRight = PhysicalKey.Unbound },
{ "RightStickLeft", () => ViewModel.Config.RightStickLeft = Key.Unbound } { "RightStickLeft", () => ViewModel.Config.RightStickLeft = PhysicalKey.Unbound }
}; };
if (buttonActions.TryGetValue(_currentAssigner.ToggledButton.Name, out Action action)) if (buttonActions.TryGetValue(_currentAssigner.ToggledButton.Name, out Action action))

View File

@@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
} }
} }
_avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this); _avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this, KeyboardInputMode.Semantic);
} }
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)

View File

@@ -30,6 +30,7 @@ using Ryujinx.HLE.HOS;
using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.Input.HLE; using Ryujinx.Input.HLE;
using Ryujinx.Input.SDL3; using Ryujinx.Input.SDL3;
using Ryujinx.Input;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -105,7 +106,7 @@ namespace Ryujinx.Ava.UI.Windows
if (Program.PreviewerDetached) if (Program.PreviewerDetached)
{ {
InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL3GamepadDriver()); InputManager = new InputManager(new AvaloniaKeyboardDriver(this, KeyboardInputMode.Semantic), new SDL3GamepadDriver());
_ = this.GetObservable(IsActiveProperty).Subscribe(it => ViewModel.IsActive = it); _ = this.GetObservable(IsActiveProperty).Subscribe(it => ViewModel.IsActive = it);
this.ScalingChanged += OnScalingChanged; this.ScalingChanged += OnScalingChanged;