diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 8412f45..10486b1 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -34,11 +34,13 @@ set(COMMON_SOURCES "src/Version.cpp" "src/dllmain.cpp" "src/Platform/WineUtilities.cpp" + "src/Utilities.cpp" ) # Explicitly list include files set(COMMON_INCLUDES "include/Core.h" + "include/Structs/FBattery.h" "include/Structs/FOSVerInfo.h" "include/Structs/FDevice.h" @@ -53,6 +55,8 @@ set(COMMON_INCLUDES "src/Platform/IPlatformUtilities.h" "src/Platform/WineUtilities.h" + + "src//Utilities.h" ) set(WINDOWS_SOURCES diff --git a/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp b/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp index e5ff858..90bd62a 100644 --- a/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp +++ b/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp @@ -14,7 +14,9 @@ #include "IPlatformUtilities.h" +#include #include +#include "Utilities.h" #include "WineUtilities.h" #if BUILD_WINDOWS @@ -100,35 +102,45 @@ namespace HarmonyLinkLib uint8_t score = 0; + Utilities::DebugPrint("Detected: ", false); + if (is_charging()) { + Utilities::DebugPrint("Charging, ", false); score += CHARGING_SCORE; } if (get_is_external_monitor_connected()) { + Utilities::DebugPrint("External monitor, ", false); score += EXTERNAL_MONITOR_SCORE; } if (get_is_steam_deck_native_resolution()) { + Utilities::DebugPrint("Non-native resolution, ", false); score += STEAM_DECK_RESOLUTION_SCORE; } if (get_keyboard_detected()) { + Utilities::DebugPrint("keyboard ", false); score += KEYBOARD_DETECTION_SCORE; } if (get_mouse_detected()) { + Utilities::DebugPrint("mouse, ", false); score += MOUSE_DETECTION_SCORE; } if (get_external_controller_detected()) { + Utilities::DebugPrint("external controller, ", false); score += CONTROLLER_DETECTION_SCORE; } + + Utilities::DebugPrint(std::format("Score: {}/{}", score, FINAL_TARGET_DETECTION_SCORE).c_str()); return score >= FINAL_TARGET_DETECTION_SCORE; } diff --git a/HarmonyLinkLib/src/Utilities.cpp b/HarmonyLinkLib/src/Utilities.cpp new file mode 100644 index 0000000..608437c --- /dev/null +++ b/HarmonyLinkLib/src/Utilities.cpp @@ -0,0 +1,53 @@ +// 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 "Utilities.h" + +#include + +#include "FString.h" + +void HarmonyLinkLib::Utilities::DebugPrint(const FString& String, bool AddNewline) +{ +#ifdef DEBUG_MODE + std::wcout << String.c_str(); + + if (AddNewline) + { + std::wcout << L"\n"; + } +#endif +} + +void HarmonyLinkLib::Utilities::DebugPrint(const char* String, bool AddNewline) +{ +#ifdef DEBUG_MODE + std::wcout << std::wstring(String, String + std::strlen(String)); + + if (AddNewline) { + std::wcout << L"\n"; + } +#endif +} + +void HarmonyLinkLib::Utilities::DebugPrint(const wchar_t* String, bool AddNewline) +{ +#ifdef DEBUG_MODE + std::wcout << String; + + if (AddNewline) { + std::wcout << L"\n"; + } +#endif +} diff --git a/HarmonyLinkLib/src/Utilities.h b/HarmonyLinkLib/src/Utilities.h new file mode 100644 index 0000000..d6114c8 --- /dev/null +++ b/HarmonyLinkLib/src/Utilities.h @@ -0,0 +1,30 @@ +// 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 "HarmonyLinkLib.h" + +namespace HarmonyLinkLib +{ + class FString; + + class Utilities + { + public: + static void DebugPrint(const FString& String, bool AddNewline = true); + static void DebugPrint(const char* String, bool AddNewline = true); + static void DebugPrint(const wchar_t* String, bool AddNewline = true); + }; +}