Accept gamepad inputs when not focused (#941)

This commit is contained in:
Thog 2020-02-15 12:30:53 +01:00 committed by GitHub
parent 4789f79254
commit 91b37ae36e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -323,10 +323,7 @@ namespace Ryujinx.Ui
}); });
} }
if (IsFocused) UpdateFrame();
{
UpdateFrame();
}
// Polling becomes expensive if it's not slept // Polling becomes expensive if it's not slept
Thread.Sleep(1); Thread.Sleep(1);
@ -351,29 +348,33 @@ namespace Ryujinx.Ui
JoystickPosition rightJoystick; JoystickPosition rightJoystick;
HLE.Input.Keyboard? hidKeyboard = null; HLE.Input.Keyboard? hidKeyboard = null;
KeyboardState keyboard = OpenTK.Input.Keyboard.GetState();
Gtk.Application.Invoke(delegate
{
HandleScreenState(keyboard);
});
int leftJoystickDx = 0; int leftJoystickDx = 0;
int leftJoystickDy = 0; int leftJoystickDy = 0;
int rightJoystickDx = 0; int rightJoystickDx = 0;
int rightJoystickDy = 0; int rightJoystickDy = 0;
// Normal Input // OpenTK always captures keyboard events, even if out of focus, so check if window is focused.
currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); if (IsFocused)
currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
if (ConfigurationState.Instance.Hid.EnableKeyboard)
{ {
hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); KeyboardState keyboard = OpenTK.Input.Keyboard.GetState();
}
(leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); Gtk.Application.Invoke(delegate
(rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); {
HandleScreenState(keyboard);
});
// Normal Input
currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard);
currentButton = KeyboardControls.GetButtons(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) if (!hidKeyboard.HasValue)
{ {