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