RendererWidgetBase.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. using ARMeilleure.Translation;
  2. using ARMeilleure.Translation.PTC;
  3. using Gdk;
  4. using Gtk;
  5. using Ryujinx.Common;
  6. using Ryujinx.Common.Configuration;
  7. using Ryujinx.Common.Logging;
  8. using Ryujinx.Ui.Common.Configuration;
  9. using Ryujinx.Graphics.GAL;
  10. using Ryujinx.Graphics.GAL.Multithreading;
  11. using Ryujinx.Input;
  12. using Ryujinx.Input.GTK3;
  13. using Ryujinx.Input.HLE;
  14. using Ryujinx.Ui.Widgets;
  15. using SixLabors.ImageSharp;
  16. using SixLabors.ImageSharp.Formats.Png;
  17. using SixLabors.ImageSharp.PixelFormats;
  18. using SixLabors.ImageSharp.Processing;
  19. using System;
  20. using System.Diagnostics;
  21. using System.IO;
  22. using System.Threading;
  23. using System.Threading.Tasks;
  24. namespace Ryujinx.Ui
  25. {
  26. using Image = SixLabors.ImageSharp.Image;
  27. using Key = Input.Key;
  28. using Switch = HLE.Switch;
  29. public abstract class RendererWidgetBase : DrawingArea
  30. {
  31. private const int SwitchPanelWidth = 1280;
  32. private const int SwitchPanelHeight = 720;
  33. private const int TargetFps = 60;
  34. public ManualResetEvent WaitEvent { get; set; }
  35. public NpadManager NpadManager { get; }
  36. public TouchScreenManager TouchScreenManager { get; }
  37. public Switch Device { get; private set; }
  38. public IRenderer Renderer { get; private set; }
  39. public bool ScreenshotRequested { get; set; }
  40. protected int WindowWidth { get; private set; }
  41. protected int WindowHeight { get; private set; }
  42. public static event EventHandler<StatusUpdatedEventArgs> StatusUpdatedEvent;
  43. private bool _isActive;
  44. private bool _isStopped;
  45. private bool _toggleFullscreen;
  46. private bool _toggleDockedMode;
  47. private readonly long _ticksPerFrame;
  48. private long _ticks = 0;
  49. private readonly Stopwatch _chrono;
  50. private KeyboardHotkeyState _prevHotkeyState;
  51. private readonly ManualResetEvent _exitEvent;
  52. private readonly CancellationTokenSource _gpuCancellationTokenSource;
  53. // Hide Cursor
  54. const int CursorHideIdleTime = 8; // seconds
  55. private static readonly Cursor _invisibleCursor = new Cursor(Display.Default, CursorType.BlankCursor);
  56. private long _lastCursorMoveTime;
  57. private bool _hideCursorOnIdle;
  58. private InputManager _inputManager;
  59. private IKeyboard _keyboardInterface;
  60. private GraphicsDebugLevel _glLogLevel;
  61. private string _gpuVendorName;
  62. private bool _isMouseInClient;
  63. public RendererWidgetBase(InputManager inputManager, GraphicsDebugLevel glLogLevel)
  64. {
  65. var mouseDriver = new GTK3MouseDriver(this);
  66. _inputManager = inputManager;
  67. _inputManager.SetMouseDriver(mouseDriver);
  68. NpadManager = _inputManager.CreateNpadManager();
  69. TouchScreenManager = _inputManager.CreateTouchScreenManager();
  70. _keyboardInterface = (IKeyboard)_inputManager.KeyboardDriver.GetGamepad("0");
  71. WaitEvent = new ManualResetEvent(false);
  72. _glLogLevel = glLogLevel;
  73. Destroyed += Renderer_Destroyed;
  74. _chrono = new Stopwatch();
  75. _ticksPerFrame = Stopwatch.Frequency / TargetFps;
  76. AddEvents((int)(EventMask.ButtonPressMask
  77. | EventMask.ButtonReleaseMask
  78. | EventMask.PointerMotionMask
  79. | EventMask.ScrollMask
  80. | EventMask.EnterNotifyMask
  81. | EventMask.LeaveNotifyMask
  82. | EventMask.KeyPressMask
  83. | EventMask.KeyReleaseMask));
  84. _exitEvent = new ManualResetEvent(false);
  85. _gpuCancellationTokenSource = new CancellationTokenSource();
  86. _hideCursorOnIdle = ConfigurationState.Instance.HideCursorOnIdle;
  87. _lastCursorMoveTime = Stopwatch.GetTimestamp();
  88. ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorStateChanged;
  89. }
  90. public abstract void InitializeRenderer();
  91. public abstract void SwapBuffers(object image);
  92. public abstract string GetGpuVendorName();
  93. private void HideCursorStateChanged(object sender, ReactiveEventArgs<bool> state)
  94. {
  95. Gtk.Application.Invoke(delegate
  96. {
  97. _hideCursorOnIdle = state.NewValue;
  98. if (_hideCursorOnIdle)
  99. {
  100. _lastCursorMoveTime = Stopwatch.GetTimestamp();
  101. }
  102. else
  103. {
  104. Window.Cursor = null;
  105. }
  106. });
  107. }
  108. private void Renderer_Destroyed(object sender, EventArgs e)
  109. {
  110. ConfigurationState.Instance.HideCursorOnIdle.Event -= HideCursorStateChanged;
  111. NpadManager.Dispose();
  112. Dispose();
  113. }
  114. protected override bool OnMotionNotifyEvent(EventMotion evnt)
  115. {
  116. if (_hideCursorOnIdle)
  117. {
  118. _lastCursorMoveTime = Stopwatch.GetTimestamp();
  119. }
  120. if (ConfigurationState.Instance.Hid.EnableMouse)
  121. {
  122. Window.Cursor = _invisibleCursor;
  123. }
  124. _isMouseInClient = true;
  125. return false;
  126. }
  127. protected override bool OnEnterNotifyEvent(EventCrossing evnt)
  128. {
  129. Window.Cursor = ConfigurationState.Instance.Hid.EnableMouse ? _invisibleCursor : null;
  130. _isMouseInClient = true;
  131. return base.OnEnterNotifyEvent(evnt);
  132. }
  133. protected override bool OnLeaveNotifyEvent(EventCrossing evnt)
  134. {
  135. Window.Cursor = null;
  136. _isMouseInClient = false;
  137. return base.OnLeaveNotifyEvent(evnt);
  138. }
  139. protected override void OnGetPreferredHeight(out int minimumHeight, out int naturalHeight)
  140. {
  141. Gdk.Monitor monitor = Display.GetMonitorAtWindow(Window);
  142. // If the monitor is at least 1080p, use the Switch panel size as minimal size.
  143. if (monitor.Geometry.Height >= 1080)
  144. {
  145. minimumHeight = SwitchPanelHeight;
  146. }
  147. // Otherwise, we default minimal size to 480p 16:9.
  148. else
  149. {
  150. minimumHeight = 480;
  151. }
  152. naturalHeight = minimumHeight;
  153. }
  154. protected override void OnGetPreferredWidth(out int minimumWidth, out int naturalWidth)
  155. {
  156. Gdk.Monitor monitor = Display.GetMonitorAtWindow(Window);
  157. // If the monitor is at least 1080p, use the Switch panel size as minimal size.
  158. if (monitor.Geometry.Height >= 1080)
  159. {
  160. minimumWidth = SwitchPanelWidth;
  161. }
  162. // Otherwise, we default minimal size to 480p 16:9.
  163. else
  164. {
  165. minimumWidth = 854;
  166. }
  167. naturalWidth = minimumWidth;
  168. }
  169. protected override bool OnConfigureEvent(EventConfigure evnt)
  170. {
  171. bool result = base.OnConfigureEvent(evnt);
  172. Gdk.Monitor monitor = Display.GetMonitorAtWindow(Window);
  173. WindowWidth = evnt.Width * monitor.ScaleFactor;
  174. WindowHeight = evnt.Height * monitor.ScaleFactor;
  175. Renderer?.Window.SetSize(WindowWidth, WindowHeight);
  176. return result;
  177. }
  178. private void HandleScreenState(KeyboardStateSnapshot keyboard)
  179. {
  180. bool toggleFullscreen = keyboard.IsPressed(Key.F11)
  181. || ((keyboard.IsPressed(Key.AltLeft)
  182. || keyboard.IsPressed(Key.AltRight))
  183. && keyboard.IsPressed(Key.Enter))
  184. || keyboard.IsPressed(Key.Escape);
  185. bool fullScreenToggled = ParentWindow.State.HasFlag(Gdk.WindowState.Fullscreen);
  186. if (toggleFullscreen != _toggleFullscreen)
  187. {
  188. if (toggleFullscreen)
  189. {
  190. if (fullScreenToggled)
  191. {
  192. ParentWindow.Unfullscreen();
  193. (Toplevel as MainWindow)?.ToggleExtraWidgets(true);
  194. }
  195. else
  196. {
  197. if (keyboard.IsPressed(Key.Escape))
  198. {
  199. if (!ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
  200. {
  201. Exit();
  202. }
  203. }
  204. else
  205. {
  206. ParentWindow.Fullscreen();
  207. (Toplevel as MainWindow)?.ToggleExtraWidgets(false);
  208. }
  209. }
  210. }
  211. }
  212. _toggleFullscreen = toggleFullscreen;
  213. bool toggleDockedMode = keyboard.IsPressed(Key.F9);
  214. if (toggleDockedMode != _toggleDockedMode)
  215. {
  216. if (toggleDockedMode)
  217. {
  218. ConfigurationState.Instance.System.EnableDockedMode.Value =
  219. !ConfigurationState.Instance.System.EnableDockedMode.Value;
  220. }
  221. }
  222. _toggleDockedMode = toggleDockedMode;
  223. if (_hideCursorOnIdle && !ConfigurationState.Instance.Hid.EnableMouse)
  224. {
  225. long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
  226. Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
  227. }
  228. if(ConfigurationState.Instance.Hid.EnableMouse && _isMouseInClient)
  229. {
  230. Window.Cursor = _invisibleCursor;
  231. }
  232. }
  233. public void Initialize(Switch device)
  234. {
  235. Device = device;
  236. IRenderer renderer = Device.Gpu.Renderer;
  237. if (renderer is ThreadedRenderer tr)
  238. {
  239. renderer = tr.BaseRenderer;
  240. }
  241. Renderer = renderer;
  242. Renderer?.Window.SetSize(WindowWidth, WindowHeight);
  243. if (Renderer != null)
  244. {
  245. Renderer.ScreenCaptured += Renderer_ScreenCaptured;
  246. }
  247. NpadManager.Initialize(device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
  248. TouchScreenManager.Initialize(device);
  249. }
  250. private unsafe void Renderer_ScreenCaptured(object sender, ScreenCaptureImageInfo e)
  251. {
  252. if (e.Data.Length > 0 && e.Height > 0 && e.Width > 0)
  253. {
  254. Task.Run(() =>
  255. {
  256. lock (this)
  257. {
  258. var currentTime = DateTime.Now;
  259. string filename = $"ryujinx_capture_{currentTime.Year}-{currentTime.Month:D2}-{currentTime.Day:D2}_{currentTime.Hour:D2}-{currentTime.Minute:D2}-{currentTime.Second:D2}.png";
  260. string directory = AppDataManager.Mode switch
  261. {
  262. AppDataManager.LaunchMode.Portable => System.IO.Path.Combine(AppDataManager.BaseDirPath, "screenshots"),
  263. _ => System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures), "Ryujinx")
  264. };
  265. string path = System.IO.Path.Combine(directory, filename);
  266. try
  267. {
  268. Directory.CreateDirectory(directory);
  269. }
  270. catch (Exception ex)
  271. {
  272. Logger.Error?.Print(LogClass.Application, $"Failed to create directory at path {directory}. Error : {ex.GetType().Name}", "Screenshot");
  273. return;
  274. }
  275. Image image = e.IsBgra ? Image.LoadPixelData<Bgra32>(e.Data, e.Width, e.Height)
  276. : Image.LoadPixelData<Rgba32>(e.Data, e.Width, e.Height);
  277. if (e.FlipX)
  278. {
  279. image.Mutate(x => x.Flip(FlipMode.Horizontal));
  280. }
  281. if (e.FlipY)
  282. {
  283. image.Mutate(x => x.Flip(FlipMode.Vertical));
  284. }
  285. image.SaveAsPng(path, new PngEncoder()
  286. {
  287. ColorType = PngColorType.Rgb
  288. });
  289. image.Dispose();
  290. Logger.Notice.Print(LogClass.Application, $"Screenshot saved to {path}", "Screenshot");
  291. }
  292. });
  293. }
  294. else
  295. {
  296. Logger.Error?.Print(LogClass.Application, $"Screenshot is empty. Size : {e.Data.Length} bytes. Resolution : {e.Width}x{e.Height}", "Screenshot");
  297. }
  298. }
  299. public void Render()
  300. {
  301. Gtk.Window parent = Toplevel as Gtk.Window;
  302. parent.Present();
  303. InitializeRenderer();
  304. Device.Gpu.Renderer.Initialize(_glLogLevel);
  305. _gpuVendorName = GetGpuVendorName();
  306. Device.Gpu.Renderer.RunLoop(() =>
  307. {
  308. Device.Gpu.SetGpuThread();
  309. Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
  310. Translator.IsReadyForTranslation.Set();
  311. (Toplevel as MainWindow)?.ActivatePauseMenu();
  312. while (_isActive)
  313. {
  314. if (_isStopped)
  315. {
  316. return;
  317. }
  318. _ticks += _chrono.ElapsedTicks;
  319. _chrono.Restart();
  320. if (Device.WaitFifo())
  321. {
  322. Device.Statistics.RecordFifoStart();
  323. Device.ProcessFrame();
  324. Device.Statistics.RecordFifoEnd();
  325. }
  326. while (Device.ConsumeFrameAvailable())
  327. {
  328. Device.PresentFrame((texture) => { SwapBuffers(texture);});
  329. }
  330. if (_ticks >= _ticksPerFrame)
  331. {
  332. string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld";
  333. float scale = Graphics.Gpu.GraphicsConfig.ResScale;
  334. if (scale != 1)
  335. {
  336. dockedMode += $" ({scale}x)";
  337. }
  338. StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
  339. Device.EnableDeviceVsync,
  340. Device.GetVolume(),
  341. dockedMode,
  342. ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
  343. $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
  344. $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
  345. $"GPU: {_gpuVendorName}"));
  346. _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
  347. }
  348. }
  349. });
  350. }
  351. public void Start()
  352. {
  353. _chrono.Restart();
  354. _isActive = true;
  355. Gtk.Window parent = Toplevel as Gtk.Window;
  356. Application.Invoke(delegate
  357. {
  358. parent.Present();
  359. string titleNameSection = string.IsNullOrWhiteSpace(Device.Application.TitleName) ? string.Empty
  360. : $" - {Device.Application.TitleName}";
  361. string titleVersionSection = string.IsNullOrWhiteSpace(Device.Application.DisplayVersion) ? string.Empty
  362. : $" v{Device.Application.DisplayVersion}";
  363. string titleIdSection = string.IsNullOrWhiteSpace(Device.Application.TitleIdText) ? string.Empty
  364. : $" ({Device.Application.TitleIdText.ToUpper()})";
  365. string titleArchSection = Device.Application.TitleIs64Bit ? " (64-bit)" : " (32-bit)";
  366. parent.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
  367. });
  368. Thread renderLoopThread = new Thread(Render)
  369. {
  370. Name = "GUI.RenderLoop"
  371. };
  372. renderLoopThread.Start();
  373. Thread nvStutterWorkaround = null;
  374. if (Renderer is Graphics.OpenGL.Renderer)
  375. {
  376. nvStutterWorkaround = new Thread(NVStutterWorkaround)
  377. {
  378. Name = "GUI.NVStutterWorkaround"
  379. };
  380. nvStutterWorkaround.Start();
  381. }
  382. MainLoop();
  383. renderLoopThread.Join();
  384. nvStutterWorkaround?.Join();
  385. Exit();
  386. }
  387. public void Exit()
  388. {
  389. TouchScreenManager?.Dispose();
  390. NpadManager?.Dispose();
  391. if (_isStopped)
  392. {
  393. return;
  394. }
  395. _gpuCancellationTokenSource.Cancel();
  396. _isStopped = true;
  397. _isActive = false;
  398. _exitEvent.WaitOne();
  399. _exitEvent.Dispose();
  400. }
  401. private void NVStutterWorkaround()
  402. {
  403. while (_isActive)
  404. {
  405. // When NVIDIA Threaded Optimization is on, the driver will snapshot all threads in the system whenever the application creates any new ones.
  406. // The ThreadPool has something called a "GateThread" which terminates itself after some inactivity.
  407. // However, it immediately starts up again, since the rules regarding when to terminate and when to start differ.
  408. // This creates a new thread every second or so.
  409. // The main problem with this is that the thread snapshot can take 70ms, is on the OpenGL thread and will delay rendering any graphics.
  410. // This is a little over budget on a frame time of 16ms, so creates a large stutter.
  411. // The solution is to keep the ThreadPool active so that it never has a reason to terminate the GateThread.
  412. // TODO: This should be removed when the issue with the GateThread is resolved.
  413. ThreadPool.QueueUserWorkItem((state) => { });
  414. Thread.Sleep(300);
  415. }
  416. }
  417. public void MainLoop()
  418. {
  419. while (_isActive)
  420. {
  421. UpdateFrame();
  422. // Polling becomes expensive if it's not slept
  423. Thread.Sleep(1);
  424. }
  425. _exitEvent.Set();
  426. }
  427. private bool UpdateFrame()
  428. {
  429. if (!_isActive)
  430. {
  431. return true;
  432. }
  433. if (_isStopped)
  434. {
  435. return false;
  436. }
  437. if ((Toplevel as MainWindow).IsFocused)
  438. {
  439. Application.Invoke(delegate
  440. {
  441. KeyboardStateSnapshot keyboard = _keyboardInterface.GetKeyboardStateSnapshot();
  442. HandleScreenState(keyboard);
  443. if (keyboard.IsPressed(Key.Delete))
  444. {
  445. if (!ParentWindow.State.HasFlag(WindowState.Fullscreen))
  446. {
  447. Ptc.Continue();
  448. }
  449. }
  450. });
  451. }
  452. NpadManager.Update(ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
  453. if ((Toplevel as MainWindow).IsFocused)
  454. {
  455. KeyboardHotkeyState currentHotkeyState = GetHotkeyState();
  456. if (currentHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync) &&
  457. !_prevHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync))
  458. {
  459. Device.EnableDeviceVsync = !Device.EnableDeviceVsync;
  460. }
  461. if ((currentHotkeyState.HasFlag(KeyboardHotkeyState.Screenshot) &&
  462. !_prevHotkeyState.HasFlag(KeyboardHotkeyState.Screenshot)) || ScreenshotRequested)
  463. {
  464. ScreenshotRequested = false;
  465. Renderer.Screenshot();
  466. }
  467. if (currentHotkeyState.HasFlag(KeyboardHotkeyState.ShowUi) &&
  468. !_prevHotkeyState.HasFlag(KeyboardHotkeyState.ShowUi))
  469. {
  470. (Toplevel as MainWindow).ToggleExtraWidgets(true);
  471. }
  472. if (currentHotkeyState.HasFlag(KeyboardHotkeyState.Pause) &&
  473. !_prevHotkeyState.HasFlag(KeyboardHotkeyState.Pause))
  474. {
  475. (Toplevel as MainWindow)?.TogglePause();
  476. }
  477. if (currentHotkeyState.HasFlag(KeyboardHotkeyState.ToggleMute) &&
  478. !_prevHotkeyState.HasFlag(KeyboardHotkeyState.ToggleMute))
  479. {
  480. if (Device.IsAudioMuted())
  481. {
  482. Device.SetVolume(ConfigurationState.Instance.System.AudioVolume);
  483. }
  484. else
  485. {
  486. Device.SetVolume(0);
  487. }
  488. }
  489. _prevHotkeyState = currentHotkeyState;
  490. }
  491. // Touchscreen
  492. bool hasTouch = false;
  493. // Get screen touch position
  494. if ((Toplevel as MainWindow).IsFocused && !ConfigurationState.Instance.Hid.EnableMouse)
  495. {
  496. hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
  497. }
  498. if (!hasTouch)
  499. {
  500. TouchScreenManager.Update(false);
  501. }
  502. Device.Hid.DebugPad.Update();
  503. return true;
  504. }
  505. [Flags]
  506. private enum KeyboardHotkeyState
  507. {
  508. None = 0,
  509. ToggleVSync = 1 << 0,
  510. Screenshot = 1 << 1,
  511. ShowUi = 1 << 2,
  512. Pause = 1 << 3,
  513. ToggleMute = 1 << 4
  514. }
  515. private KeyboardHotkeyState GetHotkeyState()
  516. {
  517. KeyboardHotkeyState state = KeyboardHotkeyState.None;
  518. if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleVsync))
  519. {
  520. state |= KeyboardHotkeyState.ToggleVSync;
  521. }
  522. if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot))
  523. {
  524. state |= KeyboardHotkeyState.Screenshot;
  525. }
  526. if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUi))
  527. {
  528. state |= KeyboardHotkeyState.ShowUi;
  529. }
  530. if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause))
  531. {
  532. state |= KeyboardHotkeyState.Pause;
  533. }
  534. if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleMute))
  535. {
  536. state |= KeyboardHotkeyState.ToggleMute;
  537. }
  538. return state;
  539. }
  540. }
  541. }