Fix direct keyboard not working when using a Controller. (#6716)

* Fix direct keyboard not working when connected with a controller

- Pass KeyboardDriver to NpadController.GetHLEKeyboardInput().
- Always fetch all keyboards if Direct Keyboard is turned on.
- Remove unnecessary return null.

* Get Keyboard Inputs outside of the controller loop.

- Moved GetHLEKeyboardInput outside of the controller loop.
- Made GetHLEKeyboardInput public static from public

* Removed extra newline

* Update src/Ryujinx.Input/HLE/NpadManager.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Update src/Ryujinx.Input/HLE/NpadController.cs

Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com>

---------

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com>
This commit is contained in:
MaxLastBreath 2024-04-28 20:02:29 +03:00 committed by GitHub
parent 3d4dea624d
commit 5976a5161b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 30 deletions

View file

@ -487,10 +487,10 @@ namespace Ryujinx.Input.HLE
return value; return value;
} }
public KeyboardInput? GetHLEKeyboardInput() public static KeyboardInput GetHLEKeyboardInput(IGamepadDriver KeyboardDriver)
{
if (_gamepad is IKeyboard keyboard)
{ {
var keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot(); KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
KeyboardInput hidKeyboard = new() KeyboardInput hidKeyboard = new()
@ -514,12 +514,9 @@ namespace Ryujinx.Input.HLE
} }
return hidKeyboard; return hidKeyboard;
}
return null;
} }
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (disposing) if (disposing)

View file

@ -231,11 +231,6 @@ namespace Ryujinx.Input.HLE
var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default; var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
motionState = (controller.GetHLEMotionState(), altMotionState); motionState = (controller.GetHLEMotionState(), altMotionState);
if (_enableKeyboard)
{
hleKeyboardInput = controller.GetHLEKeyboardInput();
}
} }
else else
{ {
@ -257,6 +252,11 @@ namespace Ryujinx.Input.HLE
} }
} }
if (!_blockInputUpdates && _enableKeyboard)
{
hleKeyboardInput = NpadController.GetHLEKeyboardInput(_keyboardDriver);
}
_device.Hid.Npads.Update(hleInputStates); _device.Hid.Npads.Update(hleInputStates);
_device.Hid.Npads.UpdateSixAxis(hleMotionStates); _device.Hid.Npads.UpdateSixAxis(hleMotionStates);