Skip to content

Instantly share code, notes, and snippets.

@Kovak
Created August 4, 2020 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kovak/99df656f64de7e50326755ff2b9ba22c to your computer and use it in GitHub Desktop.
Save Kovak/99df656f64de7e50326755ff2b9ba22c to your computer and use it in GitHub Desktop.
void FNpadController::ShowConnectionUI(bool bRunInAThread)
{
#if !PLATFORM_WINDOWS
// only allow one at a time
if (FPlatformAtomics::InterlockedCompareExchange(&bIsShowingConnectUI, 1, 0) == 0)
{
bIsShowingConnectUI = true;
TFunction<void()> Task = [this]()
{
nn::hid::ControllerSupportArg Arg;
Arg.SetDefault();
Arg.playerCountMax = CVarNpadMaxControllers.GetValueOnAnyThread();
Arg.playerCountMin = CVarNpadMinControllers.GetValueOnAnyThread();
//Arg.enableSingleMode = Arg.playerCountMax == 1;
nn::hid::ControllerSupportResultInfo Info;
nn::Result Result = nn::hid::ShowControllerSupport(&Info, Arg);
UE_LOG(LogSwitch, Display, TEXT("Showed connect ui. Result = %d.%d:%d-- %d, %d"), Result.GetModule(), Result.GetDescription(), Result.GetInnerValueForDebug(), Info.playerCount, Info.selectedId);
FPlatformAtomics::InterlockedDecrement(&bIsShowingConnectUI);
};
if (bRunInAThread)
{
Async(EAsyncExecution::ThreadPool, Task);
}
else
{
Task();
}
//Task();
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment