mirror of
				https://github.com/ryujinx-mirror/ryujinx.git
				synced 2025-11-04 08:18:58 -06:00 
			
		
		
		
	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:
		@@ -487,38 +487,35 @@ namespace Ryujinx.Input.HLE
 | 
			
		||||
            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();
 | 
			
		||||
 | 
			
		||||
            KeyboardInput hidKeyboard = new()
 | 
			
		||||
            {
 | 
			
		||||
                KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
 | 
			
		||||
                Modifier = 0,
 | 
			
		||||
                Keys = new ulong[0x4],
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
                KeyboardInput hidKeyboard = new()
 | 
			
		||||
                {
 | 
			
		||||
                    Modifier = 0,
 | 
			
		||||
                    Keys = new ulong[0x4],
 | 
			
		||||
                };
 | 
			
		||||
            foreach (HLEKeyboardMappingEntry entry in _keyMapping)
 | 
			
		||||
            {
 | 
			
		||||
                ulong value = keyboardState.IsPressed(entry.TargetKey) ? 1UL : 0UL;
 | 
			
		||||
 | 
			
		||||
                foreach (HLEKeyboardMappingEntry entry in _keyMapping)
 | 
			
		||||
                {
 | 
			
		||||
                    ulong value = keyboardState.IsPressed(entry.TargetKey) ? 1UL : 0UL;
 | 
			
		||||
 | 
			
		||||
                    hidKeyboard.Keys[entry.Target / 0x40] |= (value << (entry.Target % 0x40));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                foreach (HLEKeyboardMappingEntry entry in _keyModifierMapping)
 | 
			
		||||
                {
 | 
			
		||||
                    int value = keyboardState.IsPressed(entry.TargetKey) ? 1 : 0;
 | 
			
		||||
 | 
			
		||||
                    hidKeyboard.Modifier |= value << entry.Target;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return hidKeyboard;
 | 
			
		||||
                hidKeyboard.Keys[entry.Target / 0x40] |= (value << (entry.Target % 0x40));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
            foreach (HLEKeyboardMappingEntry entry in _keyModifierMapping)
 | 
			
		||||
            {
 | 
			
		||||
                int value = keyboardState.IsPressed(entry.TargetKey) ? 1 : 0;
 | 
			
		||||
 | 
			
		||||
                hidKeyboard.Modifier |= value << entry.Target;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return hidKeyboard;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected virtual void Dispose(bool disposing)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -231,11 +231,6 @@ namespace Ryujinx.Input.HLE
 | 
			
		||||
                        var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
 | 
			
		||||
 | 
			
		||||
                        motionState = (controller.GetHLEMotionState(), altMotionState);
 | 
			
		||||
 | 
			
		||||
                        if (_enableKeyboard)
 | 
			
		||||
                        {
 | 
			
		||||
                            hleKeyboardInput = controller.GetHLEKeyboardInput();
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
@@ -257,6 +252,11 @@ namespace Ryujinx.Input.HLE
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (!_blockInputUpdates && _enableKeyboard)
 | 
			
		||||
                {
 | 
			
		||||
                    hleKeyboardInput = NpadController.GetHLEKeyboardInput(_keyboardDriver);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                _device.Hid.Npads.Update(hleInputStates);
 | 
			
		||||
                _device.Hid.Npads.UpdateSixAxis(hleMotionStates);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user