mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-10 12:49:13 +00:00
Use generic conversion method
This commit is contained in:
parent
0f6ed5a53a
commit
584fc555fe
5 changed files with 71 additions and 81 deletions
|
@ -9,6 +9,7 @@ using Ryujinx.Ava.UI.ViewModels.Input;
|
|||
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Input
|
||||
{
|
||||
|
@ -74,70 +75,70 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|||
switch (button.Name)
|
||||
{
|
||||
case "ButtonZl":
|
||||
viewModel.Config.ButtonZl = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonZl = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonL":
|
||||
viewModel.Config.ButtonL = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonL = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonMinus":
|
||||
viewModel.Config.ButtonMinus = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonMinus = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "LeftStickButton":
|
||||
viewModel.Config.LeftStickButton = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.LeftStickButton = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "LeftJoystick":
|
||||
viewModel.Config.LeftJoystick = buttonValue.AsGamepadStickId();
|
||||
viewModel.Config.LeftJoystick = buttonValue.AsHidType<StickInputId>();
|
||||
break;
|
||||
case "DpadUp":
|
||||
viewModel.Config.DpadUp = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.DpadUp = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "DpadDown":
|
||||
viewModel.Config.DpadDown = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.DpadDown = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "DpadLeft":
|
||||
viewModel.Config.DpadLeft = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.DpadLeft = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "DpadRight":
|
||||
viewModel.Config.DpadRight = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.DpadRight = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "LeftButtonSr":
|
||||
viewModel.Config.LeftButtonSr = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.LeftButtonSr = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "LeftButtonSl":
|
||||
viewModel.Config.LeftButtonSl = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.LeftButtonSl = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "RightButtonSr":
|
||||
viewModel.Config.RightButtonSr = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.RightButtonSr = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "RightButtonSl":
|
||||
viewModel.Config.RightButtonSl = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.RightButtonSl = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonZr":
|
||||
viewModel.Config.ButtonZr = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonZr = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonR":
|
||||
viewModel.Config.ButtonR = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonR = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonPlus":
|
||||
viewModel.Config.ButtonPlus = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonPlus = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonA":
|
||||
viewModel.Config.ButtonA = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonA = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonB":
|
||||
viewModel.Config.ButtonB = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonB = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonX":
|
||||
viewModel.Config.ButtonX = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonX = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "ButtonY":
|
||||
viewModel.Config.ButtonY = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.ButtonY = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "RightStickButton":
|
||||
viewModel.Config.RightStickButton = buttonValue.AsGamepadButtonInputId();
|
||||
viewModel.Config.RightStickButton = buttonValue.AsHidType<GamepadInputId>();
|
||||
break;
|
||||
case "RightJoystick":
|
||||
viewModel.Config.RightJoystick = buttonValue.AsGamepadStickId();
|
||||
viewModel.Config.RightJoystick = buttonValue.AsHidType<StickInputId>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers;
|
|||
using Ryujinx.Ava.UI.ViewModels.Input;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Input
|
||||
{
|
||||
|
@ -71,88 +72,88 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|||
switch (button.Name)
|
||||
{
|
||||
case "ButtonZl":
|
||||
viewModel.Config.ButtonZl = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonZl = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonL":
|
||||
viewModel.Config.ButtonL = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonL = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonMinus":
|
||||
viewModel.Config.ButtonMinus = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonMinus = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftStickButton":
|
||||
viewModel.Config.LeftStickButton = buttonValue.AsKey();
|
||||
viewModel.Config.LeftStickButton = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftStickUp":
|
||||
viewModel.Config.LeftStickUp = buttonValue.AsKey();
|
||||
viewModel.Config.LeftStickUp = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftStickDown":
|
||||
viewModel.Config.LeftStickDown = buttonValue.AsKey();
|
||||
viewModel.Config.LeftStickDown = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftStickRight":
|
||||
viewModel.Config.LeftStickRight = buttonValue.AsKey();
|
||||
viewModel.Config.LeftStickRight = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftStickLeft":
|
||||
viewModel.Config.LeftStickLeft = buttonValue.AsKey();
|
||||
viewModel.Config.LeftStickLeft = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "DpadUp":
|
||||
viewModel.Config.DpadUp = buttonValue.AsKey();
|
||||
viewModel.Config.DpadUp = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "DpadDown":
|
||||
viewModel.Config.DpadDown = buttonValue.AsKey();
|
||||
viewModel.Config.DpadDown = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "DpadLeft":
|
||||
viewModel.Config.DpadLeft = buttonValue.AsKey();
|
||||
viewModel.Config.DpadLeft = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "DpadRight":
|
||||
viewModel.Config.DpadRight = buttonValue.AsKey();
|
||||
viewModel.Config.DpadRight = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftButtonSr":
|
||||
viewModel.Config.LeftButtonSr = buttonValue.AsKey();
|
||||
viewModel.Config.LeftButtonSr = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "LeftButtonSl":
|
||||
viewModel.Config.LeftButtonSl = buttonValue.AsKey();
|
||||
viewModel.Config.LeftButtonSl = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightButtonSr":
|
||||
viewModel.Config.RightButtonSr = buttonValue.AsKey();
|
||||
viewModel.Config.RightButtonSr = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightButtonSl":
|
||||
viewModel.Config.RightButtonSl = buttonValue.AsKey();
|
||||
viewModel.Config.RightButtonSl = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonZr":
|
||||
viewModel.Config.ButtonZr = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonZr = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonR":
|
||||
viewModel.Config.ButtonR = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonR = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonPlus":
|
||||
viewModel.Config.ButtonPlus = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonPlus = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonA":
|
||||
viewModel.Config.ButtonA = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonA = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonB":
|
||||
viewModel.Config.ButtonB = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonB = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonX":
|
||||
viewModel.Config.ButtonX = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonX = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ButtonY":
|
||||
viewModel.Config.ButtonY = buttonValue.AsKey();
|
||||
viewModel.Config.ButtonY = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightStickButton":
|
||||
viewModel.Config.RightStickButton = buttonValue.AsKey();
|
||||
viewModel.Config.RightStickButton = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightStickUp":
|
||||
viewModel.Config.RightStickUp = buttonValue.AsKey();
|
||||
viewModel.Config.RightStickUp = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightStickDown":
|
||||
viewModel.Config.RightStickDown = buttonValue.AsKey();
|
||||
viewModel.Config.RightStickDown = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightStickRight":
|
||||
viewModel.Config.RightStickRight = buttonValue.AsKey();
|
||||
viewModel.Config.RightStickRight = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "RightStickLeft":
|
||||
viewModel.Config.RightStickLeft = buttonValue.AsKey();
|
||||
viewModel.Config.RightStickLeft = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers;
|
|||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Settings
|
||||
{
|
||||
|
@ -81,31 +82,31 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||
switch (button.Name)
|
||||
{
|
||||
case "ToggleVsync":
|
||||
viewModel.KeyboardHotkeys.ToggleVsync = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.ToggleVsync = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "Screenshot":
|
||||
viewModel.KeyboardHotkeys.Screenshot = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.Screenshot = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ShowUI":
|
||||
viewModel.KeyboardHotkeys.ShowUI = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.ShowUI = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "Pause":
|
||||
viewModel.KeyboardHotkeys.Pause = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.Pause = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ToggleMute":
|
||||
viewModel.KeyboardHotkeys.ToggleMute = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.ToggleMute = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ResScaleUp":
|
||||
viewModel.KeyboardHotkeys.ResScaleUp = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.ResScaleUp = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "ResScaleDown":
|
||||
viewModel.KeyboardHotkeys.ResScaleDown = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.ResScaleDown = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "VolumeUp":
|
||||
viewModel.KeyboardHotkeys.VolumeUp = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.VolumeUp = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
case "VolumeDown":
|
||||
viewModel.KeyboardHotkeys.VolumeDown = buttonValue.AsKey();
|
||||
viewModel.KeyboardHotkeys.VolumeDown = buttonValue.AsHidType<Key>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Input
|
||||
{
|
||||
|
@ -27,22 +27,9 @@ namespace Ryujinx.Input
|
|||
_rawValue = (uint)stick;
|
||||
}
|
||||
|
||||
public Common.Configuration.Hid.Key AsKey()
|
||||
public T AsHidType<T>() where T : Enum
|
||||
{
|
||||
Debug.Assert(Type == ButtonValueType.Key);
|
||||
return (Common.Configuration.Hid.Key)_rawValue;
|
||||
}
|
||||
|
||||
public Common.Configuration.Hid.Controller.GamepadInputId AsGamepadButtonInputId()
|
||||
{
|
||||
Debug.Assert(Type == ButtonValueType.GamepadButtonInputId);
|
||||
return (Common.Configuration.Hid.Controller.GamepadInputId)_rawValue;
|
||||
}
|
||||
|
||||
public Common.Configuration.Hid.Controller.StickInputId AsGamepadStickId()
|
||||
{
|
||||
Debug.Assert(Type == ButtonValueType.StickId);
|
||||
return (Common.Configuration.Hid.Controller.StickInputId)_rawValue;
|
||||
return (T)Enum.ToObject(typeof(T), _rawValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,9 +123,9 @@ namespace Ryujinx.UI.Helper
|
|||
|
||||
if (buttonValue.Type == ButtonValueType.Key)
|
||||
{
|
||||
var key = buttonValue.AsKey();
|
||||
var key = buttonValue.AsHidType<Key>();
|
||||
|
||||
if (!_keysMap.TryGetValue(buttonValue.AsKey(), out keyString))
|
||||
if (!_keysMap.TryGetValue(buttonValue.AsHidType<Key>(), out keyString))
|
||||
{
|
||||
keyString = key.ToString();
|
||||
}
|
||||
|
@ -133,9 +133,9 @@ namespace Ryujinx.UI.Helper
|
|||
|
||||
if (buttonValue.Type == ButtonValueType.GamepadButtonInputId)
|
||||
{
|
||||
var gamepadButton = buttonValue.AsGamepadButtonInputId();
|
||||
var gamepadButton = buttonValue.AsHidType<GamepadInputId>();
|
||||
|
||||
if (!_gamepadInputIdMap.TryGetValue(buttonValue.AsGamepadButtonInputId(), out keyString))
|
||||
if (!_gamepadInputIdMap.TryGetValue(buttonValue.AsHidType<GamepadInputId>(), out keyString))
|
||||
{
|
||||
keyString = gamepadButton.ToString();
|
||||
}
|
||||
|
@ -143,9 +143,9 @@ namespace Ryujinx.UI.Helper
|
|||
|
||||
if (buttonValue.Type == ButtonValueType.StickId)
|
||||
{
|
||||
var stickInput = buttonValue.AsGamepadStickId();
|
||||
var stickInput = buttonValue.AsHidType<StickInputId>();
|
||||
|
||||
if (!_stickInputIdMap.TryGetValue(buttonValue.AsGamepadStickId(), out keyString))
|
||||
if (!_stickInputIdMap.TryGetValue(buttonValue.AsHidType<StickInputId>(), out keyString))
|
||||
{
|
||||
keyString = stickInput.ToString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue