hoc-sys: add extra features to overlay
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
@@ -24,37 +24,124 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "base_gui.h"
|
||||
|
||||
#include "../elements/base_frame.h"
|
||||
#include "logo_rgba_bin.h"
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Layout constants
|
||||
// -------------------------------------------------------------
|
||||
|
||||
#define LOGO_X 20
|
||||
#define LOGO_Y 45
|
||||
#define LOGO_LABEL_FONT_SIZE 35
|
||||
#define LOGO_Y 50
|
||||
#define LOGO_LABEL_FONT_SIZE 45
|
||||
|
||||
#define VERSION_X (LOGO_X + 250)
|
||||
#define VERSION_Y LOGO_Y-40
|
||||
#define VERSION_Y (LOGO_Y - 40)
|
||||
#define VERSION_FONT_SIZE 15
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Version string getter
|
||||
// -------------------------------------------------------------
|
||||
|
||||
std::string getVersionString() {
|
||||
char buf[0x100] = ""; // 256 bytes — safe for any expected version string
|
||||
char buf[0x100] = "";
|
||||
Result rc = sysclkIpcGetVersionString(buf, sizeof(buf));
|
||||
if (R_FAILED(rc) || buf[0] == '\0') {
|
||||
return "unknown";
|
||||
return "HorizonOC-Misc";
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Animated Ultra Text
|
||||
// -------------------------------------------------------------
|
||||
|
||||
// Your animated wave colors (example placeholders)
|
||||
static constexpr tsl::Color dynamicLogoRGB1 = tsl::Color(40, 255, 80, 255);
|
||||
static constexpr tsl::Color dynamicLogoRGB2 = tsl::Color(120, 255, 160, 255);
|
||||
|
||||
// Your project name rendered letter-by-letter
|
||||
static constexpr const char* PROJECT_NAME = "Horizon OC Gaea";
|
||||
|
||||
// Fully corrected function signature
|
||||
static s32 drawDynamicUltraText(
|
||||
tsl::gfx::Renderer* renderer,
|
||||
s32 startX,
|
||||
s32 y,
|
||||
u32 fontSize,
|
||||
const tsl::Color& staticColor,
|
||||
bool useNotificationMethod = false)
|
||||
{
|
||||
static constexpr double cycleDuration = 1.6;
|
||||
|
||||
const std::string name = "Horizon OC Gaea";
|
||||
s32 currentX = startX;
|
||||
|
||||
const u64 currentTime_ns = armTicksToNs(armGetSystemTick());
|
||||
const double timeNow = static_cast<double>(currentTime_ns) / 1e9;
|
||||
const double timeBase = fmod(timeNow, cycleDuration);
|
||||
|
||||
// Controls wave spacing
|
||||
const double waveScale = 2.0 * M_PI / cycleDuration;
|
||||
|
||||
// Every character has its own index offset
|
||||
for (size_t i = 0; i < name.size(); i++)
|
||||
{
|
||||
char letter = name[i];
|
||||
if (letter == '\0') break;
|
||||
|
||||
// phase shift per character → THIS CREATES THE WAVE
|
||||
double phase = waveScale * (timeBase + i * 0.12);
|
||||
|
||||
double raw = cos(phase);
|
||||
double n = (raw + 1.0) * 0.5;
|
||||
|
||||
// Smoothstep ×2 (ultra smooth)
|
||||
double s1 = n * n * (3.0 - 2.0 * n);
|
||||
double s2 = s1 * s1 * (3.0 - 2.0 * s1);
|
||||
|
||||
double blend = std::clamp(s2, 0.0, 1.0);
|
||||
|
||||
tsl::Color color = {
|
||||
static_cast<u8>(staticColor.r + (dynamicLogoRGB2.r - staticColor.r) * blend),
|
||||
static_cast<u8>(staticColor.g + (dynamicLogoRGB2.g - staticColor.g) * blend),
|
||||
static_cast<u8>(staticColor.b + (dynamicLogoRGB2.b - staticColor.b) * blend),
|
||||
255
|
||||
};
|
||||
|
||||
std::string ls(1, letter);
|
||||
|
||||
if (useNotificationMethod)
|
||||
currentX += renderer->drawNotificationString(ls, false, currentX, y, fontSize, color).first;
|
||||
else
|
||||
currentX += renderer->drawString(ls, false, currentX, y, fontSize, color).first;
|
||||
}
|
||||
|
||||
return currentX;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Rendering functions
|
||||
// -------------------------------------------------------------
|
||||
|
||||
void BaseGui::preDraw(tsl::gfx::Renderer* renderer)
|
||||
{
|
||||
// renderer->drawBitmap(LOGO_X, LOGO_Y, LOGO_WIDTH, LOGO_HEIGHT, logo_rgba_bin);
|
||||
renderer->drawString("Horizon OC overlay", false, LOGO_X, LOGO_Y, LOGO_LABEL_FONT_SIZE, renderer->a(TEXT_COLOR));
|
||||
// renderer->drawString(TARGET_VERSION, false, VERSION_X, VERSION_Y, VERSION_FONT_SIZE, tsl::bannerVersionTextColor);
|
||||
static constexpr tsl::Color STATIC_GREEN = tsl::Color(80, 255, 120, 255);
|
||||
|
||||
drawDynamicUltraText(
|
||||
renderer,
|
||||
LOGO_X,
|
||||
LOGO_Y,
|
||||
LOGO_LABEL_FONT_SIZE,
|
||||
STATIC_GREEN,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseGui::createUI()
|
||||
|
||||
@@ -25,154 +25,184 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "freq_choice_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
|
||||
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz,
|
||||
std::uint32_t* hzList,
|
||||
std::uint32_t hzCount,
|
||||
SysClkModule module,
|
||||
FreqChoiceListener listener,
|
||||
bool checkMax,
|
||||
std::map<uint32_t, std::string> labels)
|
||||
{
|
||||
this->selectedHz = selectedHz;
|
||||
this->hzList = hzList;
|
||||
this->hzCount = hzCount;
|
||||
this->module = module;
|
||||
this->listener = listener;
|
||||
this->checkMax = checkMax;
|
||||
this->labels = labels; // NEW
|
||||
this->configList = new SysClkConfigValueList {};
|
||||
}
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
|
||||
FreqChoiceGui::FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t *hzList, std::uint32_t hzCount, SysClkModule module, FreqChoiceListener listener, bool checkMax)
|
||||
{
|
||||
this->selectedHz = selectedHz;
|
||||
this->hzList = hzList;
|
||||
this->hzCount = hzCount;
|
||||
this->module = module;
|
||||
this->listener = listener;
|
||||
this->checkMax = checkMax;
|
||||
this->configList = new SysClkConfigValueList {};
|
||||
}
|
||||
FreqChoiceGui::~FreqChoiceGui()
|
||||
{
|
||||
delete this->configList;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety)
|
||||
{
|
||||
std::string text = formatListFreqHz(hz);
|
||||
if (selected) text += " \uE14B";
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, "", false);
|
||||
|
||||
switch (safety)
|
||||
{
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
}
|
||||
|
||||
listItem->setClickListener([this, hz](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(hz)) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return listItem;
|
||||
}
|
||||
|
||||
void FreqChoiceGui::listUI()
|
||||
{
|
||||
sysclkIpcGetConfigValues(this->configList);
|
||||
// Add CategoryHeader based on module
|
||||
std::string moduleName = sysclkFormatModule(this->module, false);
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(moduleName));
|
||||
|
||||
this->listElement->addItem(this->createFreqListItem(0, this->selectedHz == 0, false));
|
||||
std::uint32_t hz;
|
||||
for (std::uint32_t i = 0; i < this->hzCount; i++)
|
||||
{
|
||||
hz = this->hzList[i];
|
||||
uint32_t mhz = hz / 1000000;
|
||||
// Skip 204 MHz exactly
|
||||
if(checkMax && IsMariko()) {
|
||||
if (this->configList->values[HocClkConfigValue_MarikoMaxCpuClock] < mhz && moduleName == "cpu") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->configList->values[HocClkConfigValue_MarikoMaxGpuClock] < mhz && moduleName == "gpu") {
|
||||
continue;
|
||||
}
|
||||
if (this->configList->values[HocClkConfigValue_MarikoMaxMemClock] < mhz && moduleName == "mem") {
|
||||
continue;
|
||||
}
|
||||
} else if (checkMax && IsErista()) {
|
||||
if (this->configList->values[HocClkConfigValue_EristaMaxCpuClock] < mhz && moduleName == "cpu") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->configList->values[HocClkConfigValue_EristaMaxGpuClock] < mhz && moduleName == "gpu") {
|
||||
continue;
|
||||
}
|
||||
if (this->configList->values[HocClkConfigValue_EristaMaxMemClock] < mhz && moduleName == "mem") {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (moduleName == "mem" && mhz <= 600)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
uint32_t unsafe_cpu;
|
||||
uint32_t unsafe_gpu;
|
||||
uint32_t danger_cpu;
|
||||
uint32_t danger_gpu;
|
||||
if (IsMariko())
|
||||
{
|
||||
unsafe_cpu = 1964;
|
||||
unsafe_gpu = 1076;
|
||||
danger_cpu = 2398;
|
||||
danger_gpu = 1306;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsafe_cpu = 1786;
|
||||
unsafe_gpu = 922;
|
||||
danger_cpu = 2092;
|
||||
danger_gpu = 999;
|
||||
}
|
||||
tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected, int safety)
|
||||
{
|
||||
std::string text = formatListFreqHz(hz);
|
||||
if (selected)
|
||||
text += " \uE14B";
|
||||
|
||||
if (moduleName == "cpu") {
|
||||
if (mhz >= danger_cpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 2));
|
||||
continue;
|
||||
}
|
||||
if (mhz >= unsafe_cpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 1));
|
||||
continue;
|
||||
}
|
||||
if (mhz <= unsafe_cpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 0));
|
||||
// NEW: Right-side label
|
||||
std::string rightText = "";
|
||||
auto it = labels.find(hz);
|
||||
if (it != labels.end())
|
||||
rightText = it->second;
|
||||
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(text, rightText, false);
|
||||
|
||||
switch (safety)
|
||||
{
|
||||
case 0:
|
||||
listItem->setTextColor(tsl::Color(255, 255, 255, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 255, 255, 255));
|
||||
break;
|
||||
case 1:
|
||||
listItem->setTextColor(tsl::Color(255, 165, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 165, 0, 255));
|
||||
break;
|
||||
case 2:
|
||||
listItem->setTextColor(tsl::Color(255, 0, 0, 255));
|
||||
listItem->setValueColor(tsl::Color(255, 0, 0, 255));
|
||||
break;
|
||||
}
|
||||
|
||||
// Make annotation grey
|
||||
if (!rightText.empty())
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
|
||||
listItem->setClickListener([this, hz](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(hz)) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return listItem;
|
||||
}
|
||||
|
||||
void FreqChoiceGui::listUI()
|
||||
{
|
||||
sysclkIpcGetConfigValues(this->configList);
|
||||
|
||||
// Header based on CPU/GPU/MEM module
|
||||
std::string moduleName = sysclkFormatModule(this->module, false);
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(moduleName));
|
||||
|
||||
// Default option
|
||||
this->listElement->addItem(
|
||||
this->createFreqListItem(0, this->selectedHz == 0, 0));
|
||||
|
||||
for (std::uint32_t i = 0; i < this->hzCount; i++)
|
||||
{
|
||||
std::uint32_t hz = this->hzList[i];
|
||||
uint32_t mhz = hz / 1000000;
|
||||
|
||||
if (checkMax && IsMariko()) {
|
||||
if (moduleName == "cpu" &&
|
||||
this->configList->values[HocClkConfigValue_MarikoMaxCpuClock] < mhz)
|
||||
continue;
|
||||
}
|
||||
} else if (moduleName == "gpu") {
|
||||
if (mhz >= danger_gpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 2));
|
||||
continue;
|
||||
}
|
||||
if (mhz >= unsafe_gpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 1));
|
||||
continue;
|
||||
}
|
||||
if (mhz <= unsafe_gpu) {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 0));
|
||||
|
||||
if (moduleName == "gpu" &&
|
||||
this->configList->values[HocClkConfigValue_MarikoMaxGpuClock] < mhz)
|
||||
continue;
|
||||
}
|
||||
} else if (moduleName == "mem") {
|
||||
this->listElement->addItem(this->createFreqListItem(hz, mhz == this->selectedHz / 1000000, 0));
|
||||
|
||||
if (moduleName == "mem" &&
|
||||
this->configList->values[HocClkConfigValue_MarikoMaxMemClock] < mhz)
|
||||
continue;
|
||||
|
||||
} else if (checkMax && IsErista()) {
|
||||
if (moduleName == "cpu" &&
|
||||
this->configList->values[HocClkConfigValue_EristaMaxCpuClock] < mhz)
|
||||
continue;
|
||||
|
||||
if (moduleName == "gpu" &&
|
||||
this->configList->values[HocClkConfigValue_EristaMaxGpuClock] < mhz)
|
||||
continue;
|
||||
|
||||
if (moduleName == "mem" &&
|
||||
this->configList->values[HocClkConfigValue_EristaMaxMemClock] < mhz)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (moduleName == "mem" && mhz <= 600)
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
this->listElement->jumpToItem("", "");
|
||||
}
|
||||
|
||||
uint32_t unsafe_cpu;
|
||||
uint32_t unsafe_gpu;
|
||||
uint32_t danger_cpu;
|
||||
uint32_t danger_gpu;
|
||||
|
||||
if (IsMariko())
|
||||
{
|
||||
unsafe_cpu = 1964;
|
||||
unsafe_gpu = 1076;
|
||||
danger_cpu = 2398;
|
||||
danger_gpu = 1306;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsafe_cpu = 1786;
|
||||
unsafe_gpu = 922;
|
||||
danger_cpu = 2092;
|
||||
danger_gpu = 999;
|
||||
}
|
||||
|
||||
int safety = 0;
|
||||
|
||||
if (moduleName == "cpu") {
|
||||
|
||||
if (mhz >= danger_cpu)
|
||||
safety = 2;
|
||||
else if (mhz >= unsafe_cpu)
|
||||
safety = 1;
|
||||
else
|
||||
safety = 0;
|
||||
|
||||
} else if (moduleName == "gpu") {
|
||||
|
||||
if (mhz >= danger_gpu)
|
||||
safety = 2;
|
||||
else if (mhz >= unsafe_gpu)
|
||||
safety = 1;
|
||||
else
|
||||
safety = 0;
|
||||
|
||||
} else if (moduleName == "mem") {
|
||||
|
||||
safety = 0;
|
||||
|
||||
}
|
||||
|
||||
this->listElement->addItem(
|
||||
this->createFreqListItem(
|
||||
hz,
|
||||
(mhz == this->selectedHz / 1000000),
|
||||
safety
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
this->listElement->jumpToItem("", "");
|
||||
}
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
|
||||
@@ -42,19 +43,24 @@ protected:
|
||||
std::uint32_t selectedHz;
|
||||
std::uint32_t* hzList;
|
||||
std::uint32_t hzCount;
|
||||
SysClkModule module; // added module
|
||||
SysClkModule module;
|
||||
FreqChoiceListener listener;
|
||||
bool checkMax; // new member
|
||||
bool checkMax;
|
||||
|
||||
// NEW: Optional annotation labels
|
||||
std::map<uint32_t, std::string> labels;
|
||||
|
||||
tsl::elm::ListItem* createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
||||
|
||||
public:
|
||||
// Updated constructor with checkMaxValue
|
||||
FreqChoiceGui(std::uint32_t selectedHz,
|
||||
std::uint32_t* hzList,
|
||||
std::uint32_t hzCount,
|
||||
SysClkModule module,
|
||||
FreqChoiceListener listener,
|
||||
bool checkMax = true);
|
||||
bool checkMax = true,
|
||||
std::map<uint32_t, std::string> labels = {}); // NEW ARG
|
||||
|
||||
~FreqChoiceGui();
|
||||
|
||||
void listUI() override;
|
||||
|
||||
@@ -59,7 +59,8 @@ void MiscGui::addConfigButton(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds)
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels)
|
||||
{
|
||||
const char* configName = altName ? altName : sysclkFormatConfigValue(configVal, true);
|
||||
|
||||
@@ -82,7 +83,7 @@ void MiscGui::addConfigButton(SysClkConfigValue configVal,
|
||||
ValueThresholds thresholdsCopy = (thresholds ? *thresholds : ValueThresholds{});
|
||||
|
||||
listItem->setClickListener(
|
||||
[this, configVal, range, categoryName, thresholdsCopy](u64 keys)
|
||||
[this, configVal, range, categoryName, thresholdsCopy, labels](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == 0)
|
||||
return false;
|
||||
@@ -106,7 +107,8 @@ void MiscGui::addConfigButton(SysClkConfigValue configVal,
|
||||
return true;
|
||||
},
|
||||
thresholdsCopy,
|
||||
true
|
||||
true,
|
||||
labels // <── NEW
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -123,7 +125,10 @@ void MiscGui::addConfigButton(SysClkConfigValue configVal,
|
||||
}
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
ValueThresholds(),
|
||||
false,
|
||||
labels // <── NEW
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,7 +140,11 @@ void MiscGui::addConfigButton(SysClkConfigValue configVal,
|
||||
this->configRanges[configVal] = range;
|
||||
}
|
||||
|
||||
void MiscGui::addFreqButton(SysClkConfigValue configVal, const char* altName, SysClkModule module) {
|
||||
void MiscGui::addFreqButton(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
SysClkModule module,
|
||||
const std::map<uint32_t, std::string>& labels)
|
||||
{
|
||||
const char* configName = altName ? altName : sysclkFormatConfigValue(configVal, true);
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(configName);
|
||||
@@ -145,45 +154,48 @@ void MiscGui::addFreqButton(SysClkConfigValue configVal, const char* altName, Sy
|
||||
snprintf(valueText, sizeof(valueText), "%lu MHz", currentMHz);
|
||||
listItem->setValue(valueText);
|
||||
|
||||
listItem->setClickListener([this, configVal, module](u64 keys) {
|
||||
if ((keys & HidNpadButton_A) == 0)
|
||||
return false;
|
||||
listItem->setClickListener(
|
||||
[this, configVal, module, labels](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == 0)
|
||||
return false;
|
||||
|
||||
std::uint32_t hzList[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t hzCount;
|
||||
std::uint32_t hzList[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t hzCount;
|
||||
|
||||
Result rc = sysclkIpcGetFreqList(module, hzList, SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetFreqList", rc);
|
||||
return false;
|
||||
}
|
||||
Result rc = sysclkIpcGetFreqList(module, hzList, SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetFreqList", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint32_t currentHz = this->configList->values[configVal] * 1'000'000;
|
||||
std::uint32_t currentHz = this->configList->values[configVal] * 1'000'000;
|
||||
|
||||
tsl::changeTo<FreqChoiceGui>(
|
||||
currentHz,
|
||||
hzList,
|
||||
hzCount,
|
||||
module,
|
||||
[this, configVal](std::uint32_t hz) {
|
||||
tsl::changeTo<FreqChoiceGui>(
|
||||
currentHz,
|
||||
hzList,
|
||||
hzCount,
|
||||
module,
|
||||
[this, configVal](std::uint32_t hz)
|
||||
{
|
||||
uint64_t mhz = hz / 1'000'000;
|
||||
this->configList->values[configVal] = mhz;
|
||||
|
||||
uint64_t mhz = hz / 1'000'000;
|
||||
this->configList->values[configVal] = mhz;
|
||||
Result rc = sysclkIpcSetConfigValues(this->configList);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetConfigValues", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
Result rc = sysclkIpcSetConfigValues(this->configList);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetConfigValues", rc);
|
||||
return false;
|
||||
}
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
},
|
||||
false,
|
||||
labels
|
||||
);
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
this->configButtons[configVal] = listItem;
|
||||
@@ -204,18 +216,24 @@ void MiscGui::listUI()
|
||||
addConfigToggle(HocClkConfigValue_UncappedClocks, nullptr);
|
||||
addConfigToggle(HocClkConfigValue_OverwriteBoostMode, nullptr);
|
||||
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental"));
|
||||
// this->listElement->addItem(new tsl::elm::CategoryHeader("Experimental"));
|
||||
addConfigToggle(HocClkConfigValue_ThermalThrottle, nullptr);
|
||||
addConfigToggle(HocClkConfigValue_HandheldTDP, nullptr);
|
||||
addConfigToggle(HocClkConfigValue_EnforceBoardLimit, nullptr);
|
||||
|
||||
std::map<uint32_t, std::string> labels_pwr_r = {
|
||||
{8600, "Official Rating"}
|
||||
};
|
||||
std::map<uint32_t, std::string> labels_pwr_l = {
|
||||
{6400, "Official Rating"}
|
||||
};
|
||||
ValueThresholds tdpThresholds(8600, 9500);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_HandheldTDPLimit,
|
||||
"TDP Threshold",
|
||||
ValueRange(5000, 10000, 200, "mW", 1),
|
||||
"Power",
|
||||
&tdpThresholds
|
||||
&tdpThresholds,
|
||||
labels_pwr_r
|
||||
);
|
||||
|
||||
ValueThresholds tdpThresholdsLite(6400, 7500);
|
||||
@@ -224,7 +242,8 @@ void MiscGui::listUI()
|
||||
"Lite TDP Threshold",
|
||||
ValueRange(4000, 8000, 200, "mW", 1),
|
||||
"Power",
|
||||
&tdpThresholdsLite
|
||||
&tdpThresholdsLite,
|
||||
labels_pwr_l
|
||||
);
|
||||
|
||||
ValueThresholds throttleThresholds(70, 80);
|
||||
@@ -235,45 +254,130 @@ void MiscGui::listUI()
|
||||
"Temp",
|
||||
&throttleThresholds
|
||||
);
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Max Clocks"));
|
||||
std::map<uint32_t, std::string> cpu_freq_label_m = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{1963000000, "Safe Max"},
|
||||
{2397000000, "Unsafe Max"},
|
||||
{2805000000, "Aboslute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_e = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode & Safe Max"},
|
||||
{2091000000, "Unsafe Max"},
|
||||
{2295000000, "Aboslute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_e = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{460800000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{844000000, "Safe Max"},
|
||||
{998400000, "Unsafe Max"},
|
||||
{1075200000, "Aboslute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1152200000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Aboslute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> emc_freq_label_e = {
|
||||
{133120000, "Handheld"},
|
||||
{160000000, "Docked & Safe Max"},
|
||||
{213100000, "JEDEC Max"},
|
||||
{236000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32_t, std::string> emc_freq_label_m = {
|
||||
{133120000, "Handheld"},
|
||||
{160000000, "Docked"},
|
||||
{186600000, "Safe Max (3733MT/s)"},
|
||||
{213300000, "Safe Max (4266MT/s)"},
|
||||
{320000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Clocks"));
|
||||
if(IsMariko()) {
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxCpuClock, nullptr, SysClkModule_CPU);
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxGpuClock, nullptr, SysClkModule_GPU);
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxMemClock, nullptr, SysClkModule_MEM);
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxCpuClock, nullptr, SysClkModule_CPU, cpu_freq_label_m);
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxGpuClock, nullptr, SysClkModule_GPU, gpu_freq_label_m);
|
||||
addFreqButton(HocClkConfigValue_MarikoMaxMemClock, nullptr, SysClkModule_MEM, emc_freq_label_m);
|
||||
} else {
|
||||
addFreqButton(HocClkConfigValue_EristaMaxCpuClock, nullptr, SysClkModule_CPU);
|
||||
addFreqButton(HocClkConfigValue_EristaMaxGpuClock, nullptr, SysClkModule_GPU);
|
||||
addFreqButton(HocClkConfigValue_EristaMaxMemClock, nullptr, SysClkModule_MEM);
|
||||
addFreqButton(HocClkConfigValue_EristaMaxCpuClock, nullptr, SysClkModule_CPU, cpu_freq_label_e);
|
||||
addFreqButton(HocClkConfigValue_EristaMaxGpuClock, nullptr, SysClkModule_GPU, gpu_freq_label_e);
|
||||
addFreqButton(HocClkConfigValue_EristaMaxMemClock, nullptr, SysClkModule_MEM, emc_freq_label_e);
|
||||
}
|
||||
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("EMC"));
|
||||
|
||||
addConfigToggle(HocClkConfigValue_EMCDVFS, nullptr);
|
||||
|
||||
ValueThresholds emcUvThresholds(1212500, 1250000);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_EMCVdd2VoltageUV,
|
||||
"EMC VDD2 Voltage",
|
||||
ValueRange(1100000, 1237500, 12500, "mV", 1000, 1),
|
||||
"EMC VDD2 Voltage",
|
||||
&emcUvThresholds
|
||||
);
|
||||
std::map<uint32_t, std::string> emc_voltage_label_m = {
|
||||
{1100000, "Default"},
|
||||
{1175000, "Rating"},
|
||||
{1212500, "Safe Max"},
|
||||
};
|
||||
|
||||
// if(IsMariko()) {
|
||||
// addConfigButton(
|
||||
// HocClkConfigValue_EMCVdd2VoltageUVStockMariko,
|
||||
// "EMC Stock VDD2 Voltage",
|
||||
// ValueRange(912500, 1175000, 12500, "mV", 1000, 1),
|
||||
// "EMC Stock VDD2 Voltage",
|
||||
// &emcUvThresholds
|
||||
// );
|
||||
// } else {
|
||||
std::map<uint32_t, std::string> emc_voltage_label_e = {
|
||||
{1125000, "Default"},
|
||||
{1175000, "Rating"},
|
||||
{1237500, "Safe Max"},
|
||||
};
|
||||
|
||||
|
||||
if(IsMariko()) {
|
||||
ValueThresholds emcUvThresholds(1212500, 1250000);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_EMCVdd2VoltageUV,
|
||||
"EMC VDD2 Voltage",
|
||||
ValueRange(1100000, 1237500, 12500, "mV", 1000, 1),
|
||||
"EMC VDD2 Voltage",
|
||||
&emcUvThresholds,
|
||||
emc_voltage_label_m
|
||||
);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_EMCVdd2VoltageUVStockMariko,
|
||||
"EMC Stock VDD2 Voltage",
|
||||
ValueRange(912500, 1175000, 12500, "mV", 1000, 1),
|
||||
"EMC Stock VDD2 Voltage",
|
||||
&emcUvThresholds,
|
||||
emc_voltage_label_m
|
||||
);
|
||||
} else {
|
||||
ValueThresholds emcUvThresholds(1237500, 1300000);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_EMCVdd2VoltageUV,
|
||||
"EMC VDD2 Voltage",
|
||||
ValueRange(1100000, 1237500, 12500, "mV", 1000, 1),
|
||||
"EMC VDD2 Voltage",
|
||||
&emcUvThresholds,
|
||||
emc_voltage_label_e
|
||||
);
|
||||
addConfigButton(
|
||||
HocClkConfigValue_EMCVdd2VoltageUVStockErista,
|
||||
"EMC Stock VDD2 Voltage",
|
||||
ValueRange(1000000, 1175000, 12500, "mV", 1000, 1),
|
||||
"EMC Stock VDD2 Voltage",
|
||||
&emcUvThresholds
|
||||
&emcUvThresholds,
|
||||
emc_voltage_label_e
|
||||
);
|
||||
// }
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* applyBtn = new tsl::elm::ListItem("Apply EMC Regs");
|
||||
applyBtn->setClickListener([](u64 keys) {
|
||||
|
||||
@@ -27,8 +27,12 @@ protected:
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds = nullptr);
|
||||
void addFreqButton(SysClkConfigValue configVal, const char* altName, SysClkModule module);
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels = {});
|
||||
void addFreqButton(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
SysClkModule module,
|
||||
const std::map<uint32_t, std::string>& labels = {});
|
||||
void updateConfigToggles();
|
||||
|
||||
tsl::elm::ToggleListItem* enabledToggle;
|
||||
|
||||
@@ -9,13 +9,15 @@ ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds)
|
||||
bool enableThresholds,
|
||||
std::map<std::uint32_t, std::string> labels)
|
||||
: selectedValue(selectedValue),
|
||||
range(range),
|
||||
categoryName(categoryName),
|
||||
listener(listener),
|
||||
thresholds(thresholds),
|
||||
enableThresholds(enableThresholds)
|
||||
enableThresholds(enableThresholds),
|
||||
labels(labels)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,12 +33,10 @@ std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
||||
return VALUE_DEFAULT_TEXT;
|
||||
}
|
||||
|
||||
// Convert to floating point for division
|
||||
double displayValue = static_cast<double>(value) / static_cast<double>(range.divisor);
|
||||
|
||||
// Set precision and formatting
|
||||
oss << std::fixed << std::setprecision(range.decimalPlaces) << displayValue;
|
||||
|
||||
|
||||
if (!range.suffix.empty()) {
|
||||
oss << " " << range.suffix;
|
||||
}
|
||||
@@ -45,12 +45,6 @@ std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
||||
|
||||
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
||||
{
|
||||
// if (!enableThresholds) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
std::uint32_t scaledValue = value / range.divisor;
|
||||
|
||||
if (value > thresholds.danger) {
|
||||
return 2;
|
||||
}
|
||||
@@ -67,7 +61,13 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
||||
text += " \uE14B";
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, "", false);
|
||||
std::string rightText = "";
|
||||
auto it = labels.find(value);
|
||||
if (it != labels.end()) {
|
||||
rightText = it->second;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, rightText, false);
|
||||
|
||||
switch (safety)
|
||||
{
|
||||
@@ -85,6 +85,9 @@ tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, boo
|
||||
break;
|
||||
}
|
||||
|
||||
if (!rightText.empty())
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
|
||||
listItem->setClickListener([this, value](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
@@ -115,4 +118,4 @@ void ValueChoiceGui::listUI()
|
||||
}
|
||||
|
||||
this->listElement->jumpToItem("", "\uE14B");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,62 +25,69 @@
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using ValueChoiceListener = std::function<bool(std::uint32_t value)>;
|
||||
|
||||
#define VALUE_DEFAULT_TEXT "Default"
|
||||
|
||||
struct ValueRange {
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using ValueChoiceListener = std::function<bool(std::uint32_t value)>;
|
||||
|
||||
#define VALUE_DEFAULT_TEXT "Default"
|
||||
|
||||
struct ValueRange {
|
||||
std::uint32_t min;
|
||||
std::uint32_t max;
|
||||
std::uint32_t step;
|
||||
std::string suffix;
|
||||
std::uint32_t divisor; // Divide input values by this for display
|
||||
int decimalPlaces; // Number of decimal places to display (0-6)
|
||||
|
||||
ValueRange() : min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {}
|
||||
|
||||
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
||||
std::uint32_t divisor;
|
||||
int decimalPlaces;
|
||||
|
||||
ValueRange()
|
||||
: min(0), max(0), step(1), suffix(""), divisor(1), decimalPlaces(0) {}
|
||||
|
||||
ValueRange(std::uint32_t min, std::uint32_t max, std::uint32_t step,
|
||||
const std::string& suffix = "", std::uint32_t divisor = 1, int decimalPlaces = 0)
|
||||
: min(min), max(max), step(step), suffix(suffix), divisor(divisor), decimalPlaces(decimalPlaces) {}
|
||||
: min(min), max(max), step(step), suffix(suffix),
|
||||
divisor(divisor), decimalPlaces(decimalPlaces) {}
|
||||
};
|
||||
|
||||
struct ValueThresholds {
|
||||
std::uint32_t warning; // Values >= this show orange
|
||||
std::uint32_t danger; // Values >= this show red
|
||||
|
||||
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0)
|
||||
: warning(warning), danger(danger) {}
|
||||
};
|
||||
|
||||
class ValueChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::uint32_t selectedValue;
|
||||
ValueRange range;
|
||||
std::string categoryName;
|
||||
ValueChoiceListener listener;
|
||||
ValueThresholds thresholds;
|
||||
bool enableThresholds;
|
||||
|
||||
tsl::elm::ListItem* createValueListItem(std::uint32_t value, bool selected, int safety);
|
||||
std::string formatValue(std::uint32_t value);
|
||||
int getSafetyLevel(std::uint32_t value);
|
||||
|
||||
public:
|
||||
ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false);
|
||||
~ValueChoiceGui();
|
||||
|
||||
void listUI() override;
|
||||
};
|
||||
struct ValueThresholds {
|
||||
std::uint32_t warning;
|
||||
std::uint32_t danger;
|
||||
|
||||
ValueThresholds(std::uint32_t warning = 0, std::uint32_t danger = 0)
|
||||
: warning(warning), danger(danger) {}
|
||||
};
|
||||
|
||||
class ValueChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::uint32_t selectedValue;
|
||||
ValueRange range;
|
||||
std::string categoryName;
|
||||
ValueChoiceListener listener;
|
||||
ValueThresholds thresholds;
|
||||
bool enableThresholds;
|
||||
|
||||
// NEW — map of value → right-side text (like version numbers)
|
||||
std::map<std::uint32_t, std::string> labels;
|
||||
|
||||
tsl::elm::ListItem* createValueListItem(std::uint32_t value, bool selected, int safety);
|
||||
std::string formatValue(std::uint32_t value);
|
||||
int getSafetyLevel(std::uint32_t value);
|
||||
|
||||
public:
|
||||
ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false,
|
||||
std::map<std::uint32_t, std::string> labels = {});
|
||||
~ValueChoiceGui();
|
||||
|
||||
void listUI() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user