Working in UE4

This commit is contained in:
Jordon Brooks 2024-05-31 23:43:22 +01:00
parent f25ca44f03
commit daa49af247
Signed by: jordon
GPG key ID: DBD9758CD53E786A
6 changed files with 29 additions and 73 deletions

View file

@ -69,7 +69,6 @@ set(COMMON_SOURCES
"src/Platform/IPlatformUtilities.cpp"
"src/HarmonyLinkLib.cpp"
"src/Version.cpp"
"src/dllmain.cpp"
"src/Platform/WineUtilities.cpp"
"src/Utilities.cpp"
)

View file

@ -44,17 +44,19 @@ class IPlatformUtilities;
namespace HarmonyLinkLib
{
extern "C" HARMONYLINKLIB_API bool get_is_wine();
HARMONYLINKLIB_API bool HL_Init();
extern "C" HARMONYLINKLIB_API bool get_is_linux();
HARMONYLINKLIB_API bool get_is_wine();
extern "C" HARMONYLINKLIB_API bool get_is_docked();
HARMONYLINKLIB_API bool get_is_linux();
extern "C" HARMONYLINKLIB_API FCPUInfo* get_cpu_info();
HARMONYLINKLIB_API bool get_is_docked();
extern "C" HARMONYLINKLIB_API FDevice* get_device_info();
HARMONYLINKLIB_API FCPUInfo* get_cpu_info();
extern "C" HARMONYLINKLIB_API FOSVerInfo* get_os_version();
HARMONYLINKLIB_API FDevice* get_device_info();
HARMONYLINKLIB_API FOSVerInfo* get_os_version();
extern "C" HARMONYLINKLIB_API FBattery* get_battery_status();
HARMONYLINKLIB_API FBattery* get_battery_status();
}

View file

@ -16,10 +16,19 @@
#include <iostream>
#include "Platform/IPlatformUtilities.h"
#include "Version.h"
namespace HarmonyLinkLib
{
std::shared_ptr<IPlatformUtilities> PlatformUtilities = IPlatformUtilities::GetInstance();
std::shared_ptr<IPlatformUtilities> PlatformUtilities = nullptr;
bool HL_Init()
{
std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n";
PlatformUtilities = IPlatformUtilities::GetInstance();
return PlatformUtilities != nullptr;
}
bool get_is_wine()
{
@ -92,8 +101,6 @@ namespace HarmonyLinkLib
FOSVerInfo* get_os_version()
{
if (!PlatformUtilities)
{
std::wcout << "Failed to get platform utilities!\n";

View file

@ -1,61 +0,0 @@
// Copyright (c) 2024 Jordon Brooks
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include "Version.h"
namespace HarmonyLinkLib
{
void HarmonyLinkInit()
{
std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n";
}
}
#if BUILD_WINDOWS
#include <windows.h>
// Standard DLL entry point
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
// Code to run when the DLL is loaded
HarmonyLinkLib::HarmonyLinkInit();
break;
case DLL_THREAD_ATTACH:
// Code to run when a thread is created during the DLL's lifetime
case DLL_THREAD_DETACH:
// Code to run when a thread ends normally.
case DLL_PROCESS_DETACH:
// Code to run when the DLL is unloaded
default:
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
#endif
#if BUILD_UNIX
__attribute__((constructor))
static void onLibraryLoad() {
// Code to run when the library is loaded
HarmonyLinkLib::HarmonyLinkInit();
}
__attribute__((destructor))
static void onLibraryUnload() {
// Code to run when the library is unloaded
}
#endif