SwitchSettings.cs 26 KB

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