Add Utilities class to add utility functions
This commit is contained in:
parent
ea7042c9ad
commit
ce7de29721
4 changed files with 99 additions and 0 deletions
|
@ -34,11 +34,13 @@ set(COMMON_SOURCES
|
||||||
"src/Version.cpp"
|
"src/Version.cpp"
|
||||||
"src/dllmain.cpp"
|
"src/dllmain.cpp"
|
||||||
"src/Platform/WineUtilities.cpp"
|
"src/Platform/WineUtilities.cpp"
|
||||||
|
"src/Utilities.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Explicitly list include files
|
# Explicitly list include files
|
||||||
set(COMMON_INCLUDES
|
set(COMMON_INCLUDES
|
||||||
"include/Core.h"
|
"include/Core.h"
|
||||||
|
|
||||||
"include/Structs/FBattery.h"
|
"include/Structs/FBattery.h"
|
||||||
"include/Structs/FOSVerInfo.h"
|
"include/Structs/FOSVerInfo.h"
|
||||||
"include/Structs/FDevice.h"
|
"include/Structs/FDevice.h"
|
||||||
|
@ -53,6 +55,8 @@ set(COMMON_INCLUDES
|
||||||
|
|
||||||
"src/Platform/IPlatformUtilities.h"
|
"src/Platform/IPlatformUtilities.h"
|
||||||
"src/Platform/WineUtilities.h"
|
"src/Platform/WineUtilities.h"
|
||||||
|
|
||||||
|
"src//Utilities.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(WINDOWS_SOURCES
|
set(WINDOWS_SOURCES
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
#include "IPlatformUtilities.h"
|
#include "IPlatformUtilities.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
#include "WineUtilities.h"
|
#include "WineUtilities.h"
|
||||||
#if BUILD_WINDOWS
|
#if BUILD_WINDOWS
|
||||||
|
@ -100,35 +102,45 @@ namespace HarmonyLinkLib
|
||||||
|
|
||||||
uint8_t score = 0;
|
uint8_t score = 0;
|
||||||
|
|
||||||
|
Utilities::DebugPrint("Detected: ", false);
|
||||||
|
|
||||||
if (is_charging())
|
if (is_charging())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("Charging, ", false);
|
||||||
score += CHARGING_SCORE;
|
score += CHARGING_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_is_external_monitor_connected())
|
if (get_is_external_monitor_connected())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("External monitor, ", false);
|
||||||
score += EXTERNAL_MONITOR_SCORE;
|
score += EXTERNAL_MONITOR_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_is_steam_deck_native_resolution())
|
if (get_is_steam_deck_native_resolution())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("Non-native resolution, ", false);
|
||||||
score += STEAM_DECK_RESOLUTION_SCORE;
|
score += STEAM_DECK_RESOLUTION_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_keyboard_detected())
|
if (get_keyboard_detected())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("keyboard ", false);
|
||||||
score += KEYBOARD_DETECTION_SCORE;
|
score += KEYBOARD_DETECTION_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_mouse_detected())
|
if (get_mouse_detected())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("mouse, ", false);
|
||||||
score += MOUSE_DETECTION_SCORE;
|
score += MOUSE_DETECTION_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_external_controller_detected())
|
if (get_external_controller_detected())
|
||||||
{
|
{
|
||||||
|
Utilities::DebugPrint("external controller, ", false);
|
||||||
score += CONTROLLER_DETECTION_SCORE;
|
score += CONTROLLER_DETECTION_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utilities::DebugPrint(std::format("Score: {}/{}", score, FINAL_TARGET_DETECTION_SCORE).c_str());
|
||||||
|
|
||||||
return score >= FINAL_TARGET_DETECTION_SCORE;
|
return score >= FINAL_TARGET_DETECTION_SCORE;
|
||||||
}
|
}
|
||||||
|
|
53
HarmonyLinkLib/src/Utilities.cpp
Normal file
53
HarmonyLinkLib/src/Utilities.cpp
Normal file
|
@ -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 <iostream>
|
||||||
|
|
||||||
|
#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
|
||||||
|
}
|
30
HarmonyLinkLib/src/Utilities.h
Normal file
30
HarmonyLinkLib/src/Utilities.h
Normal file
|
@ -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);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue