2018-02-04 18:08:20 -05:00
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
2018-03-02 20:49:17 -05:00
|
|
|
using OpenTK.Input;
|
2019-12-21 14:52:31 -05:00
|
|
|
using Ryujinx.Configuration;
|
2019-10-13 02:02:07 -04:00
|
|
|
using Ryujinx.Graphics.OpenGL;
|
2018-06-10 20:46:42 -04:00
|
|
|
using Ryujinx.HLE;
|
|
|
|
using Ryujinx.HLE.Input;
|
2019-04-26 00:53:10 -04:00
|
|
|
using Ryujinx.Profiler.UI;
|
2019-12-21 14:52:31 -05:00
|
|
|
using Ryujinx.Ui;
|
2018-02-04 18:08:20 -05:00
|
|
|
using System;
|
2018-07-12 13:03:52 -04:00
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using Stopwatch = System.Diagnostics.Stopwatch;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2019-11-28 23:32:51 -05:00
|
|
|
namespace Ryujinx.Ui
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
public class GlScreen : GameWindow
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-02 20:49:17 -05:00
|
|
|
private const int TouchScreenWidth = 1280;
|
|
|
|
private const int TouchScreenHeight = 720;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private const int TargetFps = 60;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private Switch _device;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2019-10-13 02:02:07 -04:00
|
|
|
private Renderer _renderer;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2019-07-22 13:15:46 -04:00
|
|
|
private HotkeyButtons _prevHotkeyButtons = 0;
|
2019-04-22 02:54:31 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private KeyboardState? _keyboard = null;
|
2018-06-21 17:10:19 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private MouseState? _mouse = null;
|
2018-06-23 20:39:25 -04:00
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
private Input.NpadController _primaryController;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private Thread _renderThread;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private bool _resizeEvent;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private bool _titleEvent;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private string _newTitle;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2019-04-26 00:53:10 -04:00
|
|
|
#if USE_PROFILING
|
|
|
|
private ProfileWindowManager _profileWindow;
|
|
|
|
#endif
|
|
|
|
|
2019-10-13 02:02:07 -04:00
|
|
|
public GlScreen(Switch device, Renderer renderer)
|
2018-02-04 18:08:20 -05:00
|
|
|
: base(1280, 720,
|
|
|
|
new GraphicsMode(), "Ryujinx", 0,
|
|
|
|
DisplayDevice.Default, 3, 3,
|
|
|
|
GraphicsContextFlags.ForwardCompatible)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_device = device;
|
|
|
|
_renderer = renderer;
|
2018-03-04 18:32:18 -05:00
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
_primaryController = new Input.NpadController(ConfigurationState.Instance.Hid.JoystickControls);
|
|
|
|
|
2018-03-04 18:32:18 -05:00
|
|
|
Location = new Point(
|
|
|
|
(DisplayDevice.Default.Width / 2) - (Width / 2),
|
|
|
|
(DisplayDevice.Default.Height / 2) - (Height / 2));
|
2019-10-13 02:02:07 -04:00
|
|
|
|
2019-04-26 00:53:10 -04:00
|
|
|
#if USE_PROFILING
|
|
|
|
// Start profile window, it will handle itself from there
|
|
|
|
_profileWindow = new ProfileWindowManager();
|
|
|
|
#endif
|
2018-07-12 13:03:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void RenderLoop()
|
|
|
|
{
|
|
|
|
MakeCurrent();
|
|
|
|
|
2020-01-09 19:41:49 -05:00
|
|
|
_renderer.Initialize();
|
2019-10-13 02:02:07 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
Stopwatch chrono = new Stopwatch();
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
chrono.Start();
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
long ticksPerFrame = Stopwatch.Frequency / TargetFps;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
long ticks = 0;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
|
|
|
while (Exists && !IsExiting)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
if (_device.WaitFifo())
|
2018-07-12 13:03:52 -04:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.ProcessFrame();
|
2018-07-12 13:03:52 -04:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (_resizeEvent)
|
2018-07-12 13:03:52 -04:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_resizeEvent = false;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2019-10-31 20:32:43 -04:00
|
|
|
_renderer.Window.SetSize(Width, Height);
|
2018-07-12 13:03:52 -04:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
ticks += chrono.ElapsedTicks;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
chrono.Restart();
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (ticks >= ticksPerFrame)
|
2018-07-12 13:03:52 -04:00
|
|
|
{
|
|
|
|
RenderFrame();
|
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Queue max. 1 vsync
|
2018-10-30 21:43:02 -04:00
|
|
|
ticks = Math.Min(ticks - ticksPerFrame, ticksPerFrame);
|
2018-07-12 13:03:52 -04:00
|
|
|
}
|
|
|
|
}
|
2019-12-31 17:09:49 -05:00
|
|
|
|
|
|
|
_device.DisposeGpu();
|
|
|
|
_renderer.Dispose();
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-07-12 13:03:52 -04:00
|
|
|
public void MainLoop()
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-07-12 13:03:52 -04:00
|
|
|
VSync = VSyncMode.Off;
|
|
|
|
|
|
|
|
Visible = true;
|
2018-04-14 00:31:27 -04:00
|
|
|
|
2018-07-12 13:03:52 -04:00
|
|
|
Context.MakeCurrent(null);
|
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// OpenTK doesn't like sleeps in its thread, to avoid this a renderer thread is created
|
2018-10-30 21:43:02 -04:00
|
|
|
_renderThread = new Thread(RenderLoop);
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_renderThread.Start();
|
2018-07-12 13:03:52 -04:00
|
|
|
|
|
|
|
while (Exists && !IsExiting)
|
|
|
|
{
|
|
|
|
ProcessEvents();
|
|
|
|
|
|
|
|
if (!IsExiting)
|
|
|
|
{
|
|
|
|
UpdateFrame();
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (_titleEvent)
|
2018-07-12 13:03:52 -04:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_titleEvent = false;
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
Title = _newTitle;
|
2018-07-12 13:03:52 -04:00
|
|
|
}
|
|
|
|
}
|
2018-07-02 18:08:54 -04:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Polling becomes expensive if it's not slept
|
2018-07-29 00:35:36 -04:00
|
|
|
Thread.Sleep(1);
|
2018-07-02 18:08:54 -04:00
|
|
|
}
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-07-12 13:03:52 -04:00
|
|
|
private new void UpdateFrame()
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2019-07-22 13:15:46 -04:00
|
|
|
HotkeyButtons currentHotkeyButtons = 0;
|
|
|
|
ControllerButtons currentButton = 0;
|
|
|
|
JoystickPosition leftJoystick;
|
|
|
|
JoystickPosition rightJoystick;
|
|
|
|
HLE.Input.Keyboard? hidKeyboard = null;
|
2018-02-22 08:28:27 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
int leftJoystickDx = 0;
|
|
|
|
int leftJoystickDy = 0;
|
|
|
|
int rightJoystickDx = 0;
|
|
|
|
int rightJoystickDy = 0;
|
2018-06-23 20:39:25 -04:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Keyboard Input
|
2018-10-30 21:43:02 -04:00
|
|
|
if (_keyboard.HasValue)
|
2018-06-21 17:10:19 -04:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
KeyboardState keyboard = _keyboard.Value;
|
2018-06-21 17:10:19 -04:00
|
|
|
|
2019-04-26 00:53:10 -04:00
|
|
|
#if USE_PROFILING
|
|
|
|
// Profiler input, lets the profiler get access to the main windows keyboard state
|
|
|
|
_profileWindow.UpdateKeyInput(keyboard);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Normal Input
|
2019-12-21 14:52:31 -05:00
|
|
|
currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
|
|
|
currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
2018-07-29 00:35:36 -04:00
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
if (ConfigurationState.Instance.Hid.EnableKeyboard)
|
2019-05-02 19:29:01 -04:00
|
|
|
{
|
2019-12-21 14:52:31 -05:00
|
|
|
hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
2019-05-02 19:29:01 -04:00
|
|
|
}
|
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
(leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
|
|
|
(rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
|
2018-07-02 18:08:54 -04:00
|
|
|
}
|
2019-05-02 19:29:01 -04:00
|
|
|
|
|
|
|
if (!hidKeyboard.HasValue)
|
|
|
|
{
|
2019-07-22 13:15:46 -04:00
|
|
|
hidKeyboard = new HLE.Input.Keyboard
|
2019-05-02 19:29:01 -04:00
|
|
|
{
|
|
|
|
Modifier = 0,
|
|
|
|
Keys = new int[0x8]
|
|
|
|
};
|
|
|
|
}
|
2019-10-13 02:02:07 -04:00
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
currentButton |= _primaryController.GetButtons();
|
2018-08-16 19:47:36 -04:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Keyboard has priority stick-wise
|
2018-10-30 21:43:02 -04:00
|
|
|
if (leftJoystickDx == 0 && leftJoystickDy == 0)
|
2018-07-02 18:08:54 -04:00
|
|
|
{
|
2019-12-21 14:52:31 -05:00
|
|
|
(leftJoystickDx, leftJoystickDy) = _primaryController.GetLeftStick();
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (rightJoystickDx == 0 && rightJoystickDy == 0)
|
2018-07-29 00:35:36 -04:00
|
|
|
{
|
2019-12-21 14:52:31 -05:00
|
|
|
(rightJoystickDx, rightJoystickDy) = _primaryController.GetRightStick();
|
2018-07-29 00:35:36 -04:00
|
|
|
}
|
2018-08-16 19:47:36 -04:00
|
|
|
|
2019-07-22 13:15:46 -04:00
|
|
|
leftJoystick = new JoystickPosition
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
Dx = leftJoystickDx,
|
|
|
|
Dy = leftJoystickDy
|
2018-02-17 18:54:19 -05:00
|
|
|
};
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2019-07-22 13:15:46 -04:00
|
|
|
rightJoystick = new JoystickPosition
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
Dx = rightJoystickDx,
|
|
|
|
Dy = rightJoystickDy
|
2018-02-17 18:54:19 -05:00
|
|
|
};
|
|
|
|
|
2018-12-07 15:59:38 -05:00
|
|
|
currentButton |= _device.Hid.UpdateStickButtons(leftJoystick, rightJoystick);
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
bool hasTouch = false;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Get screen touch position from left mouse click
|
|
|
|
// OpenTK always captures mouse events, even if out of focus, so check if window is focused.
|
2018-10-30 21:43:02 -04:00
|
|
|
if (Focused && _mouse?.LeftButton == ButtonState.Pressed)
|
2018-03-02 20:49:17 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
MouseState mouse = _mouse.Value;
|
2018-06-21 17:10:19 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
int scrnWidth = Width;
|
|
|
|
int scrnHeight = Height;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-07-29 00:35:36 -04:00
|
|
|
if (Width > (Height * TouchScreenWidth) / TouchScreenHeight)
|
2018-02-22 08:28:27 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
scrnWidth = (Height * TouchScreenWidth) / TouchScreenHeight;
|
2018-03-02 20:49:17 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
scrnHeight = (Width * TouchScreenHeight) / TouchScreenWidth;
|
2018-03-02 20:49:17 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
int startX = (Width - scrnWidth) >> 1;
|
|
|
|
int startY = (Height - scrnHeight) >> 1;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
int endX = startX + scrnWidth;
|
|
|
|
int endY = startY + scrnHeight;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (mouse.X >= startX &&
|
|
|
|
mouse.Y >= startY &&
|
|
|
|
mouse.X < endX &&
|
|
|
|
mouse.Y < endY)
|
2018-03-02 20:49:17 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
int scrnMouseX = mouse.X - startX;
|
|
|
|
int scrnMouseY = mouse.Y - startY;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
int mX = (scrnMouseX * TouchScreenWidth) / scrnWidth;
|
|
|
|
int mY = (scrnMouseY * TouchScreenHeight) / scrnHeight;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2019-07-22 13:15:46 -04:00
|
|
|
TouchPoint currentPoint = new TouchPoint
|
2018-02-22 08:28:27 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
X = mX,
|
|
|
|
Y = mY,
|
2018-02-22 08:28:27 -05:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// Placeholder values till more data is acquired
|
2018-02-22 08:28:27 -05:00
|
|
|
DiameterX = 10,
|
|
|
|
DiameterY = 10,
|
2018-03-02 20:49:17 -05:00
|
|
|
Angle = 90
|
2018-02-22 08:28:27 -05:00
|
|
|
};
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
hasTouch = true;
|
2018-03-02 20:49:17 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.Hid.SetTouchPoints(currentPoint);
|
2018-02-22 08:28:27 -05:00
|
|
|
}
|
2018-03-02 20:49:17 -05:00
|
|
|
}
|
2018-02-22 08:28:27 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (!hasTouch)
|
2018-03-02 20:49:17 -05:00
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.Hid.SetTouchPoints();
|
2018-03-02 20:49:17 -05:00
|
|
|
}
|
|
|
|
|
2019-12-21 14:52:31 -05:00
|
|
|
if (ConfigurationState.Instance.Hid.EnableKeyboard && hidKeyboard.HasValue)
|
2019-05-02 19:29:01 -04:00
|
|
|
{
|
|
|
|
_device.Hid.WriteKeyboard(hidKeyboard.Value);
|
|
|
|
}
|
|
|
|
|
2019-07-22 13:15:46 -04:00
|
|
|
BaseController controller = _device.Hid.PrimaryController;
|
2018-11-19 19:01:36 -05:00
|
|
|
|
|
|
|
controller.SendInput(currentButton, leftJoystick, rightJoystick);
|
2019-04-22 02:54:31 -04:00
|
|
|
|
|
|
|
// Toggle vsync
|
2019-07-22 13:15:46 -04:00
|
|
|
if (currentHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync) &&
|
|
|
|
!_prevHotkeyButtons.HasFlag(HotkeyButtons.ToggleVSync))
|
2019-04-22 02:54:31 -04:00
|
|
|
{
|
|
|
|
_device.EnableDeviceVsync = !_device.EnableDeviceVsync;
|
|
|
|
}
|
|
|
|
|
|
|
|
_prevHotkeyButtons = currentHotkeyButtons;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-07-12 13:03:52 -04:00
|
|
|
private new void RenderFrame()
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2019-11-23 21:24:03 -05:00
|
|
|
_device.PresentFrame(SwapBuffers);
|
2018-03-06 15:18:49 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.Statistics.RecordSystemFrameTime();
|
2018-02-08 19:43:22 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
double hostFps = _device.Statistics.GetSystemFrameRate();
|
|
|
|
double gameFps = _device.Statistics.GetGameFrameRate();
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2019-11-28 23:32:51 -05:00
|
|
|
string titleNameSection = string.IsNullOrWhiteSpace(_device.System.TitleName) ? string.Empty
|
|
|
|
: " | " + _device.System.TitleName;
|
2018-09-19 08:09:49 -04:00
|
|
|
|
2020-01-12 06:15:17 -05:00
|
|
|
string titleIdSection = string.IsNullOrWhiteSpace(_device.System.TitleIdText) ? string.Empty
|
|
|
|
: " | " + _device.System.TitleIdText.ToUpper();
|
2019-11-28 23:32:51 -05:00
|
|
|
|
2020-01-12 06:15:17 -05:00
|
|
|
_newTitle = $"Ryujinx{titleNameSection}{titleIdSection} | Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0} | " +
|
2018-10-30 21:43:02 -04:00
|
|
|
$"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}";
|
2018-07-12 13:03:52 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_titleEvent = true;
|
2018-03-06 15:18:49 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.System.SignalVsync();
|
2018-09-09 19:38:56 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_device.VsyncEvent.Set();
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-07-12 13:03:52 -04:00
|
|
|
protected override void OnUnload(EventArgs e)
|
|
|
|
{
|
2019-04-26 00:53:10 -04:00
|
|
|
#if USE_PROFILING
|
|
|
|
_profileWindow.Close();
|
|
|
|
#endif
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_renderThread.Join();
|
2018-07-12 13:03:52 -04:00
|
|
|
|
|
|
|
base.OnUnload(e);
|
|
|
|
}
|
|
|
|
|
2018-02-20 05:52:35 -05:00
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_resizeEvent = true;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
2018-06-21 17:10:19 -04:00
|
|
|
|
|
|
|
protected override void OnKeyDown(KeyboardKeyEventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
bool toggleFullscreen = e.Key == Key.F11 ||
|
2018-07-29 00:35:36 -04:00
|
|
|
(e.Modifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Enter);
|
|
|
|
|
|
|
|
if (WindowState == WindowState.Fullscreen)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
if (e.Key == Key.Escape || toggleFullscreen)
|
2018-07-29 00:35:36 -04:00
|
|
|
{
|
|
|
|
WindowState = WindowState.Normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e.Key == Key.Escape)
|
|
|
|
{
|
|
|
|
Exit();
|
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
if (toggleFullscreen)
|
2018-07-29 00:35:36 -04:00
|
|
|
{
|
|
|
|
WindowState = WindowState.Fullscreen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
_keyboard = e.Keyboard;
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnKeyUp(KeyboardKeyEventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_keyboard = e.Keyboard;
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnMouseDown(MouseButtonEventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_mouse = e.Mouse;
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnMouseUp(MouseButtonEventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_mouse = e.Mouse;
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnMouseMove(MouseMoveEventArgs e)
|
|
|
|
{
|
2018-10-30 21:43:02 -04:00
|
|
|
_mouse = e.Mouse;
|
2018-06-21 17:10:19 -04:00
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
2019-04-26 00:53:10 -04:00
|
|
|
}
|