SwitchSettings.cs 25 KB

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