SwitchSettings.cs 26 KB

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