mirror of
				https://github.com/kevinporetti/UnrealImGui.git
				synced 2025-11-03 23:33:16 +00:00 
			
		
		
		
	Fixed Linux crash caused by wrong mapping of key codes.
This commit is contained in:
		
							parent
							
								
									860b922206
								
							
						
					
					
						commit
						ea74c3c872
					
				@ -11,6 +11,7 @@ Improving stability
 | 
				
			|||||||
- Improved hot-reload stability and support for reloading after recompiling outside of the editor. Both methods should be equally supported and work together.
 | 
					- Improved hot-reload stability and support for reloading after recompiling outside of the editor. Both methods should be equally supported and work together.
 | 
				
			||||||
- Improved behaviour of delegates when hot-reloading.
 | 
					- Improved behaviour of delegates when hot-reloading.
 | 
				
			||||||
- Changed context index mapping to fix issues with multi-PIE debugging in 4.25.
 | 
					- Changed context index mapping to fix issues with multi-PIE debugging in 4.25.
 | 
				
			||||||
 | 
					- Fixed Linux crash caused by wrong mapping of key codes.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Version: 1.20 (2020/06)
 | 
					Version: 1.20 (2020/06)
 | 
				
			||||||
Transition to IWYU and maintenance:
 | 
					Transition to IWYU and maintenance:
 | 
				
			||||||
 | 
				
			|||||||
@ -122,6 +122,17 @@ namespace ImGuiInterops
 | 
				
			|||||||
		Copy(Mapping.KeyMap, IO.KeyMap);
 | 
							Copy(Mapping.KeyMap, IO.KeyMap);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Simple transform mapping key codes to 0-511 range used in ImGui.
 | 
				
			||||||
 | 
						// From what I can tell, on most supported platforms key codes should comfortably fit in that range anyway
 | 
				
			||||||
 | 
						// but the SDL key-codes used on Linux can go way out of this range (because of the extra flag). However,
 | 
				
			||||||
 | 
						// after this transform they should fit in the range without conflicts.
 | 
				
			||||||
 | 
						// NOTE: Should any of the platforms have other conflicts or any trouble with inputs, this is the likely
 | 
				
			||||||
 | 
						// candidate for change.
 | 
				
			||||||
 | 
						static uint32 MapKeyCode(uint32 KeyCode)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return (KeyCode < 512) ? KeyCode : 256 + (KeyCode % 256);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32 GetKeyIndex(const FKey& Key)
 | 
						uint32 GetKeyIndex(const FKey& Key)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		const uint32* pKeyCode = nullptr;
 | 
							const uint32* pKeyCode = nullptr;
 | 
				
			||||||
@ -129,17 +140,17 @@ namespace ImGuiInterops
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		FInputKeyManager::Get().GetCodesFromKey(Key, pKeyCode, pCharCode);
 | 
							FInputKeyManager::Get().GetCodesFromKey(Key, pKeyCode, pCharCode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pKeyCode)
 | 
							const uint32 KeyCode =
 | 
				
			||||||
		{
 | 
								pKeyCode ? *pKeyCode
 | 
				
			||||||
			return *pKeyCode;
 | 
								: pCharCode ? *pCharCode
 | 
				
			||||||
 | 
								: 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return MapKeyCode(KeyCode);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pCharCode)
 | 
						uint32 GetKeyIndex(const FKeyEvent& KeyEvent)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
			return *pCharCode;
 | 
							return MapKeyCode(KeyEvent.GetKeyCode());
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32 GetMouseIndex(const FKey& MouseButton)
 | 
						uint32 GetMouseIndex(const FKey& MouseButton)
 | 
				
			||||||
 | 
				
			|||||||
@ -40,10 +40,7 @@ namespace ImGuiInterops
 | 
				
			|||||||
	uint32 GetKeyIndex(const FKey& Key);
 | 
						uint32 GetKeyIndex(const FKey& Key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Map key event to index in keys buffer.
 | 
						// Map key event to index in keys buffer.
 | 
				
			||||||
	FORCEINLINE uint32 GetKeyIndex(const FKeyEvent& KeyEvent)
 | 
						uint32 GetKeyIndex(const FKeyEvent& KeyEvent);
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return KeyEvent.GetKeyCode();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Map mouse FKey to index in mouse buttons buffer.
 | 
						// Map mouse FKey to index in mouse buttons buffer.
 | 
				
			||||||
	uint32 GetMouseIndex(const FKey& MouseButton);
 | 
						uint32 GetMouseIndex(const FKey& MouseButton);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user