From 179fc92763eab34542e65d1a8a1bc6dcf4810cc2 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Fri, 11 Nov 2022 14:53:21 +0100 Subject: [PATCH] separate the unreal c++/bp implementation of SGConnect wrappers --- .../Private/SGConnect/SGConnect.cpp | 7 +- .../Private/SenseGloveConnect.cpp | 2 +- .../Private/SenseGloveConnect.h | 2 +- .../Private/SenseGloveConnectModule.cpp | 4 +- .../Private/SenseGloveConnectModule.h | 2 +- .../Public/SGConnect/SGConnect.h | 9 +- .../SGConnectKismetLibrary.cpp | 53 ++++++++++++ .../SGConnectKismet/SGConnectKismetLibrary.h | 84 +++++++++++++++++++ .../SenseGloveConnectKismet.Build.cs | 10 +-- .../SenseGloveCoreKismet.Build.cs | 2 +- 10 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 Source/SenseGloveConnectKismet/Private/SGConnectKismet/SGConnectKismetLibrary.cpp create mode 100644 Source/SenseGloveConnectKismet/Public/SGConnectKismet/SGConnectKismetLibrary.h diff --git a/Source/SenseGloveConnect/Private/SGConnect/SGConnect.cpp b/Source/SenseGloveConnect/Private/SGConnect/SGConnect.cpp index d6340c2d..f09b0761 100644 --- a/Source/SenseGloveConnect/Private/SGConnect/SGConnect.cpp +++ b/Source/SenseGloveConnect/Private/SGConnect/SGConnect.cpp @@ -34,20 +34,21 @@ #include "SGConnect/SGConnect.h" + #include "SGConnectImpl/SGExportedFunctions.h" #include "SGInterop/SGIC_FString.h" -int32 USGConnect::Init() +int32 FSGConnect::Init() { return SGConnect_Init(); } -int32 USGConnect::Dispose() +int32 FSGConnect::Dispose() { return SGConnect_Dispose(); } -FString USGConnect::GetLibraryVersion() +FString FSGConnect::GetLibraryVersion() { FSGIC_FString Container; SGConnect_GetLibraryVersion(&Container); diff --git a/Source/SenseGloveConnect/Private/SenseGloveConnect.cpp b/Source/SenseGloveConnect/Private/SenseGloveConnect.cpp index 203e8317..ba419d04 100644 --- a/Source/SenseGloveConnect/Private/SenseGloveConnect.cpp +++ b/Source/SenseGloveConnect/Private/SenseGloveConnect.cpp @@ -37,4 +37,4 @@ #include "Modules/ModuleManager.h" #include "SenseGloveConnectModule.h" -IMPLEMENT_MODULE(FSenseGloveConnectModule, SenseGloveConnect) +IMPLEMENT_MODULE(FSenseGloveConnectModule, SenseGloveConnect) \ No newline at end of file diff --git a/Source/SenseGloveConnect/Private/SenseGloveConnect.h b/Source/SenseGloveConnect/Private/SenseGloveConnect.h index 93863a37..d445de63 100644 --- a/Source/SenseGloveConnect/Private/SenseGloveConnect.h +++ b/Source/SenseGloveConnect/Private/SenseGloveConnect.h @@ -35,4 +35,4 @@ #pragma once -#include "CoreMinimal.h" +#include "CoreMinimal.h" \ No newline at end of file diff --git a/Source/SenseGloveConnect/Private/SenseGloveConnectModule.cpp b/Source/SenseGloveConnect/Private/SenseGloveConnectModule.cpp index 1acd1aa6..43920021 100644 --- a/Source/SenseGloveConnect/Private/SenseGloveConnectModule.cpp +++ b/Source/SenseGloveConnect/Private/SenseGloveConnectModule.cpp @@ -43,8 +43,8 @@ void FSenseGloveConnectModule::StartupModule() { SGLOG("Starting up SenseGloveConnect module..."); - SGLOG(FString::Printf(TEXT("The Unreal Engine implementation of '%s' has been loaded successfully!"), *USGConnect:: - GetLibraryVersion())); + SGLOG(FString::Printf(TEXT("The Unreal Engine implementation of '%s' has been loaded successfully!"), + *FSGConnect::GetLibraryVersion())); } void FSenseGloveConnectModule::PreUnloadCallback() diff --git a/Source/SenseGloveConnect/Private/SenseGloveConnectModule.h b/Source/SenseGloveConnect/Private/SenseGloveConnectModule.h index 6489a216..121a33ee 100644 --- a/Source/SenseGloveConnect/Private/SenseGloveConnectModule.h +++ b/Source/SenseGloveConnect/Private/SenseGloveConnectModule.h @@ -48,4 +48,4 @@ public: virtual void ShutdownModule() override; }; -#undef LOCTEXT_NAMESPACE +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/SenseGloveConnect/Public/SGConnect/SGConnect.h b/Source/SenseGloveConnect/Public/SGConnect/SGConnect.h index 58004a3e..5c866a64 100644 --- a/Source/SenseGloveConnect/Public/SGConnect/SGConnect.h +++ b/Source/SenseGloveConnect/Public/SGConnect/SGConnect.h @@ -35,12 +35,12 @@ #pragma once -#include "UObject/Object.h" #include "UObject/ObjectMacros.h" + #include "SGConnect.generated.h" -UCLASS(BlueprintType) -class SENSEGLOVECONNECT_API USGConnect: public UObject +USTRUCT() +struct SENSEGLOVECONNECT_API FSGConnect { GENERATED_BODY() @@ -55,7 +55,6 @@ public: * 0 : Device Scanning is already running in within this program. * 1 : Successfully started up DeviceScanning from the current program. */ - UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") static int32 Init(); /** @@ -69,12 +68,10 @@ public: * 1 : Successfully disposed of DeviceScanner resources. * @remark If the Dispose function returns 1, the resources were neatly disposed of. Only a value of -3 is cause for concern. */ - UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") static int32 Dispose(); /** * Check which version of SGConnect you are using. */ - UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") static FString GetLibraryVersion(); }; diff --git a/Source/SenseGloveConnectKismet/Private/SGConnectKismet/SGConnectKismetLibrary.cpp b/Source/SenseGloveConnectKismet/Private/SGConnectKismet/SGConnectKismetLibrary.cpp new file mode 100644 index 00000000..75d3552b --- /dev/null +++ b/Source/SenseGloveConnectKismet/Private/SGConnectKismet/SGConnectKismetLibrary.cpp @@ -0,0 +1,53 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2022 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#include "SGConnectKismet/SGConnectKismetLibrary.h" + +#include "SGConnect/SGConnect.h" + +int32 USGConnectKismetLibrary::Init() +{ + return FSGConnect::Init(); +} + +int32 USGConnectKismetLibrary::Dispose() +{ + return FSGConnect::Dispose(); +} + +FString USGConnectKismetLibrary::GetLibraryVersion() +{ + return FSGConnect::GetLibraryVersion(); +} \ No newline at end of file diff --git a/Source/SenseGloveConnectKismet/Public/SGConnectKismet/SGConnectKismetLibrary.h b/Source/SenseGloveConnectKismet/Public/SGConnectKismet/SGConnectKismetLibrary.h new file mode 100644 index 00000000..d588ac32 --- /dev/null +++ b/Source/SenseGloveConnectKismet/Public/SGConnectKismet/SGConnectKismetLibrary.h @@ -0,0 +1,84 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2022 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#pragma once + +#include "Containers/Array.h" +#include "HAL/Platform.h" + +#include "SGKismet/SGBlueprintFunctionLibrary.h" + +#include "SGConnectKismetLibrary.generated.h" + +UCLASS(meta=(ScriptName = "SesneGloveConnectKismetLibrary")) +class SENSEGLOVECONNECTKISMET_API USGConnectKismetLibrary final : public USGBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: +public: + /** + * Begin Scanning for Sense Glove Devices and set up communications with them. + * + * @return + * -3 : An Unexpected error occured. Please try again. + * -2 : Device Scanning is already running within a different program. + * -1 : Device Scanning already being initialized (function called twice in short succession). + * 0 : Device Scanning is already running in within this program. + * 1 : Successfully started up DeviceScanning from the current program. + */ + UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") + static int32 Init(); + + /** + * Dispose of unmanaged resources and finalize Sense Glove devices. + * + * @return + * -3 : An Unexpected error occured. Please try again. + * -2 : Not allowed to dispose of Device Scanning because this is not the program which started it. + * -1 : Device Scanning is currently being disposed off. This takes a second or two. (function called twice in short succession). + * 0 : There is no deviceScanner running from any program, so disposing is skipped. + * 1 : Successfully disposed of DeviceScanner resources. + * @remark If the Dispose function returns 1, the resources were neatly disposed of. Only a value of -3 is cause for concern. + */ + UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") + static int32 Dispose(); + + /** + * Check which version of SGConnect you are using. + */ + UFUNCTION(BlueprintCallable, Category="SenseGlove | Connect") + static FString GetLibraryVersion(); +}; \ No newline at end of file diff --git a/Source/SenseGloveConnectKismet/SenseGloveConnectKismet.Build.cs b/Source/SenseGloveConnectKismet/SenseGloveConnectKismet.Build.cs index b872baa2..e8897b1d 100644 --- a/Source/SenseGloveConnectKismet/SenseGloveConnectKismet.Build.cs +++ b/Source/SenseGloveConnectKismet/SenseGloveConnectKismet.Build.cs @@ -55,16 +55,10 @@ public class SenseGloveConnectKismet : ModuleRules "CoreUObject", "Engine", "SenseGloveConnect", + "SenseGloveKismet", "SenseGloveLog", "SenseGloveTypes", } ); - - PrivateIncludePathModuleNames.AddRange( - new string[] - { - "SenseGloveKismet", - } - ); } -} +} \ No newline at end of file diff --git a/Source/SenseGloveCoreKismet/SenseGloveCoreKismet.Build.cs b/Source/SenseGloveCoreKismet/SenseGloveCoreKismet.Build.cs index eba4b5eb..9198993a 100644 --- a/Source/SenseGloveCoreKismet/SenseGloveCoreKismet.Build.cs +++ b/Source/SenseGloveCoreKismet/SenseGloveCoreKismet.Build.cs @@ -62,4 +62,4 @@ public class SenseGloveCoreKismet : ModuleRules } ); } -} +} \ No newline at end of file