aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThog <me@thog.eu>2020-02-15 12:30:53 +0100
committerGitHub <noreply@github.com>2020-02-15 12:30:53 +0100
commit91b37ae36e0cecfb6dcf02b378c93c3119fa9132 (patch)
treee78c3439be610c0abb48fb6d8b3d181a066480bd
parent4789f79254aea21740e8bf96d1b129a748bdd002 (diff)
Accept gamepad inputs when not focused (#941)
-rw-r--r--Ryujinx/Ui/GLRenderer.cs41
1 files changed, 21 insertions, 20 deletions
diff --git a/Ryujinx/Ui/GLRenderer.cs b/Ryujinx/Ui/GLRenderer.cs
index 6feb3ed4..591a24df 100644
--- a/Ryujinx/Ui/GLRenderer.cs
+++ b/Ryujinx/Ui/GLRenderer.cs
@@ -323,10 +323,7 @@ namespace Ryujinx.Ui
});
}
- if (IsFocused)
- {
- UpdateFrame();
- }
+ UpdateFrame();
// Polling becomes expensive if it's not slept
Thread.Sleep(1);
@@ -351,29 +348,33 @@ namespace Ryujinx.Ui
JoystickPosition rightJoystick;
HLE.Input.Keyboard? hidKeyboard = null;
- KeyboardState keyboard = OpenTK.Input.Keyboard.GetState();
-
- Gtk.Application.Invoke(delegate
- {
- HandleScreenState(keyboard);
- });
-
int leftJoystickDx = 0;
int leftJoystickDy = 0;
int rightJoystickDx = 0;
int rightJoystickDy = 0;
- // Normal Input
- currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
- currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
-
- if (ConfigurationState.Instance.Hid.EnableKeyboard)
+ // OpenTK always captures keyboard events, even if out of focus, so check if window is focused.
+ if (IsFocused)
{
- hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
- }
+ KeyboardState keyboard = OpenTK.Input.Keyboard.GetState();
+
+ Gtk.Application.Invoke(delegate
+ {
+ HandleScreenState(keyboard);
+ });
+
+ // Normal Input
+ currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
+ currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
- (leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
- (rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
+ if (ConfigurationState.Instance.Hid.EnableKeyboard)
+ {
+ hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
+ }
+
+ (leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
+ (rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
+ }
if (!hidKeyboard.HasValue)
{