diff --git a/Ryujinx.UI/Configuration/DefaultSettings.cs b/Ryujinx.UI/Configuration/DefaultSettings.cs new file mode 100644 index 0000000000..4cb20c4e21 --- /dev/null +++ b/Ryujinx.UI/Configuration/DefaultSettings.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Ryujinx.UI.Configuration +{ + partial class Settings + { + public Dictionary DefaultSettings + { + get + { + Dictionary Defaults = new Dictionary() + { + { "Enable_Memory_Checks", false}, + { "Graphics_Shaders_Dump_Path", string.Empty }, + { "Logging_Enable_Debug" , false}, + { "Logging_Enable_Stub" , true}, + { "Logging_Enable_Info", true }, + { "Logging_Enable_Warn", true}, + { "Logging_Enable_Error", true }, + { "Logging_Filtered_Classes", string.Empty}, + { "Docked_Mode", false}, + { "Enable_Vsync", true}, + { "Enable_MultiCore_Scheduling", false}, + { "Enable_FS_Integrity_Checks", true}, + { "GamePad_Index", 0}, + { "GamePad_Deadzone", 0.05}, + { "GamePad_Trigger_Threshold", 0.5}, + { "GamePad_Enable", true}, + { "Controls_Left_JoyConKeyboard_Stick_Up", 105 }, + { "Controls_Left_JoyConKeyboard_Stick_Down", 101 }, + { "Controls_Left_JoyConKeyboard_Stick_Left", 83 }, + { "Controls_Left_JoyConKeyboard_Stick_Right", 86 }, + { "Controls_Left_JoyConKeyboard_Stick_Button", 88 }, + { "Controls_Left_JoyConKeyboard_DPad_Up", 45 }, + { "Controls_Left_JoyConKeyboard_DPad_Down", 46 }, + { "Controls_Left_JoyConKeyboard_DPad_Left", 47 }, + { "Controls_Left_JoyConKeyboard_DPad_Right", 48 }, + { "Controls_Left_JoyConKeyboard_Button_Minus", 120 }, + { "Controls_Left_JoyConKeyboard_Button_L", 87 }, + { "Controls_Left_JoyConKeyboard_Button_ZL", 99 }, + { "Controls_Right_JoyConKeyboard_Stick_Up", 91 }, + { "Controls_Right_JoyConKeyboard_Stick_Down", 93 }, + { "Controls_Right_JoyConKeyboard_Stick_Left", 92 }, + { "Controls_Right_JoyConKeyboard_Stick_Right", 94 }, + { "Controls_Right_JoyConKeyboard_Stick_Button", 90 }, + { "Controls_Right_JoyConKeyboard_Button_A", 108 }, + { "Controls_Right_JoyConKeyboard_Button_B", 106 }, + { "Controls_Right_JoyConKeyboard_Button_X", 85 }, + { "Controls_Right_JoyConKeyboard_Button_Y", 104 }, + { "Controls_Right_JoyConKeyboard_Button_Plus", 121 }, + { "Controls_Right_JoyConKeyboard_Button_R", 103 }, + { "Controls_Right_JoyConKeyboard_Button_ZR", 97 }, + { "Controls_Left_JoyConController_Stick_Button", "LStick"}, + { "Controls_Left_JoyConController_DPad_Up", "DPadUp" }, + { "Controls_Left_JoyConController_DPad_Down", "DPadDown" }, + { "Controls_Left_JoyConController_DPad_Left", "DPadLeft" }, + { "Controls_Left_JoyConController_DPad_Right", "DPadRight" }, + { "Controls_Left_JoyConController_Button_Minus", "Back" }, + { "Controls_Left_JoyConController_Button_L", "LShoulder" }, + { "Controls_Left_JoyConController_Button_ZL", "LTrigger" }, + { "Controls_Right_JoyConController_Stick_Button", "RStick" }, + { "Controls_Right_JoyConController_Button_A", "B" }, + { "Controls_Right_JoyConController_Button_B", "A" }, + { "Controls_Right_JoyConController_Button_X", "Y" }, + { "Controls_Right_JoyConController_Button_Y", "X" }, + { "Controls_Right_JoyConController_Button_Plus", "Start" }, + { "Controls_Right_JoyConController_Button_R", "RShoulder" }, + { "Controls_Right_JoyConController_Button_ZR", "RTrigger" }, + { "Controls_Left_JoyConController_Stick", "LJoystick" }, + { "Controls_Right_JoyConController_Stick", "RJoystick" } + }; + + return Defaults; + } + } + } +} diff --git a/Ryujinx.UI/Configuration/Settings.cs b/Ryujinx.UI/Configuration/Settings.cs new file mode 100644 index 0000000000..e904ea0b58 --- /dev/null +++ b/Ryujinx.UI/Configuration/Settings.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using Ryujinx.HLE; +using Ryujinx.HLE; +using Ryujinx.HLE.Logging; +using Ryujinx.UI.Input; +using System; +using System.Globalization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using static Ryujinx.Config; + +namespace Ryujinx.UI.Configuration +{ + public partial class Settings + { + private string Path; + + private Dictionary SettingsDictionary { get; set; } + + public Settings(string Path) + { + if (!File.Exists(Path)) + { + SettingsDictionary = DefaultSettings; + } + else + { + string SettingsString = File.ReadAllText(Path); + + SettingsDictionary = JsonConvert.DeserializeObject>(SettingsString); + + foreach((string Key, object Value) in DefaultSettings) + { + if (!SettingsDictionary.ContainsKey(Key)) + { + SettingsDictionary.TryAdd(Key, Value); + } + } + } + + this.Path = Path; + } + + public T GetValue(string Key) + { + object Value = null; + + if (!SettingsDictionary.TryGetValue(Key, out Value)) + { + if (DefaultSettings.TryGetValue(Key, out Value)) + { + SettingsDictionary.TryAdd(Key, Value); + } + } + + return (T)Value; + } + + public void Apply(Switch Device) + { + if (Device != null) + { + GraphicsConfig.ShadersDumpPath = GetValue("Graphics_Shaders_Dump_Path"); + + Device.Log.SetEnable(LogLevel.Debug, GetValue("Logging_Enable_Debug")); + Device.Log.SetEnable(LogLevel.Stub, GetValue("Logging_Enable_Stub")); + Device.Log.SetEnable(LogLevel.Info, GetValue("Logging_Enable_Info")); + Device.Log.SetEnable(LogLevel.Warning, GetValue("Logging_Enable_Warn")); + Device.Log.SetEnable(LogLevel.Error, GetValue("Logging_Enable_Error")); + + string[] FilteredLogClasses = GetValue("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); + + //When the classes are specified on the list, we only + //enable the classes that are on the list. + //So, first disable everything, then enable + //the classes that the user added to the list. + if (FilteredLogClasses.Length > 0) + { + foreach (LogClass Class in Enum.GetValues(typeof(LogClass))) + { + Device.Log.SetEnable(Class, false); + } + } + + foreach (string LogClass in FilteredLogClasses) + { + if (!string.IsNullOrEmpty(LogClass.Trim())) + { + foreach (LogClass Class in Enum.GetValues(typeof(LogClass))) + { + if (Class.ToString().ToLower().Contains(LogClass.Trim().ToLower())) + { + Device.Log.SetEnable(Class, true); + } + } + } + } + + Device.System.State.DockedMode = GetValue("Docked_Mode"); + Device.EnableDeviceVsync = GetValue("Enable_Vsync"); + + if (GetValue("Enable_MultiCore_Scheduling")) + { + Device.System.EnableMultiCoreScheduling(); + } + + Device.System.EnableFsIntegrityChecks = GetValue("Enable_FS_Integrity_Checks"); + + Config.JoyConKeyboard = new JoyConKeyboard( + + new JoyConKeyboardLeft + { + StickUp = GetValue("Controls_Left_JoyConKeyboard_Stick_Up"), + StickDown = GetValue("Controls_Left_JoyConKeyboard_Stick_Down"), + StickLeft = GetValue("Controls_Left_JoyConKeyboard_Stick_Left"), + StickRight = GetValue("Controls_Left_JoyConKeyboard_Stick_Right"), + StickButton = GetValue("Controls_Left_JoyConKeyboard_Stick_Button"), + DPadUp = GetValue("Controls_Left_JoyConKeyboard_DPad_Up"), + DPadDown = GetValue("Controls_Left_JoyConKeyboard_DPad_Down"), + DPadLeft = GetValue("Controls_Left_JoyConKeyboard_DPad_Left"), + DPadRight = GetValue("Controls_Left_JoyConKeyboard_DPad_Right"), + ButtonMinus = GetValue("Controls_Left_JoyConKeyboard_Button_Minus"), + ButtonL = GetValue("Controls_Left_JoyConKeyboard_Button_L"), + ButtonZL = GetValue("Controls_Left_JoyConKeyboard_Button_ZL") + }, + + new JoyConKeyboardRight + { + StickUp = GetValue("Controls_Right_JoyConKeyboard_Stick_Up"), + StickDown = GetValue("Controls_Right_JoyConKeyboard_Stick_Down"), + StickLeft = GetValue("Controls_Right_JoyConKeyboard_Stick_Left"), + StickRight = GetValue("Controls_Right_JoyConKeyboard_Stick_Right"), + StickButton = GetValue("Controls_Right_JoyConKeyboard_Stick_Button"), + ButtonA = GetValue("Controls_Right_JoyConKeyboard_Button_A"), + ButtonB = GetValue("Controls_Right_JoyConKeyboard_Button_B"), + ButtonX = GetValue("Controls_Right_JoyConKeyboard_Button_X"), + ButtonY = GetValue("Controls_Right_JoyConKeyboard_Button_Y"), + ButtonPlus = GetValue("Controls_Right_JoyConKeyboard_Button_Plus"), + ButtonR = GetValue("Controls_Right_JoyConKeyboard_Button_R"), + ButtonZR = GetValue("Controls_Right_JoyConKeyboard_Button_ZR") + }); + + Config.JoyConController = new JoyConController( + + GetValue("GamePad_Enable"), + GetValue("GamePad_Index"), + (float)Convert.ToDouble(GetValue("GamePad_Deadzone"), CultureInfo.InvariantCulture), + (float)Convert.ToDouble(GetValue("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture), + + new JoyConControllerLeft + { + Stick = ToID(GetValue("Controls_Left_JoyConController_Stick")), + StickButton = ToID(GetValue("Controls_Left_JoyConController_Stick_Button")), + DPadUp = ToID(GetValue("Controls_Left_JoyConController_DPad_Up")), + DPadDown = ToID(GetValue("Controls_Left_JoyConController_DPad_Down")), + DPadLeft = ToID(GetValue("Controls_Left_JoyConController_DPad_Left")), + DPadRight = ToID(GetValue("Controls_Left_JoyConController_DPad_Right")), + ButtonMinus = ToID(GetValue("Controls_Left_JoyConController_Button_Minus")), + ButtonL = ToID(GetValue("Controls_Left_JoyConController_Button_L")), + ButtonZL = ToID(GetValue("Controls_Left_JoyConController_Button_ZL")) + }, + + new JoyConControllerRight + { + Stick = ToID(GetValue("Controls_Right_JoyConController_Stick")), + StickButton = ToID(GetValue("Controls_Right_JoyConController_Stick_Button")), + ButtonA = ToID(GetValue("Controls_Right_JoyConController_Button_A")), + ButtonB = ToID(GetValue("Controls_Right_JoyConController_Button_B")), + ButtonX = ToID(GetValue("Controls_Right_JoyConController_Button_X")), + ButtonY = ToID(GetValue("Controls_Right_JoyConController_Button_Y")), + ButtonPlus = ToID(GetValue("Controls_Right_JoyConController_Button_Plus")), + ButtonR = ToID(GetValue("Controls_Right_JoyConController_Button_R")), + ButtonZR = ToID(GetValue("Controls_Right_JoyConController_Button_ZR")) + }); + } + } + + internal void SetValue(string Key, object Value) + { + SettingsDictionary[Key] = Value; + } + + public void Commit() + { + lock (Path) + { + string SettingsString = JsonConvert.SerializeObject(SettingsDictionary); + + File.WriteAllText(Path, SettingsString); + } + } + } +} diff --git a/Ryujinx.UI/Emulation/EmulationController.cs b/Ryujinx.UI/Emulation/EmulationController.cs index bfc7d4f4d1..f2e443c149 100644 --- a/Ryujinx.UI/Emulation/EmulationController.cs +++ b/Ryujinx.UI/Emulation/EmulationController.cs @@ -16,8 +16,9 @@ namespace Ryujinx.UI.Emulation [Signal("unloaded")] class EmulationController { + public static Switch Device; + private static GLScreen RenderScreen; - private static Switch Device; private static IAalOutput AudioOut; private static IGalRenderer Renderer; diff --git a/Ryujinx.UI/Program.cs b/Ryujinx.UI/Program.cs index 4925791652..0ccc015a13 100644 --- a/Ryujinx.UI/Program.cs +++ b/Ryujinx.UI/Program.cs @@ -1,5 +1,7 @@ using Qml.Net; using Ryujinx.UI.Emulation; +using Ryujinx.UI.UI.Models; +using OpenTK.Platform; using static Qml.Net.Qml; @@ -16,9 +18,12 @@ namespace Ryujinx.UI using (var QmlEngine = new QQmlApplicationEngine()) { RegisterType("Ryujinx"); + RegisterType("Ryujinx"); QmlEngine.Load("UI/MainWindow.qml"); + OpenTK.Toolkit.Init(); + return Application.Exec(); } } diff --git a/Ryujinx.UI/Ryujinx.UI.csproj b/Ryujinx.UI/Ryujinx.UI.csproj index cc9cc6bb26..27c24c77b1 100644 --- a/Ryujinx.UI/Ryujinx.UI.csproj +++ b/Ryujinx.UI/Ryujinx.UI.csproj @@ -6,15 +6,13 @@ - + + - - - diff --git a/Ryujinx.UI/UI/Models/ConfigurationModel.cs b/Ryujinx.UI/UI/Models/ConfigurationModel.cs new file mode 100644 index 0000000000..46127f3cba --- /dev/null +++ b/Ryujinx.UI/UI/Models/ConfigurationModel.cs @@ -0,0 +1,258 @@ +using OpenTK.Graphics; +using OpenTK.Input; +using OpenTK; +using Qml.Net; +using Ryujinx.UI.Configuration; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; + +using static OpenTK.Input.Keyboard; + +namespace Ryujinx.UI.UI.Models +{ + [Signal("waitReleased")] + [Signal("showWaitDialog")] + public class ConfigurationModel + { + private static Settings CurrentSettings; + + private static GamePadState[] GamePadStates; + + private bool IsWaiting; + + public ConfigurationModel() + { + if(CurrentSettings == null) + { + string Path = "./Ryujinx.json"; + + CurrentSettings = new Settings(Path); + } + } + + public void Save() + { + CurrentSettings.Apply(Emulation.EmulationController.Device); + + CurrentSettings.Commit(); + } + + public void Discard() + { + CurrentSettings = null; + } + + public void ReleaseWait() + { + IsWaiting = false; + + this.ActivateSignal("waitReleased"); + } + + public void RefreshInputDevices() + { + int GamePadIndex = 0; + + List GamePads = new List(); + + while (true) + { + GamePadState State = GamePad.GetState(GamePadIndex); + + if (State.IsConnected) + { + GamePads.Add(State); + } + else + { + break; + } + + GamePadIndex++; + } + + GamePadStates = GamePads.ToArray(); + } + + public void SetValue(string Key,object Value) + { + CurrentSettings.SetValue(Key, Value); + } + + public object GetValue(string Key) + { + return CurrentSettings.GetValue(Key); + } + + public string GetKeyboardKey(string Key) + { + Key KeyCode = (Key)GetValue(Key); + + return Enum.GetName(typeof(Key), KeyCode); + } + + public async Task GetKeyboardInput(string SettingKey) + { + if (IsWaiting) + { + return string.Empty; + } + + this.ActivateSignal("showWaitDialog"); + + IsWaiting = true; + + Key Key = default(Key); + + bool GotKey = false; + + while (IsWaiting) + { + await Task.Delay(16); + + KeyboardState Keyboard = GetState(); + + if (Keyboard.IsAnyKeyDown) + { + foreach (Key KeyCode in Enum.GetValues(typeof(Key))) + { + if (Keyboard.IsKeyDown(KeyCode)) + { + Key = KeyCode; + + GotKey = true; + + break; + } + } + } + + if (GotKey) + { + break; + } + } + + if (!GotKey) + { + return string.Empty; + } + + CurrentSettings.SetValue(SettingKey, (short)Key); + + ReleaseWait(); + + return Enum.GetName(typeof(Key), Key); + } + + public async Task GetGamePadInput(string SettingKey, int GamePadIndex) + { + float TriggerThreshold = CurrentSettings.GetValue("GamePad_Trigger_Threshold"); + + while (true) + { + await Task.Delay(33); + + RefreshInputDevices(); + + if (GamePadIndex >= GamePadStates.Length) + { + // TODO :throw error here + + return string.Empty; + } + + if(GamePadStates[GamePadIndex].Buttons.IsAnyButtonPressed) + { + if (GamePadStates[GamePadIndex].Buttons.A == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "A"); + + return "A"; + } + if (GamePadStates[GamePadIndex].Buttons.B == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "B"); + + return "B"; + } + if (GamePadStates[GamePadIndex].Buttons.X == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "X"); + + return "X"; + } + if (GamePadStates[GamePadIndex].Buttons.Y == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "Y"); + + return "Y"; + } + if (GamePadStates[GamePadIndex].Buttons.LeftShoulder == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "LShoulder"); + + return "LShoulder"; + } + if (GamePadStates[GamePadIndex].Buttons.RightShoulder == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "RShoulder"); + + return "RShoulder"; + } + if (GamePadStates[GamePadIndex].Buttons.LeftStick == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "LStick"); + + return "LStick"; + } + if (GamePadStates[GamePadIndex].Buttons.RightStick == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "RStick"); + + return "RStick"; + } + if (GamePadStates[GamePadIndex].Buttons.Start == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "Start"); + + return "Start"; + } + if (GamePadStates[GamePadIndex].Buttons.Back == ButtonState.Pressed) + { + CurrentSettings.SetValue(SettingKey, "Back"); + + return "Back"; + } + } + else if (GamePadStates[GamePadIndex].DPad.IsUp) + { + CurrentSettings.SetValue(SettingKey, "DPadUp"); + + return "A"; + } + else if (GamePadStates[GamePadIndex].DPad.IsDown) + { + CurrentSettings.SetValue(SettingKey, "DPadDown"); + + return "DPadDown"; + } + else if (GamePadStates[GamePadIndex].DPad.IsLeft) + { + CurrentSettings.SetValue(SettingKey, "DPadLeft"); + + return "DPadLeft"; + } + else if (GamePadStates[GamePadIndex].DPad.IsRight) + { + CurrentSettings.SetValue(SettingKey, "DPadRight"); + + return "DPadRight"; + } + } + + } + } +} diff --git a/Ryujinx.UI/UI/Views/Configuration.qml b/Ryujinx.UI/UI/Views/Configuration.qml index f7ac395617..65c552b0ec 100644 --- a/Ryujinx.UI/UI/Views/Configuration.qml +++ b/Ryujinx.UI/UI/Views/Configuration.qml @@ -3,6 +3,7 @@ import QtQuick.Window 2.11 import QtQuick.Layouts 1.3 import QtQuick.Templates 2.4 import QtQuick.Controls 2.3 +import Ryujinx 1.0 Window { id: configWindow @@ -12,6 +13,10 @@ Window { title: "Configuration" modality: Qt.ApplicationModal + onClosing: { + configModel.dispose() + } + ColumnLayout { spacing: 10 id: contentColumn @@ -102,6 +107,7 @@ Window { text: "OK" onClicked: { + configModel.save() configWindow.close() } @@ -115,10 +121,15 @@ Window { visible: true onClicked: { + configModel.discard() configWindow.close() } } } } + + ConfigurationModel { + id: configModel + } } diff --git a/Ryujinx.UI/UI/Views/GeneralSettings.qml b/Ryujinx.UI/UI/Views/GeneralSettings.qml index 3d0fdd8908..c1b4cb5e64 100644 --- a/Ryujinx.UI/UI/Views/GeneralSettings.qml +++ b/Ryujinx.UI/UI/Views/GeneralSettings.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 +import Ryujinx 1.0 Frame { id: generalSetttingsFrame @@ -16,12 +17,24 @@ Frame { id: dockedCheckBox text: "Enable Docked Mode" + checked: configModel.getValue("Docked_Mode") + + onCheckedChanged: { + configModel.setValue("Docked_Mode", checked) + } + } CheckBox { id: vsyncCheckBox text: "Enable Ingame VSync" + checked: configModel.getValue("Enable_Vsync") + + onCheckedChanged: { + configModel.setValue("Enable_Vsync", checked) + } + } } } @@ -32,17 +45,45 @@ Frame { Column { CheckBox { id: memoryCheckBox - text: "Enable Memory Checks" + text: "Enable Memory Checks (slow)" + + checked: configModel.getValue("Enable_Memory_Checks") + + onCheckedChanged: { + configModel.setValue("Enable_Memory_Checks", checked) + } } CheckBox { id: multiCoreCheckBox - text: "Enable Multi-Core Scheduling" + text: "Enable MultiCore Scheduling" + + checked: configModel.getValue("Enable_MultiCore_Scheduling") + + onCheckedChanged: { + configModel.setValue("Enable_MultiCore_Scheduling", checked) + } + + } + + CheckBox { + id: fsIntegrityCheckBox + text: "Enable RomFS Integrity Checks" + + checked: configModel.getValue("Enable_FS_Integrity_Checks") + + onCheckedChanged: { + configModel.setValue("Enable_FS_Integrity_Checks", checked) + } } } } } + ConfigurationModel { + id:configModel + } + } diff --git a/Ryujinx.UI/UI/Views/KeyboardSettings.qml b/Ryujinx.UI/UI/Views/KeyboardSettings.qml index 972141aeec..1c3818d6f7 100644 --- a/Ryujinx.UI/UI/Views/KeyboardSettings.qml +++ b/Ryujinx.UI/UI/Views/KeyboardSettings.qml @@ -1,6 +1,8 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 +import QtQuick.Dialogs 1.3 +import Ryujinx 1.0 Frame { id: keyboardSettingsFrame @@ -42,10 +44,22 @@ Frame { } Button { - text: "Up" Layout.fillHeight: true Layout.fillWidth: true id: leftStickUpButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Stick_Up") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Stick_Up") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -60,10 +74,22 @@ Frame { } Button { - text: "Down" Layout.fillHeight: true Layout.fillWidth: true id: leftStickDownButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Stick_Down") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Stick_Down") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -78,10 +104,22 @@ Frame { } Button { - text: "Left" Layout.fillHeight: true Layout.fillWidth: true id: leftStickLeftButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Stick_Left") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Stick_Left") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -97,10 +135,22 @@ Frame { } Button { - text: "Right" Layout.fillHeight: true Layout.fillWidth: true id: leftStickRightButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Stick_Right") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Stick_Right") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -115,10 +165,22 @@ Frame { } Button { - text: "Button" Layout.fillHeight: true Layout.fillWidth: true id: leftStickButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Stick_Button") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Stick_Button") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -145,10 +207,22 @@ Frame { } Button { - text: "Up" Layout.fillHeight: true Layout.fillWidth: true id: leftDPadUpButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_DPad_Up") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_DPad_Up") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -163,10 +237,22 @@ Frame { } Button { - text: "Down" Layout.fillHeight: true Layout.fillWidth: true id: leftDPadDownButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_DPad_Down") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_DPad_Down") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -181,10 +267,22 @@ Frame { } Button { - text: "Left" Layout.fillHeight: true Layout.fillWidth: true id: leftDPadLeftButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_DPad_Left") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_DPad_Left") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -200,10 +298,22 @@ Frame { } Button { - text: "Right" Layout.fillHeight: true Layout.fillWidth: true id: leftDPadRightButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_DPad_Right") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_DPad_Right") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -232,10 +342,22 @@ Frame { } Button { - text: "L" Layout.fillHeight: true Layout.fillWidth: true id: lButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Button_L") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Button_L") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -250,10 +372,22 @@ Frame { } Button { - text: "ZL" Layout.fillHeight: true Layout.fillWidth: true id: zLButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Button_ZL") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Button_ZL") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -269,10 +403,22 @@ Frame { } Button { - text: "-" Layout.fillHeight: true Layout.fillWidth: true id: minusButton + + text: configModel.getKeyboardKey("Controls_Left_JoyConKeyboard_Button_Minus") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Left_JoyConKeyboard_Button_Minus") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -311,10 +457,22 @@ Frame { } Button { - text: "Up" Layout.fillHeight: true Layout.fillWidth: true id: rightStickUpButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Stick_Up") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Stick_Up") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -329,10 +487,22 @@ Frame { } Button { - text: "Down" Layout.fillHeight: true Layout.fillWidth: true id: rightStickDownButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Stick_Down") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Stick_Down") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -347,10 +517,22 @@ Frame { } Button { - text: "Left" Layout.fillHeight: true Layout.fillWidth: true id: rightStickLeftButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Stick_Left") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Stick_Left") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -366,10 +548,22 @@ Frame { } Button { - text: "Right" Layout.fillHeight: true Layout.fillWidth: true id: rightStickRightButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Stick_Right") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Stick_Right") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -384,10 +578,22 @@ Frame { } Button { - text: "Button" Layout.fillHeight: true Layout.fillWidth: true id: rightStickButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Stick_Button") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Stick_Button") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -414,10 +620,22 @@ Frame { } Button { - text: "X" Layout.fillHeight: true Layout.fillWidth: true id: xButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_X") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_X") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -432,10 +650,22 @@ Frame { } Button { - text: "B" Layout.fillHeight: true Layout.fillWidth: true id: bButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_B") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_B") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -450,10 +680,22 @@ Frame { } Button { - text: "Y" Layout.fillHeight: true Layout.fillWidth: true id: yButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_Y") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_Y") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -469,10 +711,22 @@ Frame { } Button { - text: "A" Layout.fillHeight: true Layout.fillWidth: true id: aButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_A") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_A") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -501,10 +755,22 @@ Frame { } Button { - text: "L" Layout.fillHeight: true Layout.fillWidth: true id: rButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_R") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_R") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } @@ -519,10 +785,22 @@ Frame { } Button { - text: "ZL" Layout.fillHeight: true Layout.fillWidth: true id: zRButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_ZR") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_ZR") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -538,10 +816,22 @@ Frame { } Button { - text: "+" Layout.fillHeight: true Layout.fillWidth: true id: plusButton + + text: configModel.getKeyboardKey("Controls_Right_JoyConKeyboard_Button_Plus") + + onClicked: { + var task = configModel.getKeyboardInput + ("Controls_Right_JoyConKeyboard_Button_Plus") + Net.await(task, function(result){ + if(result !== "") + { + text = result + } + }) + } } } } @@ -550,4 +840,28 @@ Frame { } } } + + MessageDialog { + id: inputWaitMessageDialog + text: "Please press a key..." + standardButtons: StandardButton.Close + + onRejected: { + configModel.releaseWait() + } + } + + ConfigurationModel { + id: configModel + + onWaitReleased: { + if(inputWaitMessageDialog.visible){ + inputWaitMessageDialog.close() + } + } + + onShowWaitDialog: { + inputWaitMessageDialog.open() + } + } } diff --git a/Ryujinx.UI/UI/Views/MiscSettings.qml b/Ryujinx.UI/UI/Views/MiscSettings.qml index 50ec0bc944..72ab70fc37 100644 --- a/Ryujinx.UI/UI/Views/MiscSettings.qml +++ b/Ryujinx.UI/UI/Views/MiscSettings.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 +import Ryujinx 1.0 Frame { id: miscSettingsFrame @@ -18,13 +19,6 @@ Frame { ColumnLayout { id: column anchors.fill: parent - CheckBox { - id: loggingCheckBox - text: "Enable Logging" - Layout.fillHeight: false - Layout.fillWidth: true - - } RowLayout { id: row @@ -43,26 +37,56 @@ Frame { CheckBox { id: debugLogCheckBox text: "Debug" + + checked: configModel.getValue("Logging_Enable_Debug") + + onCheckedChanged: { + configModel.setValue("Logging_Enable_Debug", checked) + } } CheckBox { id: stubLogCheckBox text: "Stub" + + checked: configModel.getValue("Logging_Enable_Stub") + + onCheckedChanged: { + configModel.setValue("Logging_Enable_Stub", checked) + } } CheckBox { id: infoLogCheckBox text: "Info" + + checked: configModel.getValue("Logging_Enable_Info") + + onCheckedChanged: { + configModel.setValue("Logging_Enable_Info", checked) + } } CheckBox { id: warnLogCheckBox text: "Warning" + + checked: configModel.getValue("Logging_Enable_Warn") + + onCheckedChanged: { + configModel.setValue("Logging_Enable_Warn", checked) + } } CheckBox { id: errorLogCheckBox text: "Error" + + checked: configModel.getValue("Logging_Enable_Error") + + onCheckedChanged: { + configModel.setValue("Logging_Enable_Error", checked) + } } } } @@ -73,11 +97,20 @@ Frame { Layout.fillHeight: true Layout.fillWidth: true - TextEdit { + TextArea { id: logClassesTextArea selectionColor: "#004a80" renderType: Text.NativeRendering anchors.fill: parent + background: Rectangle { + color: "#ffffff" + } + + text: configModel.getValue("Logging_Filtered_Classes") + + onEditingFinished: { + configModel.setValue("Logging_Filtered_Classes", text) + } } } @@ -86,4 +119,8 @@ Frame { } } } + + ConfigurationModel { + id: configModel + } } diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 197a8cad65..386f06a3a4 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -12,8 +12,8 @@ namespace Ryujinx { public static class Config { - public static JoyConKeyboard JoyConKeyboard { get; private set; } - public static JoyConController JoyConController { get; private set; } + public static JoyConKeyboard JoyConKeyboard { get; set; } + public static JoyConController JoyConController { get; set; } public static void Read(Switch Device) { @@ -138,7 +138,7 @@ namespace Ryujinx }); } - private static ControllerInputID ToID(string Key) + public static ControllerInputID ToID(string Key) { switch (Key.ToUpper()) {