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