From 39bf8b3fc3e82f2e944ebf964068ed2e7a126baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=B3r=C3=A1sz?= Date: Sun, 4 Jun 2023 23:31:46 +0200 Subject: [PATCH] fix errors/warnings caused by UE 5.2 --- Source/SpaceMouse/Private/SSmKeySelector.cpp | 8 +++ .../SpaceMouse/Private/SmViewportOverlay.cpp | 2 + Source/SpaceMouse/Public/SSmKeySelector.h | 5 ++ Source/SpaceMouse/Public/SmViewportOverlay.h | 1 + .../Private/SmInputDevice.cpp | 58 +++++++++++++++++++ 5 files changed, 74 insertions(+) diff --git a/Source/SpaceMouse/Private/SSmKeySelector.cpp b/Source/SpaceMouse/Private/SSmKeySelector.cpp index c4789c0..88ea57c 100644 --- a/Source/SpaceMouse/Private/SSmKeySelector.cpp +++ b/Source/SpaceMouse/Private/SSmKeySelector.cpp @@ -189,7 +189,11 @@ const FSlateBrush* SSmKeySelector::GetKeyIconImage() const if (Key.IsValid()) #endif { +#if UE_VERSION >= MAKE_UE_VERSION(5, 1) + return FAppStyle::GetBrush("Icons.Warning"); +#else return FEditorStyle::GetBrush("Icons.Warning"); +#endif } return GetIconFromKey(CurrentKeyValue.GetValue()); } @@ -564,7 +568,11 @@ bool SSmKeySelector::GetChildrenMatchingSearch(const TArray& InSearchTo const FSlateBrush* SSmKeySelector::GetIconFromKey(FKey Key) const { +#if UE_VERSION >= MAKE_UE_VERSION(5, 1) + return FAppStyle::GetBrush(EKeys::GetMenuCategoryPaletteIcon(Key.GetMenuCategory())); +#else return FEditorStyle::GetBrush(EKeys::GetMenuCategoryPaletteIcon(Key.GetMenuCategory())); +#endif } #undef LOCTEXT_NAMESPACE diff --git a/Source/SpaceMouse/Private/SmViewportOverlay.cpp b/Source/SpaceMouse/Private/SmViewportOverlay.cpp index f82fac2..d222e79 100644 --- a/Source/SpaceMouse/Private/SmViewportOverlay.cpp +++ b/Source/SpaceMouse/Private/SmViewportOverlay.cpp @@ -6,8 +6,10 @@ #include "Editor.h" #include "SEditorViewport.h" #include "EditorViewportClient.h" +#include "SceneView.h" #include "Widgets/SViewport.h" #include "Widgets/Text/STextBlock.h" +#include "Widgets/SWidget.h" FSmViewportOverlay::FSmViewportOverlay(FEditorViewportClient* VpClient) diff --git a/Source/SpaceMouse/Public/SSmKeySelector.h b/Source/SpaceMouse/Public/SSmKeySelector.h index 691c462..d438fb5 100644 --- a/Source/SpaceMouse/Public/SSmKeySelector.h +++ b/Source/SpaceMouse/Public/SSmKeySelector.h @@ -17,6 +17,7 @@ #include "Widgets/Views/STableRow.h" #include "Widgets/Views/STreeView.h" #include "EditorStyleSet.h" +#include "SmUeVersion.h" class FKeyTreeInfo; class SComboButton; @@ -40,7 +41,11 @@ class SPACEMOUSE_API SSmKeySelector : public SCompoundWidget : _CurrentKey(FKey()) , _TreeViewWidth(300.f) , _TreeViewHeight(400.f) +#if UE_VERSION >= MAKE_UE_VERSION(5, 1) + , _Font( FAppStyle::GetFontStyle( TEXT("NormalFont") ) ) +#else , _Font( FEditorStyle::GetFontStyle( TEXT("NormalFont") ) ) +#endif , _FilterBlueprintBindable( true ) , _AllowClear( true ) {} diff --git a/Source/SpaceMouse/Public/SmViewportOverlay.h b/Source/SpaceMouse/Public/SmViewportOverlay.h index 3fd4f7f..f35aa41 100644 --- a/Source/SpaceMouse/Public/SmViewportOverlay.h +++ b/Source/SpaceMouse/Public/SmViewportOverlay.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" +class SWidget; class SOverlay; class SViewport; class STextBlock; diff --git a/Source/SpaceMouseRuntime/Private/SmInputDevice.cpp b/Source/SpaceMouseRuntime/Private/SmInputDevice.cpp index 92b75f5..a4a55b4 100644 --- a/Source/SpaceMouseRuntime/Private/SmInputDevice.cpp +++ b/Source/SpaceMouseRuntime/Private/SmInputDevice.cpp @@ -122,6 +122,63 @@ void FSmInputDevice::Tick(float DeltaTime) void FSmInputDevice::SendControllerEvents() { Manager->Tick(FApp::GetDeltaTime()); + +#if UE_VERSION >= MAKE_UE_VERSION(5, 1) + + IPlatformInputDeviceMapper& DeviceMapper = IPlatformInputDeviceMapper::Get(); + FPlatformUserId PlatformUser = PLATFORMUSERID_NONE; + FInputDeviceId InputDevice = INPUTDEVICEID_NONE; + DeviceMapper.RemapControllerIdToPlatformUserAndDevice(0, OUT PlatformUser, OUT InputDevice); + + // Send axis data only while moving and an extra frame when axis values are supposedly 0 + if(Manager->MovementState->bMoving || Manager->MovementState->bOnMovementEndedFrame) + { + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Lateral"), + PlatformUser, InputDevice, + Manager->GetNormalizedTranslation().X + ); + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Horizontal"), + PlatformUser, InputDevice, + Manager->GetNormalizedTranslation().Y + ); + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Vertical"), + PlatformUser, InputDevice, + Manager->GetNormalizedTranslation().Z + ); + + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Pitch"), + PlatformUser, InputDevice, + Manager->GetNormalizedRotation().Pitch + ); + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Yaw"), + PlatformUser, InputDevice, + Manager->GetNormalizedRotation().Yaw + ); + MessageHandler->OnControllerAnalog( + SM_KEY_PREFIX_TEXT TEXT("Roll"), + PlatformUser, InputDevice, + Manager->GetNormalizedRotation().Roll + ); + } + + for(int i=0; iGetButtons().Num(); ++i) + { + auto SmButton = FSmButton::FromID(i); + if(Manager->ButtonDownFrame(SmButton)) + { + MessageHandler->OnControllerButtonPressed(GetKeyFrom(SmButton).GetFName(), PlatformUser, InputDevice, false); + } + if(Manager->ButtonUpFrame(SmButton)) + { + MessageHandler->OnControllerButtonReleased(GetKeyFrom(SmButton).GetFName(), PlatformUser, InputDevice, false); + } + } +#else // Send axis data only while moving and an extra frame when axis values are supposedly 0 if(Manager->MovementState->bMoving || Manager->MovementState->bOnMovementEndedFrame) @@ -165,6 +222,7 @@ void FSmInputDevice::SendControllerEvents() MessageHandler->OnControllerButtonReleased(GetKeyFrom(SmButton).GetFName(), 0, false); } } +#endif } void FSmInputDevice::SetMessageHandler(const TSharedRef& InMessageHandler)