Skip to content

Commit

Permalink
fix errors/warnings caused by UE 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
microdee committed Jun 4, 2023
1 parent 26f2549 commit 39bf8b3
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/SpaceMouse/Private/SSmKeySelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -564,7 +568,11 @@ bool SSmKeySelector::GetChildrenMatchingSearch(const TArray<FString>& 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
2 changes: 2 additions & 0 deletions Source/SpaceMouse/Private/SmViewportOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Source/SpaceMouse/Public/SSmKeySelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Widgets/Views/STableRow.h"
#include "Widgets/Views/STreeView.h"
#include "EditorStyleSet.h"
#include "SmUeVersion.h"

class FKeyTreeInfo;
class SComboButton;
Expand All @@ -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 )
{}
Expand Down
1 change: 1 addition & 0 deletions Source/SpaceMouse/Public/SmViewportOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "CoreMinimal.h"

class SWidget;
class SOverlay;
class SViewport;
class STextBlock;
Expand Down
58 changes: 58 additions & 0 deletions Source/SpaceMouseRuntime/Private/SmInputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<Manager->GetButtons().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)
Expand Down Expand Up @@ -165,6 +222,7 @@ void FSmInputDevice::SendControllerEvents()
MessageHandler->OnControllerButtonReleased(GetKeyFrom(SmButton).GetFName(), 0, false);
}
}
#endif
}

void FSmInputDevice::SetMessageHandler(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler)
Expand Down

0 comments on commit 39bf8b3

Please sign in to comment.