Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Unreal 5 #9

Merged
merged 11 commits into from
Sep 22, 2023
2 changes: 2 additions & 0 deletions BrainFlowPlugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Binaries/
Intermediate/
90 changes: 34 additions & 56 deletions BrainFlowPlugin/Source/BrainFlowPlugin/BrainFlowPlugin.Build.cs
Original file line number Diff line number Diff line change
@@ -1,83 +1,61 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using System;
using System.Collections.Generic;
using UnrealBuildTool;
using System.IO;
using System.Linq;

public class BrainFlowPlugin : ModuleRules
{
public BrainFlowPlugin(ReadOnlyTargetRules Target) : base(Target)
{
public BrainFlowPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));

if(Target.Platform == UnrealTargetPlatform.Win32)
Andrey1994 marked this conversation as resolved.
Show resolved Hide resolved
{
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "inc"));
PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib"));
PublicAdditionalLibraries.Add("Brainflow32.lib");
PublicAdditionalLibraries.Add("DataHandler32.lib");
PublicAdditionalLibraries.Add("BoardController32.lib");
PublicAdditionalLibraries.Add("MLModule32.lib");
RuntimeDependencies.Add("$(TargetOutputDir)/BoardController32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "BoardController32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/DataHandler32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "DataHandler32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/GanglionLib32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "GanglionLib32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/gforce32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "gforce32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/gForceSDKWrapper32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "gForceSDKWrapper32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/neurosdk-x86.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "neurosdk-x86.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/BrainBitLib32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "BrainBitLib32.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/eego-SDK32.dll", Path.Combine(ModuleDirectory, "Compiled", "Win32_dynamic", "lib", "eego-SDK32.dll"));
}
if(Target.Platform == UnrealTargetPlatform.Win64)
{
PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib"));
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "inc"));
PublicAdditionalLibraries.Add("Brainflow.lib");
PublicAdditionalLibraries.Add("DataHandler.lib");
PublicAdditionalLibraries.Add("BoardController.lib");
PublicAdditionalLibraries.Add("MLModule.lib");
RuntimeDependencies.Add("$(TargetOutputDir)/BoardController.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "BoardController.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/DataHandler.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "DataHandler.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/GanglionLib.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "GanglionLib.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/gforce64.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "gforce64.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/gForceSDKWrapper.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "gForceSDKWrapper.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/neurosdk-x64.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "neurosdk-x64.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/Unicorn.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "Unicorn.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/BrainBitLib.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "BrainBitLib.dll"));
RuntimeDependencies.Add("$(TargetOutputDir)/eego-SDK.dll", Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib", "eego-SDK.dll"));

AddPrecompiledLibraries(Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib"), "*.lib");
AddPrecompiledDLLs(Path.Combine(ModuleDirectory, "Compiled", "x64_dynamic", "lib"), "*.dll");
}
if(Target.Platform == UnrealTargetPlatform.Mac)
{
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Compiled", "macos", "inc"));
PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "Compiled", "macos", "lib"));
PublicAdditionalLibraries.Add("libBrainflow.a");
PublicDelayLoadDLLs.Add("libDataHandler.dylib");
PublicDelayLoadDLLs.Add("libBoardController.dylib");
PublicDelayLoadDLLs.Add("libMLModule.dylib");
RuntimeDependencies.Add("$(TargetOutputDir)/libBoardController.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libBoardController.dylib"));
RuntimeDependencies.Add("$(TargetOutputDir)/libDataHandler.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libDataHandler.dylib"));
RuntimeDependencies.Add("$(TargetOutputDir)/libGanglionLib.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libGanglionLib.dylib"));
RuntimeDependencies.Add("$(TargetOutputDir)/libMLModule.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libMLModule.dylib"));
RuntimeDependencies.Add("$(TargetOutputDir)/libneurosdk-shared.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libneurosdk-shared.dylib"));
RuntimeDependencies.Add("$(TargetOutputDir)/libBrainBitLib.dylib", Path.Combine(ModuleDirectory, "Compiled", "macos", "lib", "libBrainBitLib.dylib"));

AddPrecompiledLibraries(Path.Combine(ModuleDirectory, "Compiled", "macos", "lib"), "*.a");
AddPrecompiledDLLs(Path.Combine(ModuleDirectory, "Compiled", "macos", "lib"), "*.dylib");
}
if(Target.Platform == UnrealTargetPlatform.Linux)
{
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Compiled", "linux", "inc"));
PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "Compiled", "linux", "lib"));
PublicAdditionalLibraries.Add("libBrainflow.a");
PublicDelayLoadDLLs.Add("libDataHandler.so");
PublicDelayLoadDLLs.Add("libBoardController.so");
PublicDelayLoadDLLs.Add("libMLModule.so");
RuntimeDependencies.Add("$(TargetOutputDir)/libBoardController.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libBoardController.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libDataHandler.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libDataHandler.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libGanglionLib.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libGanglionLib.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libMLModule.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libMLModule.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libunicorn.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libunicorn.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libBrainBitLib.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libBrainBitLib.so"));
RuntimeDependencies.Add("$(TargetOutputDir)/libeego-SDK.so", Path.Combine(ModuleDirectory, "Compiled", "linux", "lib", "libeego-SDK.so"));

AddPrecompiledLibraries(Path.Combine(ModuleDirectory, "Compiled", "linux", "lib"), "*.a");
AddPrecompiledDLLs(Path.Combine(ModuleDirectory, "Compiled", "linux", "lib"), "*.so");
}
}

public void AddPrecompiledLibraries(string FolderPath, string Extension)
{
List<string> Files = Directory.GetFiles(FolderPath, Extension, SearchOption.AllDirectories).ToList();
foreach (string File in Files)
{
PublicAdditionalLibraries.Add(Path.Combine(FolderPath, File));
Console.WriteLine(Name + " adding library: " + File);
}
}

public void AddPrecompiledDLLs(string FolderPath, string Extension)
{
List<string> Files = Directory.GetFiles(FolderPath, Extension, SearchOption.AllDirectories).ToList();
foreach (string File in Files)
{
PublicDelayLoadDLLs.Add(Path.Combine(FolderPath, File));
Console.WriteLine(Name + " adding DLL: " + File);
}
}
}
17 changes: 4 additions & 13 deletions BrainFlowPlugin/Source/BrainFlowPlugin/Private/BrainFlowPlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#include "BrainFlowPlugin.h"

#define LOCTEXT_NAMESPACE "FBrainFlowPluginModule"

void FBrainFlowPluginModule::StartupModule() {
// This code will execute after your module is loaded into memory; the exact
// timing is specified in the .uplugin file per-module
void FBrainFlowPluginModule::StartupModule()
{
}

void FBrainFlowPluginModule::ShutdownModule() {
// This function may be called during shutdown to clean up your module. For
// modules that support dynamic reloading, we call this function before
// unloading the module.
void FBrainFlowPluginModule::ShutdownModule()
{
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FBrainFlowPluginModule, BrainFlowPlugin)
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"

#include "board_shim.h"
#include "data_filter.h"
#include "ml_model.h"

class FBrainFlowPluginModule : public IModuleInterface
{
public:

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ python tools/build.py --clear-build-dir --cmake-install-prefix %FULL_PATH_TO_CLO
# to use debug version you need to add --debug flag
```

##### MacOS ARM64

Compile brainflow using:
```
cd brainflow
python tools/build.py --clear-build-dir --cmake-install-prefix %FULL_PATH_TO_CLONED_FOLDER%/BrainFlowPlugin/Source/BrainFlowPlugin/Compiled/macos --cmake-osx-architectures=arm64
# to use debug version you need to add --debug flag
```

##### Win32

Compile brainflow using:
Expand Down