diff --git a/Source/OnDeviceConfig/Makefile b/Source/OnDeviceConfig/Makefile deleted file mode 100644 index 40faa2c8..00000000 --- a/Source/OnDeviceConfig/Makefile +++ /dev/null @@ -1,186 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -#--------------------------------------------------------------------------------- -# Project Info -#--------------------------------------------------------------------------------- -TARGET := hoc-configurator -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include -#ROMFS := romfs - -APP_TITLE := HOC Configurator -APP_AUTHOR := Dominatorul -APP_VERSION := 2.0.0 -ICON := icon.jpg - -#--------------------------------------------------------------------------------- -# Compilation Settings -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -LIBS := -lnx - -#--------------------------------------------------------------------------------- -# Library Paths -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) - -#--------------------------------------------------------------------------------- -# Automatic Build Rules -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) - -export OUTPUT := $(CURDIR)/$(TARGET) -export TOPDIR := $(CURDIR) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -ifeq ($(strip $(CPPFILES)),) - export LD := $(CC) -else - export LD := $(CXX) -endif - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) -export OFILES := $(OFILES_BIN) $(OFILES_SRC) -export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -ifeq ($(strip $(CONFIG_JSON)),) - jsons := $(wildcard *.json) - ifneq (,$(findstring $(TARGET).json,$(jsons))) - export APP_JSON := $(TOPDIR)/$(TARGET).json - else - ifneq (,$(findstring config.json,$(jsons))) - export APP_JSON := $(TOPDIR)/config.json - endif - endif -else - export APP_JSON := $(TOPDIR)/$(CONFIG_JSON) -endif - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.jpg) - ifneq (,$(findstring $(TARGET).jpg,$(icons))) - export APP_ICON := $(TOPDIR)/$(TARGET).jpg - else - ifneq (,$(findstring icon.jpg,$(icons))) - export APP_ICON := $(TOPDIR)/icon.jpg - endif - endif -else - export APP_ICON := $(TOPDIR)/$(ICON) -endif - -ifeq ($(strip $(NO_ICON)),) - export NROFLAGS += --icon=$(APP_ICON) -endif - -ifeq ($(strip $(NO_NACP)),) - export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp -endif - -ifneq ($(APP_TITLEID),) - export NACPFLAGS += --titleid=$(APP_TITLEID) -endif - -ifneq ($(ROMFS),) - export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) -endif - -.PHONY: $(BUILD) clean all rebuild - -#--------------------------------------------------------------------------------- -# Automatically clean before build -#--------------------------------------------------------------------------------- -all: clean $(BUILD) - -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo "Cleaning..." -ifeq ($(strip $(APP_JSON)),) - @rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf -else - @rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf -endif - -#--------------------------------------------------------------------------------- -# Optional: Full rebuild command -#--------------------------------------------------------------------------------- -rebuild: clean all - @echo "Rebuilt from scratch." - -#--------------------------------------------------------------------------------- -else -.PHONY: all -DEPENDS := $(OFILES:.o=.d) - -ifeq ($(strip $(APP_JSON)),) - -all : $(OUTPUT).nro - -ifeq ($(strip $(NO_NACP)),) -$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp -else -$(OUTPUT).nro : $(OUTPUT).elf -endif - -else - -all : $(OUTPUT).nsp - -$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm - -$(OUTPUT).nso : $(OUTPUT).elf - -endif - -$(OUTPUT).elf : $(OFILES) -$(OFILES_SRC) : $(HFILES_BIN) - -%.bin.o %_bin.h : %.bin - @echo $(notdir $<) - @$(bin2o) - --include $(DEPENDS) -endif -#--------------------------------------------------------------------------------- diff --git a/Source/OnDeviceConfig/hoc-configurator.elf b/Source/OnDeviceConfig/hoc-configurator.elf deleted file mode 100644 index e3024534..00000000 Binary files a/Source/OnDeviceConfig/hoc-configurator.elf and /dev/null differ diff --git a/Source/OnDeviceConfig/hoc-configurator.nacp b/Source/OnDeviceConfig/hoc-configurator.nacp deleted file mode 100644 index 35bbf967..00000000 Binary files a/Source/OnDeviceConfig/hoc-configurator.nacp and /dev/null differ diff --git a/Source/OnDeviceConfig/hoc-configurator.nro b/Source/OnDeviceConfig/hoc-configurator.nro deleted file mode 100644 index 1572f74b..00000000 Binary files a/Source/OnDeviceConfig/hoc-configurator.nro and /dev/null differ diff --git a/Source/OnDeviceConfig/icon.jpg b/Source/OnDeviceConfig/icon.jpg deleted file mode 100644 index 36704fb1..00000000 Binary files a/Source/OnDeviceConfig/icon.jpg and /dev/null differ diff --git a/Source/OnDeviceConfig/include/config.hpp b/Source/OnDeviceConfig/include/config.hpp deleted file mode 100644 index 903ce858..00000000 --- a/Source/OnDeviceConfig/include/config.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * HOC Configurator - Configuration Handler - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include - -class Config { -public: - std::string kipPath; - bool autoSave; - - Config(); - - bool loadConfig(); - bool saveConfig(); - bool checkKipExists(); - bool checkAtmosphereExists(); -}; diff --git a/Source/OnDeviceConfig/include/constants.hpp b/Source/OnDeviceConfig/include/constants.hpp deleted file mode 100644 index 072699d8..00000000 --- a/Source/OnDeviceConfig/include/constants.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * HOC Configurator - Constants - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include -#include - -namespace Constants { - // Application info - constexpr const char* APP_VERSION = "2.0.0"; - constexpr const char* APP_NAME = "HOC Configurator"; - constexpr const char* APP_AUTHOR = "Dominatorul"; - - // Paths - constexpr const char* DEFAULT_KIP_PATH = "sdmc:/atmosphere/kips/loader.kip"; - constexpr const char* CONFIG_DIR = "sdmc:/config/hoc-configurator"; - constexpr const char* CONFIG_FILE = "sdmc:/config/hoc-configurator/config.ini"; - constexpr const char* ATMOSPHERE_PATH = "sdmc:/atmosphere"; - constexpr const char* SYSTEM_SETTINGS_INI = "sdmc:/atmosphere/config/system_settings.ini"; - - // Frequency arrays (in kHz) - constexpr uint32_t MARIKO_GPU_FREQS[] = { - 76800, 153600, 230400, 307200, 384000, 460800, 537600, 614400, - 691200, 768000, 844800, 921600, 998400, 1075200, 1152000, 1228800, - 1267200, 1305600, 1344000, 1382400, 1420800, 1459200, 1497600, 1536000 - }; - - constexpr uint32_t ERISTA_GPU_FREQS[] = { - 76800, 153600, 230400, 307200, 384000, 460800, 537600, 614400, - 691200, 768000, 844800, 921600, 998400, 1075200 - }; - - constexpr uint32_t CPU_FREQS[] = { - 1020000, 1122000, 1224000, 1326000, 1428000, 1581000, 1683000, - 1785000, 1887000, 1963500, 2091000, 2193000, 2295000, 2397000, - 2499000, 2601000, 2703000, 2805000, 2907000 - }; - - constexpr uint32_t RAM_FREQS[] = { - 0, 1600000, 1633000, 1666000, 1700000, 1733000, 1766000, 1800000, - 1833000, 1866000, 1900000, 1933000, 1966000, 2000000, 2033000, 2066000, - 2100000, 2133000, 2166000, 2200000, 2233000, 2266000, 2300000 - }; - - // Voltage ranges - constexpr uint32_t MARIKO_GPU_MIN_VOLT = 480; - constexpr uint32_t MARIKO_GPU_MAX_VOLT = 960; - constexpr uint32_t MARIKO_GPU_MAX_VMIN = 700; - - constexpr uint32_t ERISTA_GPU_MIN_VOLT = 700; - constexpr uint32_t ERISTA_GPU_MAX_VOLT = 1000; - constexpr uint32_t ERISTA_GPU_MAX_VMIN = 850; - - constexpr uint32_t MARIKO_CPU_MIN_VMIN = 700; - constexpr uint32_t MARIKO_CPU_MAX_VMIN = 750; - - constexpr uint32_t VOLTAGE_STEP = 5; - constexpr uint32_t GPU_OFFSET_MAX = 50; - - // Thresholds - constexpr uint32_t MARIKO_MEME_THRESHOLD = 1536000; - constexpr uint32_t MARIKO_DANGEROUS_GPU_THRESHOLD = 1382400; - constexpr uint32_t MARIKO_UNSAFE_GPU_THRESHOLD = 1152000; - - constexpr uint32_t ERISTA_DANGEROUS_GPU_THRESHOLD = 1151000; - constexpr uint32_t ERISTA_UNSAFE_GPU_THRESHOLD = 922000; - - // RAM Types - const std::string RAM_TYPES[] = { - "Samsung AA-MGCL/MGCR", - "SK Hynix NEI/NEE/x267", - "Micron WT:B", - "Micron AUT:B", - "Micron WT:F", - "Samsung AM-MGCJ", - "Micron WT:E", - "Samsung AB-MGCL", - "SK Hynix NME", - "Samsung HB-MGCH" - }; - - // Fan curve profiles - namespace FanProfiles { - constexpr const char* V1_ERISTA = "V1_Erista"; - constexpr const char* V2_MARIKO = "V2_Mariko"; - constexpr const char* LITE_MARIKO = "Lite_Mariko"; - constexpr const char* OLED_MARIKO = "OLED_Mariko"; - } - - // PSM (Battery) options - struct PSMOption { - const char* name; - uint32_t value; - }; - - constexpr PSMOption PSM_OPTIONS[] = { - {"1024mA", 0x400}, - {"1280mA", 0x500}, - {"1536mA", 0x600}, - {"1660mA (Lite Default)", 0x67C}, - {"1792mA", 0x700}, - {"2048mA (Default)", 0x800}, - {"2304mA (UNSAFE)", 0x900}, - {"2560mA (UNSAFE)", 0xA00}, - {"2816mA (DANGEROUS)", 0xB00}, - {"3072mA (DANGEROUS)", 0xC00} - }; - - // Memory timing presets - struct TimingPreset { - uint32_t tRCD; - uint32_t tRP; - uint32_t tRAS; - uint32_t tRRD; - uint32_t tRFC; - uint32_t tRTW; - uint32_t tWTR; - uint32_t tREFI; - }; - - // Default timing preset - constexpr TimingPreset TIMING_DEFAULT = {0, 0, 0, 0, 0, 0, 0, 0}; - - // Samsung AA-MGCL/MGCR presets - constexpr TimingPreset TIMING_AAMGCL_CONSERVATIVE = {4, 4, 5, 5, 5, 5, 7, 6}; - constexpr TimingPreset TIMING_AAMGCL_TIGHT = {4, 4, 8, 6, 5, 7, 8, 6}; - - // SK Hynix NEE presets - constexpr TimingPreset TIMING_NEE_CONSERVATIVE = {3, 3, 2, 2, 5, 5, 4, 6}; - constexpr TimingPreset TIMING_NEE_TIGHT = {4, 4, 4, 3, 7, 6, 5, 6}; - - // Micron WT:B presets - constexpr TimingPreset TIMING_WTB_CONSERVATIVE = {4, 4, 5, 5, 2, 6, 5, 6}; - constexpr TimingPreset TIMING_WTB_TIGHT = {6, 6, 7, 7, 2, 6, 5, 6}; - - // UI Constants - constexpr int MAX_VISIBLE_ITEMS = 20; - constexpr int MENU_START_Y = 7; - constexpr int SCREEN_WIDTH = 80; - constexpr int SCREEN_HEIGHT = 45; -} diff --git a/Source/OnDeviceConfig/include/defaults.hpp b/Source/OnDeviceConfig/include/defaults.hpp deleted file mode 100644 index 2416e55e..00000000 --- a/Source/OnDeviceConfig/include/defaults.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * HOC Configurator - Default Values - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include - -class KipHandler; - -class Defaults { -public: - template - static void initDefaults(T& data) { - data.custRev = 0; - data.mtcConf = 0; - data.commonCpuBoostClock = 1785000; - data.commonEmcMemVolt = 1175000; - data.eristaCpuMaxVolt = 1235; - data.eristaEmcMaxClock = 1862400; - data.marikoCpuMaxVolt = 1120; - data.marikoEmcMaxClock = 1996800; - data.marikoEmcVddqVolt = 600000; - data.marikoCpuUV = 0; - data.marikoGpuUV = 0; - data.eristaCpuUV = 0; - data.eristaGpuUV = 0; - data.commonGpuVoltOffset = 0; - data.marikoEmcDvbShift = 0; - - // Memory timings - data.t1_tRCD = 0; - data.t2_tRP = 0; - data.t3_tRAS = 0; - data.t4_tRRD = 0; - data.t5_tRFC = 0; - data.t6_tRTW = 0; - data.t7_tWTR = 0; - data.t8_tREFI = 0; - data.mem_burst_latency = 2; - - // Additional voltages - data.marikoCpuVmin = 0; - data.eristaGpuVmin = 0; - data.marikoGpuVmin = 0; - data.marikoGpuVmax = 0; - - // Initialize all GPU voltages to 600 (default safe value) - data.g_volt_76800 = 600; - data.g_volt_153600 = 600; - data.g_volt_230400 = 600; - data.g_volt_307200 = 600; - data.g_volt_384000 = 600; - data.g_volt_460800 = 600; - data.g_volt_537600 = 600; - data.g_volt_614400 = 600; - data.g_volt_691200 = 600; - data.g_volt_768000 = 600; - data.g_volt_844800 = 605; - data.g_volt_921600 = 635; - data.g_volt_998400 = 665; - data.g_volt_1075200 = 695; - data.g_volt_1152000 = 730; - data.g_volt_1228800 = 760; - data.g_volt_1267200 = 785; - data.g_volt_1305600 = 800; - data.g_volt_1344000 = 0; - data.g_volt_1382400 = 0; - data.g_volt_1420800 = 0; - data.g_volt_1459200 = 0; - data.g_volt_1497600 = 0; - data.g_volt_1536000 = 0; - - // Erista GPU voltages - data.g_volt_e_76800 = 700; - data.g_volt_e_153600 = 700; - data.g_volt_e_230400 = 700; - data.g_volt_e_307200 = 700; - data.g_volt_e_384000 = 700; - data.g_volt_e_460800 = 700; - data.g_volt_e_537600 = 700; - data.g_volt_e_614400 = 700; - data.g_volt_e_691200 = 700; - data.g_volt_e_768000 = 700; - data.g_volt_e_844800 = 710; - data.g_volt_e_921600 = 740; - data.g_volt_e_998400 = 770; - data.g_volt_e_1075200 = 800; - } -}; \ No newline at end of file diff --git a/Source/OnDeviceConfig/include/ini_header.hpp b/Source/OnDeviceConfig/include/ini_header.hpp deleted file mode 100644 index bf757970..00000000 --- a/Source/OnDeviceConfig/include/ini_header.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include - -class IniHandler { -private: - std::string iniPath; - std::map> sections; - -public: - IniHandler(const std::string& path); - - bool load(); - bool save(); - - void setValue(const std::string& section, const std::string& key, const std::string& value); - std::string getValue(const std::string& section, const std::string& key, const std::string& defaultValue = ""); - void removeKey(const std::string& section, const std::string& key); - void removeSection(const std::string& section); - - bool sectionExists(const std::string& section); - bool keyExists(const std::string& section, const std::string& key); -}; \ No newline at end of file diff --git a/Source/OnDeviceConfig/include/kip_handler.hpp b/Source/OnDeviceConfig/include/kip_handler.hpp deleted file mode 100644 index 9e1b55ca..00000000 --- a/Source/OnDeviceConfig/include/kip_handler.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * HOC Configurator - KIP Handler - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include -#include -#include -#include "defaults.hpp" - -class KipHandler { -private: - std::string kipPath; - const uint8_t MAGIC[4] = {'C', 'U', 'S', 'T'}; - - struct KipData { - uint32_t custRev; - uint32_t mtcConf; - uint32_t commonCpuBoostClock; - uint32_t commonEmcMemVolt; - uint32_t eristaCpuMaxVolt; - uint32_t eristaEmcMaxClock; - uint32_t marikoCpuMaxVolt; - uint32_t marikoEmcMaxClock; - uint32_t marikoEmcVddqVolt; - uint32_t marikoCpuUV; - uint32_t marikoGpuUV; - uint32_t eristaCpuUV; - uint32_t eristaGpuUV; - uint32_t commonGpuVoltOffset; - uint32_t marikoEmcDvbShift; - - // Memory timings - uint32_t t1_tRCD; - uint32_t t2_tRP; - uint32_t t3_tRAS; - uint32_t t4_tRRD; - uint32_t t5_tRFC; - uint32_t t6_tRTW; - uint32_t t7_tWTR; - uint32_t t8_tREFI; - uint32_t mem_burst_latency; - - // Additional voltages - uint32_t marikoCpuVmin; - uint32_t eristaGpuVmin; - uint32_t marikoGpuVmin; - uint32_t marikoGpuVmax; - - // GPU voltages for each frequency (Mariko) - uint32_t g_volt_76800; - uint32_t g_volt_153600; - uint32_t g_volt_230400; - uint32_t g_volt_307200; - uint32_t g_volt_384000; - uint32_t g_volt_460800; - uint32_t g_volt_537600; - uint32_t g_volt_614400; - uint32_t g_volt_691200; - uint32_t g_volt_768000; - uint32_t g_volt_844800; - uint32_t g_volt_921600; - uint32_t g_volt_998400; - uint32_t g_volt_1075200; - uint32_t g_volt_1152000; - uint32_t g_volt_1228800; - uint32_t g_volt_1267200; - uint32_t g_volt_1305600; - uint32_t g_volt_1344000; - uint32_t g_volt_1382400; - uint32_t g_volt_1420800; - uint32_t g_volt_1459200; - uint32_t g_volt_1497600; - uint32_t g_volt_1536000; - - // GPU voltages for each frequency (Erista) - uint32_t g_volt_e_76800; - uint32_t g_volt_e_153600; - uint32_t g_volt_e_230400; - uint32_t g_volt_e_307200; - uint32_t g_volt_e_384000; - uint32_t g_volt_e_460800; - uint32_t g_volt_e_537600; - uint32_t g_volt_e_614400; - uint32_t g_volt_e_691200; - uint32_t g_volt_e_768000; - uint32_t g_volt_e_844800; - uint32_t g_volt_e_921600; - uint32_t g_volt_e_998400; - uint32_t g_volt_e_1075200; - }; - - KipData data; - -public: - KipHandler(const std::string& path) : kipPath(path) { - // Initialize with defaults - Defaults::initDefaults(data); - } - - bool readKip(); - bool writeKip(); - - // Getters - KipData& getData() { return data; } - const KipData& getData() const { return data; } - - // Setters for common values - void setCommonCpuBoostClock(uint32_t val) { data.commonCpuBoostClock = val; } - void setCommonEmcMemVolt(uint32_t val) { data.commonEmcMemVolt = val; } - void setMarikoCpuMaxVolt(uint32_t val) { data.marikoCpuMaxVolt = val; } - void setMarikoEmcMaxClock(uint32_t val) { data.marikoEmcMaxClock = val; } - void setMarikoEmcVddqVolt(uint32_t val) { data.marikoEmcVddqVolt = val; } - - // Utility - std::string getKipPath() const { return kipPath; } - void setKipPath(const std::string& path) { kipPath = path; } -}; diff --git a/Source/OnDeviceConfig/include/ui.hpp b/Source/OnDeviceConfig/include/ui.hpp deleted file mode 100644 index 8eb6beff..00000000 --- a/Source/OnDeviceConfig/include/ui.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * HOC Configurator - UI Handler - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include -#include -#include -#include - -// Forward declarations -class KipHandler; -class ValueEditor; - -enum class EditorType { - TOGGLE, - FREQUENCY, - VOLTAGE, - SLIDER, - LIST -}; - -enum class MenuState { - MAIN, - GPU, - CPU, - RAM, - MISC, - ABOUT, - SETTINGS -}; - -class UI { -private: - MenuState currentState; - int selectedIndex; - int scrollOffset; - std::string statusMessage; - std::string kipPath; - bool kipLoaded; - bool autoSave; - KipHandler* kipHandler; - ValueEditor* editor; - - const int MAX_VISIBLE_ITEMS = 20; - - void renderMainMenu(); - void renderGPUMenu(); - void renderCPUMenu(); - void renderRAMMenu(); - void renderMiscMenu(); - void renderAboutMenu(); - void renderSettingsMenu(); - - void handleMainMenuInput(u64 kDown); - void handleGPUMenuInput(u64 kDown); - void handleCPUMenuInput(u64 kDown); - void handleRAMMenuInput(u64 kDown); - void handleMiscMenuInput(u64 kDown); - void handleAboutMenuInput(u64 kDown); - void handleSettingsMenuInput(u64 kDown); - - void drawHeader(); - void drawFooter(); - void drawMenuItem(const std::string& text, bool selected, int y); - void drawText(const std::string& text, int x, int y); - - void showValueEditor(const std::string& title, EditorType type, int currentValue, - std::function callback, - const std::vector& options = {}, - int min = 0, int max = 100, int step = 1); - -public: - UI(); - ~UI(); - - void render(); - void handleInput(u64 kDown); - - void setStatus(const std::string& msg) { statusMessage = msg; } - void setKipPath(const std::string& path) { kipPath = path; } - void setKipLoaded(bool loaded) { kipLoaded = loaded; } - void setAutoSave(bool enabled) { autoSave = enabled; } - void setKipHandler(KipHandler* handler) { kipHandler = handler; } - - std::string getStatus() const { return statusMessage; } - std::string getKipPath() const { return kipPath; } - bool isKipLoaded() const { return kipLoaded; } - bool isAutoSaveEnabled() const { return autoSave; } -}; \ No newline at end of file diff --git a/Source/OnDeviceConfig/include/value_editor.hpp b/Source/OnDeviceConfig/include/value_editor.hpp deleted file mode 100644 index b37dc032..00000000 --- a/Source/OnDeviceConfig/include/value_editor.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * HOC Configurator - Value Editor - * Copyright (C) Dominatorul, Souldbminer - */ - -#pragma once -#include -#include -#include -#include -#include "ui.hpp" // This includes EditorType - -class KipHandler; - -struct EditorConfig { - std::string title; - EditorType type; - int currentValue; - int minValue; - int maxValue; - int step; - std::vector options; - std::function onValueChange; -}; - -class ValueEditor { -private: - EditorConfig config; - int selectedValue; - bool active; - -public: - ValueEditor(); - - void show(const EditorConfig& cfg); - void hide(); - bool isActive() const { return active; } - - void handleInput(u64 kDown); - void render(); - - int getSelectedValue() const { return selectedValue; } -}; \ No newline at end of file diff --git a/Source/OnDeviceConfig/source/config.cpp b/Source/OnDeviceConfig/source/config.cpp deleted file mode 100644 index f8512370..00000000 --- a/Source/OnDeviceConfig/source/config.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * HOC Configurator - Configuration Implementation - * Copyright (C) Dominatorul, Souldbminer - */ - -#include "config.hpp" -#include -#include - -Config::Config() { - kipPath = "sdmc:/atmosphere/kips/loader.kip"; - autoSave = false; -} - -bool Config::loadConfig() { - std::ifstream file("sdmc:/config/hoc-configurator/config.ini"); - if (!file.is_open()) { - return false; - } - - std::string line; - while (std::getline(file, line)) { - if (line.find("kip_path=") == 0) { - kipPath = line.substr(9); - } else if (line.find("auto_save=") == 0) { - autoSave = (line.substr(10) == "1"); - } - } - - file.close(); - return true; -} - -bool Config::saveConfig() { - // Create directory if it doesn't exist - mkdir("sdmc:/config", 0777); - mkdir("sdmc:/config/hoc-configurator", 0777); - - std::ofstream file("sdmc:/config/hoc-configurator/config.ini"); - if (!file.is_open()) { - return false; - } - - file << "kip_path=" << kipPath << "\n"; - file << "auto_save=" << (autoSave ? "1" : "0") << "\n"; - - file.close(); - return true; -} - -bool Config::checkKipExists() { - struct stat buffer; - return (stat(kipPath.c_str(), &buffer) == 0); -} - -bool Config::checkAtmosphereExists() { - struct stat buffer; - return (stat("sdmc:/atmosphere", &buffer) == 0); -} diff --git a/Source/OnDeviceConfig/source/ini_header.cpp b/Source/OnDeviceConfig/source/ini_header.cpp deleted file mode 100644 index bf757970..00000000 --- a/Source/OnDeviceConfig/source/ini_header.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include - -class IniHandler { -private: - std::string iniPath; - std::map> sections; - -public: - IniHandler(const std::string& path); - - bool load(); - bool save(); - - void setValue(const std::string& section, const std::string& key, const std::string& value); - std::string getValue(const std::string& section, const std::string& key, const std::string& defaultValue = ""); - void removeKey(const std::string& section, const std::string& key); - void removeSection(const std::string& section); - - bool sectionExists(const std::string& section); - bool keyExists(const std::string& section, const std::string& key); -}; \ No newline at end of file diff --git a/Source/OnDeviceConfig/source/kip_handler.cpp b/Source/OnDeviceConfig/source/kip_handler.cpp deleted file mode 100644 index 60205199..00000000 --- a/Source/OnDeviceConfig/source/kip_handler.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * HOC Configurator - KIP Handler Implementation - * Copyright (C) Dominatorul, Souldbminer - */ - -#include "kip_handler.hpp" -#include -#include -#include - -bool KipHandler::readKip() { - std::ifstream file(kipPath, std::ios::binary); - if (!file.is_open()) { - return false; - } - - // Read entire file - file.seekg(0, std::ios::end); - size_t fileSize = file.tellg(); - file.seekg(0, std::ios::beg); - - std::vector buffer(fileSize); - file.read(reinterpret_cast(buffer.data()), fileSize); - file.close(); - - // Find CUST magic - size_t magicPos = 0; - bool found = false; - for (size_t i = 0; i < fileSize - 4; i++) { - if (memcmp(&buffer[i], MAGIC, 4) == 0) { - magicPos = i + 4; - found = true; - break; - } - } - - if (!found) { - return false; - } - - // Read structure (assuming packed uint32_t structure) - size_t offset = magicPos; - auto readU32 = [&]() -> uint32_t { - uint32_t val; - memcpy(&val, &buffer[offset], sizeof(uint32_t)); - offset += sizeof(uint32_t); - return val; - }; - - data.custRev = readU32(); - data.mtcConf = readU32(); - data.commonCpuBoostClock = readU32(); - data.commonEmcMemVolt = readU32(); - data.eristaCpuMaxVolt = readU32(); - data.eristaEmcMaxClock = readU32(); - data.marikoCpuMaxVolt = readU32(); - data.marikoEmcMaxClock = readU32(); - data.marikoEmcVddqVolt = readU32(); - data.marikoCpuUV = readU32(); - data.marikoGpuUV = readU32(); - data.eristaCpuUV = readU32(); - data.eristaGpuUV = readU32(); - data.commonGpuVoltOffset = readU32(); - data.marikoEmcDvbShift = readU32(); - - // Memory timings - data.t1_tRCD = readU32(); - data.t2_tRP = readU32(); - data.t3_tRAS = readU32(); - data.t4_tRRD = readU32(); - data.t5_tRFC = readU32(); - data.t6_tRTW = readU32(); - data.t7_tWTR = readU32(); - data.t8_tREFI = readU32(); - data.mem_burst_latency = readU32(); - - // Additional voltages - data.marikoCpuVmin = readU32(); - data.eristaGpuVmin = readU32(); - data.marikoGpuVmin = readU32(); - data.marikoGpuVmax = readU32(); - - // GPU voltages Mariko - data.g_volt_76800 = readU32(); - data.g_volt_153600 = readU32(); - data.g_volt_230400 = readU32(); - data.g_volt_307200 = readU32(); - data.g_volt_384000 = readU32(); - data.g_volt_460800 = readU32(); - data.g_volt_537600 = readU32(); - data.g_volt_614400 = readU32(); - data.g_volt_691200 = readU32(); - data.g_volt_768000 = readU32(); - data.g_volt_844800 = readU32(); - data.g_volt_921600 = readU32(); - data.g_volt_998400 = readU32(); - data.g_volt_1075200 = readU32(); - data.g_volt_1152000 = readU32(); - data.g_volt_1228800 = readU32(); - data.g_volt_1267200 = readU32(); - data.g_volt_1305600 = readU32(); - data.g_volt_1344000 = readU32(); - data.g_volt_1382400 = readU32(); - data.g_volt_1420800 = readU32(); - data.g_volt_1459200 = readU32(); - data.g_volt_1497600 = readU32(); - data.g_volt_1536000 = readU32(); - - // GPU voltages Erista - data.g_volt_e_76800 = readU32(); - data.g_volt_e_153600 = readU32(); - data.g_volt_e_230400 = readU32(); - data.g_volt_e_307200 = readU32(); - data.g_volt_e_384000 = readU32(); - data.g_volt_e_460800 = readU32(); - data.g_volt_e_537600 = readU32(); - data.g_volt_e_614400 = readU32(); - data.g_volt_e_691200 = readU32(); - data.g_volt_e_768000 = readU32(); - data.g_volt_e_844800 = readU32(); - data.g_volt_e_921600 = readU32(); - data.g_volt_e_998400 = readU32(); - data.g_volt_e_1075200 = readU32(); - - return true; -} - -bool KipHandler::writeKip() { - std::fstream file(kipPath, std::ios::in | std::ios::out | std::ios::binary); - if (!file.is_open()) { - return false; - } - - // Read entire file - file.seekg(0, std::ios::end); - size_t fileSize = file.tellg(); - file.seekg(0, std::ios::beg); - - std::vector buffer(fileSize); - file.read(reinterpret_cast(buffer.data()), fileSize); - - // Find CUST magic - size_t magicPos = 0; - bool found = false; - for (size_t i = 0; i < fileSize - 4; i++) { - if (memcmp(&buffer[i], MAGIC, 4) == 0) { - magicPos = i + 4; - found = true; - break; - } - } - - if (!found) { - file.close(); - return false; - } - - // Write structure - size_t offset = magicPos; - auto writeU32 = [&](uint32_t val) { - memcpy(&buffer[offset], &val, sizeof(uint32_t)); - offset += sizeof(uint32_t); - }; - - writeU32(data.custRev); - writeU32(data.mtcConf); - writeU32(data.commonCpuBoostClock); - writeU32(data.commonEmcMemVolt); - writeU32(data.eristaCpuMaxVolt); - writeU32(data.eristaEmcMaxClock); - writeU32(data.marikoCpuMaxVolt); - writeU32(data.marikoEmcMaxClock); - writeU32(data.marikoEmcVddqVolt); - writeU32(data.marikoCpuUV); - writeU32(data.marikoGpuUV); - writeU32(data.eristaCpuUV); - writeU32(data.eristaGpuUV); - writeU32(data.commonGpuVoltOffset); - writeU32(data.marikoEmcDvbShift); - - // Memory timings - writeU32(data.t1_tRCD); - writeU32(data.t2_tRP); - writeU32(data.t3_tRAS); - writeU32(data.t4_tRRD); - writeU32(data.t5_tRFC); - writeU32(data.t6_tRTW); - writeU32(data.t7_tWTR); - writeU32(data.t8_tREFI); - writeU32(data.mem_burst_latency); - - // Additional voltages - writeU32(data.marikoCpuVmin); - writeU32(data.eristaGpuVmin); - writeU32(data.marikoGpuVmin); - writeU32(data.marikoGpuVmax); - - // GPU voltages Mariko - writeU32(data.g_volt_76800); - writeU32(data.g_volt_153600); - writeU32(data.g_volt_230400); - writeU32(data.g_volt_307200); - writeU32(data.g_volt_384000); - writeU32(data.g_volt_460800); - writeU32(data.g_volt_537600); - writeU32(data.g_volt_614400); - writeU32(data.g_volt_691200); - writeU32(data.g_volt_768000); - writeU32(data.g_volt_844800); - writeU32(data.g_volt_921600); - writeU32(data.g_volt_998400); - writeU32(data.g_volt_1075200); - writeU32(data.g_volt_1152000); - writeU32(data.g_volt_1228800); - writeU32(data.g_volt_1267200); - writeU32(data.g_volt_1305600); - writeU32(data.g_volt_1344000); - writeU32(data.g_volt_1382400); - writeU32(data.g_volt_1420800); - writeU32(data.g_volt_1459200); - writeU32(data.g_volt_1497600); - writeU32(data.g_volt_1536000); - - // GPU voltages Erista - writeU32(data.g_volt_e_76800); - writeU32(data.g_volt_e_153600); - writeU32(data.g_volt_e_230400); - writeU32(data.g_volt_e_307200); - writeU32(data.g_volt_e_384000); - writeU32(data.g_volt_e_460800); - writeU32(data.g_volt_e_537600); - writeU32(data.g_volt_e_614400); - writeU32(data.g_volt_e_691200); - writeU32(data.g_volt_e_768000); - writeU32(data.g_volt_e_844800); - writeU32(data.g_volt_e_921600); - writeU32(data.g_volt_e_998400); - writeU32(data.g_volt_e_1075200); - - // Write back to file - file.seekp(0, std::ios::beg); - file.write(reinterpret_cast(buffer.data()), fileSize); - file.close(); - - return true; -} \ No newline at end of file diff --git a/Source/OnDeviceConfig/source/main.cpp b/Source/OnDeviceConfig/source/main.cpp deleted file mode 100644 index 7f1406ba..00000000 --- a/Source/OnDeviceConfig/source/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * HOC Configurator - Nintendo Switch Homebrew - * Copyright (C) Dominatorul, Souldbminer - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "kip_handler.hpp" -#include "ui.hpp" -#include "config.hpp" -#include "defaults.hpp" - -int main(int argc, char* argv[]) { - // Initialize services - socketInitializeDefault(); - nxlinkStdio(); - - consoleInit(NULL); - - // Configure input - padConfigureInput(1, HidNpadStyleSet_NpadStandard); - PadState pad; - padInitializeDefault(&pad); - - // Initialize configuration - Config config; - config.loadConfig(); - - // Initialize KIP handler - KipHandler* kipHandler = new KipHandler(config.kipPath); - - // Initialize UI - UI ui; - ui.setKipPath(config.kipPath); - ui.setKipHandler(kipHandler); - ui.setAutoSave(config.autoSave); - - // Check if KIP exists and load it - if (config.checkKipExists()) { - if (kipHandler->readKip()) { - ui.setStatus("KIP loaded successfully from " + config.kipPath); - ui.setKipLoaded(true); - } else { - ui.setStatus("ERROR: Failed to parse KIP file!"); - ui.setKipLoaded(false); - } - } else if (config.checkAtmosphereExists()) { - ui.setStatus("Atmosphere found, but KIP not found at: " + config.kipPath); - ui.setKipLoaded(false); - } else { - ui.setStatus("ERROR: Atmosphere not detected! Is your SD card mounted?"); - ui.setKipLoaded(false); - } - - bool running = true; - u64 kDownOld = 0; - int frameCounter = 0; - const int FRAME_DELAY = 3; // Add input delay for better responsiveness - - while (running && appletMainLoop()) { - padUpdate(&pad); - u64 kDown = padGetButtonsDown(&pad); - - // Exit on Plus button - if (kDown & HidNpadButton_Plus) { - running = false; - break; - } - - // Process input with debouncing and frame delay - if (kDown && kDown != kDownOld && frameCounter >= FRAME_DELAY) { - ui.handleInput(kDown); - frameCounter = 0; - } - - // Render UI - ui.render(); - consoleUpdate(NULL); - - kDownOld = kDown; - frameCounter++; - - // Frame limiter - 30 FPS - svcSleepThread(33333333); // ~33ms - } - - // Save config before exit - config.autoSave = ui.isAutoSaveEnabled(); - config.kipPath = ui.getKipPath(); - config.saveConfig(); - - // Cleanup - delete kipHandler; - - consoleExit(NULL); - socketExit(); - - return 0; -} \ No newline at end of file diff --git a/Source/OnDeviceConfig/source/ui.cpp b/Source/OnDeviceConfig/source/ui.cpp deleted file mode 100644 index 09b4730d..00000000 --- a/Source/OnDeviceConfig/source/ui.cpp +++ /dev/null @@ -1,504 +0,0 @@ -/* - * HOC Configurator - Complete UI Implementation - * Copyright (C) Dominatorul, Souldbminer - */ - -#include "ui.hpp" -#include "kip_handler.hpp" -#include "value_editor.hpp" -#include "constants.hpp" -#include -#include -#include - -UI::UI() : currentState(MenuState::MAIN), selectedIndex(0), scrollOffset(0), - kipLoaded(false), autoSave(false), kipHandler(nullptr), editor(nullptr) { - statusMessage = "Welcome to HOC Configurator"; - editor = new ValueEditor(); -} - -UI::~UI() { - if (editor) delete editor; -} - -void UI::drawHeader() { - printf("\x1b[2J\x1b[1;1H"); - printf("\x1b[47;30m"); - printf("================================================================================\n"); - printf(" HOC Configurator v%s | Made by Dominatorul \n", Constants::APP_VERSION); - printf("================================================================================\n"); - printf("\x1b[0m"); -} - -void UI::drawFooter() { - printf("\x1b[42;1H"); - printf("\x1b[47;30m"); - printf("================================================================================\n"); - std::string truncStatus = statusMessage; - if (truncStatus.length() > 50) { - truncStatus = truncStatus.substr(0, 47) + "..."; - } - printf(" [A] Select [B] Back [+] Exit | %s\n", truncStatus.c_str()); - printf("================================================================================\n"); - printf("\x1b[0m"); -} - -void UI::drawMenuItem(const std::string& text, bool selected, int y) { - printf("\x1b[%d;1H", y); - std::string displayText = text; - if (displayText.length() > 74) { - displayText = displayText.substr(0, 71) + "..."; - } - if (selected) { - printf("\x1b[44;37m > %-76s\x1b[0m\n", displayText.c_str()); - } else { - printf(" %-76s\n", displayText.c_str()); - } -} - -void UI::drawText(const std::string& text, int x, int y) { - printf("\x1b[%d;%dH%s", y, x, text.c_str()); -} - -void UI::showValueEditor(const std::string& title, EditorType type, int currentValue, - std::function callback, const std::vector& options, - int min, int max, int step) { - if (!editor) return; - EditorConfig cfg; - cfg.title = title; - cfg.type = type; - cfg.currentValue = currentValue; - cfg.minValue = min; - cfg.maxValue = max; - cfg.step = step; - cfg.options = options; - cfg.onValueChange = callback; - editor->show(cfg); -} - -void UI::renderMainMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- Main Menu -------------------------------------------------------------------+\n"); - std::vector menuItems = { - "GPU Settings", "CPU Settings", "RAM Settings", - "Misc Settings", "Settings", "About" - }; - int startY = 7; - for (size_t i = 0; i < menuItems.size(); i++) { - drawMenuItem(menuItems[i], (int)i == selectedIndex, startY + (int)i); - } - printf("\x1b[%d;1H", startY + (int)menuItems.size() + 1); - printf("+-------------------------------------------------------------------------------+\n"); - printf("\n"); - printf(" KIP Path: %s\n", kipPath.c_str()); - printf(" KIP Status: %s\n", kipLoaded ? "\x1b[32mLoaded\x1b[0m" : "\x1b[31mNot Loaded\x1b[0m"); - printf(" Auto-save: %s\n", autoSave ? "\x1b[32mEnabled\x1b[0m" : "\x1b[33mDisabled\x1b[0m"); - drawFooter(); -} - -void UI::renderGPUMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- GPU Settings ----------------------------------------------------------------+\n"); - - if (!kipHandler || !kipLoaded) { - printf("\n \x1b[31mNo KIP loaded! Go to Settings to load a KIP file.\x1b[0m\n\n"); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); - return; - } - - auto& data = kipHandler->getData(); - std::vector menuItems = { - "Mariko GPU vMin: " + (data.marikoGpuVmin == 0 ? "Disabled" : std::to_string(data.marikoGpuVmin) + "mV"), - "Mariko GPU vMax: " + (data.marikoGpuVmax == 0 ? "Disabled" : std::to_string(data.marikoGpuVmax) + "mV"), - "Erista GPU vMin: " + (data.eristaGpuVmin == 0 ? "Disabled" : std::to_string(data.eristaGpuVmin) + "mV"), - "Mariko Undervolt: UV" + std::to_string(data.marikoGpuUV), - "Erista Undervolt: UV" + std::to_string(data.eristaGpuUV), - "GPU Volt Offset: " + (data.commonGpuVoltOffset == 0 ? "Disabled" : "-" + std::to_string(data.commonGpuVoltOffset) + "mV") - }; - - int startY = 7; - for (size_t i = 0; i < menuItems.size(); i++) { - drawMenuItem(menuItems[i], (int)i == selectedIndex, startY + (int)i); - } - printf("\x1b[%d;1H", startY + (int)menuItems.size() + 1); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); -} - -void UI::renderCPUMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- CPU Settings ----------------------------------------------------------------+\n"); - - if (!kipHandler || !kipLoaded) { - printf("\n \x1b[31mNo KIP loaded! Go to Settings to load a KIP file.\x1b[0m\n\n"); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); - return; - } - - auto& data = kipHandler->getData(); - std::vector menuItems = { - "CPU Boost Frequency: " + std::to_string(data.commonCpuBoostClock / 1000) + " MHz", - "Mariko CPU vMin: " + (data.marikoCpuVmin == 0 ? "Default" : std::to_string(data.marikoCpuVmin) + "mV"), - "Mariko CPU vMax: " + (data.marikoCpuMaxVolt == 0 ? "Disabled" : std::to_string(data.marikoCpuMaxVolt) + "mV"), - "Erista CPU vMax: " + (data.eristaCpuMaxVolt == 0 ? "Disabled" : std::to_string(data.eristaCpuMaxVolt) + "mV"), - "Mariko CPU Undervolt: UV" + std::to_string(data.marikoCpuUV), - "Erista CPU Undervolt: UV" + std::to_string(data.eristaCpuUV) - }; - - int startY = 7; - for (size_t i = 0; i < menuItems.size(); i++) { - drawMenuItem(menuItems[i], (int)i == selectedIndex, startY + (int)i); - } - printf("\x1b[%d;1H", startY + (int)menuItems.size() + 1); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); -} - -void UI::renderRAMMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- RAM Settings ----------------------------------------------------------------+\n"); - - if (!kipHandler || !kipLoaded) { - printf("\n \x1b[31mNo KIP loaded! Go to Settings to load a KIP file.\x1b[0m\n\n"); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); - return; - } - - auto& data = kipHandler->getData(); - std::vector menuItems = { - "RAM Max Frequency (Mariko): " + std::to_string(data.marikoEmcMaxClock / 1000) + " MHz", - "RAM Max Frequency (Erista): " + std::to_string(data.eristaEmcMaxClock / 1000) + " MHz", - "RAM Primary Voltage (VDD2): " + std::to_string(data.commonEmcMemVolt / 1000) + " mV", - "RAM Secondary Voltage (VDDQ): " + std::to_string(data.marikoEmcVddqVolt / 1000) + " mV", - "SoC DVB Shift: " + std::to_string(data.marikoEmcDvbShift), - "Base Latency: " + std::to_string(data.mem_burst_latency), - "t1 tRCD: " + std::to_string(data.t1_tRCD), - "t2 tRP: " + std::to_string(data.t2_tRP), - "t3 tRAS: " + std::to_string(data.t3_tRAS), - "t4 tRRD: " + std::to_string(data.t4_tRRD), - "t5 tRFC: " + std::to_string(data.t5_tRFC) - }; - - int startY = 7; - int visibleStart = scrollOffset; - int visibleEnd = std::min((int)menuItems.size(), scrollOffset + MAX_VISIBLE_ITEMS); - - for (int i = visibleStart; i < visibleEnd; i++) { - drawMenuItem(menuItems[i], i == selectedIndex, startY + (i - visibleStart)); - } - - printf("\x1b[%d;1H", startY + (visibleEnd - visibleStart) + 1); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); -} - -void UI::renderMiscMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- Misc Settings ---------------------------------------------------------------+\n"); - std::vector menuItems = { - "Optimize Fan Curve (V1 Erista)", - "Optimize Fan Curve (V2 Mariko)", - "Optimize Fan Curve (Lite)", - "Optimize Fan Curve (OLED)", - "Reset Fan Curve to Default", - "Sleep Mode Battery Fix: Toggle", - "Battery Charge Limit \x1b[31m(DANGEROUS)\x1b[0m" - }; - - int startY = 7; - for (size_t i = 0; i < menuItems.size(); i++) { - drawMenuItem(menuItems[i], (int)i == selectedIndex, startY + (int)i); - } - printf("\x1b[%d;1H", startY + (int)menuItems.size() + 1); - printf("+-------------------------------------------------------------------------------+\n"); - drawFooter(); -} - -void UI::renderAboutMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- About -----------------------------------------------------------------------+\n"); - printf("| |\n"); - printf("| Horizon OC Configurator v%-50s |\n", Constants::APP_VERSION); - printf("| Nintendo Switch Homebrew Edition |\n"); - printf("| |\n"); - printf("| Contributors: |\n"); - printf("| * Dominatorul - Homebrew port and development |\n"); - printf("| * Souldbminer - Original PC configurator |\n"); - printf("| * Lightos - L4T timings research |\n"); - printf("| * Lightos, Samybigio, Flopsider - Testing |\n"); - printf("| |\n"); - printf("| License: GNU General Public License v2.0 or later |\n"); - printf("| Source: github.com/souldbminersmwc/Horizon-OC |\n"); - printf("| |\n"); - printf("| \x1b[33mWARNING: Improper overclocking can damage your console!\x1b[0m |\n"); - printf("| Use at your own risk. Always test stability before daily use. |\n"); - printf("| |\n"); - printf("+------------------------------------------------------------------------------+\n"); - drawFooter(); -} - -void UI::renderSettingsMenu() { - drawHeader(); - printf("\x1b[5;1H"); - printf("+- Settings --------------------------------------------------------------------+\n"); - std::vector menuItems = { - "Toggle Auto-save: " + std::string(autoSave ? "\x1b[32mON\x1b[0m" : "\x1b[33mOFF\x1b[0m"), - "Save KIP Now", - "Reload KIP", - "Back to Main Menu" - }; - - int startY = 7; - for (size_t i = 0; i < menuItems.size(); i++) { - drawMenuItem(menuItems[i], (int)i == selectedIndex, startY + (int)i); - } - printf("\x1b[%d;1H", startY + (int)menuItems.size() + 1); - printf("+-------------------------------------------------------------------------------+\n"); - printf("\n"); - printf(" Current KIP Path: %s\n", kipPath.c_str()); - printf(" Auto-save Status: %s\n", autoSave ? "\x1b[32mEnabled\x1b[0m" : "\x1b[33mDisabled\x1b[0m"); - drawFooter(); -} - -void UI::render() { - if (editor && editor->isActive()) { - editor->render(); - return; - } - - switch (currentState) { - case MenuState::MAIN: renderMainMenu(); break; - case MenuState::GPU: renderGPUMenu(); break; - case MenuState::CPU: renderCPUMenu(); break; - case MenuState::RAM: renderRAMMenu(); break; - case MenuState::MISC: renderMiscMenu(); break; - case MenuState::ABOUT: renderAboutMenu(); break; - case MenuState::SETTINGS: renderSettingsMenu(); break; - } -} - -void UI::handleInput(u64 kDown) { - if (editor && editor->isActive()) { - editor->handleInput(kDown); - return; - } - - switch (currentState) { - case MenuState::MAIN: handleMainMenuInput(kDown); break; - case MenuState::GPU: handleGPUMenuInput(kDown); break; - case MenuState::CPU: handleCPUMenuInput(kDown); break; - case MenuState::RAM: handleRAMMenuInput(kDown); break; - case MenuState::MISC: handleMiscMenuInput(kDown); break; - case MenuState::ABOUT: handleAboutMenuInput(kDown); break; - case MenuState::SETTINGS: handleSettingsMenuInput(kDown); break; - } -} - -void UI::handleMainMenuInput(u64 kDown) { - if (kDown & HidNpadButton_Down) selectedIndex = (selectedIndex + 1) % 6; - if (kDown & HidNpadButton_Up) selectedIndex = (selectedIndex - 1 + 6) % 6; - - if (kDown & HidNpadButton_A) { - switch (selectedIndex) { - case 0: currentState = MenuState::GPU; break; - case 1: currentState = MenuState::CPU; break; - case 2: currentState = MenuState::RAM; break; - case 3: currentState = MenuState::MISC; break; - case 4: currentState = MenuState::SETTINGS; break; - case 5: currentState = MenuState::ABOUT; break; - } - selectedIndex = 0; - scrollOffset = 0; - } -} - -void UI::handleGPUMenuInput(u64 kDown) { - if (!kipHandler || !kipLoaded) { - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - return; - } - - int maxItems = 8; - if (kDown & HidNpadButton_Down) selectedIndex = (selectedIndex + 1) % maxItems; - if (kDown & HidNpadButton_Up) selectedIndex = (selectedIndex - 1 + maxItems) % maxItems; - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - - if (kDown & HidNpadButton_A) { - auto& data = kipHandler->getData(); - - switch (selectedIndex) { - case 5: { // Mariko GPU UV - std::vector opts = {"UV0 (No Table)", "UV1 (Regular)", "UV2 (High)", "UV3 (Custom)"}; - showValueEditor("Mariko GPU Undervolt Mode", EditorType::LIST, - data.marikoGpuUV, - [this, &data](int val) { - data.marikoGpuUV = val; - if (autoSave && kipHandler) kipHandler->writeKip(); - setStatus("Mariko GPU UV mode set to UV" + std::to_string(val)); - }, opts); - break; - } - case 6: { // Erista GPU UV - std::vector opts = {"UV0 (No Table)", "UV1 (Regular)", "UV2 (High)", "UV3 (Custom)"}; - showValueEditor("Erista GPU Undervolt Mode", EditorType::LIST, - data.eristaGpuUV, - [this, &data](int val) { - data.eristaGpuUV = val; - if (autoSave && kipHandler) kipHandler->writeKip(); - setStatus("Erista GPU UV mode set to UV" + std::to_string(val)); - }, opts); - break; - } - default: - setStatus("Feature in development"); - break; - } - } -} - -void UI::handleCPUMenuInput(u64 kDown) { - if (!kipHandler || !kipLoaded) { - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - return; - } - - int maxItems = 8; - if (kDown & HidNpadButton_Down) selectedIndex = (selectedIndex + 1) % maxItems; - if (kDown & HidNpadButton_Up) selectedIndex = (selectedIndex - 1 + maxItems) % maxItems; - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - - if (kDown & HidNpadButton_A) { - auto& data = kipHandler->getData(); - - switch (selectedIndex) { - default: - setStatus("Feature in development"); - break; - } - } -} - -void UI::handleRAMMenuInput(u64 kDown) { - if (!kipHandler || !kipLoaded) { - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - return; - } - - int maxItems = 11; - - if (kDown & HidNpadButton_Down) { - selectedIndex++; - if (selectedIndex >= maxItems) selectedIndex = 0; - if (selectedIndex >= scrollOffset + MAX_VISIBLE_ITEMS) { - scrollOffset = selectedIndex - MAX_VISIBLE_ITEMS + 1; - } - } - - if (kDown & HidNpadButton_Up) { - selectedIndex--; - if (selectedIndex < 0) selectedIndex = maxItems - 1; - if (selectedIndex < scrollOffset) scrollOffset = selectedIndex; - } - - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - scrollOffset = 0; - } - - if (kDown & HidNpadButton_A) { - setStatus("RAM setting (in development)"); - } -} - -void UI::handleMiscMenuInput(u64 kDown) { - int maxItems = 7; - if (kDown & HidNpadButton_Down) selectedIndex = (selectedIndex + 1) % maxItems; - if (kDown & HidNpadButton_Up) selectedIndex = (selectedIndex - 1 + maxItems) % maxItems; - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - - if (kDown & HidNpadButton_A) { - setStatus("Misc feature (in development)"); - } -} - -void UI::handleAboutMenuInput(u64 kDown) { - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } -} - -void UI::handleSettingsMenuInput(u64 kDown) { - int maxItems = 4; - if (kDown & HidNpadButton_Down) selectedIndex = (selectedIndex + 1) % maxItems; - if (kDown & HidNpadButton_Up) selectedIndex = (selectedIndex - 1 + maxItems) % maxItems; - if (kDown & HidNpadButton_B) { - currentState = MenuState::MAIN; - selectedIndex = 0; - } - - if (kDown & HidNpadButton_A) { - switch (selectedIndex) { - case 0: // Toggle Auto-save - autoSave = !autoSave; - setStatus(autoSave ? "Auto-save ENABLED" : "Auto-save DISABLED"); - break; - case 1: // Save KIP Now - if (kipHandler && kipLoaded) { - if (kipHandler->writeKip()) { - setStatus("KIP saved successfully!"); - } else { - setStatus("ERROR: Failed to save KIP!"); - } - } else { - setStatus("ERROR: No KIP loaded!"); - } - break; - case 2: // Reload KIP - if (kipHandler) { - if (kipHandler->readKip()) { - setStatus("KIP reloaded successfully!"); - kipLoaded = true; - } else { - setStatus("ERROR: Failed to reload KIP!"); - kipLoaded = false; - } - } else { - setStatus("ERROR: No KIP handler initialized!"); - } - break; - case 3: // Back to Main - currentState = MenuState::MAIN; - selectedIndex = 0; - break; - } - } -} \ No newline at end of file diff --git a/Source/OnDeviceConfig/source/value_editor.cpp b/Source/OnDeviceConfig/source/value_editor.cpp deleted file mode 100644 index fc9649ac..00000000 --- a/Source/OnDeviceConfig/source/value_editor.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * HOC Configurator - Value Editor Implementation - * Copyright (C) Dominatorul, Souldbminer - */ - -#include "value_editor.hpp" -#include -#include - -ValueEditor::ValueEditor() : selectedValue(0), active(false) {} - -void ValueEditor::show(const EditorConfig& cfg) { - config = cfg; - selectedValue = cfg.currentValue; - active = true; -} - -void ValueEditor::hide() { - active = false; -} - -void ValueEditor::handleInput(u64 kDown) { - if (!active) return; - - if (kDown & HidNpadButton_B) { - hide(); - return; - } - - if (kDown & HidNpadButton_A) { - if (config.onValueChange) { - config.onValueChange(selectedValue); - } - hide(); - return; - } - - switch (config.type) { - case EditorType::TOGGLE: - if (kDown & (HidNpadButton_Left | HidNpadButton_Right | - HidNpadButton_Up | HidNpadButton_Down)) { - selectedValue = !selectedValue; - } - break; - - case EditorType::LIST: - case EditorType::FREQUENCY: - case EditorType::VOLTAGE: - if (kDown & HidNpadButton_Down) { - selectedValue++; - if (selectedValue >= (int)config.options.size()) { - selectedValue = 0; - } - } - if (kDown & HidNpadButton_Up) { - selectedValue--; - if (selectedValue < 0) { - selectedValue = config.options.size() - 1; - } - } - break; - - case EditorType::SLIDER: - if (kDown & HidNpadButton_Right) { - selectedValue = std::min(selectedValue + config.step, config.maxValue); - } - if (kDown & HidNpadButton_Left) { - selectedValue = std::max(selectedValue - config.step, config.minValue); - } - if (kDown & HidNpadButton_Down) { - selectedValue = std::max(selectedValue - config.step * 5, config.minValue); - } - if (kDown & HidNpadButton_Up) { - selectedValue = std::min(selectedValue + config.step * 5, config.maxValue); - } - break; - } -} - -void ValueEditor::render() { - if (!active) return; - - // Draw editor overlay - printf("\x1b[2J\x1b[1;1H"); - - // Header - printf("\x1b[47;30m"); - printf("===============================================================================\n"); - printf(" %s%-73s \n", config.title.c_str(), ""); - printf("===============================================================================\n"); - printf("\x1b[0m"); - - printf("\x1b[10;1H"); - printf("+- Value Editor ----------------------------------------------------------------+\n"); - printf("| |\n"); - - // Display current value based on type - switch (config.type) { - case EditorType::TOGGLE: - printf("| Current: %-66s |\n", selectedValue ? "Enabled (1)" : "Disabled (0)"); - printf("| |\n"); - printf("| Use D-Pad to toggle |\n"); - break; - - case EditorType::LIST: - case EditorType::FREQUENCY: - case EditorType::VOLTAGE: - if (selectedValue >= 0 && selectedValue < (int)config.options.size()) { - printf("| Current: %-66s |\n", config.options[selectedValue].c_str()); - } - printf("| |\n"); - printf("| Use Up/Down to change value |\n"); - break; - - case EditorType::SLIDER: - printf("| Current: %-66d |\n", selectedValue); - printf("| |\n"); - printf("| Left/Right: +/-%d Up/Down: +/-%d |\n", - config.step, config.step * 5); - printf("| Range: %d - %d%-56s|\n", config.minValue, config.maxValue, ""); - break; - } - - printf("| |\n"); - printf("+------------------------------------------------------------------------------+\n"); - - // Footer - printf("\x1b[42;1H"); - printf("\x1b[47;30m"); - printf("===============================================================================\n"); - printf(" [A] Confirm [B] Cancel \n"); - printf("===============================================================================\n"); - printf("\x1b[0m"); -} diff --git a/Source/sys-clk/common/include/sysclk/board.h b/Source/sys-clk/common/include/sysclk/board.h index ca157d15..2ef96dcd 100644 --- a/Source/sys-clk/common/include/sysclk/board.h +++ b/Source/sys-clk/common/include/sysclk/board.h @@ -125,7 +125,6 @@ typedef enum { HorizonOCSpeedo_EnumMax, } HorizonOCSpeedo; - #define SYSCLK_ENUM_VALID(n, v) ((v) < n##_EnumMax) static inline const char* sysclkFormatModule(SysClkModule module, bool pretty) diff --git a/Source/sys-clk/overlay/Makefile b/Source/sys-clk/overlay/Makefile index 4bfb5571..9888968c 100644 --- a/Source/sys-clk/overlay/Makefile +++ b/Source/sys-clk/overlay/Makefile @@ -27,7 +27,7 @@ INCLUDES := ../common/include EXEFS_SRC := exefs_src IS_MINIMAL := 0 -APP_TITLE := Horizon OC +APP_TITLE := Horizon OC Zeus NO_ICON := 1