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:
parent
74da8785a5
commit
50d6ec9efe
5 changed files with 66 additions and 6 deletions
10
Ryujinx.HLE/Input/HidHotkeyButtons.cs
Normal file
10
Ryujinx.HLE/Input/HidHotkeyButtons.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.Input
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum HidHotkeyButtons
|
||||||
|
{
|
||||||
|
ToggleVSync = 1 << 0,
|
||||||
|
}
|
||||||
|
}
|
|
@ -84,6 +84,10 @@
|
||||||
"button_plus": "Plus",
|
"button_plus": "Plus",
|
||||||
"button_r": "U",
|
"button_r": "U",
|
||||||
"button_zr": "O"
|
"button_zr": "O"
|
||||||
|
},
|
||||||
|
|
||||||
|
"hotkeys": {
|
||||||
|
"toggle_vsync": "Tab"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace Ryujinx
|
||||||
|
|
||||||
private IGalRenderer _renderer;
|
private IGalRenderer _renderer;
|
||||||
|
|
||||||
|
private HidHotkeyButtons _prevHotkeyButtons = 0;
|
||||||
|
|
||||||
private KeyboardState? _keyboard = null;
|
private KeyboardState? _keyboard = null;
|
||||||
|
|
||||||
private MouseState? _mouse = null;
|
private MouseState? _mouse = null;
|
||||||
|
@ -128,6 +130,7 @@ namespace Ryujinx
|
||||||
|
|
||||||
private new void UpdateFrame()
|
private new void UpdateFrame()
|
||||||
{
|
{
|
||||||
|
HidHotkeyButtons currentHotkeyButtons = 0;
|
||||||
HidControllerButtons currentButton = 0;
|
HidControllerButtons currentButton = 0;
|
||||||
HidJoystickPosition leftJoystick;
|
HidJoystickPosition leftJoystick;
|
||||||
HidJoystickPosition rightJoystick;
|
HidJoystickPosition rightJoystick;
|
||||||
|
@ -142,10 +145,10 @@ namespace Ryujinx
|
||||||
{
|
{
|
||||||
KeyboardState keyboard = _keyboard.Value;
|
KeyboardState keyboard = _keyboard.Value;
|
||||||
|
|
||||||
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
|
currentHotkeyButtons = Configuration.Instance.KeyboardControls.GetHotkeyButtons(keyboard);
|
||||||
|
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
|
||||||
(leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard);
|
|
||||||
|
|
||||||
|
(leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard);
|
||||||
(rightJoystickDx, rightJoystickDy) = Configuration.Instance.KeyboardControls.GetRightStick(keyboard);
|
(rightJoystickDx, rightJoystickDy) = Configuration.Instance.KeyboardControls.GetRightStick(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +241,15 @@ namespace Ryujinx
|
||||||
HidControllerBase controller = _device.Hid.PrimaryController;
|
HidControllerBase controller = _device.Hid.PrimaryController;
|
||||||
|
|
||||||
controller.SendInput(currentButton, leftJoystick, rightJoystick);
|
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()
|
private new void RenderFrame()
|
||||||
|
|
|
@ -35,6 +35,11 @@ namespace Ryujinx.UI.Input
|
||||||
public Key ButtonZr;
|
public Key ButtonZr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct KeyboardHotkeys
|
||||||
|
{
|
||||||
|
public Key ToggleVsync;
|
||||||
|
}
|
||||||
|
|
||||||
public class NpadKeyboard
|
public class NpadKeyboard
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -47,6 +52,11 @@ namespace Ryujinx.UI.Input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NpadKeyboardRight RightJoycon { get; private set; }
|
public NpadKeyboardRight RightJoycon { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hotkey Keyboard Bindings
|
||||||
|
/// </summary>
|
||||||
|
public KeyboardHotkeys Hotkeys { get; private set; }
|
||||||
|
|
||||||
public HidControllerButtons GetButtons(KeyboardState keyboard)
|
public HidControllerButtons GetButtons(KeyboardState keyboard)
|
||||||
{
|
{
|
||||||
HidControllerButtons buttons = 0;
|
HidControllerButtons buttons = 0;
|
||||||
|
@ -97,5 +107,14 @@ namespace Ryujinx.UI.Input
|
||||||
|
|
||||||
return (dx, dy);
|
return (dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HidHotkeyButtons GetHotkeyButtons(KeyboardState keyboard)
|
||||||
|
{
|
||||||
|
HidHotkeyButtons buttons = 0;
|
||||||
|
|
||||||
|
if (keyboard[(Key)Hotkeys.ToggleVsync]) buttons |= HidHotkeyButtons.ToggleVSync;
|
||||||
|
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,9 +636,24 @@
|
||||||
"default": "O"
|
"default": "O"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"hotkeys": {
|
||||||
|
"$id": "#/properties/keyboard_controls/properties/hotkeys",
|
||||||
|
"type": "object",
|
||||||
|
"title": "Hotkey Controls",
|
||||||
|
"required": [
|
||||||
|
"toggle_vsync"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"toggle_vsync": {
|
||||||
|
"$id": "#/properties/keyboard_controls/properties/hotkeys/properties/toggle_vsync",
|
||||||
|
"$ref": "#/definitions/key",
|
||||||
|
"title": "Toggle VSync",
|
||||||
|
"default": "Tab"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
"gamepad_controls": {
|
"gamepad_controls": {
|
||||||
"$id": "#/properties/gamepad_controls",
|
"$id": "#/properties/gamepad_controls",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -843,4 +858,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue