SwitchSettings.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. using Gtk;
  2. using Ryujinx.Configuration;
  3. using Ryujinx.Configuration.Hid;
  4. using Ryujinx.Configuration.System;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using GUI = Gtk.Builder.ObjectAttribute;
  11. namespace Ryujinx.Ui
  12. {
  13. public class SwitchSettings : Window
  14. {
  15. private static ListStore _gameDirsBoxStore;
  16. private static bool _listeningForKeypress;
  17. #pragma warning disable CS0649
  18. #pragma warning disable IDE0044
  19. [GUI] Window _settingsWin;
  20. [GUI] CheckButton _errorLogToggle;
  21. [GUI] CheckButton _warningLogToggle;
  22. [GUI] CheckButton _infoLogToggle;
  23. [GUI] CheckButton _stubLogToggle;
  24. [GUI] CheckButton _debugLogToggle;
  25. [GUI] CheckButton _fileLogToggle;
  26. [GUI] CheckButton _guestLogToggle;
  27. [GUI] CheckButton _fsAccessLogToggle;
  28. [GUI] Adjustment _fsLogSpinAdjustment;
  29. [GUI] CheckButton _dockedModeToggle;
  30. [GUI] CheckButton _discordToggle;
  31. [GUI] CheckButton _vSyncToggle;
  32. [GUI] CheckButton _multiSchedToggle;
  33. [GUI] CheckButton _fsicToggle;
  34. [GUI] CheckButton _ignoreToggle;
  35. [GUI] CheckButton _directKeyboardAccess;
  36. [GUI] ComboBoxText _systemLanguageSelect;
  37. [GUI] CheckButton _custThemeToggle;
  38. [GUI] Entry _custThemePath;
  39. [GUI] ToggleButton _browseThemePath;
  40. [GUI] Label _custThemePathLabel;
  41. [GUI] TreeView _gameDirsBox;
  42. [GUI] Entry _addGameDirBox;
  43. [GUI] ToggleButton _addDir;
  44. [GUI] ToggleButton _browseDir;
  45. [GUI] ToggleButton _removeDir;
  46. [GUI] Entry _logPath;
  47. [GUI] Entry _graphicsShadersDumpPath;
  48. [GUI] Image _controller1Image;
  49. [GUI] ComboBoxText _controller1Type;
  50. [GUI] ToggleButton _lStickUp1;
  51. [GUI] ToggleButton _lStickDown1;
  52. [GUI] ToggleButton _lStickLeft1;
  53. [GUI] ToggleButton _lStickRight1;
  54. [GUI] ToggleButton _lStickButton1;
  55. [GUI] ToggleButton _dpadUp1;
  56. [GUI] ToggleButton _dpadDown1;
  57. [GUI] ToggleButton _dpadLeft1;
  58. [GUI] ToggleButton _dpadRight1;
  59. [GUI] ToggleButton _minus1;
  60. [GUI] ToggleButton _l1;
  61. [GUI] ToggleButton _zL1;
  62. [GUI] ToggleButton _rStickUp1;
  63. [GUI] ToggleButton _rStickDown1;
  64. [GUI] ToggleButton _rStickLeft1;
  65. [GUI] ToggleButton _rStickRight1;
  66. [GUI] ToggleButton _rStickButton1;
  67. [GUI] ToggleButton _a1;
  68. [GUI] ToggleButton _b1;
  69. [GUI] ToggleButton _x1;
  70. [GUI] ToggleButton _y1;
  71. [GUI] ToggleButton _plus1;
  72. [GUI] ToggleButton _r1;
  73. [GUI] ToggleButton _zR1;
  74. #pragma warning restore CS0649
  75. #pragma warning restore IDE0044
  76. public SwitchSettings() : this(new Builder("Ryujinx.Ui.SwitchSettings.glade")) { }
  77. private SwitchSettings(Builder builder) : base(builder.GetObject("_settingsWin").Handle)
  78. {
  79. builder.Autoconnect(this);
  80. _settingsWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
  81. _controller1Image.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.JoyCon.png", 500, 500);
  82. //Bind Events
  83. _lStickUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickUp1);
  84. _lStickDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickDown1);
  85. _lStickLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickLeft1);
  86. _lStickRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickRight1);
  87. _lStickButton1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickButton1);
  88. _dpadUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadUp1);
  89. _dpadDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadDown1);
  90. _dpadLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadLeft1);
  91. _dpadRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadRight1);
  92. _minus1.Clicked += (sender, args) => Button_Pressed(sender, args, _minus1);
  93. _l1.Clicked += (sender, args) => Button_Pressed(sender, args, _l1);
  94. _zL1.Clicked += (sender, args) => Button_Pressed(sender, args, _zL1);
  95. _rStickUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickUp1);
  96. _rStickDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickDown1);
  97. _rStickLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickLeft1);
  98. _rStickRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickRight1);
  99. _rStickButton1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickButton1);
  100. _a1.Clicked += (sender, args) => Button_Pressed(sender, args, _a1);
  101. _b1.Clicked += (sender, args) => Button_Pressed(sender, args, _b1);
  102. _x1.Clicked += (sender, args) => Button_Pressed(sender, args, _x1);
  103. _y1.Clicked += (sender, args) => Button_Pressed(sender, args, _y1);
  104. _plus1.Clicked += (sender, args) => Button_Pressed(sender, args, _plus1);
  105. _r1.Clicked += (sender, args) => Button_Pressed(sender, args, _r1);
  106. _zR1.Clicked += (sender, args) => Button_Pressed(sender, args, _zR1);
  107. _controller1Type.Changed += (sender, args) => Controller_Changed(sender, args, _controller1Type.ActiveId, _controller1Image);
  108. //Setup Currents
  109. if (ConfigurationState.Instance.Logger.EnableFileLog)
  110. {
  111. _fileLogToggle.Click();
  112. }
  113. if (ConfigurationState.Instance.Logger.EnableError)
  114. {
  115. _errorLogToggle.Click();
  116. }
  117. if (ConfigurationState.Instance.Logger.EnableWarn)
  118. {
  119. _warningLogToggle.Click();
  120. }
  121. if (ConfigurationState.Instance.Logger.EnableInfo)
  122. {
  123. _infoLogToggle.Click();
  124. }
  125. if (ConfigurationState.Instance.Logger.EnableStub)
  126. {
  127. _stubLogToggle.Click();
  128. }
  129. if (ConfigurationState.Instance.Logger.EnableDebug)
  130. {
  131. _debugLogToggle.Click();
  132. }
  133. if (ConfigurationState.Instance.Logger.EnableGuest)
  134. {
  135. _guestLogToggle.Click();
  136. }
  137. if (ConfigurationState.Instance.Logger.EnableFsAccessLog)
  138. {
  139. _fsAccessLogToggle.Click();
  140. }
  141. if (ConfigurationState.Instance.System.EnableDockedMode)
  142. {
  143. _dockedModeToggle.Click();
  144. }
  145. if (ConfigurationState.Instance.EnableDiscordIntegration)
  146. {
  147. _discordToggle.Click();
  148. }
  149. if (ConfigurationState.Instance.Graphics.EnableVsync)
  150. {
  151. _vSyncToggle.Click();
  152. }
  153. if (ConfigurationState.Instance.System.EnableMulticoreScheduling)
  154. {
  155. _multiSchedToggle.Click();
  156. }
  157. if (ConfigurationState.Instance.System.EnableFsIntegrityChecks)
  158. {
  159. _fsicToggle.Click();
  160. }
  161. if (ConfigurationState.Instance.System.IgnoreMissingServices)
  162. {
  163. _ignoreToggle.Click();
  164. }
  165. if (ConfigurationState.Instance.Hid.EnableKeyboard)
  166. {
  167. _directKeyboardAccess.Click();
  168. }
  169. if (ConfigurationState.Instance.Ui.EnableCustomTheme)
  170. {
  171. _custThemeToggle.Click();
  172. }
  173. _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString());
  174. _controller1Type .SetActiveId(ConfigurationState.Instance.Hid.ControllerType.Value.ToString());
  175. Controller_Changed(null, null, _controller1Type.ActiveId, _controller1Image);
  176. _lStickUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickUp.ToString();
  177. _lStickDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickDown.ToString();
  178. _lStickLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickLeft.ToString();
  179. _lStickRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickRight.ToString();
  180. _lStickButton1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickButton.ToString();
  181. _dpadUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadUp.ToString();
  182. _dpadDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadDown.ToString();
  183. _dpadLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadLeft.ToString();
  184. _dpadRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadRight.ToString();
  185. _minus1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonMinus.ToString();
  186. _l1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonL.ToString();
  187. _zL1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonZl.ToString();
  188. _rStickUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickUp.ToString();
  189. _rStickDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickDown.ToString();
  190. _rStickLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickLeft.ToString();
  191. _rStickRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickRight.ToString();
  192. _rStickButton1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickButton.ToString();
  193. _a1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonA.ToString();
  194. _b1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonB.ToString();
  195. _x1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonX.ToString();
  196. _y1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonY.ToString();
  197. _plus1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonPlus.ToString();
  198. _r1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonR.ToString();
  199. _zR1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonZr.ToString();
  200. _custThemePath.Buffer.Text = ConfigurationState.Instance.Ui.CustomThemePath;
  201. _graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Instance.Graphics.ShadersDumpPath;
  202. _fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode;
  203. _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0);
  204. _gameDirsBoxStore = new ListStore(typeof(string));
  205. _gameDirsBox.Model = _gameDirsBoxStore;
  206. foreach (string gameDir in ConfigurationState.Instance.Ui.GameDirs.Value)
  207. {
  208. _gameDirsBoxStore.AppendValues(gameDir);
  209. }
  210. if (_custThemeToggle.Active == false)
  211. {
  212. _custThemePath.Sensitive = false;
  213. _custThemePathLabel.Sensitive = false;
  214. _browseThemePath.Sensitive = false;
  215. }
  216. _logPath.Buffer.Text = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log");
  217. _listeningForKeypress = false;
  218. }
  219. //Events
  220. private void Button_Pressed(object sender, EventArgs args, ToggleButton button)
  221. {
  222. if (_listeningForKeypress == false)
  223. {
  224. KeyPressEvent += On_KeyPress;
  225. _listeningForKeypress = true;
  226. void On_KeyPress(object o, KeyPressEventArgs keyPressed)
  227. {
  228. string key = keyPressed.Event.Key.ToString();
  229. string capKey = key.First().ToString().ToUpper() + key.Substring(1);
  230. if (Enum.IsDefined(typeof(Configuration.Hid.Key), capKey))
  231. {
  232. button.Label = capKey;
  233. }
  234. else if (GdkToOpenTkInput.ContainsKey(key))
  235. {
  236. button.Label = GdkToOpenTkInput[key];
  237. }
  238. else
  239. {
  240. button.Label = "Space";
  241. }
  242. button.SetStateFlags(0, true);
  243. KeyPressEvent -= On_KeyPress;
  244. _listeningForKeypress = false;
  245. }
  246. }
  247. else
  248. {
  249. button.SetStateFlags(0, true);
  250. }
  251. }
  252. private void Controller_Changed(object sender, EventArgs args, string controllerType, Image controllerImage)
  253. {
  254. switch (controllerType)
  255. {
  256. case "ProController":
  257. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ProCon.png", 500, 500);
  258. break;
  259. case "NpadLeft":
  260. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.BlueCon.png", 500, 500);
  261. break;
  262. case "NpadRight":
  263. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.RedCon.png", 500, 500);
  264. break;
  265. default:
  266. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.JoyCon.png", 500, 500);
  267. break;
  268. }
  269. }
  270. private void AddDir_Pressed(object sender, EventArgs args)
  271. {
  272. if (Directory.Exists(_addGameDirBox.Buffer.Text))
  273. {
  274. _gameDirsBoxStore.AppendValues(_addGameDirBox.Buffer.Text);
  275. }
  276. _addDir.SetStateFlags(0, true);
  277. }
  278. private void BrowseDir_Pressed(object sender, EventArgs args)
  279. {
  280. FileChooserDialog fileChooser = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept);
  281. if (fileChooser.Run() == (int)ResponseType.Accept)
  282. {
  283. _gameDirsBoxStore.AppendValues(fileChooser.Filename);
  284. }
  285. fileChooser.Dispose();
  286. _browseDir.SetStateFlags(0, true);
  287. }
  288. private void RemoveDir_Pressed(object sender, EventArgs args)
  289. {
  290. TreeSelection selection = _gameDirsBox.Selection;
  291. selection.GetSelected(out TreeIter treeIter);
  292. _gameDirsBoxStore.Remove(ref treeIter);
  293. _removeDir.SetStateFlags(0, true);
  294. }
  295. private void CustThemeToggle_Activated(object sender, EventArgs args)
  296. {
  297. _custThemePath.Sensitive = _custThemeToggle.Active;
  298. _custThemePathLabel.Sensitive = _custThemeToggle.Active;
  299. _browseThemePath.Sensitive = _custThemeToggle.Active;
  300. }
  301. private void BrowseThemeDir_Pressed(object sender, EventArgs args)
  302. {
  303. FileChooserDialog fileChooser = new FileChooserDialog("Choose the theme to load", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept);
  304. fileChooser.Filter = new FileFilter();
  305. fileChooser.Filter.AddPattern("*.css");
  306. if (fileChooser.Run() == (int)ResponseType.Accept)
  307. {
  308. _custThemePath.Buffer.Text = fileChooser.Filename;
  309. }
  310. fileChooser.Dispose();
  311. _browseThemePath.SetStateFlags(0, true);
  312. }
  313. private void SaveToggle_Activated(object sender, EventArgs args)
  314. {
  315. List<string> gameDirs = new List<string>();
  316. _gameDirsBoxStore.GetIterFirst(out TreeIter treeIter);
  317. for (int i = 0; i < _gameDirsBoxStore.IterNChildren(); i++)
  318. {
  319. _gameDirsBoxStore.GetValue(treeIter, i);
  320. gameDirs.Add((string)_gameDirsBoxStore.GetValue(treeIter, 0));
  321. _gameDirsBoxStore.IterNext(ref treeIter);
  322. }
  323. ConfigurationState.Instance.Logger.EnableError.Value = _errorLogToggle.Active;
  324. ConfigurationState.Instance.Logger.EnableWarn.Value = _warningLogToggle.Active;
  325. ConfigurationState.Instance.Logger.EnableInfo.Value = _infoLogToggle.Active;
  326. ConfigurationState.Instance.Logger.EnableStub.Value = _stubLogToggle.Active;
  327. ConfigurationState.Instance.Logger.EnableDebug.Value = _debugLogToggle.Active;
  328. ConfigurationState.Instance.Logger.EnableGuest.Value = _guestLogToggle.Active;
  329. ConfigurationState.Instance.Logger.EnableFsAccessLog.Value = _fsAccessLogToggle.Active;
  330. ConfigurationState.Instance.Logger.EnableFileLog.Value = _fileLogToggle.Active;
  331. ConfigurationState.Instance.System.EnableDockedMode.Value = _dockedModeToggle.Active;
  332. ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active;
  333. ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active;
  334. ConfigurationState.Instance.System.EnableMulticoreScheduling.Value = _multiSchedToggle.Active;
  335. ConfigurationState.Instance.System.EnableFsIntegrityChecks.Value = _fsicToggle.Active;
  336. ConfigurationState.Instance.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
  337. ConfigurationState.Instance.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
  338. ConfigurationState.Instance.Ui.EnableCustomTheme.Value = _custThemeToggle.Active;
  339. ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon = new NpadKeyboardLeft()
  340. {
  341. StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickUp1.Label),
  342. StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickDown1.Label),
  343. StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickLeft1.Label),
  344. StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickRight1.Label),
  345. StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickButton1.Label),
  346. DPadUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadUp1.Label),
  347. DPadDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadDown1.Label),
  348. DPadLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadLeft1.Label),
  349. DPadRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadRight1.Label),
  350. ButtonMinus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _minus1.Label),
  351. ButtonL = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _l1.Label),
  352. ButtonZl = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zL1.Label),
  353. };
  354. ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon = new NpadKeyboardRight()
  355. {
  356. StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickUp1.Label),
  357. StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickDown1.Label),
  358. StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickLeft1.Label),
  359. StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickRight1.Label),
  360. StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickButton1.Label),
  361. ButtonA = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _a1.Label),
  362. ButtonB = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _b1.Label),
  363. ButtonX = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _x1.Label),
  364. ButtonY = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _y1.Label),
  365. ButtonPlus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _plus1.Label),
  366. ButtonR = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _r1.Label),
  367. ButtonZr = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zR1.Label),
  368. };
  369. ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId);
  370. ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId);
  371. ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
  372. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
  373. ConfigurationState.Instance.Ui.GameDirs.Value = gameDirs;
  374. ConfigurationState.Instance.System.FsGlobalAccessLogMode.Value = (int)_fsLogSpinAdjustment.Value;
  375. MainWindow.SaveConfig();
  376. MainWindow.ApplyTheme();
  377. #pragma warning disable CS4014
  378. MainWindow.UpdateGameTable();
  379. #pragma warning restore CS4014
  380. Dispose();
  381. }
  382. private void CloseToggle_Activated(object sender, EventArgs args)
  383. {
  384. Dispose();
  385. }
  386. public readonly Dictionary<string, string> GdkToOpenTkInput = new Dictionary<string, string>()
  387. {
  388. { "Key_0", "Number0" },
  389. { "Key_1", "Number1" },
  390. { "Key_2", "Number2" },
  391. { "Key_3", "Number3" },
  392. { "Key_4", "Number4" },
  393. { "Key_5", "Number5" },
  394. { "Key_6", "Number6" },
  395. { "Key_7", "Number7" },
  396. { "Key_8", "Number8" },
  397. { "Key_9", "Number9" },
  398. { "equal", "Plus" },
  399. { "uparrow", "Up" },
  400. { "downarrow", "Down" },
  401. { "leftarrow", "Left" },
  402. { "rightarrow", "Right" },
  403. { "Control_L", "ControlLeft" },
  404. { "Control_R", "ControlRight" },
  405. { "Shift_L", "ShiftLeft" },
  406. { "Shift_R", "ShiftRight" },
  407. { "Alt_L", "AltLeft" },
  408. { "Alt_R", "AltRight" },
  409. { "Page_Up", "PageUp" },
  410. { "Page_Down", "PageDown" },
  411. { "KP_Enter", "KeypadEnter" },
  412. { "KP_Up", "Up" },
  413. { "KP_Down", "Down" },
  414. { "KP_Left", "Left" },
  415. { "KP_Right", "Right" },
  416. { "KP_Divide", "KeypadDivide" },
  417. { "KP_Multiply", "KeypadMultiply" },
  418. { "KP_Subtract", "KeypadSubtract" },
  419. { "KP_Add", "KeypadAdd" },
  420. { "KP_Decimal", "KeypadDecimal" },
  421. { "KP_0", "Keypad0" },
  422. { "KP_1", "Keypad1" },
  423. { "KP_2", "Keypad2" },
  424. { "KP_3", "Keypad3" },
  425. { "KP_4", "Keypad4" },
  426. { "KP_5", "Keypad5" },
  427. { "KP_6", "Keypad6" },
  428. { "KP_7", "Keypad7" },
  429. { "KP_8", "Keypad8" },
  430. { "KP_9", "Keypad9" },
  431. };
  432. }
  433. }