Move the configuration system to Common
This commit is contained in:
parent
ba74f814e9
commit
7ee9a00cf0
22 changed files with 529 additions and 299 deletions
|
@ -1,8 +1,10 @@
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Input;
|
||||
using Ryujinx.Ui.Input;
|
||||
using Ryujinx.Configuration.Hid;
|
||||
using Ryujinx.Configuration.System;
|
||||
using Ryujinx.Configuration.Ui;
|
||||
using Ryujinx.UI.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -145,7 +147,7 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// Change System Language
|
||||
/// </summary>
|
||||
public ReactiveObject<SystemLanguage> Language { get; private set; }
|
||||
public ReactiveObject<Language> Language { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables Docked Mode
|
||||
|
@ -174,7 +176,7 @@ namespace Ryujinx.Configuration
|
|||
|
||||
public SystemSection()
|
||||
{
|
||||
Language = new ReactiveObject<SystemLanguage>();
|
||||
Language = new ReactiveObject<Language>();
|
||||
EnableDockedMode = new ReactiveObject<bool>();
|
||||
EnableMulticoreScheduling = new ReactiveObject<bool>();
|
||||
EnableFsIntegrityChecks = new ReactiveObject<bool>();
|
||||
|
@ -191,7 +193,7 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// The primary controller's type
|
||||
/// </summary>
|
||||
public ReactiveObject<ControllerStatus> ControllerType { get; private set; }
|
||||
public ReactiveObject<ControllerType> ControllerType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable or disable keyboard support (Independent from controllers binding)
|
||||
|
@ -206,14 +208,14 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// Controller control bindings
|
||||
/// </summary>
|
||||
public ReactiveObject<Ui.Input.NpadController> JoystickControls { get; private set; }
|
||||
public ReactiveObject<NpadController> JoystickControls { get; private set; }
|
||||
|
||||
public HidSection()
|
||||
{
|
||||
ControllerType = new ReactiveObject<ControllerStatus>();
|
||||
ControllerType = new ReactiveObject<ControllerType>();
|
||||
EnableKeyboard = new ReactiveObject<bool>();
|
||||
KeyboardControls = new ReactiveObject<NpadKeyboard>();
|
||||
JoystickControls = new ReactiveObject<Ui.Input.NpadController>();
|
||||
JoystickControls = new ReactiveObject<NpadController>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +310,7 @@ namespace Ryujinx.Configuration
|
|||
FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
|
||||
IgnoreMissingServices = System.IgnoreMissingServices,
|
||||
ControllerType = Hid.ControllerType,
|
||||
GuiColumns = new Ui.GuiColumns()
|
||||
GuiColumns = new GuiColumns()
|
||||
{
|
||||
FavColumn = Ui.GuiColumns.FavColumn,
|
||||
IconColumn = Ui.GuiColumns.IconColumn,
|
||||
|
@ -337,7 +339,7 @@ namespace Ryujinx.Configuration
|
|||
if (configurationFileFormat.Version != 1 && configurationFileFormat.Version != 0)
|
||||
{
|
||||
// TODO: load default configuration
|
||||
throw new System.NotSupportedException($"Unsupported configuration version {configurationFileFormat.Version}");
|
||||
throw new NotSupportedException($"Unsupported configuration version {configurationFileFormat.Version}");
|
||||
}
|
||||
|
||||
Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
|
|
@ -1,20 +1,16 @@
|
|||
using JsonPrettyPrinterPlus;
|
||||
using LibHac.FsSystem;
|
||||
using OpenTK.Input;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.HOS.Services;
|
||||
using Ryujinx.HLE.Input;
|
||||
using Ryujinx.Ui;
|
||||
using Ryujinx.Ui.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Utf8Json;
|
||||
using Utf8Json.Resolvers;
|
||||
using Ryujinx.Configuration.System;
|
||||
using Ryujinx.Configuration.Hid;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.UI.Input;
|
||||
using Ryujinx.Configuration.Ui;
|
||||
|
||||
namespace Ryujinx.Configuration
|
||||
{
|
||||
|
@ -75,7 +71,7 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// Change System Language
|
||||
/// </summary>
|
||||
public SystemLanguage SystemLanguage { get; set; }
|
||||
public Language SystemLanguage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables Docked Mode
|
||||
|
@ -115,7 +111,7 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// The primary controller's type
|
||||
/// </summary>
|
||||
public ControllerStatus ControllerType { get; set; }
|
||||
public ControllerType ControllerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to toggle columns in the GUI
|
||||
|
@ -150,7 +146,7 @@ namespace Ryujinx.Configuration
|
|||
/// <summary>
|
||||
/// Controller control bindings
|
||||
/// </summary>
|
||||
public Ui.Input.NpadController JoystickControls { get; set; }
|
||||
public NpadController JoystickControls { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads a configuration file from disk
|
45
Ryujinx.Common/Configuration/Hid/ControllerInputId.cs
Normal file
45
Ryujinx.Common/Configuration/Hid/ControllerInputId.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
namespace Ryujinx.Common.Configuration.Hid
|
||||
{
|
||||
public enum ControllerInputId
|
||||
{
|
||||
Button0,
|
||||
Button1,
|
||||
Button2,
|
||||
Button3,
|
||||
Button4,
|
||||
Button5,
|
||||
Button6,
|
||||
Button7,
|
||||
Button8,
|
||||
Button9,
|
||||
Button10,
|
||||
Button11,
|
||||
Button12,
|
||||
Button13,
|
||||
Button14,
|
||||
Button15,
|
||||
Button16,
|
||||
Button17,
|
||||
Button18,
|
||||
Button19,
|
||||
Button20,
|
||||
Axis0,
|
||||
Axis1,
|
||||
Axis2,
|
||||
Axis3,
|
||||
Axis4,
|
||||
Axis5,
|
||||
Hat0Up,
|
||||
Hat0Down,
|
||||
Hat0Left,
|
||||
Hat0Right,
|
||||
Hat1Up,
|
||||
Hat1Down,
|
||||
Hat1Left,
|
||||
Hat1Right,
|
||||
Hat2Up,
|
||||
Hat2Down,
|
||||
Hat2Left,
|
||||
Hat2Right,
|
||||
}
|
||||
}
|
11
Ryujinx.Common/Configuration/Hid/ControllerType.cs
Normal file
11
Ryujinx.Common/Configuration/Hid/ControllerType.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace Ryujinx.Configuration.Hid
|
||||
{
|
||||
public enum ControllerType
|
||||
{
|
||||
ProController,
|
||||
Handheld,
|
||||
NpadPair,
|
||||
NpadLeft,
|
||||
NpadRight,
|
||||
}
|
||||
}
|
153
Ryujinx.Common/Configuration/Hid/Key.cs
Normal file
153
Ryujinx.Common/Configuration/Hid/Key.cs
Normal file
|
@ -0,0 +1,153 @@
|
|||
namespace Ryujinx.Configuration.Hid
|
||||
{
|
||||
public enum Key
|
||||
{
|
||||
Unknown = 0,
|
||||
ShiftLeft = 1,
|
||||
LShift = 1,
|
||||
ShiftRight = 2,
|
||||
RShift = 2,
|
||||
ControlLeft = 3,
|
||||
LControl = 3,
|
||||
ControlRight = 4,
|
||||
RControl = 4,
|
||||
AltLeft = 5,
|
||||
LAlt = 5,
|
||||
AltRight = 6,
|
||||
RAlt = 6,
|
||||
WinLeft = 7,
|
||||
LWin = 7,
|
||||
WinRight = 8,
|
||||
RWin = 8,
|
||||
Menu = 9,
|
||||
F1 = 10,
|
||||
F2 = 11,
|
||||
F3 = 12,
|
||||
F4 = 13,
|
||||
F5 = 14,
|
||||
F6 = 15,
|
||||
F7 = 16,
|
||||
F8 = 17,
|
||||
F9 = 18,
|
||||
F10 = 19,
|
||||
F11 = 20,
|
||||
F12 = 21,
|
||||
F13 = 22,
|
||||
F14 = 23,
|
||||
F15 = 24,
|
||||
F16 = 25,
|
||||
F17 = 26,
|
||||
F18 = 27,
|
||||
F19 = 28,
|
||||
F20 = 29,
|
||||
F21 = 30,
|
||||
F22 = 31,
|
||||
F23 = 32,
|
||||
F24 = 33,
|
||||
F25 = 34,
|
||||
F26 = 35,
|
||||
F27 = 36,
|
||||
F28 = 37,
|
||||
F29 = 38,
|
||||
F30 = 39,
|
||||
F31 = 40,
|
||||
F32 = 41,
|
||||
F33 = 42,
|
||||
F34 = 43,
|
||||
F35 = 44,
|
||||
Up = 45,
|
||||
Down = 46,
|
||||
Left = 47,
|
||||
Right = 48,
|
||||
Enter = 49,
|
||||
Escape = 50,
|
||||
Space = 51,
|
||||
Tab = 52,
|
||||
BackSpace = 53,
|
||||
Back = 53,
|
||||
Insert = 54,
|
||||
Delete = 55,
|
||||
PageUp = 56,
|
||||
PageDown = 57,
|
||||
Home = 58,
|
||||
End = 59,
|
||||
CapsLock = 60,
|
||||
ScrollLock = 61,
|
||||
PrintScreen = 62,
|
||||
Pause = 63,
|
||||
NumLock = 64,
|
||||
Clear = 65,
|
||||
Sleep = 66,
|
||||
Keypad0 = 67,
|
||||
Keypad1 = 68,
|
||||
Keypad2 = 69,
|
||||
Keypad3 = 70,
|
||||
Keypad4 = 71,
|
||||
Keypad5 = 72,
|
||||
Keypad6 = 73,
|
||||
Keypad7 = 74,
|
||||
Keypad8 = 75,
|
||||
Keypad9 = 76,
|
||||
KeypadDivide = 77,
|
||||
KeypadMultiply = 78,
|
||||
KeypadSubtract = 79,
|
||||
KeypadMinus = 79,
|
||||
KeypadAdd = 80,
|
||||
KeypadPlus = 80,
|
||||
KeypadDecimal = 81,
|
||||
KeypadPeriod = 81,
|
||||
KeypadEnter = 82,
|
||||
A = 83,
|
||||
B = 84,
|
||||
C = 85,
|
||||
D = 86,
|
||||
E = 87,
|
||||
F = 88,
|
||||
G = 89,
|
||||
H = 90,
|
||||
I = 91,
|
||||
J = 92,
|
||||
K = 93,
|
||||
L = 94,
|
||||
M = 95,
|
||||
N = 96,
|
||||
O = 97,
|
||||
P = 98,
|
||||
Q = 99,
|
||||
R = 100,
|
||||
S = 101,
|
||||
T = 102,
|
||||
U = 103,
|
||||
V = 104,
|
||||
W = 105,
|
||||
X = 106,
|
||||
Y = 107,
|
||||
Z = 108,
|
||||
Number0 = 109,
|
||||
Number1 = 110,
|
||||
Number2 = 111,
|
||||
Number3 = 112,
|
||||
Number4 = 113,
|
||||
Number5 = 114,
|
||||
Number6 = 115,
|
||||
Number7 = 116,
|
||||
Number8 = 117,
|
||||
Number9 = 118,
|
||||
Tilde = 119,
|
||||
Grave = 119,
|
||||
Minus = 120,
|
||||
Plus = 121,
|
||||
BracketLeft = 122,
|
||||
LBracket = 122,
|
||||
BracketRight = 123,
|
||||
RBracket = 123,
|
||||
Semicolon = 124,
|
||||
Quote = 125,
|
||||
Comma = 126,
|
||||
Period = 127,
|
||||
Slash = 128,
|
||||
BackSlash = 129,
|
||||
NonUSBackSlash = 130,
|
||||
LastKey = 131
|
||||
}
|
||||
}
|
7
Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs
Normal file
7
Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Ryujinx.Configuration.Hid
|
||||
{
|
||||
public struct KeyboardHotkeys
|
||||
{
|
||||
public Key ToggleVsync;
|
||||
}
|
||||
}
|
35
Ryujinx.Common/Configuration/Hid/NpadController.cs
Normal file
35
Ryujinx.Common/Configuration/Hid/NpadController.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
namespace Ryujinx.Common.Configuration.Hid
|
||||
{
|
||||
public class NpadController
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables or disables controller support
|
||||
/// </summary>
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controller Device Index
|
||||
/// </summary>
|
||||
public int Index { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controller Analog Stick Deadzone
|
||||
/// </summary>
|
||||
public float Deadzone { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controller Trigger Threshold
|
||||
/// </summary>
|
||||
public float TriggerThreshold { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Left JoyCon Controller Bindings
|
||||
/// </summary>
|
||||
public NpadControllerLeft LeftJoycon { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Right JoyCon Controller Bindings
|
||||
/// </summary>
|
||||
public NpadControllerRight RightJoycon { get; private set; }
|
||||
}
|
||||
}
|
15
Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs
Normal file
15
Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
namespace Ryujinx.Common.Configuration.Hid
|
||||
{
|
||||
public struct NpadControllerLeft
|
||||
{
|
||||
public ControllerInputId Stick;
|
||||
public ControllerInputId StickButton;
|
||||
public ControllerInputId ButtonMinus;
|
||||
public ControllerInputId ButtonL;
|
||||
public ControllerInputId ButtonZl;
|
||||
public ControllerInputId DPadUp;
|
||||
public ControllerInputId DPadDown;
|
||||
public ControllerInputId DPadLeft;
|
||||
public ControllerInputId DPadRight;
|
||||
}
|
||||
}
|
16
Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs
Normal file
16
Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace Ryujinx.Common.Configuration.Hid
|
||||
{
|
||||
public struct NpadControllerRight
|
||||
{
|
||||
public ControllerInputId Stick;
|
||||
public ControllerInputId StickY;
|
||||
public ControllerInputId StickButton;
|
||||
public ControllerInputId ButtonA;
|
||||
public ControllerInputId ButtonB;
|
||||
public ControllerInputId ButtonX;
|
||||
public ControllerInputId ButtonY;
|
||||
public ControllerInputId ButtonPlus;
|
||||
public ControllerInputId ButtonR;
|
||||
public ControllerInputId ButtonZr;
|
||||
}
|
||||
}
|
20
Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs
Normal file
20
Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
namespace Ryujinx.UI.Input
|
||||
{
|
||||
public class NpadKeyboard
|
||||
{
|
||||
/// <summary>
|
||||
/// Left JoyCon Keyboard Bindings
|
||||
/// </summary>
|
||||
public Configuration.Hid.NpadKeyboardLeft LeftJoycon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Right JoyCon Keyboard Bindings
|
||||
/// </summary>
|
||||
public Configuration.Hid.NpadKeyboardRight RightJoycon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hotkey Keyboard Bindings
|
||||
/// </summary>
|
||||
public Configuration.Hid.KeyboardHotkeys Hotkeys { get; private set; }
|
||||
}
|
||||
}
|
18
Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs
Normal file
18
Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Ryujinx.Configuration.Hid
|
||||
{
|
||||
public struct NpadKeyboardLeft
|
||||
{
|
||||
public Key StickUp;
|
||||
public Key StickDown;
|
||||
public Key StickLeft;
|
||||
public Key StickRight;
|
||||
public Key StickButton;
|
||||
public Key DPadUp;
|
||||
public Key DPadDown;
|
||||
public Key DPadLeft;
|
||||
public Key DPadRight;
|
||||
public Key ButtonMinus;
|
||||
public Key ButtonL;
|
||||
public Key ButtonZl;
|
||||
}
|
||||
}
|
18
Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs
Normal file
18
Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Ryujinx.Configuration.Hid
|
||||
{
|
||||
public struct NpadKeyboardRight
|
||||
{
|
||||
public Key StickUp;
|
||||
public Key StickDown;
|
||||
public Key StickLeft;
|
||||
public Key StickRight;
|
||||
public Key StickButton;
|
||||
public Key ButtonA;
|
||||
public Key ButtonB;
|
||||
public Key ButtonX;
|
||||
public Key ButtonY;
|
||||
public Key ButtonPlus;
|
||||
public Key ButtonR;
|
||||
public Key ButtonZr;
|
||||
}
|
||||
}
|
23
Ryujinx.Common/Configuration/System/Language.cs
Normal file
23
Ryujinx.Common/Configuration/System/Language.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
namespace Ryujinx.Configuration.System
|
||||
{
|
||||
public enum Language
|
||||
{
|
||||
Japanese,
|
||||
AmericanEnglish,
|
||||
French,
|
||||
German,
|
||||
Italian,
|
||||
Spanish,
|
||||
Chinese,
|
||||
Korean,
|
||||
Dutch,
|
||||
Portuguese,
|
||||
Russian,
|
||||
Taiwanese,
|
||||
BritishEnglish,
|
||||
CanadianFrench,
|
||||
LatinAmericanSpanish,
|
||||
SimplifiedChinese,
|
||||
TraditionalChinese
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ryujinx.Ui
|
||||
namespace Ryujinx.Configuration.Ui
|
||||
{
|
||||
public struct GuiColumns
|
||||
{
|
|
@ -27,6 +27,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JsonPrettyPrinter" Version="1.0.1.1" />
|
||||
<PackageReference Include="Utf8Json" Version="1.3.7" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
<PackageReference Include="DiscordRichPresence" Version="1.0.121" />
|
||||
<PackageReference Include="GtkSharp" Version="3.22.25.24" />
|
||||
<PackageReference Include="GtkSharp.Dependencies" Version="1.1.0" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
|
||||
<PackageReference Include="JsonPrettyPrinter" Version="1.0.1.1" />
|
||||
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using Ryujinx.Configuration;
|
|||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.Input;
|
||||
using Ryujinx.Ui;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -29,6 +30,8 @@ namespace Ryujinx.Ui
|
|||
|
||||
private MouseState? _mouse = null;
|
||||
|
||||
private Input.NpadController _primaryController;
|
||||
|
||||
private Thread _renderThread;
|
||||
|
||||
private bool _resizeEvent;
|
||||
|
@ -50,6 +53,8 @@ namespace Ryujinx.Ui
|
|||
_device = device;
|
||||
_renderer = renderer;
|
||||
|
||||
_primaryController = new Input.NpadController(ConfigurationState.Instance.Hid.JoystickControls);
|
||||
|
||||
Location = new Point(
|
||||
(DisplayDevice.Default.Width / 2) - (Width / 2),
|
||||
(DisplayDevice.Default.Height / 2) - (Height / 2));
|
||||
|
@ -162,16 +167,16 @@ namespace Ryujinx.Ui
|
|||
#endif
|
||||
|
||||
// Normal Input
|
||||
currentHotkeyButtons = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetHotkeyButtons(keyboard);
|
||||
currentButton = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetButtons(keyboard);
|
||||
currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
||||
currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
||||
|
||||
if (ConfigurationState.Instance.Hid.EnableKeyboard)
|
||||
{
|
||||
hidKeyboard = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetKeysDown(keyboard);
|
||||
hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
||||
}
|
||||
|
||||
(leftJoystickDx, leftJoystickDy) = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetLeftStick(keyboard);
|
||||
(rightJoystickDx, rightJoystickDy) = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetRightStick(keyboard);
|
||||
(leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
||||
(rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
||||
}
|
||||
|
||||
if (!hidKeyboard.HasValue)
|
||||
|
@ -183,17 +188,17 @@ namespace Ryujinx.Ui
|
|||
};
|
||||
}
|
||||
|
||||
currentButton |= ConfigurationState.Instance.Hid.JoystickControls.Value.GetButtons();
|
||||
currentButton |= _primaryController.GetButtons();
|
||||
|
||||
// Keyboard has priority stick-wise
|
||||
if (leftJoystickDx == 0 && leftJoystickDy == 0)
|
||||
{
|
||||
(leftJoystickDx, leftJoystickDy) = ConfigurationState.Instance.Hid.JoystickControls.Value.GetLeftStick();
|
||||
(leftJoystickDx, leftJoystickDy) = _primaryController.GetLeftStick();
|
||||
}
|
||||
|
||||
if (rightJoystickDx == 0 && rightJoystickDy == 0)
|
||||
{
|
||||
(rightJoystickDx, rightJoystickDy) = ConfigurationState.Instance.Hid.JoystickControls.Value.GetRightStick();
|
||||
(rightJoystickDx, rightJoystickDy) = _primaryController.GetRightStick();
|
||||
}
|
||||
|
||||
leftJoystick = new JoystickPosition
|
||||
|
|
|
@ -1,118 +1,67 @@
|
|||
using OpenTK.Input;
|
||||
using OpenTK.Input;
|
||||
using Ryujinx.HLE.Input;
|
||||
using Ryujinx.UI.Input;
|
||||
|
||||
namespace Ryujinx.Ui.Input
|
||||
namespace Ryujinx.Ui
|
||||
{
|
||||
public struct NpadKeyboardLeft
|
||||
public static class KeyboardControls
|
||||
{
|
||||
public Key StickUp;
|
||||
public Key StickDown;
|
||||
public Key StickLeft;
|
||||
public Key StickRight;
|
||||
public Key StickButton;
|
||||
public Key DPadUp;
|
||||
public Key DPadDown;
|
||||
public Key DPadLeft;
|
||||
public Key DPadRight;
|
||||
public Key ButtonMinus;
|
||||
public Key ButtonL;
|
||||
public Key ButtonZl;
|
||||
}
|
||||
|
||||
public struct NpadKeyboardRight
|
||||
{
|
||||
public Key StickUp;
|
||||
public Key StickDown;
|
||||
public Key StickLeft;
|
||||
public Key StickRight;
|
||||
public Key StickButton;
|
||||
public Key ButtonA;
|
||||
public Key ButtonB;
|
||||
public Key ButtonX;
|
||||
public Key ButtonY;
|
||||
public Key ButtonPlus;
|
||||
public Key ButtonR;
|
||||
public Key ButtonZr;
|
||||
}
|
||||
|
||||
public struct KeyboardHotkeys
|
||||
{
|
||||
public Key ToggleVsync;
|
||||
}
|
||||
|
||||
public class NpadKeyboard
|
||||
{
|
||||
/// <summary>
|
||||
/// Left JoyCon Keyboard Bindings
|
||||
/// </summary>
|
||||
public NpadKeyboardLeft LeftJoycon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Right JoyCon Keyboard Bindings
|
||||
/// </summary>
|
||||
public NpadKeyboardRight RightJoycon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hotkey Keyboard Bindings
|
||||
/// </summary>
|
||||
public KeyboardHotkeys Hotkeys { get; private set; }
|
||||
|
||||
public ControllerButtons GetButtons(KeyboardState keyboard)
|
||||
public static ControllerButtons GetButtons(NpadKeyboard npad, KeyboardState keyboard)
|
||||
{
|
||||
ControllerButtons buttons = 0;
|
||||
|
||||
if (keyboard[(Key)LeftJoycon.StickButton]) buttons |= ControllerButtons.StickLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadUp]) buttons |= ControllerButtons.DpadUp;
|
||||
if (keyboard[(Key)LeftJoycon.DPadDown]) buttons |= ControllerButtons.DpadDown;
|
||||
if (keyboard[(Key)LeftJoycon.DPadLeft]) buttons |= ControllerButtons.DpadLeft;
|
||||
if (keyboard[(Key)LeftJoycon.DPadRight]) buttons |= ControllerButtons.DPadRight;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonMinus]) buttons |= ControllerButtons.Minus;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonL]) buttons |= ControllerButtons.L;
|
||||
if (keyboard[(Key)LeftJoycon.ButtonZl]) buttons |= ControllerButtons.Zl;
|
||||
if (keyboard[(Key)npad.LeftJoycon.StickButton]) buttons |= ControllerButtons.StickLeft;
|
||||
if (keyboard[(Key)npad.LeftJoycon.DPadUp]) buttons |= ControllerButtons.DpadUp;
|
||||
if (keyboard[(Key)npad.LeftJoycon.DPadDown]) buttons |= ControllerButtons.DpadDown;
|
||||
if (keyboard[(Key)npad.LeftJoycon.DPadLeft]) buttons |= ControllerButtons.DpadLeft;
|
||||
if (keyboard[(Key)npad.LeftJoycon.DPadRight]) buttons |= ControllerButtons.DPadRight;
|
||||
if (keyboard[(Key)npad.LeftJoycon.ButtonMinus]) buttons |= ControllerButtons.Minus;
|
||||
if (keyboard[(Key)npad.LeftJoycon.ButtonL]) buttons |= ControllerButtons.L;
|
||||
if (keyboard[(Key)npad.LeftJoycon.ButtonZl]) buttons |= ControllerButtons.Zl;
|
||||
|
||||
if (keyboard[(Key)RightJoycon.StickButton]) buttons |= ControllerButtons.StickRight;
|
||||
if (keyboard[(Key)RightJoycon.ButtonA]) buttons |= ControllerButtons.A;
|
||||
if (keyboard[(Key)RightJoycon.ButtonB]) buttons |= ControllerButtons.B;
|
||||
if (keyboard[(Key)RightJoycon.ButtonX]) buttons |= ControllerButtons.X;
|
||||
if (keyboard[(Key)RightJoycon.ButtonY]) buttons |= ControllerButtons.Y;
|
||||
if (keyboard[(Key)RightJoycon.ButtonPlus]) buttons |= ControllerButtons.Plus;
|
||||
if (keyboard[(Key)RightJoycon.ButtonR]) buttons |= ControllerButtons.R;
|
||||
if (keyboard[(Key)RightJoycon.ButtonZr]) buttons |= ControllerButtons.Zr;
|
||||
if (keyboard[(Key)npad.RightJoycon.StickButton]) buttons |= ControllerButtons.StickRight;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonA]) buttons |= ControllerButtons.A;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonB]) buttons |= ControllerButtons.B;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonX]) buttons |= ControllerButtons.X;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonY]) buttons |= ControllerButtons.Y;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonPlus]) buttons |= ControllerButtons.Plus;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonR]) buttons |= ControllerButtons.R;
|
||||
if (keyboard[(Key)npad.RightJoycon.ButtonZr]) buttons |= ControllerButtons.Zr;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public (short, short) GetLeftStick(KeyboardState keyboard)
|
||||
public static (short, short) GetLeftStick(NpadKeyboard npad, KeyboardState keyboard)
|
||||
{
|
||||
short dx = 0;
|
||||
short dy = 0;
|
||||
|
||||
if (keyboard[(Key)LeftJoycon.StickUp]) dy = short.MaxValue;
|
||||
if (keyboard[(Key)LeftJoycon.StickDown]) dy = -short.MaxValue;
|
||||
if (keyboard[(Key)LeftJoycon.StickLeft]) dx = -short.MaxValue;
|
||||
if (keyboard[(Key)LeftJoycon.StickRight]) dx = short.MaxValue;
|
||||
if (keyboard[(Key)npad.LeftJoycon.StickUp]) dy = short.MaxValue;
|
||||
if (keyboard[(Key)npad.LeftJoycon.StickDown]) dy = -short.MaxValue;
|
||||
if (keyboard[(Key)npad.LeftJoycon.StickLeft]) dx = -short.MaxValue;
|
||||
if (keyboard[(Key)npad.LeftJoycon.StickRight]) dx = short.MaxValue;
|
||||
|
||||
return (dx, dy);
|
||||
}
|
||||
|
||||
public (short, short) GetRightStick(KeyboardState keyboard)
|
||||
public static (short, short) GetRightStick(NpadKeyboard npad, KeyboardState keyboard)
|
||||
{
|
||||
short dx = 0;
|
||||
short dy = 0;
|
||||
|
||||
if (keyboard[(Key)RightJoycon.StickUp]) dy = short.MaxValue;
|
||||
if (keyboard[(Key)RightJoycon.StickDown]) dy = -short.MaxValue;
|
||||
if (keyboard[(Key)RightJoycon.StickLeft]) dx = -short.MaxValue;
|
||||
if (keyboard[(Key)RightJoycon.StickRight]) dx = short.MaxValue;
|
||||
if (keyboard[(Key)npad.RightJoycon.StickUp]) dy = short.MaxValue;
|
||||
if (keyboard[(Key)npad.RightJoycon.StickDown]) dy = -short.MaxValue;
|
||||
if (keyboard[(Key)npad.RightJoycon.StickLeft]) dx = -short.MaxValue;
|
||||
if (keyboard[(Key)npad.RightJoycon.StickRight]) dx = short.MaxValue;
|
||||
|
||||
return (dx, dy);
|
||||
}
|
||||
|
||||
public HotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
||||
public static HotkeyButtons GetHotkeyButtons(NpadKeyboard npad, KeyboardState keyboard)
|
||||
{
|
||||
HotkeyButtons buttons = 0;
|
||||
|
||||
if (keyboard[(Key)Hotkeys.ToggleVsync]) buttons |= HotkeyButtons.ToggleVSync;
|
||||
if (keyboard[(Key)npad.Hotkeys.ToggleVsync]) buttons |= HotkeyButtons.ToggleVSync;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
@ -267,7 +216,7 @@ namespace Ryujinx.Ui.Input
|
|||
new KeyMappingEntry { TargetKey = Key.NumLock, Target = 10 },
|
||||
};
|
||||
|
||||
public HLE.Input.Keyboard GetKeysDown(KeyboardState keyboard)
|
||||
public static HLE.Input.Keyboard GetKeysDown(NpadKeyboard npad, KeyboardState keyboard)
|
||||
{
|
||||
HLE.Input.Keyboard hidKeyboard = new HLE.Input.Keyboard
|
||||
{
|
|
@ -13,14 +13,18 @@ using Ryujinx.Configuration;
|
|||
using System.Diagnostics;
|
||||
using OpenTK.Input;
|
||||
using Ryujinx.Ui.Input;
|
||||
|
||||
using GUI = Gtk.Builder.ObjectAttribute;
|
||||
using System.Threading.Tasks;
|
||||
using Utf8Json;
|
||||
using JsonPrettyPrinterPlus;
|
||||
using Utf8Json.Resolvers;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
|
||||
|
||||
using GUI = Gtk.Builder.ObjectAttribute;
|
||||
using Ryujinx.HLE.Input;
|
||||
using Ryujinx.Configuration.Hid;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
|
||||
namespace Ryujinx.Ui
|
||||
{
|
||||
public class MainWindow : Window
|
||||
|
@ -202,8 +206,7 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
HLE.Switch instance = new HLE.Switch(_renderer, _audioOut);
|
||||
|
||||
instance.Initialize(ConfigurationState.Instance.System.Language, ConfigurationState.Instance.System.EnableMulticoreScheduling, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.System.EnableFsIntegrityChecks, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.IgnoreMissingServices);
|
||||
|
||||
instance.Initialize((SystemLanguage)ConfigurationState.Instance.System.Language.Value, ConfigurationState.Instance.System.EnableMulticoreScheduling, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.System.EnableFsIntegrityChecks, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.IgnoreMissingServices);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -233,7 +236,7 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
Logger.RestartTime();
|
||||
|
||||
// TODO: move this somewhere else + reloadable
|
||||
// TODO: move this somewhere else + reloadable?
|
||||
GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
|
||||
|
||||
if (Directory.Exists(path))
|
||||
|
@ -340,19 +343,29 @@ namespace Ryujinx.Ui
|
|||
// TODO: Make HLE.Switch handle the state itself + reloading
|
||||
private static void ConfigureHid()
|
||||
{
|
||||
NpadController controller = ConfigurationState.Instance.Hid.JoystickControls.Value;
|
||||
|
||||
if (controller.Enabled)
|
||||
{
|
||||
if (!Joystick.GetState(controller.Index).IsConnected)
|
||||
{
|
||||
controller.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
_device.Hid.InitializePrimaryController(ConfigurationState.Instance.Hid.ControllerType);
|
||||
_device.Hid.InitializePrimaryController(ConvertControllerTypeToState(ConfigurationState.Instance.Hid.ControllerType));
|
||||
_device.Hid.InitializeKeyboard();
|
||||
}
|
||||
|
||||
private static ControllerStatus ConvertControllerTypeToState(ControllerType controllerType)
|
||||
{
|
||||
switch (controllerType)
|
||||
{
|
||||
case ControllerType.Handheld:
|
||||
return ControllerStatus.Handheld;
|
||||
case ControllerType.NpadLeft:
|
||||
return ControllerStatus.NpadLeft;
|
||||
case ControllerType.NpadRight:
|
||||
return ControllerStatus.NpadRight;
|
||||
case ControllerType.NpadPair:
|
||||
return ControllerStatus.NpadPair;
|
||||
case ControllerType.ProController:
|
||||
return ControllerStatus.ProController;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateGameWindow()
|
||||
{
|
||||
ConfigureHid();
|
||||
|
|
|
@ -1,160 +1,62 @@
|
|||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.HLE.Input;
|
||||
using System;
|
||||
|
||||
using InnerNpadController = Ryujinx.Common.Configuration.Hid.NpadController;
|
||||
|
||||
namespace Ryujinx.Ui.Input
|
||||
{
|
||||
public enum ControllerInputId
|
||||
{
|
||||
Button0,
|
||||
Button1,
|
||||
Button2,
|
||||
Button3,
|
||||
Button4,
|
||||
Button5,
|
||||
Button6,
|
||||
Button7,
|
||||
Button8,
|
||||
Button9,
|
||||
Button10,
|
||||
Button11,
|
||||
Button12,
|
||||
Button13,
|
||||
Button14,
|
||||
Button15,
|
||||
Button16,
|
||||
Button17,
|
||||
Button18,
|
||||
Button19,
|
||||
Button20,
|
||||
Axis0,
|
||||
Axis1,
|
||||
Axis2,
|
||||
Axis3,
|
||||
Axis4,
|
||||
Axis5,
|
||||
Hat0Up,
|
||||
Hat0Down,
|
||||
Hat0Left,
|
||||
Hat0Right,
|
||||
Hat1Up,
|
||||
Hat1Down,
|
||||
Hat1Left,
|
||||
Hat1Right,
|
||||
Hat2Up,
|
||||
Hat2Down,
|
||||
Hat2Left,
|
||||
Hat2Right,
|
||||
}
|
||||
|
||||
public struct NpadControllerLeft
|
||||
{
|
||||
public ControllerInputId Stick;
|
||||
public ControllerInputId StickButton;
|
||||
public ControllerInputId ButtonMinus;
|
||||
public ControllerInputId ButtonL;
|
||||
public ControllerInputId ButtonZl;
|
||||
public ControllerInputId DPadUp;
|
||||
public ControllerInputId DPadDown;
|
||||
public ControllerInputId DPadLeft;
|
||||
public ControllerInputId DPadRight;
|
||||
}
|
||||
|
||||
public struct NpadControllerRight
|
||||
{
|
||||
public ControllerInputId Stick;
|
||||
public ControllerInputId StickButton;
|
||||
public ControllerInputId ButtonA;
|
||||
public ControllerInputId ButtonB;
|
||||
public ControllerInputId ButtonX;
|
||||
public ControllerInputId ButtonY;
|
||||
public ControllerInputId ButtonPlus;
|
||||
public ControllerInputId ButtonR;
|
||||
public ControllerInputId ButtonZr;
|
||||
}
|
||||
|
||||
public class NpadController
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables or disables controller support
|
||||
/// </summary>
|
||||
public bool Enabled { get; private set; }
|
||||
private InnerNpadController _inner;
|
||||
|
||||
/// <summary>
|
||||
/// Controller Device Index
|
||||
/// </summary>
|
||||
public int Index { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controller Analog Stick Deadzone
|
||||
/// </summary>
|
||||
public float Deadzone { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Controller Trigger Threshold
|
||||
/// </summary>
|
||||
public float TriggerThreshold { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Left JoyCon Controller Bindings
|
||||
/// </summary>
|
||||
public NpadControllerLeft LeftJoycon { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Right JoyCon Controller Bindings
|
||||
/// </summary>
|
||||
public NpadControllerRight RightJoycon { get; private set; }
|
||||
|
||||
public NpadController(
|
||||
bool enabled,
|
||||
int index,
|
||||
float deadzone,
|
||||
float triggerThreshold,
|
||||
NpadControllerLeft leftJoycon,
|
||||
NpadControllerRight rightJoycon)
|
||||
// NOTE: This should be initialized AFTER GTK for compat reasons with OpenTK SDL2 backend and GTK on Linux.
|
||||
// BODY: Usage of Joystick.GetState must be defer to after GTK full initialization. Otherwise, GTK will segfault because SDL2 was already init *sighs*
|
||||
public NpadController(InnerNpadController inner)
|
||||
{
|
||||
Enabled = enabled;
|
||||
Index = index;
|
||||
Deadzone = deadzone;
|
||||
TriggerThreshold = triggerThreshold;
|
||||
LeftJoycon = leftJoycon;
|
||||
RightJoycon = rightJoycon;
|
||||
_inner = inner;
|
||||
}
|
||||
|
||||
public void SetEnabled(bool enabled)
|
||||
private bool IsEnabled()
|
||||
{
|
||||
Enabled = enabled;
|
||||
return _inner.Enabled && Joystick.GetState(_inner.Index).IsConnected;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ControllerButtons GetButtons()
|
||||
{
|
||||
if (!Enabled)
|
||||
if (!IsEnabled())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
JoystickState joystickState = Joystick.GetState(Index);
|
||||
JoystickState joystickState = Joystick.GetState(_inner.Index);
|
||||
|
||||
ControllerButtons buttons = 0;
|
||||
|
||||
if (IsActivated(joystickState, LeftJoycon.DPadUp)) buttons |= ControllerButtons.DpadUp;
|
||||
if (IsActivated(joystickState, LeftJoycon.DPadDown)) buttons |= ControllerButtons.DpadDown;
|
||||
if (IsActivated(joystickState, LeftJoycon.DPadLeft)) buttons |= ControllerButtons.DpadLeft;
|
||||
if (IsActivated(joystickState, LeftJoycon.DPadRight)) buttons |= ControllerButtons.DPadRight;
|
||||
if (IsActivated(joystickState, LeftJoycon.StickButton)) buttons |= ControllerButtons.StickLeft;
|
||||
if (IsActivated(joystickState, LeftJoycon.ButtonMinus)) buttons |= ControllerButtons.Minus;
|
||||
if (IsActivated(joystickState, LeftJoycon.ButtonL)) buttons |= ControllerButtons.L;
|
||||
if (IsActivated(joystickState, LeftJoycon.ButtonZl)) buttons |= ControllerButtons.Zl;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.DPadUp)) buttons |= ControllerButtons.DpadUp;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.DPadDown)) buttons |= ControllerButtons.DpadDown;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.DPadLeft)) buttons |= ControllerButtons.DpadLeft;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.DPadRight)) buttons |= ControllerButtons.DPadRight;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.StickButton)) buttons |= ControllerButtons.StickLeft;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.ButtonMinus)) buttons |= ControllerButtons.Minus;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.ButtonL)) buttons |= ControllerButtons.L;
|
||||
if (IsActivated(joystickState, _inner.LeftJoycon.ButtonZl)) buttons |= ControllerButtons.Zl;
|
||||
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonA)) buttons |= ControllerButtons.A;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonB)) buttons |= ControllerButtons.B;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonX)) buttons |= ControllerButtons.X;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonY)) buttons |= ControllerButtons.Y;
|
||||
if (IsActivated(joystickState, RightJoycon.StickButton)) buttons |= ControllerButtons.StickRight;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonPlus)) buttons |= ControllerButtons.Plus;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonR)) buttons |= ControllerButtons.R;
|
||||
if (IsActivated(joystickState, RightJoycon.ButtonZr)) buttons |= ControllerButtons.Zr;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonA)) buttons |= ControllerButtons.A;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonB)) buttons |= ControllerButtons.B;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonX)) buttons |= ControllerButtons.X;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonY)) buttons |= ControllerButtons.Y;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.StickButton)) buttons |= ControllerButtons.StickRight;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonPlus)) buttons |= ControllerButtons.Plus;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonR)) buttons |= ControllerButtons.R;
|
||||
if (IsActivated(joystickState, _inner.RightJoycon.ButtonZr)) buttons |= ControllerButtons.Zr;
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
@ -169,7 +71,7 @@ namespace Ryujinx.Ui.Input
|
|||
{
|
||||
int axis = controllerInputId - ControllerInputId.Axis0;
|
||||
|
||||
return joystickState.GetAxis(axis) > TriggerThreshold;
|
||||
return joystickState.GetAxis(axis) > _inner.TriggerThreshold;
|
||||
}
|
||||
else if (controllerInputId <= ControllerInputId.Hat2Right)
|
||||
{
|
||||
|
@ -190,22 +92,22 @@ namespace Ryujinx.Ui.Input
|
|||
|
||||
public (short, short) GetLeftStick()
|
||||
{
|
||||
if (!Enabled)
|
||||
if (!IsEnabled())
|
||||
{
|
||||
return (0, 0);
|
||||
}
|
||||
|
||||
return GetStick(LeftJoycon.Stick);
|
||||
return GetStick(_inner.LeftJoycon.Stick);
|
||||
}
|
||||
|
||||
public (short, short) GetRightStick()
|
||||
{
|
||||
if (!Enabled)
|
||||
if (!IsEnabled())
|
||||
{
|
||||
return (0, 0);
|
||||
}
|
||||
|
||||
return GetStick(RightJoycon.Stick);
|
||||
return GetStick(_inner.RightJoycon.Stick);
|
||||
}
|
||||
|
||||
private (short, short) GetStick(ControllerInputId stickInputId)
|
||||
|
@ -215,7 +117,7 @@ namespace Ryujinx.Ui.Input
|
|||
return (0, 0);
|
||||
}
|
||||
|
||||
JoystickState jsState = Joystick.GetState(Index);
|
||||
JoystickState jsState = Joystick.GetState(_inner.Index);
|
||||
|
||||
int xAxis = stickInputId - ControllerInputId.Axis0;
|
||||
|
||||
|
@ -227,8 +129,8 @@ namespace Ryujinx.Ui.Input
|
|||
|
||||
private (short, short) ApplyDeadzone(Vector2 axis)
|
||||
{
|
||||
return (ClampAxis(MathF.Abs(axis.X) > Deadzone ? axis.X : 0f),
|
||||
ClampAxis(MathF.Abs(axis.Y) > Deadzone ? axis.Y : 0f));
|
||||
return (ClampAxis(MathF.Abs(axis.X) > _inner.Deadzone ? axis.X : 0f),
|
||||
ClampAxis(MathF.Abs(axis.Y) > _inner.Deadzone ? axis.Y : 0f));
|
||||
}
|
||||
|
||||
private static short ClampAxis(float value)
|
||||
|
|
|
@ -9,6 +9,8 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using Ryujinx.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Configuration.System;
|
||||
using Ryujinx.Configuration.Hid;
|
||||
|
||||
using GUI = Gtk.Builder.ObjectAttribute;
|
||||
|
||||
|
@ -202,7 +204,7 @@ namespace Ryujinx.Ui
|
|||
string key = keyPressed.Event.Key.ToString();
|
||||
string capKey = key.First().ToString().ToUpper() + key.Substring(1);
|
||||
|
||||
if (Enum.IsDefined(typeof(OpenTK.Input.Key), capKey))
|
||||
if (Enum.IsDefined(typeof(Configuration.Hid.Key), capKey))
|
||||
{
|
||||
button.Label = capKey;
|
||||
}
|
||||
|
@ -338,38 +340,38 @@ namespace Ryujinx.Ui
|
|||
|
||||
ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon = new NpadKeyboardLeft()
|
||||
{
|
||||
StickUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickUp1.Label),
|
||||
StickDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickDown1.Label),
|
||||
StickLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickLeft1.Label),
|
||||
StickRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickRight1.Label),
|
||||
StickButton = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickButton1.Label),
|
||||
DPadUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadUp1.Label),
|
||||
DPadDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadDown1.Label),
|
||||
DPadLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadLeft1.Label),
|
||||
DPadRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadRight1.Label),
|
||||
ButtonMinus = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _minus1.Label),
|
||||
ButtonL = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _l1.Label),
|
||||
ButtonZl = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _zL1.Label),
|
||||
StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickUp1.Label),
|
||||
StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickDown1.Label),
|
||||
StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickLeft1.Label),
|
||||
StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickRight1.Label),
|
||||
StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickButton1.Label),
|
||||
DPadUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadUp1.Label),
|
||||
DPadDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadDown1.Label),
|
||||
DPadLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadLeft1.Label),
|
||||
DPadRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadRight1.Label),
|
||||
ButtonMinus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _minus1.Label),
|
||||
ButtonL = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _l1.Label),
|
||||
ButtonZl = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zL1.Label),
|
||||
};
|
||||
|
||||
ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon = new NpadKeyboardRight()
|
||||
{
|
||||
StickUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickUp1.Label),
|
||||
StickDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickDown1.Label),
|
||||
StickLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickLeft1.Label),
|
||||
StickRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickRight1.Label),
|
||||
StickButton = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickButton1.Label),
|
||||
ButtonA = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _a1.Label),
|
||||
ButtonB = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _b1.Label),
|
||||
ButtonX = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _x1.Label),
|
||||
ButtonY = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _y1.Label),
|
||||
ButtonPlus = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _plus1.Label),
|
||||
ButtonR = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _r1.Label),
|
||||
ButtonZr = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _zR1.Label),
|
||||
StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickUp1.Label),
|
||||
StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickDown1.Label),
|
||||
StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickLeft1.Label),
|
||||
StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickRight1.Label),
|
||||
StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickButton1.Label),
|
||||
ButtonA = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _a1.Label),
|
||||
ButtonB = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _b1.Label),
|
||||
ButtonX = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _x1.Label),
|
||||
ButtonY = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _y1.Label),
|
||||
ButtonPlus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _plus1.Label),
|
||||
ButtonR = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _r1.Label),
|
||||
ButtonZr = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zR1.Label),
|
||||
};
|
||||
|
||||
ConfigurationState.Instance.System.Language.Value = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), _systemLanguageSelect.ActiveId);
|
||||
ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerStatus)Enum.Parse(typeof(ControllerStatus), _controller1Type.ActiveId);
|
||||
ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId);
|
||||
ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId);
|
||||
ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
|
||||
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
|
||||
ConfigurationState.Instance.Ui.GameDirs.Value = gameDirs;
|
||||
|
|
Loading…
Add table
Reference in a new issue