aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Input/HLE/NpadController.cs
diff options
context:
space:
mode:
authorMaxLastBreath <136052075+MaxLastBreath@users.noreply.github.com>2024-04-28 20:02:29 +0300
committerGitHub <noreply@github.com>2024-04-28 19:02:29 +0200
commit5976a5161b850e4082d6f354a1be6b153547590a (patch)
treed93da5c887c56dc38e6f3b56064e8f13e697bf22 /src/Ryujinx.Input/HLE/NpadController.cs
parent3d4dea624da2cac015b9d86eb8c2360ab7e8df58 (diff)
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>
Diffstat (limited to 'src/Ryujinx.Input/HLE/NpadController.cs')
-rw-r--r--src/Ryujinx.Input/HLE/NpadController.cs41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/Ryujinx.Input/HLE/NpadController.cs b/src/Ryujinx.Input/HLE/NpadController.cs
index cde20f5d..38074528 100644
--- a/src/Ryujinx.Input/HLE/NpadController.cs
+++ b/src/Ryujinx.Input/HLE/NpadController.cs
@@ -487,38 +487,35 @@ namespace Ryujinx.Input.HLE
return value;
}
- public KeyboardInput? GetHLEKeyboardInput()
+ public static KeyboardInput GetHLEKeyboardInput(IGamepadDriver KeyboardDriver)
{
- if (_gamepad is IKeyboard keyboard)
- {
- KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
+ var keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
- KeyboardInput hidKeyboard = new()
- {
- Modifier = 0,
- Keys = new ulong[0x4],
- };
+ KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
- foreach (HLEKeyboardMappingEntry entry in _keyMapping)
- {
- ulong value = keyboardState.IsPressed(entry.TargetKey) ? 1UL : 0UL;
+ KeyboardInput hidKeyboard = new()
+ {
+ Modifier = 0,
+ Keys = new ulong[0x4],
+ };
- hidKeyboard.Keys[entry.Target / 0x40] |= (value << (entry.Target % 0x40));
- }
+ foreach (HLEKeyboardMappingEntry entry in _keyMapping)
+ {
+ ulong value = keyboardState.IsPressed(entry.TargetKey) ? 1UL : 0UL;
- foreach (HLEKeyboardMappingEntry entry in _keyModifierMapping)
- {
- int value = keyboardState.IsPressed(entry.TargetKey) ? 1 : 0;
+ hidKeyboard.Keys[entry.Target / 0x40] |= (value << (entry.Target % 0x40));
+ }
- hidKeyboard.Modifier |= value << entry.Target;
- }
+ foreach (HLEKeyboardMappingEntry entry in _keyModifierMapping)
+ {
+ int value = keyboardState.IsPressed(entry.TargetKey) ? 1 : 0;
- return hidKeyboard;
+ hidKeyboard.Modifier |= value << entry.Target;
}
- return null;
- }
+ return hidKeyboard;
+ }
protected virtual void Dispose(bool disposing)
{