Working in UE4
This commit is contained in:
parent
f25ca44f03
commit
daa49af247
6 changed files with 29 additions and 73 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -26,3 +26,4 @@ winbuild/
|
||||||
|
|
||||||
!Compile.sh
|
!Compile.sh
|
||||||
!Compile.bat
|
!Compile.bat
|
||||||
|
HarmonyLinkLib/.vscode/
|
||||||
|
|
|
@ -69,7 +69,6 @@ set(COMMON_SOURCES
|
||||||
"src/Platform/IPlatformUtilities.cpp"
|
"src/Platform/IPlatformUtilities.cpp"
|
||||||
"src/HarmonyLinkLib.cpp"
|
"src/HarmonyLinkLib.cpp"
|
||||||
"src/Version.cpp"
|
"src/Version.cpp"
|
||||||
"src/dllmain.cpp"
|
|
||||||
"src/Platform/WineUtilities.cpp"
|
"src/Platform/WineUtilities.cpp"
|
||||||
"src/Utilities.cpp"
|
"src/Utilities.cpp"
|
||||||
)
|
)
|
||||||
|
|
|
@ -44,17 +44,19 @@ class IPlatformUtilities;
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
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();
|
||||||
|
|
||||||
extern "C" HARMONYLINKLIB_API FBattery* get_battery_status();
|
HARMONYLINKLIB_API FOSVerInfo* get_os_version();
|
||||||
|
|
||||||
|
HARMONYLINKLIB_API FBattery* get_battery_status();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,19 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Platform/IPlatformUtilities.h"
|
#include "Platform/IPlatformUtilities.h"
|
||||||
|
#include "Version.h"
|
||||||
|
|
||||||
namespace HarmonyLinkLib
|
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()
|
bool get_is_wine()
|
||||||
{
|
{
|
||||||
|
@ -92,8 +101,6 @@ namespace HarmonyLinkLib
|
||||||
|
|
||||||
FOSVerInfo* get_os_version()
|
FOSVerInfo* get_os_version()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!PlatformUtilities)
|
if (!PlatformUtilities)
|
||||||
{
|
{
|
||||||
std::wcout << "Failed to get platform utilities!\n";
|
std::wcout << "Failed to get platform utilities!\n";
|
||||||
|
|
|
@ -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
|
|
|
@ -85,10 +85,18 @@ void checkForQuit() {
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << "Hello, World!" << '\n';
|
std::cout << "Hello, World!\n";
|
||||||
|
|
||||||
std::thread inputThread(checkForQuit);
|
std::thread inputThread(checkForQuit);
|
||||||
|
|
||||||
|
if (!HarmonyLinkLib::HL_Init())
|
||||||
|
{
|
||||||
|
std::cout << "Failed to init HarmonyLinkLib\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "HarmonyLinkLib successfully initialised!\n";
|
||||||
|
|
||||||
const bool isWine = HarmonyLinkLib::get_is_wine();
|
const bool isWine = HarmonyLinkLib::get_is_wine();
|
||||||
const char* test = isWine ? "is" : "isn't";
|
const char* test = isWine ? "is" : "isn't";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue