Toggle VSync Hotkey (#659)

* Added toggle vsync button and hotkeys section to config

* Uses hasflag instead of bitwise comparison

* fixed schema name

Co-Authored-By: BaronKiko <BaronKiko@users.noreply.github.com>
This commit is contained in:
BaronKiko 2019-04-22 07:54:31 +01:00 committed by jduncanator
parent 74da8785a5
commit 50d6ec9efe
5 changed files with 66 additions and 6 deletions

View file

@ -22,6 +22,8 @@ namespace Ryujinx
private IGalRenderer _renderer;
private HidHotkeyButtons _prevHotkeyButtons = 0;
private KeyboardState? _keyboard = null;
private MouseState? _mouse = null;
@ -128,6 +130,7 @@ namespace Ryujinx
private new void UpdateFrame()
{
HidHotkeyButtons currentHotkeyButtons = 0;
HidControllerButtons currentButton = 0;
HidJoystickPosition leftJoystick;
HidJoystickPosition rightJoystick;
@ -142,10 +145,10 @@ namespace Ryujinx
{
KeyboardState keyboard = _keyboard.Value;
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
(leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard);
currentHotkeyButtons = Configuration.Instance.KeyboardControls.GetHotkeyButtons(keyboard);
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
(leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard);
(rightJoystickDx, rightJoystickDy) = Configuration.Instance.KeyboardControls.GetRightStick(keyboard);
}
@ -238,6 +241,15 @@ namespace Ryujinx
HidControllerBase controller = _device.Hid.PrimaryController;
controller.SendInput(currentButton, leftJoystick, rightJoystick);
// Toggle vsync
if (currentHotkeyButtons.HasFlag(HidHotkeyButtons.ToggleVSync) &&
!_prevHotkeyButtons.HasFlag(HidHotkeyButtons.ToggleVSync))
{
_device.EnableDeviceVsync = !_device.EnableDeviceVsync;
}
_prevHotkeyButtons = currentHotkeyButtons;
}
private new void RenderFrame()