More work
This commit is contained in:
parent
b35dec2fdc
commit
6b90c9f76a
30 changed files with 710 additions and 109 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,8 +15,9 @@ build/**
|
|||
|
||||
!Images/*
|
||||
!.github/**
|
||||
!HarmonyLinkLib/**
|
||||
!LibHarmonyLink/**
|
||||
!HarmonyLinkTest/**
|
||||
!HarmonyLinkTest_CPP/**
|
||||
|
||||
# Blacklist specific build directories
|
||||
linuxbuild/
|
||||
|
|
|
@ -53,8 +53,9 @@ endforeach()
|
|||
|
||||
# Add the library and executable directories
|
||||
|
||||
add_subdirectory(HarmonyLinkLib)
|
||||
add_subdirectory(LibHarmonyLink)
|
||||
add_subdirectory(HarmonyLinkTest)
|
||||
add_subdirectory(HarmonyLinkTest_CPP)
|
||||
|
||||
# Add Google Test as a subdirectory
|
||||
#add_subdirectory(ThirdParty/googletest)
|
||||
|
|
|
@ -1,28 +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 "HarmonyLinkLib.h"
|
||||
|
||||
#include <wchar.h>
|
||||
#include "Version.h"
|
||||
|
||||
bool HarmonyLink_Init(void)
|
||||
{
|
||||
wprintf(L"HarmonyLink V%hs Copyright (C) 2023 Jordon Brooks\n", get_version_string());
|
||||
wprintf(L"Build Timestamp: %hs\n", get_version_build_timestamp());
|
||||
wprintf(L"Git Branch: %hs\n", get_git_branch());
|
||||
wprintf(L"Git Commit Timestamp: %hs\n", get_git_commit_timestamp());
|
||||
wprintf(L"Build type: %ls\n", get_is_debug() ? L"True" : L"False");
|
||||
return 1;
|
||||
}
|
|
@ -24,13 +24,13 @@ file(GLOB_RECURSE TEST_HEADERS "src/*.h" "src/*.hpp")
|
|||
|
||||
# Add executable for static library
|
||||
add_executable(HarmonyLinkTestStatic ${TEST_SOURCES} ${TEST_HEADERS})
|
||||
target_link_libraries(HarmonyLinkTestStatic PRIVATE HarmonyLinkLibStatic)
|
||||
target_compile_definitions(HarmonyLinkTestStatic PRIVATE HARMONYLINKLIB_STATIC)
|
||||
target_link_libraries(HarmonyLinkTestStatic PRIVATE LibHarmonyLinkStatic)
|
||||
target_compile_definitions(HarmonyLinkTestStatic PRIVATE HARMONYLINK_STATIC)
|
||||
|
||||
# Add executable for shared library
|
||||
add_executable(HarmonyLinkTestShared ${TEST_SOURCES} ${TEST_HEADERS})
|
||||
target_link_libraries(HarmonyLinkTestShared PRIVATE HarmonyLinkLibShared)
|
||||
target_compile_definitions(HarmonyLinkTestShared PRIVATE HARMONYLINKLIB_SHARED)
|
||||
target_link_libraries(HarmonyLinkTestShared PRIVATE LibHarmonyLinkShared)
|
||||
target_compile_definitions(HarmonyLinkTestShared PRIVATE HARMONYLINK_SHARED)
|
||||
|
||||
# Set output directories for all build types
|
||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||
|
@ -54,5 +54,5 @@ endforeach()
|
|||
# Copy the DLL to the executable directory after building the shared test executable
|
||||
add_custom_command(TARGET HarmonyLinkTestShared POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"$<TARGET_FILE:HarmonyLinkLibShared>"
|
||||
"$<TARGET_FILE:LibHarmonyLinkShared>"
|
||||
"$<TARGET_FILE_DIR:HarmonyLinkTestShared>")
|
||||
|
|
58
HarmonyLinkTest_CPP/CMakeLists.txt
Normal file
58
HarmonyLinkTest_CPP/CMakeLists.txt
Normal file
|
@ -0,0 +1,58 @@
|
|||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.22.1)
|
||||
project(HarmonyLinkTest)
|
||||
|
||||
# Specify the C++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Automatically add all .cpp and .h/.hpp files in the src directory
|
||||
file(GLOB_RECURSE TEST_SOURCES "src/*.cpp")
|
||||
file(GLOB_RECURSE TEST_HEADERS "src/*.h" "src/*.hpp")
|
||||
|
||||
# Add executable for static library
|
||||
add_executable(HarmonyLinkTestStatic_CPP ${TEST_SOURCES} ${TEST_HEADERS})
|
||||
target_link_libraries(HarmonyLinkTestStatic_CPP PRIVATE LibHarmonyLinkStatic)
|
||||
target_compile_definitions(HarmonyLinkTestStatic_CPP PRIVATE HARMONYLINK_STATIC)
|
||||
|
||||
# Add executable for shared library
|
||||
add_executable(HarmonyLinkTestShared_CPP ${TEST_SOURCES} ${TEST_HEADERS})
|
||||
target_link_libraries(HarmonyLinkTestShared_CPP PRIVATE LibHarmonyLinkShared)
|
||||
target_compile_definitions(HarmonyLinkTestShared_CPP PRIVATE HARMONYLINK_SHARED)
|
||||
|
||||
# Set output directories for all build types
|
||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||
string(TOUPPER ${TYPE} TYPE_UPPER)
|
||||
|
||||
# Static test executable properties
|
||||
set_target_properties(HarmonyLinkTestStatic_CPP PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkTestStatic_CPP"
|
||||
LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkTestStatic_CPP"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkTestStatic_CPP"
|
||||
)
|
||||
|
||||
# Shared test executable properties
|
||||
set_target_properties(HarmonyLinkTestShared_CPP PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkTestShared_CPP"
|
||||
LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkTestShared_CPP"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkTestShared_CPP"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Copy the DLL to the executable directory after building the shared test executable
|
||||
add_custom_command(TARGET HarmonyLinkTestShared_CPP POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"$<TARGET_FILE:LibHarmonyLinkShared>"
|
||||
"$<TARGET_FILE_DIR:HarmonyLinkTestShared_CPP>")
|
170
HarmonyLinkTest_CPP/src/main.cpp
Normal file
170
HarmonyLinkTest_CPP/src/main.cpp
Normal file
|
@ -0,0 +1,170 @@
|
|||
// 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 <chrono>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
#include "HarmonyLinkLib.h"
|
||||
|
||||
// Include necessary headers for platform-specific functionality
|
||||
#ifdef BUILD_WINDOWS
|
||||
#include <conio.h> // For _kbhit() and _getch()
|
||||
#include <windows.h> // For system("cls")
|
||||
#else
|
||||
#include <unistd.h> // For read()
|
||||
#include <termios.h> // For termios
|
||||
#include <stdio.h> // For getchar()
|
||||
#include <fcntl.h> // For F_GETFL, F_SETFL and O_NONBLOCK
|
||||
#endif
|
||||
|
||||
std::atomic<bool> quitFlag(false);
|
||||
|
||||
// Function to clear the screen cross-platform
|
||||
void clearScreen() {
|
||||
#ifdef BUILD_WINDOWS
|
||||
system("cls");
|
||||
#else
|
||||
std::cout << "\x1B[2J\x1B[H";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Function to check if 'q' or 'Q' is pressed in Windows
|
||||
void checkForQuit() {
|
||||
while (!quitFlag) {
|
||||
#ifdef BUILD_WINDOWS
|
||||
if (_kbhit()) {
|
||||
const char c = static_cast<char>(_getch());
|
||||
if (c == 'q' || c == 'Q') {
|
||||
quitFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
struct termios oldt, newt;
|
||||
int ch;
|
||||
int oldf;
|
||||
|
||||
tcgetattr(STDIN_FILENO, &oldt);
|
||||
newt = oldt;
|
||||
newt.c_lflag &= ~(ICANON | ECHO);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
||||
|
||||
ch = getchar();
|
||||
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
||||
|
||||
if (ch != EOF) {
|
||||
ungetc(ch, stdin);
|
||||
if (ch == 'q' || ch == 'Q') {
|
||||
quitFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Checks for input every roughly 60 frames
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello, World!" << '\n';
|
||||
|
||||
std::thread inputThread(checkForQuit);
|
||||
|
||||
if (!LibHarmonyLink::HarmonyLink_Init())
|
||||
{
|
||||
printf("Failed to Initialize HarmonyLink!");
|
||||
}
|
||||
|
||||
printf("HarmonyLink Initialized!");
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
|
||||
//const bool isWine = LibHarmonyLink::get_is_wine();
|
||||
//const char* test = isWine ? "is" : "isn't";
|
||||
|
||||
//const HarmonyLinkLib::FOSVerInfo* os_info = HarmonyLinkLib::get_os_version();
|
||||
|
||||
//const HarmonyLinkLib::FDevice* device_info = HarmonyLinkLib::get_device_info();
|
||||
|
||||
//const HarmonyLinkLib::FCPUInfo* cpu_info = HarmonyLinkLib::get_cpu_info();
|
||||
|
||||
// This loop is to test how stable & expensive these functions are
|
||||
while (!quitFlag)
|
||||
{
|
||||
// Clear the screen
|
||||
clearScreen();
|
||||
|
||||
//std::wcout << "This program " << test << " running under wine.\n";
|
||||
|
||||
//if (cpu_info)
|
||||
//{
|
||||
// cpu_info->print();
|
||||
//}
|
||||
|
||||
//if (os_info)
|
||||
//{
|
||||
// os_info->print();
|
||||
//}
|
||||
|
||||
//if (device_info)
|
||||
//{
|
||||
// wprintf(L"Is SteamDeck: %s\n", device_info->device == HarmonyLinkLib::EDevice::STEAM_DECK ? L"true" : L"false");
|
||||
//}
|
||||
|
||||
// we can't do this before the loop because we need updated values
|
||||
//if (const HarmonyLinkLib::FBattery* battery = HarmonyLinkLib::get_battery_status())
|
||||
//{
|
||||
// battery->print();
|
||||
// battery->free();
|
||||
//}
|
||||
|
||||
//const bool is_docked = HarmonyLinkLib::get_is_docked();
|
||||
|
||||
//const char* dock_check_string = is_docked ? "is" : "isn't";
|
||||
|
||||
//wprintf(L"Device %hs docked\n", dock_check_string);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
if (inputThread.joinable())
|
||||
{
|
||||
inputThread.join();
|
||||
}
|
||||
|
||||
//if (os_info)
|
||||
//{
|
||||
// os_info->free();
|
||||
//}
|
||||
|
||||
//if (device_info)
|
||||
//{
|
||||
// device_info->free();
|
||||
//}
|
||||
|
||||
//if (cpu_info)
|
||||
//{
|
||||
// cpu_info->free();
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(HarmonyLinkLib VERSION 2.1.1)
|
||||
project(LibHarmonyLink VERSION 2.1.1)
|
||||
|
||||
# Specify the C++ standard
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
@ -42,9 +42,9 @@ configure_file(include/Version.h.in Version.generated.h)
|
|||
|
||||
# Define metadata variables
|
||||
set(FILE_DESCRIPTION "Enhances handheld gaming with intelligent hardware recognition, dynamic adaptability, and robust API access for Windows and Linux, including Steam Deck and Wine support.")
|
||||
set(INTERNAL_NAME "HarmonyLinkLib")
|
||||
set(ORIGINAL_FILENAME "HarmonyLinkLib.dll")
|
||||
set(PRODUCT_NAME "HarmonyLinkLib")
|
||||
set(INTERNAL_NAME "LibHarmonyLink")
|
||||
set(ORIGINAL_FILENAME "LibHarmonyLink.dll")
|
||||
set(PRODUCT_NAME "LibHarmonyLink")
|
||||
set(COMMENTS "")
|
||||
|
||||
# Configure version.rc file for shared library
|
||||
|
@ -52,7 +52,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Resources/Version.rc.in ${CMAKE_CURRE
|
|||
|
||||
# Explicitly list source files
|
||||
set(COMMON_SOURCES
|
||||
src/dllmain.c
|
||||
src/HarmonyLinkLib.c
|
||||
src/Version.c
|
||||
src/Utilities.c
|
||||
|
@ -60,6 +59,8 @@ set(COMMON_SOURCES
|
|||
src/Structs/Battery.c
|
||||
src/Structs/CPUInfo.c
|
||||
src/Structs/StringArray.c
|
||||
src/Structs/Device.c
|
||||
src/Structs/OSInfo.C
|
||||
)
|
||||
|
||||
# Explicitly list include files
|
||||
|
@ -76,6 +77,8 @@ set(COMMON_INCLUDES
|
|||
include/Structs/Battery.h
|
||||
include/Structs/CPUInfo.h
|
||||
include/Structs/StringArray.h
|
||||
include/Structs/Device.h
|
||||
include/Structs/OSInfo.h
|
||||
)
|
||||
|
||||
set(WINDOWS_SOURCES
|
||||
|
@ -117,40 +120,36 @@ elseif(UNIX)
|
|||
endif()
|
||||
|
||||
# Create the shared library
|
||||
add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES})
|
||||
target_include_directories(HarmonyLinkLibShared
|
||||
add_library(LibHarmonyLinkShared SHARED ${LIB_SOURCES} ${LIB_INCLUDES} ${SHARED_SOURCES})
|
||||
target_include_directories(LibHarmonyLinkShared
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
PUBLIC
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
)
|
||||
target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED)
|
||||
target_compile_definitions(LibHarmonyLinkShared PRIVATE HARMONYLINK_SHARED)
|
||||
|
||||
# Create the static library
|
||||
add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES})
|
||||
target_include_directories(HarmonyLinkLibStatic
|
||||
add_library(LibHarmonyLinkStatic STATIC ${LIB_SOURCES} ${LIB_INCLUDES})
|
||||
target_include_directories(LibHarmonyLinkStatic
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
PUBLIC
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
)
|
||||
target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC)
|
||||
target_compile_definitions(LibHarmonyLinkStatic PRIVATE HARMONYLINK_STATIC)
|
||||
|
||||
# Set output directories for all build types
|
||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||
string(TOUPPER ${TYPE} TYPE_UPPER)
|
||||
set_target_properties(HarmonyLinkLibShared PROPERTIES
|
||||
set_target_properties(LibHarmonyLinkShared PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkLib"
|
||||
LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkLib"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLib"
|
||||
)
|
||||
set_target_properties(HarmonyLinkLibStatic PROPERTIES
|
||||
set_target_properties(LibHarmonyLinkStatic PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLibStatic"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
if (UNIX)
|
||||
endif()
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
// Use a preprocessor definition to switch between export and import declarations
|
||||
#ifdef _WIN32
|
||||
#ifdef HARMONYLINKLIB_STATIC
|
||||
#define HARMONYLINKLIB_API
|
||||
#ifdef HARMONYLINK_STATIC
|
||||
#define HARMONYLINK_API
|
||||
#else
|
||||
#ifdef HARMONYLINKLIB_SHARED
|
||||
#define HARMONYLINKLIB_API __declspec(dllexport)
|
||||
#ifdef HARMONYLINK_SHARED
|
||||
#define HARMONYLINK_API __declspec(dllexport)
|
||||
#else
|
||||
#define HARMONYLINKLIB_API __declspec(dllimport)
|
||||
#define HARMONYLINK_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
|
@ -14,18 +14,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
// Undefine the LINUX macro to avoid conflicts with the enum definition.
|
||||
#undef LINUX
|
||||
|
||||
typedef enum
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
EDevice_UNKNOWN,
|
||||
EDevice_DESKTOP,
|
||||
EDevice_LAPTOP,
|
||||
EDevice_HANDHELD,
|
||||
|
||||
|
||||
EDevice_STEAM_DECK,
|
||||
// EDevice_ROG_ALLY
|
||||
// EDevice_AYONEO_SLIDE
|
||||
// etc...
|
||||
} EDevice;
|
||||
|
||||
HARMONYLINK_API const char* Device_ToString(EDevice device) {
|
||||
switch (device) {
|
||||
case EDevice_DESKTOP: return "DESKTOP";
|
||||
case EDevice_LAPTOP: return "LAPTOP";
|
||||
case EDevice_HANDHELD: return "HANDHELD";
|
||||
case EDevice_STEAM_DECK: return "STEAM_DECK";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
46
LibHarmonyLink/include/Enums/Platform.h
Normal file
46
LibHarmonyLink/include/Enums/Platform.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
EPlatform_UNKNOWN,
|
||||
EPlatform_WINDOWS,
|
||||
EPlatform_LINUX,
|
||||
EPlatform_MAC,
|
||||
EPlatform_UNIX,
|
||||
} EPlatform;
|
||||
|
||||
// Helper functions to convert enums to strings (must be implemented somewhere in your code)
|
||||
HARMONYLINK_API const char* Platform_ToString(EPlatform platform) {
|
||||
switch (platform) {
|
||||
case EPlatform_WINDOWS: return "WINDOWS";
|
||||
case EPlatform_LINUX: return "LINUX";
|
||||
case EPlatform_MAC: return "MAC";
|
||||
case EPlatform_UNIX: return "UNIX";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -14,10 +14,31 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
{
|
||||
#include "Core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESteamDeck_NONE, // Device is not a steam deck
|
||||
ESteamDeck_UNKNOWN, // Device is a steam deck but model cannot be determined
|
||||
ESteamDeck_LCD,
|
||||
ESteamDeck_OLED,
|
||||
} ESteamDeck;
|
||||
|
||||
HARMONYLINK_API const char* SteamDeck_ToString(ESteamDeck steam_deck_model) {
|
||||
switch (steam_deck_model) {
|
||||
case ESteamDeck_NONE: return "NONE";
|
||||
case ESteamDeck_LCD: return "STEAMDECK_LCD";
|
||||
case ESteamDeck_OLED: return "STEAMDECK_OLED";
|
||||
// Add other cases as needed
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -17,4 +17,14 @@
|
|||
#include <stdbool.h>
|
||||
#include "Core.h"
|
||||
|
||||
HARMONYLINKLIB_API bool HarmonyLink_Init(void);
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HARMONYLINK_API bool HarmonyLink_Init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -18,14 +18,23 @@
|
|||
|
||||
#include "Core.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool has_battery;
|
||||
bool is_connected_to_ac;
|
||||
unsigned char battery_percent;
|
||||
} FBattery;
|
||||
|
||||
HARMONYLINKLIB_API FBattery* FBattery_Init(const FBattery* self);
|
||||
HARMONYLINK_API FBattery* HL_FBattery_Init(bool has_battery, bool is_connected_to_ac, unsigned char battery_percent);
|
||||
|
||||
HARMONYLINKLIB_API void FBattery_print(const FBattery* self);
|
||||
HARMONYLINK_API void HL_FBattery_print(const FBattery *self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -22,25 +22,36 @@
|
|||
#include "Core.h"
|
||||
#include "Structs/StringArray.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char* VendorID;
|
||||
char* Model_Name;
|
||||
char *VendorID;
|
||||
char *Model_Name;
|
||||
unsigned int Physical_Cores;
|
||||
unsigned int Logical_Cores;
|
||||
StringArray flagsInfo;
|
||||
} FCPUInfo;
|
||||
|
||||
// Initialize FCPUInfo
|
||||
FCPUInfo* FCPUInfo_Init(const char* vendorID, const char* modelName, unsigned int physicalCores, unsigned int logicalCores, size_t flagsCount);
|
||||
FCPUInfo* FCPUInfo_Init(const char *vendorID, const char *modelName, unsigned int physicalCores, unsigned int logicalCores,
|
||||
size_t flagsCount);
|
||||
|
||||
// Print FlagsInfo
|
||||
HARMONYLINKLIB_API void HL_FlagsInfo_Print(const FCPUInfo* cpuInfo);
|
||||
HARMONYLINK_API void HL_FlagsInfo_Print(const FCPUInfo *cpuInfo);
|
||||
|
||||
// Print FCPUInfo
|
||||
HARMONYLINKLIB_API void HL_FCPUInfo_Print(const FCPUInfo* cpuInfo);
|
||||
HARMONYLINK_API void HL_FCPUInfo_Print(const FCPUInfo *cpuInfo);
|
||||
|
||||
// Free FCPUInfo
|
||||
HARMONYLINKLIB_API void HL_FCPUInfo_Free(FCPUInfo* cpuInfo);
|
||||
HARMONYLINK_API void HL_FCPUInfo_Free(FCPUInfo *cpuInfo);
|
||||
|
||||
// Check if a flag exists in FlagsInfo
|
||||
HARMONYLINKLIB_API bool HL_FlagsInfo_Contains(const FCPUInfo* cpuInfo, const char* flag);
|
||||
HARMONYLINK_API bool HL_FlagsInfo_Contains(const FCPUInfo *cpuInfo, const char *flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
47
LibHarmonyLink/include/Structs/Device.h
Normal file
47
LibHarmonyLink/include/Structs/Device.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
#include "Enums/Platform.h"
|
||||
#include "Enums/Device.h"
|
||||
#include "Enums/SteamDeck.h"
|
||||
|
||||
#define DEFAULT_INITIAL_FLAGS_SIZE 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
EPlatform platform;
|
||||
EDevice device;
|
||||
ESteamDeck steam_deck_model;
|
||||
} FDevice;
|
||||
|
||||
// Initialize FlagsInfo
|
||||
FDevice* Device_Init(EPlatform platform, EDevice device, ESteamDeck steam_deck_model);
|
||||
|
||||
// Print FlagsInfo
|
||||
HARMONYLINK_API void HL_Device_Print(const FDevice* Device);
|
||||
|
||||
// Free FlagsInfo
|
||||
HARMONYLINK_API void HL_Device_Free(FDevice* Device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
49
LibHarmonyLink/include/Structs/OSInfo.h
Normal file
49
LibHarmonyLink/include/Structs/OSInfo.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
char* version;
|
||||
unsigned int id;
|
||||
char* version_id;
|
||||
char* version_codename;
|
||||
char* pretty_name;
|
||||
char* variant_id;
|
||||
} FOSVerInfo;
|
||||
|
||||
// Initialize FCPUInfo
|
||||
FOSVerInfo* FOSVerInfo_Init(char* name, char* version, unsigned int id, char* version_id, char* version_codename, char* pretty_name, char* variant_id);
|
||||
|
||||
// Print FlagsInfo
|
||||
HARMONYLINK_API void HL_FOSVerInfo_Print(const FOSVerInfo* OSVerInfo);
|
||||
|
||||
// Free FCPUInfo
|
||||
HARMONYLINK_API void HL_FOSVerInfo_Free(FOSVerInfo* OSVerInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -23,29 +23,39 @@
|
|||
|
||||
#define DEFAULT_INITIAL_FLAGS_SIZE 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char** data; // Array of strings (flags)
|
||||
char **data; // Array of strings (flags)
|
||||
size_t FlagsCount; // Number of flags
|
||||
size_t AllocatedSize; // Number of allocated slots
|
||||
} StringArray;
|
||||
|
||||
// Initialize FlagsInfo
|
||||
void StringArray_Init(StringArray* flagsInfo, size_t overrideInitialSize);
|
||||
void StringArray_Init(StringArray *flagsInfo, size_t overrideInitialSize);
|
||||
|
||||
// Print FlagsInfo
|
||||
HARMONYLINKLIB_API void HL_StringArray_Print(const StringArray* flagsInfo);
|
||||
HARMONYLINK_API void HL_StringArray_Print(const StringArray *flagsInfo);
|
||||
|
||||
// Free FlagsInfo
|
||||
HARMONYLINKLIB_API void HL_StringArray_Free(StringArray* flagsInfo);
|
||||
HARMONYLINK_API void HL_StringArray_Free(StringArray *flagsInfo);
|
||||
|
||||
// Check if a flag exists in FlagsInfo
|
||||
HARMONYLINKLIB_API bool HL_StringArray_Contains(const StringArray* flagsInfo, const char* flag);
|
||||
HARMONYLINK_API bool HL_StringArray_Contains(const StringArray *flagsInfo, const char *flag);
|
||||
|
||||
// Add a flag to FlagsInfo
|
||||
void StringArray_AddFlag(StringArray* flagsInfo, const char* flag);
|
||||
void StringArray_AddFlag(StringArray *flagsInfo, const char *flag);
|
||||
|
||||
// Remove a flag from FlagsInfo by value
|
||||
void StringArray_Remove(StringArray* flagsInfo, const char* flag);
|
||||
void StringArray_Remove(StringArray *flagsInfo, const char *flag);
|
||||
|
||||
// Resize FlagsInfo array
|
||||
void StringArray_Resize(StringArray* flagsInfo, size_t newSize);
|
||||
void StringArray_Resize(StringArray *flagsInfo, size_t newSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -14,5 +14,15 @@
|
|||
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Utility function to convert char* to wchar_t*
|
||||
wchar_t* convertToWideChar(const char* str);
|
||||
wchar_t *convertToWideChar(const char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -17,8 +17,24 @@
|
|||
#include <stdbool.h>
|
||||
#include "Core.h"
|
||||
|
||||
HARMONYLINKLIB_API char* get_version_string(void);
|
||||
HARMONYLINKLIB_API char* get_version_build_timestamp(void);
|
||||
HARMONYLINKLIB_API char* get_git_branch(void);
|
||||
HARMONYLINKLIB_API char* get_git_commit_timestamp(void);
|
||||
HARMONYLINKLIB_API bool get_is_debug(void);
|
||||
#ifdef __cplusplus
|
||||
namespace LibHarmonyLink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HARMONYLINK_API char* HL_version_get_string(void);
|
||||
|
||||
HARMONYLINK_API char* HL_version_build_timestamp(void);
|
||||
|
||||
HARMONYLINK_API char* HL_git_branch(void);
|
||||
|
||||
HARMONYLINK_API char* HL_git_commit_timestamp(void);
|
||||
|
||||
HARMONYLINK_API bool HL_is_debug(void);
|
||||
|
||||
HARMONYLINK_API void HL_version_print(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -15,11 +15,11 @@
|
|||
// Version.h.in
|
||||
#pragma once
|
||||
|
||||
#define HARMONYLINK_VERSION_MAJOR @HarmonyLinkLib_VERSION_MAJOR@
|
||||
#define HARMONYLINK_VERSION_MINOR @HarmonyLinkLib_VERSION_MINOR@
|
||||
#define HARMONYLINK_VERSION_PATCH @HarmonyLinkLib_VERSION_PATCH@
|
||||
#define HARMONYLINK_VERSION_TWEAK @HarmonyLinkLib_VERSION_TWEAK@
|
||||
#define HARMONYLINK_VERSION "@HarmonyLinkLib_VERSION@"
|
||||
#define HARMONYLINK_VERSION_MAJOR @LibHarmonyLink_VERSION_MAJOR@
|
||||
#define HARMONYLINK_VERSION_MINOR @LibHarmonyLink_VERSION_MINOR@
|
||||
#define HARMONYLINK_VERSION_PATCH @LibHarmonyLink_VERSION_PATCH@
|
||||
#define HARMONYLINK_VERSION_TWEAK @LibHarmonyLink_VERSION_TWEAK@
|
||||
#define HARMONYLINK_VERSION "@LibHarmonyLink_VERSION@"
|
||||
|
||||
#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@"
|
||||
#define GIT_COMMIT_TIMESTAMP "@GIT_COMMIT_TIMESTAMP@"
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2024 Jordon Brooks
|
||||
// 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.
|
||||
|
@ -12,13 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "HarmonyLinkLib.h"
|
||||
|
||||
typedef enum
|
||||
#include "Version.h"
|
||||
|
||||
bool HarmonyLink_Init(void)
|
||||
{
|
||||
EPlatform_UNKNOWN,
|
||||
EPlatform_WINDOWS,
|
||||
EPlatform_LINUX,
|
||||
EPlatform_MAC,
|
||||
EPlatform_UNIX,
|
||||
} EPlatform;
|
||||
HL_version_print();
|
||||
return 1;
|
||||
}
|
|
@ -15,6 +15,23 @@
|
|||
#include "Structs/Battery.h"
|
||||
|
||||
#include <wchar.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
FBattery* HL_FBattery_Init(bool has_battery, bool is_connected_to_ac, unsigned char battery_percent) {
|
||||
FBattery* battery = (FBattery*)malloc(sizeof(FBattery));
|
||||
|
||||
if (battery == NULL) {
|
||||
fprintf(stderr, "Memory allocation failed for FCPUInfo.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
battery->has_battery = has_battery;
|
||||
battery->battery_percent = is_connected_to_ac;
|
||||
battery->is_connected_to_ac = battery_percent;
|
||||
|
||||
return battery;
|
||||
}
|
||||
|
||||
void FBattery_print(const FBattery* self)
|
||||
{
|
|
@ -26,9 +26,14 @@ FCPUInfo* FCPUInfo_Init(const char *vendorID, const char *modelName, unsigned in
|
|||
fprintf(stderr, "Memory allocation failed for FCPUInfo.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#if defined(BUILD_WINDOWS)
|
||||
cpuInfo->VendorID = _strdup(vendorID);
|
||||
cpuInfo->Model_Name = _strdup(modelName);
|
||||
#else
|
||||
cpuInfo->VendorID = strdup(vendorID);
|
||||
cpuInfo->Model_Name = strdup(modelName);
|
||||
#endif
|
||||
|
||||
cpuInfo->Physical_Cores = physicalCores;
|
||||
cpuInfo->Logical_Cores = logicalCores;
|
||||
StringArray_Init(&cpuInfo->flagsInfo, flagsCount);
|
58
LibHarmonyLink/src/Structs/Device.c
Normal file
58
LibHarmonyLink/src/Structs/Device.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
// 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 "Structs/Device.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
FDevice* Device_Init(EPlatform platform, EDevice device, ESteamDeck steam_deck_model) {
|
||||
FDevice* newDevice = (FDevice*)malloc(sizeof(FDevice));
|
||||
if (newDevice != NULL) {
|
||||
newDevice->platform = platform;
|
||||
newDevice->device = device;
|
||||
newDevice->steam_deck_model = steam_deck_model;
|
||||
}
|
||||
return newDevice;
|
||||
}
|
||||
|
||||
void HL_Device_Print(const FDevice *Device) {
|
||||
if (Device == NULL) {
|
||||
wprintf(L"Device is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Assuming that EPlatform, EDevice, and ESteamDeck have corresponding string representations
|
||||
// which should be implemented for a proper print function
|
||||
|
||||
wchar_t* platformStr = convertToWideChar(Platform_ToString(Device->platform));
|
||||
wchar_t* deviceStr = convertToWideChar(Device_ToString(Device->device));
|
||||
wchar_t* steamDeckStr = convertToWideChar(SteamDeck_ToString(Device->steam_deck_model));
|
||||
|
||||
wprintf(L"Device Information:\n");
|
||||
wprintf(L"Platform: %ls\n", platformStr);
|
||||
wprintf(L"Device: %ls\n", deviceStr);
|
||||
wprintf(L"Steam Deck Model: %ls\n", steamDeckStr);
|
||||
|
||||
free(platformStr);
|
||||
free(deviceStr);
|
||||
free(steamDeckStr);
|
||||
}
|
||||
|
||||
void HL_Device_Free(FDevice *Device) {
|
||||
if (Device != NULL) {
|
||||
free(Device);
|
||||
}
|
||||
}
|
40
LibHarmonyLink/src/Structs/OSInfo.c
Normal file
40
LibHarmonyLink/src/Structs/OSInfo.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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 <malloc.h>
|
||||
#include "Structs/OSInfo.h"
|
||||
|
||||
FOSVerInfo* FOSVerInfo_Init(char* name, char* version, unsigned int id, char* version_id, char* version_codename, char* pretty_name,
|
||||
char* variant_id) {
|
||||
FOSVerInfo* OSVerInfo = (FOSVerInfo*)malloc(sizeof(FOSVerInfo));
|
||||
|
||||
if (OSVerInfo == NULL) {
|
||||
fprintf(stderr, "Memory allocation failed for FOSVerInfo.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
OSVerInfo->name = name;
|
||||
OSVerInfo->version = version;
|
||||
OSVerInfo->id = id;
|
||||
OSVerInfo->variant_id = version_id;
|
||||
OSVerInfo->version_codename = version_codename;
|
||||
OSVerInfo->pretty_name = pretty_name;
|
||||
OSVerInfo->version_id = variant_id;
|
||||
|
||||
return OSVerInfo;
|
||||
}
|
||||
|
||||
void HL_FOSVerInfo_Free(FOSVerInfo *OSVerInfo) {
|
||||
|
||||
}
|
|
@ -39,7 +39,11 @@ void StringArray_AddFlag(StringArray *flagsInfo, const char *flag) {
|
|||
if (flagsInfo->FlagsCount >= flagsInfo->AllocatedSize) {
|
||||
StringArray_Resize(flagsInfo, flagsInfo->AllocatedSize * 2);
|
||||
}
|
||||
#if defined(BUILD_WINDOWS)
|
||||
flagsInfo->data[flagsInfo->FlagsCount] = _strdup(flag);
|
||||
#else
|
||||
flagsInfo->data[flagsInfo->FlagsCount] = strdup(flag);
|
||||
#endif
|
||||
flagsInfo->FlagsCount++;
|
||||
}
|
||||
|
|
@ -17,11 +17,28 @@
|
|||
|
||||
wchar_t* convertToWideChar(const char* str) {
|
||||
size_t len = 0;
|
||||
mbstowcs_s(&len, NULL, 0, str, 0); // Get the length of the wide string (including null terminator)
|
||||
|
||||
#if defined(BUILD_WINDOWS)
|
||||
// Use mbstowcs_s on Windows
|
||||
mbstowcs_s(&len, NULL, 0, str, 0);
|
||||
#else
|
||||
// Use mbstowcs on Linux
|
||||
len = mbstowcs(NULL, str, 0) + 1;
|
||||
#endif
|
||||
|
||||
// Allocate memory for the wide string
|
||||
wchar_t* wstr = (wchar_t*)malloc(len * sizeof(wchar_t));
|
||||
if (wstr == NULL) {
|
||||
return NULL; // Handle memory allocation failure
|
||||
}
|
||||
|
||||
#if defined(BUILD_WINDOWS)
|
||||
// Use mbstowcs_s on Windows
|
||||
mbstowcs_s(&len, wstr, len, str, len - 1);
|
||||
#else
|
||||
// Use mbstowcs on Linux
|
||||
mbstowcs(wstr, str, len);
|
||||
#endif
|
||||
|
||||
return wstr;
|
||||
}
|
|
@ -15,28 +15,29 @@
|
|||
#include "Version.h"
|
||||
|
||||
#include <Version.generated.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char* get_version_string(void)
|
||||
char* HL_version_get_string(void)
|
||||
{
|
||||
return HARMONYLINK_VERSION;
|
||||
}
|
||||
|
||||
char* get_version_build_timestamp(void)
|
||||
char* HL_version_build_timestamp(void)
|
||||
{
|
||||
return __TIMESTAMP__;
|
||||
}
|
||||
|
||||
char* get_git_branch(void)
|
||||
char* HL_git_branch(void)
|
||||
{
|
||||
return GIT_BRANCH_NAME;
|
||||
}
|
||||
|
||||
char* get_git_commit_timestamp(void)
|
||||
char* HL_git_commit_timestamp(void)
|
||||
{
|
||||
return GIT_COMMIT_TIMESTAMP;
|
||||
}
|
||||
|
||||
bool get_is_debug(void)
|
||||
bool HL_is_debug(void)
|
||||
{
|
||||
#ifdef DEBUG_MODE
|
||||
return true;
|
||||
|
@ -44,3 +45,11 @@ bool get_is_debug(void)
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void HL_version_print(void) {
|
||||
wprintf(L"HarmonyLink V%hs Copyright (C) 2023 Jordon Brooks\n", HL_version_get_string());
|
||||
wprintf(L"Build Timestamp: %hs\n", HL_version_build_timestamp());
|
||||
wprintf(L"Git Branch: %hs\n", HL_git_branch());
|
||||
wprintf(L"Git Commit Timestamp: %hs\n", HL_git_commit_timestamp());
|
||||
wprintf(L"Build type: %ls\n", HL_is_debug() ? L"True" : L"False");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue