A simple method exposing if a gamepad is currently connected to blueprints
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
UCLASS()
class YDEV_API UYDEVFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, meta = (DisplayName = "IsGamepadConnected"), Category = "System Information")
static bool IsGamePadConnected();
};
#include "Extension/UYDEVFunctionLibrary.h"
#include "GeneralProjectSettings.h"
bool UYDEVFunctionLibrary::IsGamePadConnected()
{
auto genericApplication = FSlateApplication::Get().GetPlatformApplication();
if (genericApplication.Get() != nullptr && genericApplication->IsGamepadAttached())
{
return true;
}
return false;
}