From 85dec4fbbbbb0f28adceb67e462c7572b2eb26e7 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 31 May 2026 23:04:26 +0200 Subject: [PATCH] Add default keys for file Optimize CCs --- include/utils.hpp | 1 + rpi_setup/setup.sh | 1 + .../cypress_optimize_3ds_acquisition.cpp | 14 ++-------- source/cc3dsfs.cpp | 26 +++++++++++++++++++ source/utils.cpp | 10 +++++++ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/include/utils.hpp b/include/utils.hpp index 0d7be21..6f70155 100755 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -58,6 +58,7 @@ void ActualConsoleOutText(std::string out_string); std::string get_base_path(bool for_presets, bool do_existence_check=true); std::string get_base_path_keys(); std::string get_base_path_device_specific_configs(); +std::string get_optimize_keys_file_path(bool is_new_device); std::string LayoutNameGenerator(int index); std::string LayoutPathGenerator(int index); std::string load_layout_name(int index, bool &success); diff --git a/rpi_setup/setup.sh b/rpi_setup/setup.sh index 5266b7c..5d8bcf4 100755 --- a/rpi_setup/setup.sh +++ b/rpi_setup/setup.sh @@ -81,6 +81,7 @@ echo "${HOME}/${KIOSK_SINGLE_EXECUTION_SCRIPT}" >> ${HOME}/.bashrc # Copy the real program... sudo rm -f ${BASE_TARGET_DIR}/${PROGRAM_NAME}_script.sh sudo cp -Rf ${BASE_SOURCE_DIR}/files/main_files/* ${BASE_TARGET_DIR}/ +sudo cp -f ${BASE_SOURCE_DIR}/instructions.txt ${BASE_TARGET_DIR}/ if [ $(getconf LONG_BIT) -eq 32 ]; then $(cd ${HOME} ; rm -f ${PROGRAM_NAME}_link ; ln -s ${BASE_TARGET_DIR}/${PROGRAM_NAME}_versions/${PROGRAM_NAME}_32 ${PROGRAM_NAME}_link) else diff --git a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp index 8d57b7c..24225bc 100644 --- a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp +++ b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp @@ -1317,18 +1317,8 @@ bool cyop_is_key_for_device(CaptureDevice* device, std::string key) { return check_key_matches_device_id(device->device_id, key, (const cyop_device_usb_device*)device->descriptor); } -static std::string get_keys_file_path(bool is_new_device) { - std::string path = get_base_path_keys(); - - if(is_new_device) - path += "optimize_new_3ds.txt"; - else - path += "optimize_old_3ds.txt"; - return path; -} - static std::string read_key_for_device_id_from_file(uint64_t device_id, bool is_new_device) { - std::ifstream file(get_keys_file_path(is_new_device)); + std::ifstream file(get_optimize_keys_file_path(is_new_device)); std::string line; std::string out_key = ""; @@ -1363,7 +1353,7 @@ static void add_key_for_device_id_to_file(uint64_t device_id, std::string key, b if(read_key_for_device_id_from_file(device_id, is_new_device) == key) return; - std::ofstream file(get_keys_file_path(is_new_device), std::ios_base::app | std::ios_base::out); + std::ofstream file(get_optimize_keys_file_path(is_new_device), std::ios_base::app | std::ios_base::out); file << key << std::endl; file.close(); } diff --git a/source/cc3dsfs.cpp b/source/cc3dsfs.cpp index 79c6ac0..afd76b5 100755 --- a/source/cc3dsfs.cpp +++ b/source/cc3dsfs.cpp @@ -926,6 +926,30 @@ static bool create_folder(const std::string path) { return false; } +static bool create_file(const std::string path, std::string base_content) { + try { + #if (!defined(_MSC_VER)) || (_MSC_VER > 1916) + bool file_exists = std::filesystem::exists(path); + #else + bool file_exists = std::experimental::filesystem::exists(path); + #endif + if(file_exists) + return true; + std::ofstream file(path, std::ios_base::app | std::ios_base::out); + if(!file.good()) { + ActualConsoleOutTextError("Error creating file " + path); + return false; + } + file << base_content << std::endl; + file.close(); + return true; + } + catch(...) { + ActualConsoleOutTextError("Error creating file " + path); + } + return false; +} + static bool create_out_folder() { bool success = create_folder(get_base_path(false, false)); if(!success) @@ -933,6 +957,8 @@ static bool create_out_folder() { create_folder(get_base_path(true)); create_folder(get_base_path_keys()); create_folder(get_base_path_device_specific_configs()); + create_file(get_optimize_keys_file_path(true), "THIS-ISAN-EXAM-PLE0-KEY0\nONE0-LINE-FOR0-ONE0-KEY0"); + create_file(get_optimize_keys_file_path(false), "THIS-ISAN-EXAM-PLE0-KEY0\nONE0-LINE-FOR0-ONE0-KEY0"); return success; } diff --git a/source/utils.cpp b/source/utils.cpp index e22a232..be3c6c3 100755 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -410,6 +410,16 @@ std::string get_base_path_device_specific_configs() { return get_base_path(false) + "device_specific_configs/"; } +std::string get_optimize_keys_file_path(bool is_new_device) { + std::string path = get_base_path_keys(); + + if(is_new_device) + path += "optimize_new_3ds.txt"; + else + path += "optimize_old_3ds.txt"; + return path; +} + std::string LayoutPathGenerator(int index) { return get_base_path(index != STARTUP_FILE_INDEX); }