2023-01-17 19:21:34 +01:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
*
|
|
|
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
|
|
|
|
* (The MIT License)
|
|
|
|
|
*
|
2025-01-17 11:08:45 +01:00
|
|
|
* Copyright (c) 2020 - 2025 SenseGlove
|
2023-01-17 19:21:34 +01:00
|
|
|
*
|
|
|
|
|
* 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 "SenseGloveAndroidModule.h"
|
|
|
|
|
|
2024-11-13 15:29:51 +01:00
|
|
|
#include "Misc/CoreDelegates.h"
|
|
|
|
|
|
2024-11-13 14:35:39 +01:00
|
|
|
#include "SGAndroid/SGAndroidPermissions.h"
|
2023-02-02 21:35:33 +01:00
|
|
|
#include "SGAndroid/SGConnectJNI.h"
|
|
|
|
|
#include "SGAndroid/SGCoreJNI.h"
|
2023-01-17 19:21:34 +01:00
|
|
|
#include "SGLog/SGLog.h"
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FSenseGloveAndroidModule"
|
|
|
|
|
|
|
|
|
|
void FSenseGloveAndroidModule::StartupModule()
|
|
|
|
|
{
|
2024-03-20 18:20:11 +01:00
|
|
|
SGLOG("Starting up the SenseGloveAndroid module...");
|
2023-01-31 14:36:16 +01:00
|
|
|
|
2024-11-13 14:35:39 +01:00
|
|
|
OnPostEngineInitHandle = FCoreDelegates::OnPostEngineInit.AddRaw(
|
|
|
|
|
this, &FSenseGloveAndroidModule::OnPostEngineInit);
|
2023-01-17 19:21:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSenseGloveAndroidModule::PreUnloadCallback()
|
|
|
|
|
{
|
2024-03-20 18:20:11 +01:00
|
|
|
SGLOG("Unloading the SenseGloveAndroid module...");
|
2023-01-17 19:21:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSenseGloveAndroidModule::PostLoadCallback()
|
|
|
|
|
{
|
2024-03-20 18:20:11 +01:00
|
|
|
SGLOG("Loading the SenseGloveAndroid module has succeeded!");
|
2023-01-17 19:21:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSenseGloveAndroidModule::ShutdownModule()
|
|
|
|
|
{
|
2024-03-20 18:20:11 +01:00
|
|
|
SGLOG("Shutting down the SenseGloveAndroid module...");
|
2023-01-17 19:21:34 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-13 14:35:39 +01:00
|
|
|
void FSenseGloveAndroidModule::OnPostEngineInit() const
|
|
|
|
|
{
|
|
|
|
|
#if PLATFORM_ANDROID
|
|
|
|
|
USGAndroidPermissions::GetInstance()->Request(
|
|
|
|
|
[](const TArray<FString>& Permissions, const TArray<bool>& GrantResults)
|
|
|
|
|
{
|
|
|
|
|
const int32 R1 = FSGConnectJNI::Initialize();
|
|
|
|
|
const int32 R2 = FSGCoreJNI::Initialize();
|
|
|
|
|
|
2025-01-24 12:21:25 +01:00
|
|
|
SGLOG("FSGConnectJNI::Initialize() return code", R1);
|
|
|
|
|
SGLOG("FSGCoreJNI::Initialize() return code", R2);
|
|
|
|
|
|
2024-11-13 14:35:39 +01:00
|
|
|
ensureAlwaysMsgf(R1 == 0,
|
|
|
|
|
TEXT(
|
|
|
|
|
"Failed to initialize the SGConnect JNI bridge to SGConnect for Android! Status Code: %d"
|
|
|
|
|
), R1);
|
|
|
|
|
|
|
|
|
|
ensureAlwaysMsgf(R2 == 0,
|
|
|
|
|
TEXT("Failed to initialize the SGCore JNI bridge to SGConnect for Android! Status Code: %d"
|
|
|
|
|
), R2);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
#endif /* PLATFORM_ANDROID */
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-31 14:36:16 +01:00
|
|
|
#undef LOCTEXT_NAMESPACE
|