Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Common/ControllerStates/StandardHid_Keyboard_State.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "StandardHid_Keyboard_State.h"


const pabb_HID_Keyboard_State pabb_HID_Keyboard_State_NEUTRAL_STATE = {};
const pabb_HID_Keyboard_State pabb_HID_Keyboard_State_NEUTRAL_STATE = {0};

bool pabb_HID_Keyboard_State_equals(
const pabb_HID_Keyboard_State* state0,
Expand Down
2 changes: 1 addition & 1 deletion Common/Cpp/Json/JsonTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef PokemonAutomation_Common_Json_JsonTools_H
#define PokemonAutomation_Common_Json_JsonTools_H

#include "3rdParty/nlohmann/json.hpp"
#include "3rdParty-Core/nlohmann/json.hpp"
#include "JsonValue.h"

namespace PokemonAutomation{
Expand Down
2 changes: 1 addition & 1 deletion Common/Cpp/Json/JsonValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/

#include "3rdParty/nlohmann/json.hpp"
#include "3rdParty-Core/nlohmann/json.hpp"
#include "Common/Cpp/Filesystem/FileIO.h"
#include "JsonValue.h"
#include "JsonArray.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void ReliableStreamConnection::process_RET_BUFFER_SLOTS(const PacketHeader* pack
{
std::lock_guard<Mutex> lg(m_lock);
m_reliable_sender.remove(packet->seqnum);
m_max_unacked_packets = std::min<uint8_t>(message->data, PABB2_PacketSender_REORDER_WINDOW);
m_max_unacked_packets = std::min<uint8_t>((uint8_t)message->data, PABB2_PacketSender_REORDER_WINDOW);
}
m_logger.log(
"[RSC]: Setting Reorder Window: " + std::to_string(m_max_unacked_packets) + " slots",
Expand All @@ -544,7 +544,7 @@ void ReliableStreamConnection::process_RET_BUFFER_BYTES(const PacketHeader* pack
{
std::lock_guard<Mutex> lg(m_lock);
m_reliable_sender.remove(packet->seqnum);
m_max_unacked_bytes = std::min<uint16_t>(message->data, PABB2_PacketSender_BUFFER_SIZE);
m_max_unacked_bytes = std::min<uint16_t>((uint16_t)message->data, PABB2_PacketSender_BUFFER_SIZE);
}
m_logger.log(
"[RSC]: Setting Reorder Window: " + std::to_string(m_max_unacked_bytes) + " bytes",
Expand Down
63 changes: 51 additions & 12 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,24 @@ add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
# add current directory to find tesseractPA.lib
link_directories(${CMAKE_CURRENT_LIST_DIR})

# add the list of all code file paths as ${LIBRARY_SOURCES} and ${EXECUTABLE_SOURCES}
# add the list of all code file paths as ${CORE_LIBRARY_SOURCES}, ${LIBRARY_SOURCES} and ${EXECUTABLE_SOURCES}
include(cmake/SourceFiles.cmake)

# Organize source files in IDE project view
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/../../ FILES ${CORE_LIBRARY_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/../../ FILES ${LIBRARY_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/../../ FILES ${EXECUTABLE_SOURCES})

# Create library target first
add_library(SerialProgramsLib STATIC ${LIBRARY_SOURCES})
# Create GUI-free Controller library
add_library(CoreLib STATIC ${CORE_LIBRARY_SOURCES})

# see apply_common_target_properties() for target_include_directories, set_target_properties, target_compile_definitions



# Create the GUI library
add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES})


# Create binary target
if (APPLE)
Expand Down Expand Up @@ -215,6 +224,21 @@ endif()
# Function to apply common properties to both library and executable targets
function(apply_common_target_properties target_name)
set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${target_name} PRIVATE Threads::Threads)

#add defines
target_compile_definitions(${target_name} PRIVATE NOMINMAX DPP_NO_DEPRECATED)

#add include directory
target_include_directories(${target_name} SYSTEM PRIVATE ../3rdParty-Core)
target_include_directories(${target_name} PRIVATE ../ ../../Internal/ Source/)

if("NO_GUI" IN_LIST ARGN)
target_compile_definitions(${target_name} PRIVATE PA_IMAGE_BACKEND_None)
return()
endif()

# include Qt headers
target_link_libraries(${target_name} PRIVATE
Qt${QT_MAJOR}::Widgets
Qt${QT_MAJOR}::SerialPort
Expand All @@ -224,27 +248,24 @@ function(apply_common_target_properties target_name)
Qt${QT_MAJOR}::Qml
Qt${QT_MAJOR}::Quick
Qt${QT_MAJOR}::QuickWidgets
)
target_link_libraries(${target_name} PRIVATE Threads::Threads)

#add defines
target_compile_definitions(${target_name} PRIVATE NOMINMAX DPP_NO_DEPRECATED)
)

#add include directory
# more include directories
target_include_directories(${target_name} SYSTEM PRIVATE ../3rdParty/)
target_include_directories(${target_name} PRIVATE ../ ../../Internal/ Source/)
target_link_directories(${target_name} PRIVATE ../3rdPartyBinaries/)

endfunction()

# Apply common properties to both targets
apply_common_target_properties(CoreLib NO_GUI)
apply_common_target_properties(SerialProgramsLib)
apply_common_target_properties(SerialPrograms)

if(MSVC)
set_source_files_properties("../3rdParty/miniz-3.1.1/miniz.c" PROPERTIES COMPILE_FLAGS "/W0")
set_source_files_properties("../3rdParty-Core/miniz-3.1.1/miniz.c" PROPERTIES COMPILE_FLAGS "/W0")
else()
# For GCC/Clang
set_source_files_properties("../3rdParty/miniz-3.1.1/miniz.c" PROPERTIES COMPILE_FLAGS "-w")
set_source_files_properties("../3rdParty-Core/miniz-3.1.1/miniz.c" PROPERTIES COMPILE_FLAGS "-w")
endif()

# REPO_ROOT_DIR: the root folder of the git repository, "Arduino-Source/"
Expand Down Expand Up @@ -355,6 +376,10 @@ if (WIN32)
target_compile_options(SerialProgramsLib PRIVATE /wd5054) # Deprecated enum arithemtic
target_compile_options(SerialProgramsLib PRIVATE /wd4505) # unreferenced local function has been removed

target_compile_options(CoreLib PRIVATE /FAs /FaAssembly/ /MP /W4 /WX /external:anglebrackets /external:W0 /utf-8)
target_compile_options(CoreLib PRIVATE /wd5054) # Deprecated enum arithemtic
target_compile_options(CoreLib PRIVATE /wd4505) # unreferenced local function has been removed

set(ARCH_FLAGS_09_Nehalem /W4) # Dummy parameter
set(ARCH_FLAGS_13_Haswell /arch:AVX2)
set(ARCH_FLAGS_17_Skylake /arch:AVX512)
Expand All @@ -363,6 +388,8 @@ if (WIN32)
if(CMAKE_GENERATOR_TOOLSET MATCHES "ClangCL")
target_compile_options(SerialProgramsLib PRIVATE -Wno-unused-function)
target_compile_options(SerialProgramsLib PRIVATE -march=nehalem)
target_compile_options(CoreLib PRIVATE -Wno-unused-function)
target_compile_options(CoreLib PRIVATE -march=nehalem)
set(ARCH_FLAGS_09_Nehalem -march=nehalem)
set(ARCH_FLAGS_13_Haswell -march=haswell)
set(ARCH_FLAGS_17_Skylake -march=skylake-avx512)
Expand Down Expand Up @@ -501,6 +528,14 @@ else() # macOS and Linux
${REPO_ROOT_DIR}/3rdParty/sdbus-cpp/lib/libsdbus-c++.a
systemd #sdbus-c++ relies on libsystemd, almost all distros should have this
)

target_include_directories(CoreLib PRIVATE
${REPO_ROOT_DIR}/3rdParty/sdbus-cpp/include
)
target_link_libraries(CoreLib PRIVATE
${REPO_ROOT_DIR}/3rdParty/sdbus-cpp/lib/libsdbus-c++.a
systemd #sdbus-c++ relies on libsystemd, almost all distros should have this
)
endif() # end Linux

# Find OpenCV
Expand Down Expand Up @@ -562,9 +597,13 @@ else() # macOS and Linux
target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
# on macOS, need this framework to query OS API to control display sleep and system sleep behavior
target_link_libraries(SerialProgramsLib PRIVATE "-framework IOKit -framework CoreFoundation")

target_compile_options(CoreLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
target_link_libraries(CoreLib PRIVATE "-framework IOKit -framework CoreFoundation")
else() # Linux
# Assume GCC
target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)
target_compile_options(CoreLib PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)
endif()

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
Expand Down
6 changes: 3 additions & 3 deletions SerialPrograms/Source/CommandLine/CommandLineExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ set(COMMANDLINE_SOURCES
add_executable(SerialProgramsCommandLine ${COMMANDLINE_SOURCES})

# Link to SerialProgramsLib (contains all the core functionality)
target_link_libraries(SerialProgramsCommandLine PRIVATE SerialProgramsLib)
target_link_libraries(SerialProgramsCommandLine PRIVATE CoreLib)

# Ensure SerialProgramsCommandLine rebuilds when SerialProgramsLib is updated
add_dependencies(SerialProgramsCommandLine SerialProgramsLib)
add_dependencies(SerialProgramsCommandLine CoreLib)

# Apply common target properties (includes, compile flags, etc.)
# This function is defined in the parent CMakeLists.txt
apply_common_target_properties(SerialProgramsCommandLine)
apply_common_target_properties(SerialProgramsCommandLine NO_GUI)
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ ImageRGB32::ImageRGB32(const std::string& filename){
*this = OpenCV_load_image(filename);
}
#endif
#ifdef PA_IMAGE_BACKEND_None
ImageRGB32::ImageRGB32(const std::string& filename){}
#endif

ImageRGB32::ImageRGB32(std::unique_ptr<CustomImageRGB32Owner> image)
: m_custom_owner(std::move(image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ ImageRGB32 ImageViewRGB32::scale_to(size_t width, size_t height) const{
#ifdef PA_IMAGE_BACKEND_OpenCV
return OpenCV_scale_image(*this, width, height);
#endif
#ifdef PA_IMAGE_BACKEND_None
return ImageRGB32();
#endif
}


Expand Down
1 change: 0 additions & 1 deletion SerialPrograms/Source/CommonFramework/ProgramSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "CommonFramework/ResourceDownload/ProgramMissingResourceTracker.h"
#include "CommonFramework/ResourceDownload/GlobalResourceDownloadManager.h"
#include "CommonFramework/ResourceDownload/ResourceDownloadHelpers.h"
#include "CommonFramework/ResourceDownload/ResourceDownloadHelpersQt.h"
#include "Integrations/ProgramTracker.h"

namespace PokemonAutomation{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "Common/Cpp/Exceptions.h"
#include "CommonFramework/GlobalSettingsPanel.h"
#include "CommonFramework/ResourceDownload/ResourceDownloadHelpers.h"
#include "CommonFramework/ResourceDownload/ResourceDownloadHelpersQt.h"
#include "CommonFramework/ResourceDownload/ResourceDownload.h"
#include "GlobalResourceDownloadManager.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
*
*/

#include "CommonFramework/Tools/FileDownloader.h"
#include "Common/Cpp/Filesystem/Filesystem.h"
#include "Common/Cpp/Json/JsonArray.h"
#include "Common/Cpp/Json/JsonObject.h"
#include "Common/Cpp/Json/JsonValue.h"
#include "CommonFramework/GlobalAutoPaths.h"
#include "CommonFramework/Logging/Logger.h"
#include "CommonFramework/Exceptions/OperationFailedException.h"
Expand Down Expand Up @@ -162,4 +164,62 @@ const std::unordered_set<std::string>& all_resource_names(){

}




JsonValue fetch_resource_download_list_json_from_remote(){
#ifdef QT_CORE_LIB
Logger& logger = global_logger_tagged();
JsonValue json =
FileDownloader::download_json_file(
logger,
"https://raw.githubusercontent.com/PokemonAutomation/Packages/refs/heads/master/Resources/ResourceDownloadList.json"
);
#else
JsonValue json; // placeholder when no Qt
#endif

return json;
}


const JsonValue& remote_resource_download_list_json(){
static const JsonValue json = fetch_resource_download_list_json_from_remote();

return json;
}

const std::vector<DownloadedResourceMetadata>& remote_resource_download_list(){
// cout << "remote_resource_download_list" << endl;
static std::vector<DownloadedResourceMetadata> remote_resources = deserialize_resource_list_json(remote_resource_download_list_json());

return remote_resources;
}

DownloadedResourceMetadata get_remote_resource_metadata_from_resource_slug(const std::string& target_resource_slug){
Logger& logger = global_logger_tagged();
std::vector<DownloadedResourceMetadata> remote_resources;

// Step 1: Attempt to fetch the list of available downloads
try{
remote_resources = remote_resource_download_list();
}catch(OperationFailedException&){
std::cerr << "get_remote_resource_metadata_from_resource_slug: Error" << endl;
throw_and_log<OperationFailedException>(logger, ErrorReport::NO_ERROR_REPORT,
"Error: Download failed. Failed to fetch the list of available downloads. Check your internet connection.");
}

// Step 2: Attempt to extract metadata for the specific slug
try{
return get_resource_metadata_from_resource_type(target_resource_slug, remote_resources);
}catch(OperationFailedException&){
std::cerr << "get_remote_resource_metadata_from_resource_slug: Error" << endl;
throw_and_log<OperationFailedException>(logger, ErrorReport::NO_ERROR_REPORT,
"get_remote_resource_metadata_from_resource_slug: Unable to find " + target_resource_slug + " within resource_list. "
"Likely caused by resource being no longer available for download. We recommend updating the Computer Control program.");
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,16 @@ DownloadedResourceMetadata get_expected_resource_metadata_from_resource_slug(con

const std::unordered_set<std::string>& all_resource_names();



const std::vector<DownloadedResourceMetadata>& remote_resource_download_list();


// - throws OperationFailedException if target_resource_slug isn't found within remote_resource_download_list
// this would indicate that CC is out of date.
// - also throws OperationFailedException if Internet is not turned on.
DownloadedResourceMetadata get_remote_resource_metadata_from_resource_slug(const std::string& target_resource_slug);


}
#endif

This file was deleted.

Loading
Loading