diff --git a/Ryujinx/Configuration.cs b/Ryujinx/Configuration.cs
index 9f2a08d0bf..444ac468bd 100644
--- a/Ryujinx/Configuration.cs
+++ b/Ryujinx/Configuration.cs
@@ -138,12 +138,12 @@ namespace Ryujinx
///
/// Enable or disable keyboard support (Independent from controllers binding)
///
- public bool EnableKeyboard { get; private set; }
+ public bool EnableKeyboard { get; set; }
///
/// Keyboard control bindings
///
- public NpadKeyboard KeyboardControls { get; private set; }
+ public NpadKeyboard KeyboardControls { get; set; }
///
/// Controller control bindings
@@ -211,6 +211,7 @@ namespace Ryujinx
}
GeneralSettings.ConfigureSettings(Instance);
+ ControlSettings.ConfigureControls(Instance);
Logger.AddTarget(new AsyncLogTargetWrapper(
new ConsoleLogTarget(),
diff --git a/Ryujinx/GUI/ControlSettings.cs b/Ryujinx/GUI/ControlSettings.cs
new file mode 100644
index 0000000000..9f0790115f
--- /dev/null
+++ b/Ryujinx/GUI/ControlSettings.cs
@@ -0,0 +1,246 @@
+using Gtk;
+using GUI = Gtk.Builder.ObjectAttribute;
+using Ryujinx.UI.Input;
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+
+namespace Ryujinx
+{
+ public class ControlSettings : Window
+ {
+ private HLE.Switch device { get; set; }
+
+ internal static Configuration SwitchConfig { get; private set; }
+
+ [GUI] Window CSWin;
+ [GUI] CheckButton EnableKeyboard;
+ [GUI] Image ControllerImage;
+
+ [GUI] ToggleButton LStickUp1;
+ [GUI] ToggleButton LStickDown1;
+ [GUI] ToggleButton LStickLeft1;
+ [GUI] ToggleButton LStickRight1;
+ [GUI] ToggleButton LStickButton1;
+ [GUI] ToggleButton DpadUp1;
+ [GUI] ToggleButton DpadDown1;
+ [GUI] ToggleButton DpadLeft1;
+ [GUI] ToggleButton DpadRight1;
+ [GUI] ToggleButton Minus1;
+ [GUI] ToggleButton L1;
+ [GUI] ToggleButton ZL1;
+ [GUI] ToggleButton RStickUp1;
+ [GUI] ToggleButton RStickDown1;
+ [GUI] ToggleButton RStickLeft1;
+ [GUI] ToggleButton RStickRight1;
+ [GUI] ToggleButton RStickButton1;
+ [GUI] ToggleButton A1;
+ [GUI] ToggleButton B1;
+ [GUI] ToggleButton X1;
+ [GUI] ToggleButton Y1;
+ [GUI] ToggleButton Plus1;
+ [GUI] ToggleButton R1;
+ [GUI] ToggleButton ZR1;
+
+ public static void ConfigureControls(Configuration Instance) { SwitchConfig = Instance; }
+
+ public ControlSettings(HLE.Switch _device) : this(new Builder("Ryujinx.GUI.ControlSettings.glade"), _device) { }
+
+ private ControlSettings(Builder builder, HLE.Switch _device) : base(builder.GetObject("CSWin").Handle)
+ {
+ device = _device;
+
+ builder.Autoconnect(this);
+
+ CSWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
+ ControllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png", 500, 500);
+
+ LStickUp1.Toggled += (o, args) => Button_Pressed(o, args, LStickUp1);
+ LStickDown1.Toggled += (o, args) => Button_Pressed(o, args, LStickDown1);
+ LStickLeft1.Toggled += (o, args) => Button_Pressed(o, args, LStickLeft1);
+ LStickRight1.Toggled += (o, args) => Button_Pressed(o, args, LStickRight1);
+ LStickButton1.Toggled += (o, args) => Button_Pressed(o, args, LStickButton1);
+ DpadUp1.Toggled += (o, args) => Button_Pressed(o, args, DpadUp1);
+ DpadDown1.Toggled += (o, args) => Button_Pressed(o, args, DpadDown1);
+ DpadLeft1.Toggled += (o, args) => Button_Pressed(o, args, DpadLeft1);
+ DpadRight1.Toggled += (o, args) => Button_Pressed(o, args, DpadRight1);
+ Minus1.Toggled += (o, args) => Button_Pressed(o, args, Minus1);
+ L1.Toggled += (o, args) => Button_Pressed(o, args, L1);
+ ZL1.Toggled += (o, args) => Button_Pressed(o, args, ZL1);
+ RStickUp1.Toggled += (o, args) => Button_Pressed(o, args, RStickUp1);
+ RStickDown1.Toggled += (o, args) => Button_Pressed(o, args, RStickDown1);
+ RStickLeft1.Toggled += (o, args) => Button_Pressed(o, args, RStickLeft1);
+ RStickRight1.Toggled += (o, args) => Button_Pressed(o, args, RStickRight1);
+ RStickButton1.Toggled += (o, args) => Button_Pressed(o, args, RStickButton1);
+ A1.Toggled += (o, args) => Button_Pressed(o, args, A1);
+ B1.Toggled += (o, args) => Button_Pressed(o, args, B1);
+ X1.Toggled += (o, args) => Button_Pressed(o, args, X1);
+ Y1.Toggled += (o, args) => Button_Pressed(o, args, Y1);
+ Plus1.Toggled += (o, args) => Button_Pressed(o, args, Plus1);
+ R1.Toggled += (o, args) => Button_Pressed(o, args, R1);
+ ZR1.Toggled += (o, args) => Button_Pressed(o, args, ZR1);
+
+ if (SwitchConfig.EnableKeyboard) { EnableKeyboard.Click(); }
+ LStickUp1.Label = SwitchConfig.KeyboardControls.LeftJoycon.StickUp.ToString();
+ LStickDown1.Label = SwitchConfig.KeyboardControls.LeftJoycon.StickDown.ToString();
+ LStickLeft1.Label = SwitchConfig.KeyboardControls.LeftJoycon.StickLeft.ToString();
+ LStickRight1.Label = SwitchConfig.KeyboardControls.LeftJoycon.StickRight.ToString();
+ LStickButton1.Label = SwitchConfig.KeyboardControls.LeftJoycon.StickButton.ToString();
+ DpadUp1.Label = SwitchConfig.KeyboardControls.LeftJoycon.DPadUp.ToString();
+ DpadDown1.Label = SwitchConfig.KeyboardControls.LeftJoycon.DPadDown.ToString();
+ DpadLeft1.Label = SwitchConfig.KeyboardControls.LeftJoycon.DPadLeft.ToString();
+ DpadRight1.Label = SwitchConfig.KeyboardControls.LeftJoycon.DPadRight.ToString();
+ Minus1.Label = SwitchConfig.KeyboardControls.LeftJoycon.ButtonMinus.ToString();
+ L1.Label = SwitchConfig.KeyboardControls.LeftJoycon.ButtonL.ToString();
+ ZL1.Label = SwitchConfig.KeyboardControls.LeftJoycon.ButtonZl.ToString();
+ RStickUp1.Label = SwitchConfig.KeyboardControls.RightJoycon.StickUp.ToString();
+ RStickDown1.Label = SwitchConfig.KeyboardControls.RightJoycon.StickDown.ToString();
+ RStickLeft1.Label = SwitchConfig.KeyboardControls.RightJoycon.StickLeft.ToString();
+ RStickRight1.Label = SwitchConfig.KeyboardControls.RightJoycon.StickRight.ToString();
+ RStickButton1.Label = SwitchConfig.KeyboardControls.RightJoycon.StickButton.ToString();
+ A1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonA.ToString();
+ B1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonB.ToString();
+ X1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonX.ToString();
+ Y1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonY.ToString();
+ Plus1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonPlus.ToString();
+ R1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonR.ToString();
+ ZR1.Label = SwitchConfig.KeyboardControls.RightJoycon.ButtonZr.ToString();
+ }
+
+ //Events
+ private void Button_Pressed(object button, EventArgs args, ToggleButton Button)
+ {
+ KeyPressEvent += On_KeyPress;
+
+ void On_KeyPress(object obj , KeyPressEventArgs KeyPressed)
+ {
+ string key = KeyPressed.Event.Key.ToString();
+
+ if (GdkToTKInput.ContainsKey(key)) { Button.Label = GdkToTKInput[key]; }
+ else { Button.Label = "A"; }
+
+ Button.SetStateFlags(0, true);
+ KeyPressEvent -= On_KeyPress;
+ }
+ }
+
+ private void SaveToggle_Activated(object obj, EventArgs args)
+ {
+ if (EnableKeyboard.Active) { SwitchConfig.EnableKeyboard = true; }
+
+ SwitchConfig.KeyboardControls.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),
+ };
+
+ SwitchConfig.KeyboardControls.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),
+ };
+
+ Configuration.SaveConfig(SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
+ Configuration.Configure(device, SwitchConfig);
+
+ Destroy();
+ }
+
+ private void CloseToggle_Activated(object obj, EventArgs args)
+ {
+ Destroy();
+ }
+
+ public readonly Dictionary GdkToTKInput = new Dictionary()
+ {
+ {"A", "A"},
+ {"B", "B"},
+ {"C", "C"},
+ {"D", "D"},
+ {"E", "E"},
+ {"F", "F"},
+ {"G", "G"},
+ {"H", "H"},
+ {"I", "I"},
+ {"J", "J"},
+ {"K", "K"},
+ {"L", "L"},
+ {"M", "M"},
+ {"N", "N"},
+ {"O", "O"},
+ {"P", "P"},
+ {"Q", "Q"},
+ {"R", "R"},
+ {"S", "S"},
+ {"T", "T"},
+ {"U", "U"},
+ {"V", "V"},
+ {"W", "W"},
+ {"X", "X"},
+ {"Y", "Y"},
+ {"Z", "Z"},
+ {"a", "A"},
+ {"b", "B"},
+ {"c", "C"},
+ {"d", "D"},
+ {"e", "E"},
+ {"f", "F"},
+ {"g", "G"},
+ {"h", "H"},
+ {"i", "I"},
+ {"j", "J"},
+ {"k", "K"},
+ {"l", "L"},
+ {"m", "M"},
+ {"n", "N"},
+ {"o", "O"},
+ {"p", "P"},
+ {"q", "Q"},
+ {"r", "R"},
+ {"s", "S"},
+ {"t", "T"},
+ {"u", "U"},
+ {"v", "V"},
+ {"w", "W"},
+ {"x", "X"},
+ {"y", "Y"},
+ {"z", "Z"},
+ {"Key_0", "Number0"},
+ {"Key_1", "Number1"},
+ {"Key_2", "Number2"},
+ {"Key_3", "Number3"},
+ {"Key_4", "Number4"},
+ {"Key_5", "Number5"},
+ {"Key_6", "Number6"},
+ {"Key_7", "Number7"},
+ {"Key_8", "Number8"},
+ {"Key_9", "Number9"},
+ {"equal", "Plus"},
+ {"minus", "Minus"},
+ {"uparrow", "Up"},
+ {"downarrow", "Down"},
+ {"leftarrow", "Left"},
+ {"rightarrow", "Right"},
+ };
+ }
+}
diff --git a/Ryujinx/GUI/ControlSettings.glade b/Ryujinx/GUI/ControlSettings.glade
new file mode 100644
index 0000000000..b296a2f731
--- /dev/null
+++ b/Ryujinx/GUI/ControlSettings.glade
@@ -0,0 +1,850 @@
+
+
+
+
+
+
diff --git a/Ryujinx/GUI/GeneralSettings.cs b/Ryujinx/GUI/GeneralSettings.cs
index e3d16483df..92cf24cf88 100644
--- a/Ryujinx/GUI/GeneralSettings.cs
+++ b/Ryujinx/GUI/GeneralSettings.cs
@@ -13,7 +13,6 @@ namespace Ryujinx
internal static Configuration SwitchConfig { get; private set; }
- //UI Controls
[GUI] Window GSWin;
[GUI] CheckButton ErrorLogToggle;
[GUI] CheckButton WarningLogToggle;
@@ -28,6 +27,7 @@ namespace Ryujinx
[GUI] CheckButton FSICToggle;
[GUI] CheckButton AggrToggle;
[GUI] CheckButton IgnoreToggle;
+ [GUI] CheckButton DirectKeyboardAccess;
[GUI] ComboBoxText SystemLanguageSelect;
[GUI] CheckButton CustThemeToggle;
[GUI] Entry CustThemeDir;
@@ -58,6 +58,7 @@ namespace Ryujinx
if (SwitchConfig.EnableFsIntegrityChecks) { FSICToggle.Click(); }
if (SwitchConfig.EnableAggressiveCpuOpts) { AggrToggle.Click(); }
if (SwitchConfig.IgnoreMissingServices) { IgnoreToggle.Click(); }
+ if (SwitchConfig.EnableKeyboard) { DirectKeyboardAccess.Click(); }
if (SwitchConfig.EnableCustomTheme) { CustThemeToggle.Click(); }
SystemLanguageSelect.SetActiveId(SwitchConfig.SystemLanguage.ToString());
@@ -73,27 +74,23 @@ namespace Ryujinx
if (CustThemeToggle.Active == false) { CustThemeDir.Sensitive = false; } else { CustThemeDir.Sensitive = true; }
}
- private void CloseToggle_Activated(object obj, EventArgs args)
- {
- Destroy();
- }
-
private void SaveToggle_Activated(object obj, EventArgs args)
{
- if (ErrorLogToggle.Active) { SwitchConfig.LoggingEnableError = true; }
- if (WarningLogToggle.Active) { SwitchConfig.LoggingEnableWarn = true; }
- if (InfoLogToggle.Active) { SwitchConfig.LoggingEnableInfo = true; }
- if (StubLogToggle.Active) { SwitchConfig.LoggingEnableStub = true; }
- if (DebugLogToggle.Active) { SwitchConfig.LoggingEnableDebug = true; }
- if (FileLogToggle.Active) { SwitchConfig.EnableFileLog = true; }
- if (DockedModeToggle.Active) { SwitchConfig.DockedMode = true; }
- if (DiscordToggle.Active) { SwitchConfig.EnableDiscordIntergration = true; }
- if (VSyncToggle.Active) { SwitchConfig.EnableVsync = true; }
- if (MultiSchedToggle.Active) { SwitchConfig.EnableMulticoreScheduling = true; }
- if (FSICToggle.Active) { SwitchConfig.EnableFsIntegrityChecks = true; }
- if (AggrToggle.Active) { SwitchConfig.EnableAggressiveCpuOpts = true; }
- if (IgnoreToggle.Active) { SwitchConfig.IgnoreMissingServices = true; }
- if (CustThemeToggle.Active) { SwitchConfig.EnableCustomTheme = true; }
+ if (ErrorLogToggle.Active) { SwitchConfig.LoggingEnableError = true; }
+ if (WarningLogToggle.Active) { SwitchConfig.LoggingEnableWarn = true; }
+ if (InfoLogToggle.Active) { SwitchConfig.LoggingEnableInfo = true; }
+ if (StubLogToggle.Active) { SwitchConfig.LoggingEnableStub = true; }
+ if (DebugLogToggle.Active) { SwitchConfig.LoggingEnableDebug = true; }
+ if (FileLogToggle.Active) { SwitchConfig.EnableFileLog = true; }
+ if (DockedModeToggle.Active) { SwitchConfig.DockedMode = true; }
+ if (DiscordToggle.Active) { SwitchConfig.EnableDiscordIntergration = true; }
+ if (VSyncToggle.Active) { SwitchConfig.EnableVsync = true; }
+ if (MultiSchedToggle.Active) { SwitchConfig.EnableMulticoreScheduling = true; }
+ if (FSICToggle.Active) { SwitchConfig.EnableFsIntegrityChecks = true; }
+ if (AggrToggle.Active) { SwitchConfig.EnableAggressiveCpuOpts = true; }
+ if (IgnoreToggle.Active) { SwitchConfig.IgnoreMissingServices = true; }
+ if (DirectKeyboardAccess.Active) { SwitchConfig.EnableKeyboard = true; }
+ if (CustThemeToggle.Active) { SwitchConfig.EnableCustomTheme = true; }
SwitchConfig.SystemLanguage = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), SystemLanguageSelect.ActiveId);
SwitchConfig.CustomThemePath = CustThemeDir.Buffer.Text;
@@ -105,5 +102,10 @@ namespace Ryujinx
Destroy();
}
+
+ private void CloseToggle_Activated(object obj, EventArgs args)
+ {
+ Destroy();
+ }
}
}
diff --git a/Ryujinx/GUI/GeneralSettings.glade b/Ryujinx/GUI/GeneralSettings.glade
index ca4c4d6da6..8203e3a1ca 100644
--- a/Ryujinx/GUI/GeneralSettings.glade
+++ b/Ryujinx/GUI/GeneralSettings.glade
@@ -4,6 +4,7 @@
False
+ Ryujinx - General Settings
True
dialog
@@ -236,6 +237,7 @@
True
False
+ end
System Language:
@@ -273,10 +275,12 @@
-
+
+ Direct Keyboard Access
True
- False
- gtk-discard
+ True
+ False
+ True
1
diff --git a/Ryujinx/GUI/MainMenu.cs b/Ryujinx/GUI/MainMenu.cs
index 141efebdb9..1a6800f7e2 100644
--- a/Ryujinx/GUI/MainMenu.cs
+++ b/Ryujinx/GUI/MainMenu.cs
@@ -31,10 +31,8 @@ namespace Ryujinx
private static ListStore TableStore { get; set; }
- //UI Controls
[GUI] Window MainWin;
[GUI] MenuItem NFC;
- [GUI] MenuItem ControlSettingsMenu;
[GUI] TreeView GameTable;
[GUI] ScrolledWindow GameTableWindow;
[GUI] GLArea GLScreen;
@@ -102,7 +100,6 @@ namespace Ryujinx
GLScreen.Hide();
NFC.Sensitive = false;
- ControlSettingsMenu.Sensitive = false;
GameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0);
GameTable.AppendColumn("Game", new CellRendererText(), "text", 1);
@@ -327,6 +324,14 @@ namespace Ryujinx
GSWin.Show();
}
+ private void Control_Settings_Pressed(object o, EventArgs args)
+ {
+ var CSWin = new ControlSettings(device);
+ gtkapp.Register(GLib.Cancellable.Current);
+ gtkapp.AddWindow(CSWin);
+ CSWin.Show();
+ }
+
private void NFC_Pressed(object o, EventArgs args)
{
FileChooserDialog fc = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
diff --git a/Ryujinx/GUI/MainMenu.glade b/Ryujinx/GUI/MainMenu.glade
index 47665c4f98..ddece64b5e 100644
--- a/Ryujinx/GUI/MainMenu.glade
+++ b/Ryujinx/GUI/MainMenu.glade
@@ -7,6 +7,9 @@
Ryujinx
1280
750
+
+
+
True
@@ -88,6 +91,7 @@
False
Control Settings
True
+
diff --git a/Ryujinx/GUI/assets/ryujinxIcon.png b/Ryujinx/GUI/assets/ryujinxIcon.png
index 17716fb3e4..2fc7b0174c 100644
Binary files a/Ryujinx/GUI/assets/ryujinxIcon.png and b/Ryujinx/GUI/assets/ryujinxIcon.png differ
diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj
index c24b888c80..8178411287 100644
--- a/Ryujinx/Ryujinx.csproj
+++ b/Ryujinx/Ryujinx.csproj
@@ -21,6 +21,7 @@
+
diff --git a/Ryujinx/Ui/NpadKeyboard.cs b/Ryujinx/Ui/NpadKeyboard.cs
index 79d6330c61..ac739c0867 100644
--- a/Ryujinx/Ui/NpadKeyboard.cs
+++ b/Ryujinx/Ui/NpadKeyboard.cs
@@ -45,12 +45,12 @@ namespace Ryujinx.UI.Input
///
/// Left JoyCon Keyboard Bindings
///
- public NpadKeyboardLeft LeftJoycon { get; private set; }
+ public NpadKeyboardLeft LeftJoycon { get; set; }
///
/// Right JoyCon Keyboard Bindings
///
- public NpadKeyboardRight RightJoycon { get; private set; }
+ public NpadKeyboardRight RightJoycon { get; set; }
///
/// Hotkey Keyboard Bindings