Using @SumbodySumwher logic, in case anyone needs this. Just add a new C++ class from within the Editor (if you’re a noob like me), then can choose smth like Blueprint Function Library as the parent class, name it MyBlueprintFunctionLibrary.
Then, in .h
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Framework/Application/SlateApplication.h"
#include "Framework/Application/NavigationConfig.h"
#include "MyBlueprintFunctionLibrary.generated.h"
UCLASS()
class YOURPROJECT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "UI")
static void ToggleThumbstickUiNavigation(bool bEnableThumbstickNavigation);
};
and in .cpp
#include "MyBlueprintFunctionLibrary.h"
void UMyBlueprintFunctionLibrary::ToggleThumbstickUiNavigation(bool bEnableThumbstickNavigation)
{
if (FSlateApplication::IsInitialized())
{
// Get the current navigation configuration
TSharedRef<FNavigationConfig> CurrentNavConfig = FSlateApplication::Get().GetNavigationConfig();
// Set the bAnalogNavigation flag to enable or disable thumbstick navigation
CurrentNavConfig->bAnalogNavigation = bEnableThumbstickNavigation;
// Apply the updated navigation configuration
FSlateApplication::Get().SetNavigationConfig(CurrentNavConfig);
}
}
Then, after regenerating visual studio files by right clicking on your .uproject and selecting Generate Visual Studio files, if you try to build the project, and if you get linking issues, check that this is uncommented in your YourProjectName.Build.cs file:
// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { Slate, SlateCore });
After that, you can call that function from Blueprints. Hope this helps!