sysclk: remove old hocclk, bump version
This commit is contained in:
48
Source/hoc-clk/overlay/src/ui/elements/base_frame.h
Normal file
48
Source/hoc-clk/overlay/src/ui/elements/base_frame.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include "../gui/base_gui.h"
|
||||
|
||||
class BaseFrame : public tsl::elm::HeaderOverlayFrame
|
||||
{
|
||||
public:
|
||||
BaseFrame(BaseGui* gui) : tsl::elm::HeaderOverlayFrame(234) {
|
||||
this->gui = gui;
|
||||
}
|
||||
|
||||
void draw(tsl::gfx::Renderer* renderer) override
|
||||
{
|
||||
tsl::elm::HeaderOverlayFrame::draw(renderer);
|
||||
this->gui->preDraw(renderer);
|
||||
}
|
||||
|
||||
protected:
|
||||
BaseGui* gui;
|
||||
};
|
||||
47
Source/hoc-clk/overlay/src/ui/format.h
Normal file
47
Source/hoc-clk/overlay/src/ui/format.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
#define FREQ_DEFAULT_TEXT "Do not override"
|
||||
|
||||
static inline std::string formatListFreqMHz(std::uint32_t mhz)
|
||||
{
|
||||
if(mhz == 0)
|
||||
{
|
||||
return FREQ_DEFAULT_TEXT;
|
||||
}
|
||||
|
||||
char buf[10];
|
||||
return std::string(buf, snprintf(buf, sizeof(buf), "%u MHz", mhz));
|
||||
}
|
||||
|
||||
static inline std::string formatListFreqHz(std::uint32_t hz) { return formatListFreqMHz(hz / 1000000); }
|
||||
309
Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp
Normal file
309
Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "about_gui.h"
|
||||
#include "../format.h"
|
||||
#include <tesla.hpp>
|
||||
#include <string>
|
||||
#include "cat.h"
|
||||
#include "ult_ext.h"
|
||||
|
||||
tsl::elm::ListItem* SpeedoItem = NULL;
|
||||
tsl::elm::ListItem* IddqItem = NULL;
|
||||
tsl::elm::ListItem* DramModule = NULL;
|
||||
tsl::elm::ListItem* sysdockStatusItem = NULL;
|
||||
tsl::elm::ListItem* saltyNXStatusItem = NULL;
|
||||
tsl::elm::ListItem* RETROStatusItem = NULL;
|
||||
tsl::elm::ListItem* waferCordsItem = NULL;
|
||||
|
||||
ImageElement* CatImage = NULL;
|
||||
HideableCategoryHeader* CatHeader = NULL;
|
||||
HideableCustomDrawer* CatSpacer = NULL;
|
||||
int lightosClickCount = 0;
|
||||
|
||||
AboutGui::AboutGui()
|
||||
{
|
||||
memset(strings, 0, sizeof(strings));
|
||||
}
|
||||
|
||||
AboutGui::~AboutGui()
|
||||
{
|
||||
}
|
||||
|
||||
void AboutGui::listUI()
|
||||
{
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Information")
|
||||
);
|
||||
|
||||
SpeedoItem =
|
||||
new tsl::elm::ListItem("Speedo:");
|
||||
this->listElement->addItem(SpeedoItem);
|
||||
|
||||
IddqItem =
|
||||
new tsl::elm::ListItem("IDDQ:");
|
||||
this->listElement->addItem(IddqItem);
|
||||
|
||||
DramModule =
|
||||
new tsl::elm::ListItem("Module: ");
|
||||
this->listElement->addItem(DramModule);
|
||||
|
||||
if(!IsHoag()) {
|
||||
sysdockStatusItem =
|
||||
new tsl::elm::ListItem("sys-dock status:");
|
||||
this->listElement->addItem(sysdockStatusItem);
|
||||
}
|
||||
|
||||
saltyNXStatusItem =
|
||||
new tsl::elm::ListItem("SaltyNX status:");
|
||||
this->listElement->addItem(saltyNXStatusItem);
|
||||
|
||||
if(IsHoag()) {
|
||||
RETROStatusItem =
|
||||
new tsl::elm::ListItem("RR Display status:");
|
||||
this->listElement->addItem(RETROStatusItem);
|
||||
}
|
||||
|
||||
waferCordsItem =
|
||||
new tsl::elm::ListItem("Wafer Position:");
|
||||
this->listElement->addItem(waferCordsItem);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Credits")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Developers")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Souldbminer")
|
||||
);
|
||||
|
||||
// Create special clickable item for Lightos
|
||||
auto lightosItem = new tsl::elm::ListItem("Lightos_");
|
||||
lightosItem->setClickListener([this](u64 keys) -> bool {
|
||||
if (keys & HidNpadButton_A) {
|
||||
lightosClickCount++;
|
||||
if (lightosClickCount >= 10) {
|
||||
if (CatImage != NULL) CatImage->setVisible(true);
|
||||
if (CatHeader != NULL) CatHeader->setVisible(true);
|
||||
if (CatSpacer != NULL) CatSpacer->setVisible(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(lightosItem);
|
||||
|
||||
// ---- Contributors ----
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Contributors")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Dom")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Blaise25")
|
||||
);
|
||||
|
||||
// ---- Testers ----
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Testers")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Dom")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Samybigio2011")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Delta")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Miki1305")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Happy")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Flopsider")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Winnerboi77")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Blaise25")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("WE1ZARD")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Alvise")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("TDRR")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("agjeococh")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Xenshen")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("Frost")
|
||||
);
|
||||
|
||||
// ---- Special Thanks ----
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::CategoryHeader("Special Thanks")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("ScriesM - Atmosphere CFW")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("KazushiMe - Switch OC Suite")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("hanai3bi - Switch OC Suite & EOS")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("NaGaa95 - L4T-OC-Kernel")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("B3711 - EOS")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("RetroNX - sys-clk")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("b0rd2death - Ultrahand")
|
||||
);
|
||||
|
||||
this->listElement->addItem(
|
||||
new tsl::elm::ListItem("MasaGratoR - Status Monitor")
|
||||
);
|
||||
|
||||
// Create cat elements but hide them initially
|
||||
CatHeader = new HideableCategoryHeader("Cat");
|
||||
CatHeader->setVisible(false);
|
||||
this->listElement->addItem(CatHeader);
|
||||
|
||||
CatImage = new ImageElement(CAT_DATA, CAT_WIDTH, CAT_HEIGHT);
|
||||
CatImage->setVisible(false);
|
||||
this->listElement->addItem(CatImage);
|
||||
|
||||
CatSpacer = new HideableCustomDrawer(75);
|
||||
CatSpacer->setVisible(false);
|
||||
this->listElement->addItem(CatSpacer);
|
||||
}
|
||||
|
||||
std::string AboutGui::formatRamModule() {
|
||||
switch (this->context->dramID) {
|
||||
case 0: return "HB-MGCH 4GB";
|
||||
case 4: return "HM-MGCH 6GB";
|
||||
case 7: return "HM-MGXX 8GB";
|
||||
|
||||
case 1: return "NLE 4GB";
|
||||
case 2: return "WT:C 4GB";
|
||||
|
||||
case 3:
|
||||
case 5 ... 6: return "NEE 4GB";
|
||||
|
||||
case 8:
|
||||
case 12: return "AM-MGCJ 4GB";
|
||||
case 9:
|
||||
case 13: return "AM-MGCJ 8GB";
|
||||
|
||||
case 10:
|
||||
case 14: return "NME 4GB";
|
||||
|
||||
case 11:
|
||||
case 15: return "WT:E 4GB";
|
||||
|
||||
case 17:
|
||||
case 19:
|
||||
case 24: return "AA-MGCL 4GB";
|
||||
|
||||
case 18:
|
||||
case 23:
|
||||
case 28: return "AA-MGCL 8GB";
|
||||
|
||||
case 20 ... 22: return "AB-MGCL 4GB";
|
||||
|
||||
case 25 ... 27: return "WT:F 4GB";
|
||||
|
||||
case 29 ... 31: return "x267 4GB";
|
||||
|
||||
case 32 ... 34: return "WT:B 4GB";
|
||||
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void AboutGui::update()
|
||||
{
|
||||
BaseMenuGui::update();
|
||||
}
|
||||
|
||||
void AboutGui::refresh()
|
||||
{
|
||||
BaseMenuGui::refresh();
|
||||
|
||||
if (!this->context)
|
||||
return;
|
||||
// Format strings once per refresh
|
||||
sprintf(strings[0], "%u/%u/%u", this->context->speedos[HorizonOCSpeedo_CPU], this->context->speedos[HorizonOCSpeedo_GPU], this->context->speedos[HorizonOCSpeedo_SOC]);
|
||||
// This is how hekate does it
|
||||
sprintf(strings[1], "%u/%u/%u", this->context->iddq[HorizonOCSpeedo_CPU], this->context->iddq[HorizonOCSpeedo_GPU], this->context->iddq[HorizonOCSpeedo_SOC]);
|
||||
SpeedoItem->setValue(strings[0]);
|
||||
IddqItem->setValue(strings[1]);
|
||||
DramModule->setValue(formatRamModule());
|
||||
if(!IsHoag())
|
||||
sysdockStatusItem->setValue(this->context->isSysDockInstalled ? "Installed" : "Not Installed");
|
||||
|
||||
saltyNXStatusItem->setValue(this->context->isSaltyNXInstalled ? "Installed" : "Not Installed");
|
||||
|
||||
if(IsHoag())
|
||||
RETROStatusItem->setValue(this->context->isUsingRetroSuper ? "Installed" : "Not Installed");
|
||||
|
||||
sprintf(strings[2], "X: %u Y: %u", this->context->waferX, this->context->waferY);
|
||||
waferCordsItem->setValue(strings[2]);
|
||||
}
|
||||
41
Source/hoc-clk/overlay/src/ui/gui/about_gui.h
Normal file
41
Source/hoc-clk/overlay/src/ui/gui/about_gui.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
#include "fatal_gui.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class AboutGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
char strings[32][32];
|
||||
|
||||
public:
|
||||
AboutGui();
|
||||
~AboutGui();
|
||||
|
||||
void listUI() override;
|
||||
void update() override;
|
||||
void refresh() override;
|
||||
|
||||
private:
|
||||
std::string formatRamModule();
|
||||
};
|
||||
468
Source/hoc-clk/overlay/src/ui/gui/app_profile_gui.cpp
Normal file
468
Source/hoc-clk/overlay/src/ui/gui/app_profile_gui.cpp
Normal file
@@ -0,0 +1,468 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "app_profile_gui.h"
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "labels.h"
|
||||
AppProfileGui::AppProfileGui(std::uint64_t applicationId, SysClkTitleProfileList* profileList)
|
||||
{
|
||||
this->applicationId = applicationId;
|
||||
this->profileList = profileList;
|
||||
}
|
||||
|
||||
AppProfileGui::~AppProfileGui()
|
||||
{
|
||||
delete this->profileList;
|
||||
}
|
||||
|
||||
void AppProfileGui::openFreqChoiceGui(tsl::elm::ListItem* listItem, SysClkProfile profile, SysClkModule module)
|
||||
{
|
||||
std::uint32_t hzList[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t hzCount;
|
||||
Result rc = sysclkIpcGetFreqList(module, &hzList[0], SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcGetFreqList", rc);
|
||||
return;
|
||||
}
|
||||
std::map<uint32_t, std::string> labels = {};
|
||||
|
||||
if (module == SysClkModule_CPU) {
|
||||
bool isUsingUv = IsMariko() ? configList.values[KipConfigValue_marikoCpuUVHigh] : configList.values[KipConfigValue_eristaCpuUV];
|
||||
labels = IsMariko() ? (isUsingUv ? cpu_freq_label_m_uv : cpu_freq_label_m) : (isUsingUv ? cpu_freq_label_e_uv : cpu_freq_label_e);
|
||||
} else if (module == SysClkModule_GPU) {
|
||||
labels = IsMariko() ? *(marikoUV[configList.values[KipConfigValue_marikoGpuUV]]) : *(eristaUV[configList.values[KipConfigValue_eristaGpuUV]]);
|
||||
}
|
||||
tsl::changeTo<FreqChoiceGui>(this->profileList->mhzMap[profile][module] * 1000000, hzList, hzCount, module, [this, listItem, profile, module](std::uint32_t hz) {
|
||||
this->profileList->mhzMap[profile][module] = hz / 1000000;
|
||||
listItem->setValue(formatListFreqMHz(this->profileList->mhzMap[profile][module]));
|
||||
Result rc = sysclkIpcSetProfiles(this->applicationId, this->profileList);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, true, labels
|
||||
);
|
||||
}
|
||||
|
||||
void AppProfileGui::openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
tsl::changeTo<ValueChoiceGui>(
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
listener,
|
||||
thresholds,
|
||||
enableThresholds,
|
||||
labels,
|
||||
namedValues,
|
||||
showDefaultValue,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
void AppProfileGui::addModuleListItem(SysClkProfile profile, SysClkModule module)
|
||||
{
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
listItem->setValue(formatListFreqMHz(this->profileList->mhzMap[profile][module]));
|
||||
listItem->setClickListener([this, listItem, profile, module](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
this->openFreqChoiceGui(listItem, profile, module);
|
||||
return true;
|
||||
}
|
||||
else if((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
// Reset to "Default" (0 MHz)
|
||||
this->profileList->mhzMap[profile][module] = 0;
|
||||
listItem->setValue(formatListFreqMHz(0));
|
||||
|
||||
Result rc = sysclkIpcSetProfiles(this->applicationId, this->profileList);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(listItem);
|
||||
}
|
||||
|
||||
void AppProfileGui::addModuleListItemToggle(SysClkProfile profile, SysClkModule module)
|
||||
{
|
||||
const char* moduleName = sysclkFormatModule(module, true);
|
||||
std::uint32_t currentValue = this->profileList->mhzMap[profile][module];
|
||||
|
||||
tsl::elm::ToggleListItem* toggle = new tsl::elm::ToggleListItem(moduleName, currentValue != 0);
|
||||
|
||||
toggle->setStateChangedListener([this, profile, module](bool state) {
|
||||
this->profileList->mhzMap[profile][module] = state ? 1 : 0;
|
||||
|
||||
Result rc = sysclkIpcSetProfiles(this->applicationId, this->profileList);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
}
|
||||
});
|
||||
|
||||
this->listElement->addItem(toggle);
|
||||
}
|
||||
|
||||
std::string AppProfileGui::formatValueDisplay(
|
||||
std::uint32_t value,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
)
|
||||
{
|
||||
if (value == 0) {
|
||||
return FREQ_DEFAULT_TEXT;
|
||||
}
|
||||
|
||||
if (!namedValues.empty()) {
|
||||
for (const auto& namedValue : namedValues) {
|
||||
if (namedValue.value == value) {
|
||||
return namedValue.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)value / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s", decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s", value / divisor, suffix.c_str());
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
void AppProfileGui::addModuleListItemValue(
|
||||
SysClkProfile profile,
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds,
|
||||
std::vector<NamedValue> namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
std::uint32_t storedValue = this->profileList->mhzMap[profile][module];
|
||||
|
||||
listItem->setValue(this->formatValueDisplay(storedValue, namedValues, suffix, divisor, decimalPlaces));
|
||||
|
||||
listItem->setClickListener(
|
||||
[this,
|
||||
listItem,
|
||||
profile,
|
||||
module,
|
||||
categoryName,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces,
|
||||
thresholds,
|
||||
namedValues,
|
||||
showDefaultValue](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
std::uint32_t currentValue =
|
||||
this->profileList->mhzMap[profile][module] * divisor;
|
||||
ValueRange range(
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces
|
||||
);
|
||||
this->openValueChoiceGui(
|
||||
listItem,
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
[this, listItem, profile, module, divisor, suffix, decimalPlaces, thresholds, namedValues](std::uint32_t value) -> bool
|
||||
{
|
||||
this->profileList->mhzMap[profile][module] = value / divisor;
|
||||
listItem->setValue(this->formatValueDisplay(value / divisor, namedValues, suffix, divisor, decimalPlaces));
|
||||
|
||||
Result rc =
|
||||
sysclkIpcSetProfiles(this->applicationId,
|
||||
this->profileList);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode(
|
||||
"sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
thresholds,
|
||||
false,
|
||||
{},
|
||||
namedValues,
|
||||
showDefaultValue
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else if ((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
this->profileList->mhzMap[profile][module] = 0;
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
Result rc =
|
||||
sysclkIpcSetProfiles(this->applicationId,
|
||||
this->profileList);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(listItem);
|
||||
}
|
||||
|
||||
class GovernorProfileSubMenuGui : public BaseMenuGui {
|
||||
uint64_t applicationId;
|
||||
SysClkTitleProfileList* profileList;
|
||||
SysClkProfile profile;
|
||||
public:
|
||||
GovernorProfileSubMenuGui(uint64_t appId, SysClkTitleProfileList* pList, SysClkProfile prof)
|
||||
: applicationId(appId), profileList(pList), profile(prof) {}
|
||||
|
||||
void listUI() override {
|
||||
Result rc = sysclkIpcGetConfigValues(&configList);
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetConfigValues", rc);
|
||||
return;
|
||||
}
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Governor"));
|
||||
|
||||
static constexpr struct { const char* label; int shift; } kAll[] = {
|
||||
{"CPU", 0}, {"GPU", 8}, {"VRR", 16}
|
||||
};
|
||||
int count = configList.values[HorizonOCConfigValue_OverwriteRefreshRate] ? 3 : 2;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
u8 cur = (this->profileList->mhzMap[this->profile][HorizonOCModule_Governor] >> kAll[i].shift) & 0xFF;
|
||||
auto* bar = new tsl::elm::NamedStepTrackBar(
|
||||
"", {"Do Not Override", "Disabled", "Enabled"},
|
||||
true, kAll[i].label
|
||||
);
|
||||
bar->setProgress(cur);
|
||||
int shift = kAll[i].shift;
|
||||
bar->setValueChangedListener([this, shift](u8 value) {
|
||||
u32& packed = this->profileList->mhzMap[this->profile][HorizonOCModule_Governor];
|
||||
packed = (packed & ~(0xFFu << shift)) | ((u32)value << shift);
|
||||
Result rc = sysclkIpcSetProfiles(this->applicationId, this->profileList);
|
||||
if (R_FAILED(rc)) FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
});
|
||||
this->listElement->addItem(bar);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AppProfileGui::addGovernorSection(SysClkProfile profile) {
|
||||
auto* item = new tsl::elm::ListItem("Governor");
|
||||
item->setValue("\u2192"); // Right arrow
|
||||
item->setClickListener([this, profile](u64 keys) {
|
||||
if (keys & HidNpadButton_A) {
|
||||
tsl::changeTo<GovernorProfileSubMenuGui>(
|
||||
this->applicationId, this->profileList, profile
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(item);
|
||||
}
|
||||
|
||||
void AppProfileGui::addProfileUI(SysClkProfile profile)
|
||||
{
|
||||
BaseMenuGui::refresh();
|
||||
if(!this->context)
|
||||
return;
|
||||
Result rc = sysclkIpcGetConfigValues(&configList);
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetConfigValues", rc);
|
||||
return;
|
||||
}
|
||||
if((profile == SysClkProfile_Docked && IsHoag()) || profile == SysClkProfile_HandheldCharging)
|
||||
return;
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(sysclkFormatProfile(profile, true) + std::string(" ") + ult::DIVIDER_SYMBOL + " \ue0e3 Reset"));
|
||||
this->addModuleListItem(profile, SysClkModule_CPU);
|
||||
this->addModuleListItem(profile, SysClkModule_GPU);
|
||||
this->addModuleListItem(profile, SysClkModule_MEM);
|
||||
#if IS_MINIMAL == 0
|
||||
ValueThresholds lcdThresholds(60, 65);
|
||||
ValueThresholds DThresholdsOLED(120, 500); // nothing is dangerous, past 120hz you can get applet crashes
|
||||
|
||||
if(configList.values[HorizonOCConfigValue_OverwriteRefreshRate]) {
|
||||
if(profile != SysClkProfile_Docked) {
|
||||
this->addModuleListItemValue(profile, HorizonOCModule_Display, "Display", IsAula() ? 45 : 40, configList.values[HorizonOCConfigValue_MaxDisplayClockH], this->context->isUsingRetroSuper ? 5 : 1, " Hz", 1, 0, lcdThresholds);
|
||||
} else {
|
||||
if(IsAula() && this->context->isSysDockInstalled) {
|
||||
std::vector<NamedValue> dockedFreqs = {
|
||||
NamedValue("40 Hz", 40),
|
||||
NamedValue("45 Hz", 45),
|
||||
NamedValue("50 Hz", 50),
|
||||
NamedValue("55 Hz", 55),
|
||||
NamedValue("60 Hz", 60),
|
||||
NamedValue("70 Hz", 70),
|
||||
NamedValue("72 Hz", 72),
|
||||
NamedValue("75 Hz", 75),
|
||||
NamedValue("80 Hz", 80),
|
||||
NamedValue("90 Hz", 90),
|
||||
NamedValue("95 Hz", 95),
|
||||
NamedValue("100 Hz", 100),
|
||||
NamedValue("110 Hz", 110),
|
||||
NamedValue("120 Hz", 120),
|
||||
NamedValue("130 Hz", 130),
|
||||
NamedValue("140 Hz", 140),
|
||||
NamedValue("144 Hz", 144),
|
||||
NamedValue("150 Hz", 150),
|
||||
NamedValue("160 Hz", 160),
|
||||
NamedValue("165 Hz", 165),
|
||||
NamedValue("170 Hz", 170),
|
||||
NamedValue("180 Hz", 180),
|
||||
NamedValue("190 Hz", 190),
|
||||
NamedValue("200 Hz", 200),
|
||||
NamedValue("210 Hz", 210),
|
||||
NamedValue("220 Hz", 220),
|
||||
NamedValue("230 Hz", 230),
|
||||
NamedValue("240 Hz", 240)
|
||||
};
|
||||
|
||||
this->addModuleListItemValue(profile, HorizonOCModule_Display, "Display", 40, 240, 1, " Hz", 1, 0, DThresholdsOLED, dockedFreqs);
|
||||
} else if (IsAula() && !this->context->isSysDockInstalled) {
|
||||
std::vector<NamedValue> dockedFreqsLimited = {
|
||||
NamedValue("50 Hz", 50),
|
||||
NamedValue("55 Hz", 55),
|
||||
NamedValue("60 Hz", 60),
|
||||
NamedValue("65 Hz", 65),
|
||||
NamedValue("70 Hz", 70),
|
||||
NamedValue("72 Hz", 72),
|
||||
NamedValue("75 Hz", 75)
|
||||
};
|
||||
|
||||
this->addModuleListItemValue(profile, HorizonOCModule_Display, "Display", 50, 75, 1, " Hz", 1, 0, DThresholdsOLED, dockedFreqsLimited);
|
||||
} else {
|
||||
std::vector<NamedValue> dockedFreqsStandard = {
|
||||
NamedValue("50 Hz", 50),
|
||||
NamedValue("55 Hz", 55),
|
||||
NamedValue("60 Hz", 60),
|
||||
NamedValue("65 Hz", 65),
|
||||
NamedValue("70 Hz", 70),
|
||||
NamedValue("72 Hz", 72),
|
||||
NamedValue("75 Hz", 75),
|
||||
NamedValue("80 Hz", 80),
|
||||
NamedValue("85 Hz", 85),
|
||||
NamedValue("90 Hz", 90),
|
||||
NamedValue("95 Hz", 95),
|
||||
NamedValue("100 Hz", 100),
|
||||
NamedValue("105 Hz", 105),
|
||||
NamedValue("110 Hz", 110),
|
||||
NamedValue("115 Hz", 115),
|
||||
NamedValue("120 Hz", 120)
|
||||
};
|
||||
this->addModuleListItemValue(profile, HorizonOCModule_Display, "Display", 50, 120, 1, " Hz", 1, 0, ValueThresholds(), dockedFreqsStandard);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
this->addGovernorSection(profile);
|
||||
}
|
||||
|
||||
void AppProfileGui::listUI()
|
||||
{
|
||||
this->addProfileUI(SysClkProfile_Docked);
|
||||
this->addProfileUI(SysClkProfile_Handheld);
|
||||
this->addProfileUI(SysClkProfile_HandheldCharging);
|
||||
this->addProfileUI(SysClkProfile_HandheldChargingOfficial);
|
||||
this->addProfileUI(SysClkProfile_HandheldChargingUSB);
|
||||
}
|
||||
|
||||
void AppProfileGui::changeTo(std::uint64_t applicationId)
|
||||
{
|
||||
SysClkTitleProfileList* profileList = new SysClkTitleProfileList;
|
||||
Result rc = sysclkIpcGetProfiles(applicationId, profileList);
|
||||
if(R_FAILED(rc))
|
||||
{
|
||||
delete profileList;
|
||||
FatalGui::openWithResultCode("sysclkIpcGetProfiles", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
tsl::changeTo<AppProfileGui>(applicationId, profileList);
|
||||
}
|
||||
|
||||
void AppProfileGui::update()
|
||||
{
|
||||
BaseMenuGui::update();
|
||||
|
||||
if((this->context && this->applicationId != this->context->applicationId) && this->applicationId != SYSCLK_GLOBAL_PROFILE_TID)
|
||||
{
|
||||
tsl::changeTo<FatalGui>(
|
||||
"Application changed\n\n"
|
||||
"\n"
|
||||
"The running application changed\n\n"
|
||||
"while editing was going on.",
|
||||
""
|
||||
);
|
||||
}
|
||||
}
|
||||
81
Source/hoc-clk/overlay/src/ui/gui/app_profile_gui.h
Normal file
81
Source/hoc-clk/overlay/src/ui/gui/app_profile_gui.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
#define SYSCLK_GLOBAL_PROFILE_TID 0xA111111111111111
|
||||
class AppProfileGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::uint64_t applicationId;
|
||||
SysClkTitleProfileList* profileList;
|
||||
void openFreqChoiceGui(tsl::elm::ListItem* listItem, SysClkProfile profile, SysClkModule module);
|
||||
void addModuleListItem(SysClkProfile profile, SysClkModule module);
|
||||
void addModuleListItemToggle(SysClkProfile profile, SysClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds = ValueThresholds(),
|
||||
bool enableThresholds = false,
|
||||
const std::map<std::uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
std::string formatValueDisplay(
|
||||
std::uint32_t value,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
SysClkProfile profile,
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds,
|
||||
std::vector<NamedValue> namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
void addGovernorSection(SysClkProfile profile);
|
||||
void addProfileUI(SysClkProfile profile);
|
||||
public:
|
||||
AppProfileGui(std::uint64_t applicationId, SysClkTitleProfileList* profileList);
|
||||
~AppProfileGui();
|
||||
void listUI() override;
|
||||
static void changeTo(std::uint64_t applicationId);
|
||||
void update() override;
|
||||
};
|
||||
144
Source/hoc-clk/overlay/src/ui/gui/base_gui.cpp
Normal file
144
Source/hoc-clk/overlay/src/ui/gui/base_gui.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "base_gui.h"
|
||||
|
||||
#include "../elements/base_frame.h"
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include <math.h>
|
||||
|
||||
#define LOGO_X 20
|
||||
#define LOGO_Y 50
|
||||
#define LOGO_LABEL_FONT_SIZE 45
|
||||
|
||||
#define VERSION_X (LOGO_X + 250)
|
||||
#define VERSION_Y (LOGO_Y - 40)
|
||||
#define VERSION_FONT_SIZE 15
|
||||
|
||||
std::string getVersionString() {
|
||||
char buf[0x100] = "";
|
||||
Result rc = sysclkIpcGetVersionString(buf, sizeof(buf));
|
||||
if (R_FAILED(rc) || buf[0] == '\0') {
|
||||
return "Unknown";
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
static constexpr tsl::Color dynamicLogoRGB1 = tsl::Color(0, 4, 8, 15);
|
||||
static constexpr tsl::Color dynamicLogoRGB2 = tsl::Color(7, 15, 15, 15);
|
||||
static constexpr tsl::Color STATIC_AQUA = tsl::Color(2, 10, 12, 15);
|
||||
const std::string name = "Horizon OC Zeus";
|
||||
|
||||
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;
|
||||
|
||||
s32 currentX = startX;
|
||||
|
||||
const u64 currentTime_ns = armTicksToNs(armGetSystemTick());
|
||||
const double timeNow = static_cast<double>(currentTime_ns) / 1e9;
|
||||
const double timeBase = fmod(timeNow, cycleDuration);
|
||||
|
||||
const double waveScale = 2.0 * M_PI / cycleDuration;
|
||||
|
||||
for (size_t i = 0; i < name.size(); i++)
|
||||
{
|
||||
char letter = name[i];
|
||||
if (letter == '\0') break;
|
||||
|
||||
double phase = waveScale * (timeBase + i * 0.12);
|
||||
|
||||
double raw = cos(phase);
|
||||
double n = (raw + 1.0) * 0.5;
|
||||
double s1 = n * n * (3.0 - 2.0 * n);
|
||||
double blend = std::clamp(s1, 0.0, 1.0);
|
||||
|
||||
double glow = (cos(phase * 1.5) + 1.0) * 0.5;
|
||||
double brightness = 0.75 + glow * 0.25;
|
||||
|
||||
u8 r = static_cast<u8>(
|
||||
(dynamicLogoRGB1.r + (dynamicLogoRGB2.r - dynamicLogoRGB1.r) * blend) * brightness
|
||||
);
|
||||
u8 g = static_cast<u8>(
|
||||
(dynamicLogoRGB1.g + (dynamicLogoRGB2.g - dynamicLogoRGB1.g) * blend) * brightness
|
||||
);
|
||||
u8 b = static_cast<u8>(
|
||||
(dynamicLogoRGB1.b + (dynamicLogoRGB2.b - dynamicLogoRGB1.b) * blend) * brightness
|
||||
);
|
||||
|
||||
r = std::clamp<u8>(r, 0, 15);
|
||||
g = std::clamp<u8>(g, 0, 15);
|
||||
b = std::clamp<u8>(b, 0, 15);
|
||||
|
||||
bool lightning = (fmod(timeNow, 5.0) < 0.15);
|
||||
if (lightning) {
|
||||
r = std::min<u8>(r + 4, 15);
|
||||
g = std::min<u8>(g + 4, 15);
|
||||
b = std::min<u8>(b + 15, 15);
|
||||
}
|
||||
|
||||
tsl::Color color(r, g, b, 15);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void BaseGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
drawDynamicUltraText(
|
||||
renderer,
|
||||
LOGO_X,
|
||||
LOGO_Y,
|
||||
LOGO_LABEL_FONT_SIZE,
|
||||
STATIC_AQUA,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseGui::createUI()
|
||||
{
|
||||
BaseFrame* rootFrame = new BaseFrame(this);
|
||||
rootFrame->setContent(this->baseUI());
|
||||
return rootFrame;
|
||||
}
|
||||
|
||||
void BaseGui::update()
|
||||
{
|
||||
this->refresh();
|
||||
}
|
||||
53
Source/hoc-clk/overlay/src/ui/gui/base_gui.h
Normal file
53
Source/hoc-clk/overlay/src/ui/gui/base_gui.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tesla.hpp>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../style.h"
|
||||
#include "../../ipc.h"
|
||||
|
||||
class BaseGui : public tsl::Gui
|
||||
{
|
||||
public:
|
||||
BaseGui() {}
|
||||
~BaseGui() {}
|
||||
virtual void preDraw(tsl::gfx::Renderer* renderer);
|
||||
void update() override;
|
||||
tsl::elm::Element* createUI() override;
|
||||
virtual tsl::elm::Element* baseUI() = 0;
|
||||
virtual void refresh() {}
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
extern std::string getVersionString();
|
||||
323
Source/hoc-clk/overlay/src/ui/gui/base_menu_gui.cpp
Normal file
323
Source/hoc-clk/overlay/src/ui/gui/base_menu_gui.cpp
Normal file
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "base_menu_gui.h"
|
||||
#include "fatal_gui.h"
|
||||
|
||||
// Cache hardware model to avoid repeated syscalls
|
||||
|
||||
BaseMenuGui::BaseMenuGui() : tempColors{ tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), tsl::Color(0), }
|
||||
{
|
||||
tsl::initializeThemeVars();
|
||||
this->context = nullptr;
|
||||
this->lastContextUpdate = 0;
|
||||
this->listElement = nullptr;
|
||||
|
||||
|
||||
// Pre-cache hardware model during initialization
|
||||
IsAula();
|
||||
IsMariko();
|
||||
IsHoag();
|
||||
|
||||
// Initialize display strings
|
||||
memset(displayStrings, 0, sizeof(displayStrings));
|
||||
}
|
||||
|
||||
BaseMenuGui::~BaseMenuGui() {
|
||||
delete this->context; // delete handles nullptr automatically
|
||||
}
|
||||
|
||||
// Fast preDraw - just renders pre-computed strings
|
||||
void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
||||
BaseGui::preDraw(renderer);
|
||||
if(!this->context) [[unlikely]] return;
|
||||
|
||||
// All constants pre-calculated and cached
|
||||
static constexpr const char* const labels[] = {
|
||||
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "FAN", "DISP", "FPS", "RES"
|
||||
};
|
||||
|
||||
static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1};
|
||||
|
||||
static u32 labelWidths[10];
|
||||
static bool positionsInitialized = false;
|
||||
|
||||
if (!positionsInitialized) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
labelWidths[i] = renderer->getTextDimensions(labels[i], false, SMALL_TEXT_SIZE).first;
|
||||
}
|
||||
positionsInitialized = true;
|
||||
}
|
||||
static u32 positions[10] = {24-1, 310-labelWidths[1], 24-1, 192-labelWidths[3], 332-labelWidths[4], 24-1, 192 - labelWidths[6], 332-labelWidths[7], 192 - labelWidths[8], 332-labelWidths[9]};
|
||||
|
||||
static u32 maxProfileValueWidth = renderer->getTextDimensions("USB Charger", false, SMALL_TEXT_SIZE).first; // longest word
|
||||
|
||||
u32 y = 91;
|
||||
|
||||
// === TOP SECTION ===
|
||||
renderer->drawRoundedRect(14, 70-1, 420, 30+2, 12.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
|
||||
// App ID - use pre-formatted string
|
||||
renderer->drawString(labels[0], false, positions[0], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(displayStrings[0], false, positions[0] + labelWidths[0] + 9, y, SMALL_TEXT_SIZE, tsl::infoTextColor);
|
||||
|
||||
// Profile - use pre-formatted string
|
||||
renderer->drawString(labels[1], false, 423 - maxProfileValueWidth - labelWidths[1] - 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(displayStrings[1], false, 423 - maxProfileValueWidth, y, SMALL_TEXT_SIZE, tsl::infoTextColor);
|
||||
|
||||
y += 38; // Direct assignment instead of += 38
|
||||
|
||||
// === MAIN DATA SECTION ===
|
||||
// renderer->drawRoundedRect(14, 106, 420, 156, 10.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
renderer->drawRoundedRect(14, 106, 420, 136, 12.0f, renderer->aWithOpacity(tsl::tableBGColor));
|
||||
// === FREQUENCY SECTION ===
|
||||
// Labels first (better cache locality)
|
||||
renderer->drawString(labels[2], false, positions[2], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[3], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[4], false, positions[4], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
renderer->drawString(displayStrings[5], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real
|
||||
renderer->drawString(displayStrings[6], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real
|
||||
renderer->drawString(displayStrings[7], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM real
|
||||
|
||||
// Current frequencies - use pre-formatted strings
|
||||
// renderer->drawString(displayStrings[2], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU
|
||||
// renderer->drawString(displayStrings[3], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU
|
||||
// renderer->drawString(displayStrings[4], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM
|
||||
|
||||
y += 20; // Direct assignment (129 + 20)
|
||||
|
||||
renderer->drawString(displayStrings[19], false, positions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU Usage
|
||||
renderer->drawString(displayStrings[17], false, positions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU Usage
|
||||
if(configList.values[HorizonOCConfigValue_RAMVoltUsageDisplayMode] == RamDisplayMode_VDD2Usage || configList.values[HorizonOCConfigValue_RAMVoltUsageDisplayMode] == RamDisplayMode_VDDQUsage)
|
||||
renderer->drawString(displayStrings[18], false, positions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // RAM Usage
|
||||
// === REAL FREQUENCIES ===
|
||||
|
||||
// y += 20; // Direct assignment (149 + 20)
|
||||
|
||||
// === VOLTAGES ===
|
||||
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
|
||||
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
|
||||
|
||||
renderer->drawStringWithColoredSections(displayStrings[10], false, {""}, configList.values[HorizonOCConfigValue_RAMVoltUsageDisplayMode] == RamDisplayMode_VDD2VDDQ ? dataPositions[5]-16 : dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor, tsl::separatorColor);
|
||||
|
||||
y += 22; // Direct assignment (169 + 22)
|
||||
|
||||
// === TEMPERATURE SECTION ===
|
||||
// Labels
|
||||
renderer->drawString(labels[5], false, positions[5], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[6], false, positions[6]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[7], false, positions[7], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
// Temperatures with color - use pre-computed colors
|
||||
renderer->drawString(displayStrings[11], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[SysClkThermalSensor_SOC]); // SOC
|
||||
renderer->drawString(displayStrings[12], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[SysClkThermalSensor_PCB]); // PCB
|
||||
renderer->drawString(displayStrings[13], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[SysClkThermalSensor_Skin]); // Skin
|
||||
|
||||
y += 20; // Direct assignment (191 + 20)
|
||||
|
||||
renderer->drawString(displayStrings[14], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor);
|
||||
|
||||
// Power labels and values
|
||||
renderer->drawString(labels[8], false, positions[8]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
renderer->drawString(labels[9], false, positions[9], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
renderer->drawString(displayStrings[15], false, dataPositions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power now
|
||||
renderer->drawString(displayStrings[16], false, dataPositions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power avg
|
||||
|
||||
y+=20;
|
||||
|
||||
renderer->drawString(labels[10], false, positions[2], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
|
||||
|
||||
renderer->drawString(displayStrings[20], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[HorizonOCThermalSensor_Battery]); // Battery
|
||||
|
||||
renderer->drawString(labels[13], false, positions[4], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // disp label
|
||||
|
||||
renderer->drawString(displayStrings[25], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // disp freq
|
||||
|
||||
renderer->drawString(labels[12], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // fan label
|
||||
|
||||
renderer->drawString(displayStrings[24], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // fan speed
|
||||
|
||||
y+=20;
|
||||
|
||||
renderer->drawString(displayStrings[21], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat voltage
|
||||
renderer->drawString(displayStrings[23], false, positions[2] - 2, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat Age
|
||||
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
|
||||
renderer->drawString(labels[15], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // RES label
|
||||
renderer->drawString(displayStrings[27], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // RES
|
||||
|
||||
renderer->drawString(labels[14], false, positions[4], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // FPS label
|
||||
renderer->drawString(displayStrings[26], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
||||
|
||||
}
|
||||
|
||||
y+=20;
|
||||
}
|
||||
|
||||
// Optimized refresh - now does all the string formatting once per second
|
||||
void BaseMenuGui::refresh()
|
||||
{
|
||||
const u64 ticks = armGetSystemTick();
|
||||
// Use cached comparison - 1 billion nanoseconds
|
||||
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] {
|
||||
return; // Early exit for most calls
|
||||
}
|
||||
|
||||
this->lastContextUpdate = ticks;
|
||||
|
||||
// Lazy context allocation
|
||||
if (!this->context) [[unlikely]] {
|
||||
this->context = new SysClkContext;
|
||||
}
|
||||
|
||||
// === SYSCLK CONTEXT UPDATE ===
|
||||
Result rc = sysclkIpcGetCurrentContext(this->context);
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetCurrentContext", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
rc = sysclkIpcGetConfigValues(&configList);
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetConfigValues", rc);
|
||||
return;
|
||||
}
|
||||
// dockedHighestAllowedRefreshRate = this->context->maxDisplayFreq;
|
||||
|
||||
// === FORMAT ALL DISPLAY STRINGS (once per second) ===
|
||||
// App ID (hex conversion)
|
||||
sprintf(displayStrings[0], "%016lX", context->applicationId);
|
||||
|
||||
// Profile
|
||||
strcpy(displayStrings[1], sysclkFormatProfile(context->profile, true));
|
||||
|
||||
// Current frequencies
|
||||
u32 hz = context->freqs[SysClkModule_CPU]; // CPU
|
||||
sprintf(displayStrings[2], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->freqs[SysClkModule_GPU]; // GPU
|
||||
sprintf(displayStrings[3], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->freqs[SysClkModule_MEM]; // MEM
|
||||
sprintf(displayStrings[4], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
// Real frequencies
|
||||
hz = context->realFreqs[SysClkModule_CPU]; // CPU
|
||||
sprintf(displayStrings[5], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->realFreqs[SysClkModule_GPU]; // GPU
|
||||
sprintf(displayStrings[6], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
hz = context->realFreqs[SysClkModule_MEM]; // MEM
|
||||
sprintf(displayStrings[7], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
|
||||
|
||||
// Voltages
|
||||
sprintf(displayStrings[8], "%.1f mV", context->voltages[HocClkVoltage_CPU] / 1000.0);
|
||||
sprintf(displayStrings[9], "%.1f mV", context->voltages[HocClkVoltage_GPU] / 1000.0);
|
||||
|
||||
switch(configList.values[HorizonOCConfigValue_RAMVoltUsageDisplayMode]) {
|
||||
case RamDisplayMode_VDD2VDDQ:
|
||||
sprintf(displayStrings[10], "%u.%u%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U, (context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U, context->voltages[HocClkVoltage_EMCVDDQ_MarikoOnly] / 1000U);
|
||||
break;
|
||||
case RamDisplayMode_VDD2Usage:
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDD2] / 1000U, (context->voltages[HocClkVoltage_EMCVDD2] % 1000U) / 100U);
|
||||
break;
|
||||
case RamDisplayMode_VDDQUsage:
|
||||
sprintf(displayStrings[10], "%u.%u mV", context->voltages[HocClkVoltage_EMCVDDQ_MarikoOnly] / 1000U, (context->voltages[HocClkVoltage_EMCVDDQ_MarikoOnly] % 1000U) / 100U);
|
||||
break;
|
||||
default:
|
||||
strcpy(displayStrings[10], "N/A");
|
||||
break;
|
||||
}
|
||||
|
||||
// Temperatures and pre-compute colors
|
||||
u32 millis = context->temps[SysClkThermalSensor_SOC]; // SOC
|
||||
sprintf(displayStrings[11], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[SysClkThermalSensor_SOC] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
millis = context->temps[SysClkThermalSensor_PCB]; // PCB
|
||||
sprintf(displayStrings[12], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[SysClkThermalSensor_PCB] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
millis = context->temps[SysClkThermalSensor_Skin]; // Skin
|
||||
sprintf(displayStrings[13], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[SysClkThermalSensor_Skin] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
// SOC voltage (if available)
|
||||
sprintf(displayStrings[14], "%u mV", context->voltages[HocClkVoltage_SOC] / 1000U);
|
||||
|
||||
// Power
|
||||
sprintf(displayStrings[15], "%d mW", context->power[0]); // Now
|
||||
sprintf(displayStrings[16], "%d mW", context->power[1]); // Avg
|
||||
|
||||
sprintf(displayStrings[17], "%u%%", context->partLoad[HocClkPartLoad_GPU] / 10);
|
||||
sprintf(displayStrings[18], "%u%%", context->partLoad[SysClkPartLoad_EMC] / 10);
|
||||
sprintf(displayStrings[19], "%u%%", context->partLoad[HocClkPartLoad_CPUMax] / 10);
|
||||
|
||||
millis = context->temps[HorizonOCThermalSensor_Battery]; // Battery
|
||||
sprintf(displayStrings[20], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
|
||||
tempColors[HorizonOCThermalSensor_Battery] = tsl::GradientColor(millis * 0.001f);
|
||||
|
||||
sprintf(displayStrings[21], "%d mV", context->voltages[HocClkVoltage_Battery]); // BAT AVG
|
||||
|
||||
sprintf(displayStrings[23], "%u%%", context->partLoad[HocClkPartLoad_BAT] / 1000);
|
||||
|
||||
sprintf(displayStrings[24], "%u%%", context->partLoad[HocClkPartLoad_FAN]);
|
||||
|
||||
sprintf(displayStrings[25], "%u Hz", context->realFreqs[HorizonOCModule_Display]);
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
if(context->fps == 254) {
|
||||
strcpy(displayStrings[26], "N/A");
|
||||
} else {
|
||||
memset(displayStrings[26], 0, sizeof(displayStrings[26]));
|
||||
sprintf(displayStrings[26], "%u", context->fps);
|
||||
}
|
||||
}
|
||||
|
||||
if(this->context->isSaltyNXInstalled) {
|
||||
if(context->resolutionHeight == 0) {
|
||||
strcpy(displayStrings[27], "N/A");
|
||||
} else {
|
||||
memset(displayStrings[27], 0, sizeof(displayStrings[27]));
|
||||
sprintf(displayStrings[27], "%up", context->resolutionHeight);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tsl::elm::Element* BaseMenuGui::baseUI()
|
||||
{
|
||||
auto* list = new tsl::elm::List();
|
||||
list->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer*, s32, s32, s32, s32) {}), 10); // add a bit of space
|
||||
this->listElement = list;
|
||||
this->listUI();
|
||||
|
||||
return list;
|
||||
}
|
||||
91
Source/hoc-clk/overlay/src/ui/gui/base_menu_gui.h
Normal file
91
Source/hoc-clk/overlay/src/ui/gui/base_menu_gui.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../ipc.h"
|
||||
#include "base_gui.h"
|
||||
|
||||
class BaseMenuGui : public BaseGui
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
// u8 dockedHighestAllowedRefreshRate = 60;
|
||||
SysClkContext* context;
|
||||
std::uint64_t lastContextUpdate;
|
||||
SysClkConfigValueList configList;
|
||||
bool g_hardwareModelCached = false;
|
||||
bool g_isMariko = false;
|
||||
bool g_isAula = false;
|
||||
bool g_isHoag = false;
|
||||
SetSysProductModel HWmodel = SetSysProductModel_Invalid;
|
||||
|
||||
bool IsAula() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isAula = (HWmodel == SetSysProductModel_Aula);
|
||||
return g_isAula;
|
||||
}
|
||||
bool IsHoag() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isHoag = (HWmodel == SetSysProductModel_Hoag);
|
||||
return g_isHoag;
|
||||
}
|
||||
bool IsMariko() {
|
||||
if (!g_hardwareModelCached) {
|
||||
setsysGetProductModel(&HWmodel);
|
||||
g_hardwareModelCached = true;
|
||||
}
|
||||
g_isMariko = (HWmodel == SetSysProductModel_Iowa ||
|
||||
HWmodel == SetSysProductModel_Hoag ||
|
||||
HWmodel == SetSysProductModel_Calcio ||
|
||||
HWmodel == SetSysProductModel_Aula);
|
||||
|
||||
return g_isMariko;
|
||||
}
|
||||
|
||||
bool IsErista() {
|
||||
return !IsMariko();
|
||||
}
|
||||
BaseMenuGui();
|
||||
~BaseMenuGui();
|
||||
void preDraw(tsl::gfx::Renderer* renderer) override;
|
||||
tsl::elm::List* listElement;
|
||||
tsl::elm::Element* baseUI() override;
|
||||
void refresh() override;
|
||||
virtual void listUI() = 0;
|
||||
|
||||
private:
|
||||
char displayStrings[32][32]; // Pre-formatted display strings
|
||||
tsl::Color tempColors[7]; // Pre-computed temperature colors
|
||||
};
|
||||
4118
Source/hoc-clk/overlay/src/ui/gui/cat.h
Normal file
4118
Source/hoc-clk/overlay/src/ui/gui/cat.h
Normal file
File diff suppressed because it is too large
Load Diff
84
Source/hoc-clk/overlay/src/ui/gui/fatal_gui.cpp
Normal file
84
Source/hoc-clk/overlay/src/ui/gui/fatal_gui.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "fatal_gui.h"
|
||||
|
||||
FatalGui::FatalGui(const std::string message, const std::string info)
|
||||
{
|
||||
this->message = message;
|
||||
this->info = info;
|
||||
}
|
||||
|
||||
void FatalGui::openWithResultCode(std::string tag, Result rc)
|
||||
{
|
||||
char rcStr[32];
|
||||
std::string info = tag;
|
||||
info.append(rcStr, snprintf(rcStr, sizeof(rcStr), "\n\n[0x%x] %04d-%04d", rc, R_MODULE(rc), R_DESCRIPTION(rc)));
|
||||
|
||||
tsl::changeTo<FatalGui>(
|
||||
"Could not connect to hoc-clk sysmodule.\n\n"
|
||||
"\n"
|
||||
"Please make sure everything is\n\n"
|
||||
"correctly installed and enabled.",
|
||||
info
|
||||
);
|
||||
}
|
||||
|
||||
tsl::elm::Element* FatalGui::baseUI()
|
||||
{
|
||||
tsl::elm::CustomDrawer* drawer = new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer* renderer, u16 x, u16 y, u16 w, u16 h) {
|
||||
renderer->drawString("\uE150", false, 40, 210, 40, TEXT_COLOR);
|
||||
renderer->drawString("Fatal error", false, 100, 210, 30, TEXT_COLOR);
|
||||
|
||||
std::uint32_t txtY = 255;
|
||||
if(!this->message.empty())
|
||||
{
|
||||
txtY += renderer->drawString(this->message.c_str(), false, 40, txtY, 23, TEXT_COLOR).second;
|
||||
txtY += 55;
|
||||
}
|
||||
|
||||
if(!this->info.empty())
|
||||
{
|
||||
renderer->drawString(this->info.c_str(), false, 40, txtY, 18, DESC_COLOR);
|
||||
}
|
||||
});
|
||||
|
||||
return drawer;
|
||||
}
|
||||
|
||||
bool FatalGui::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight)
|
||||
{
|
||||
if((keysDown & HidNpadButton_A) == HidNpadButton_A || (keysDown & HidNpadButton_B) == HidNpadButton_B)
|
||||
{
|
||||
while(tsl::Overlay::get()->getCurrentGui() != nullptr) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
46
Source/hoc-clk/overlay/src/ui/gui/fatal_gui.h
Normal file
46
Source/hoc-clk/overlay/src/ui/gui/fatal_gui.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "base_gui.h"
|
||||
|
||||
class FatalGui : public BaseGui
|
||||
{
|
||||
protected:
|
||||
std::string message;
|
||||
std::string info;
|
||||
|
||||
public:
|
||||
FatalGui(const std::string message, const std::string info);
|
||||
~FatalGui() {}
|
||||
tsl::elm::Element* baseUI() override;
|
||||
bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState joyStickPosLeft, HidAnalogStickState joyStickPosRight);
|
||||
static void openWithResultCode(std::string tag, Result rc);
|
||||
};
|
||||
219
Source/hoc-clk/overlay/src/ui/gui/freq_choice_gui.cpp
Normal file
219
Source/hoc-clk/overlay/src/ui/gui/freq_choice_gui.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#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;
|
||||
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);
|
||||
|
||||
std::string rightText = "";
|
||||
auto it = labels.find(hz);
|
||||
if (it != labels.end())
|
||||
rightText = it->second;
|
||||
|
||||
if (selected)
|
||||
const_cast<std::string&>(rightText) = "\uE14B";
|
||||
|
||||
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() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
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;
|
||||
|
||||
// // if (moduleName == "gpu" &&
|
||||
// // this->configList->values[HocClkConfigValue_MarikoMaxGpuClock] < mhz)
|
||||
// // continue;
|
||||
|
||||
// // if (moduleName == "mem" &&
|
||||
// // this->configList->values[HocClkConfigValue_MarikoMaxMemClock] < mhz)
|
||||
// // continue;
|
||||
|
||||
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;
|
||||
|
||||
uint32_t unsafe_cpu;
|
||||
uint32_t unsafe_gpu;
|
||||
uint32_t danger_cpu;
|
||||
uint32_t danger_gpu;
|
||||
|
||||
if (IsMariko())
|
||||
{
|
||||
unsafe_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2398 : 1964;
|
||||
if(this->configList->values[KipConfigValue_marikoGpuUV] == 0) {
|
||||
unsafe_gpu = 1076;
|
||||
} else if (this->configList->values[KipConfigValue_marikoGpuUV] == 1) {
|
||||
unsafe_gpu = 1153;
|
||||
} else {
|
||||
unsafe_gpu = 1229;
|
||||
}
|
||||
danger_cpu = this->configList->values[KipConfigValue_marikoCpuUVHigh] ? 2500 : 2398;
|
||||
danger_gpu = 1306;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsafe_cpu = this->configList->values[KipConfigValue_eristaCpuUV] ? 2092 : 1786;
|
||||
if(this->configList->values[KipConfigValue_eristaGpuUV] == 0) {
|
||||
unsafe_gpu = 922;
|
||||
} else {
|
||||
unsafe_gpu = 961;
|
||||
}
|
||||
danger_cpu = this->configList->values[KipConfigValue_eristaCpuUV] ? 2194 : 1964;
|
||||
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("", "");
|
||||
}
|
||||
64
Source/hoc-clk/overlay/src/ui/gui/freq_choice_gui.h
Normal file
64
Source/hoc-clk/overlay/src/ui/gui/freq_choice_gui.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
|
||||
|
||||
class FreqChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
SysClkConfigValueList* configList;
|
||||
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;
|
||||
|
||||
tsl::elm::ListItem* createFreqListItem(std::uint32_t hz, bool selected, int safety);
|
||||
|
||||
public:
|
||||
FreqChoiceGui(std::uint32_t selectedHz,
|
||||
std::uint32_t* hzList,
|
||||
std::uint32_t hzCount,
|
||||
SysClkModule module,
|
||||
FreqChoiceListener listener,
|
||||
bool checkMax = true,
|
||||
std::map<uint32_t, std::string> labels = {});
|
||||
|
||||
~FreqChoiceGui();
|
||||
|
||||
void listUI() override;
|
||||
};
|
||||
418
Source/hoc-clk/overlay/src/ui/gui/global_override_gui.cpp
Normal file
418
Source/hoc-clk/overlay/src/ui/gui/global_override_gui.cpp
Normal file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) Souldbminer and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include "global_override_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
#include "labels.h"
|
||||
|
||||
GlobalOverrideGui::GlobalOverrideGui()
|
||||
{
|
||||
for (std::uint16_t m = 0; m < SysClkModule_EnumMax; m++) {
|
||||
this->listItems[m] = nullptr;
|
||||
this->listHz[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::openFreqChoiceGui(SysClkModule module)
|
||||
{
|
||||
std::uint32_t hzList[SYSCLK_FREQ_LIST_MAX];
|
||||
std::uint32_t hzCount;
|
||||
Result rc =
|
||||
sysclkIpcGetFreqList(module, &hzList[0], SYSCLK_FREQ_LIST_MAX, &hzCount);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetFreqList", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<uint32_t, std::string> labels = {};
|
||||
|
||||
if (module == SysClkModule_CPU) {
|
||||
bool isUsingUv = IsMariko() ? configList.values[KipConfigValue_marikoCpuUVHigh] : configList.values[KipConfigValue_eristaCpuUV];
|
||||
labels = IsMariko() ? (isUsingUv ? cpu_freq_label_m_uv : cpu_freq_label_m) : (isUsingUv ? cpu_freq_label_e_uv : cpu_freq_label_e);
|
||||
} else if (module == SysClkModule_GPU) {
|
||||
labels = IsMariko() ? *(marikoUV[configList.values[KipConfigValue_marikoGpuUV]]) : *(eristaUV[configList.values[KipConfigValue_eristaGpuUV]]);
|
||||
}
|
||||
tsl::changeTo<FreqChoiceGui>(
|
||||
this->context->overrideFreqs[module], hzList, hzCount, module,
|
||||
[this, module](std::uint32_t hz) {
|
||||
Result rc = sysclkIpcSetOverride(module, hz);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
this->context->overrideFreqs[module] = hz;
|
||||
|
||||
return true;
|
||||
},
|
||||
true, labels
|
||||
);
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
tsl::changeTo<ValueChoiceGui>(
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
listener,
|
||||
thresholds,
|
||||
enableThresholds,
|
||||
labels,
|
||||
namedValues,
|
||||
showDefaultValue,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleListItemValue(
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
)
|
||||
{
|
||||
bool hasNamedValues = !namedValues.empty();
|
||||
|
||||
if (!hasNamedValues) {
|
||||
this->customFormatModules[module] = std::make_tuple(suffix, divisor, decimalPlaces);
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
|
||||
listItem->setClickListener(
|
||||
[this,
|
||||
listItem,
|
||||
module,
|
||||
categoryName,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces,
|
||||
thresholds,
|
||||
namedValues,
|
||||
hasNamedValues,
|
||||
showDefaultValue](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A)
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint32_t currentValue =
|
||||
this->context->overrideFreqs[module] * divisor;
|
||||
|
||||
ValueRange range(
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
suffix,
|
||||
divisor,
|
||||
decimalPlaces
|
||||
);
|
||||
|
||||
this->openValueChoiceGui(
|
||||
listItem,
|
||||
currentValue,
|
||||
range,
|
||||
categoryName,
|
||||
|
||||
[this, listItem, module, divisor, suffix, decimalPlaces, thresholds, namedValues, hasNamedValues, showDefaultValue](std::uint32_t value) -> bool
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->context->overrideFreqs[module] = value / divisor;
|
||||
this->listHz[module] = value / divisor;
|
||||
|
||||
if (value == 0) {
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else if (hasNamedValues) {
|
||||
for (const auto& namedValue : namedValues) {
|
||||
if (namedValue.value == value / divisor) {
|
||||
listItem->setValue(namedValue.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)value / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s",
|
||||
decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s",
|
||||
value / divisor, suffix.c_str());
|
||||
}
|
||||
listItem->setValue(buf);
|
||||
}
|
||||
|
||||
Result rc =
|
||||
sysclkIpcSetOverride(module, this->context->overrideFreqs[module]);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode(
|
||||
"sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
},
|
||||
|
||||
thresholds,
|
||||
false,
|
||||
std::map<std::uint32_t, std::string>(),
|
||||
namedValues,
|
||||
showDefaultValue
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ((keys & HidNpadButton_Y) == HidNpadButton_Y)
|
||||
{
|
||||
if (!this->context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
listItem->setValue(FREQ_DEFAULT_TEXT);
|
||||
|
||||
Result rc = sysclkIpcSetOverride(module, 0);
|
||||
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
this->listItems[module] = listItem;
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleListItem(SysClkModule module)
|
||||
{
|
||||
tsl::elm::ListItem *listItem =
|
||||
new tsl::elm::ListItem(sysclkFormatModule(module, true));
|
||||
listItem->setValue(formatListFreqMHz(0));
|
||||
listItem->setClickListener([this, module](u64 keys) {
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A) {
|
||||
this->openFreqChoiceGui(module);
|
||||
return true;
|
||||
} else if ((keys & HidNpadButton_Y) == HidNpadButton_Y) {
|
||||
Result rc = sysclkIpcSetOverride(module, 0);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
|
||||
this->listItems[module]->setValue(formatListFreqHz(0));
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this->listElement->addItem(listItem);
|
||||
this->listItems[module] = listItem;
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::addModuleToggleItem(SysClkModule module)
|
||||
{
|
||||
const char *moduleName = sysclkFormatModule(module, true);
|
||||
bool isOn = this->listHz[module];
|
||||
|
||||
tsl::elm::ToggleListItem *toggle =
|
||||
new tsl::elm::ToggleListItem(moduleName, isOn);
|
||||
|
||||
toggle->setStateChangedListener([this, module, toggle](bool state) {
|
||||
Result rc = sysclkIpcSetOverride(module, state ? 1 : 0);
|
||||
if (R_FAILED(rc)) {
|
||||
FatalGui::openWithResultCode("sysclkIpcSetProfiles", rc);
|
||||
}
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
this->context->overrideFreqs[module] = 0;
|
||||
this->listHz[module] = 0;
|
||||
});
|
||||
this->listElement->addItem(toggle);
|
||||
this->listItems[module] = toggle;
|
||||
}
|
||||
|
||||
class GovernorOverrideSubMenuGui : public BaseMenuGui {
|
||||
u32 packed;
|
||||
public:
|
||||
GovernorOverrideSubMenuGui(u32 initialPacked) : packed(initialPacked) {}
|
||||
|
||||
void listUI() override {
|
||||
Result rc = sysclkIpcGetConfigValues(&configList); // idk why this is needed, probably some refreshing issue
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetConfigValues", rc);
|
||||
return;
|
||||
}
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Governor"));
|
||||
|
||||
static constexpr struct { const char* label; int shift; } kAll[] = {
|
||||
{"CPU", 0}, {"GPU", 8}, {"VRR", 16}
|
||||
};
|
||||
int count = configList.values[HorizonOCConfigValue_OverwriteRefreshRate] ? 3 : 2;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
u8 cur = (this->packed >> kAll[i].shift) & 0xFF;
|
||||
auto* bar = new tsl::elm::NamedStepTrackBar(
|
||||
"", {"Do Not Override", "Disabled", "Enabled"},
|
||||
true, kAll[i].label
|
||||
);
|
||||
bar->setProgress(cur);
|
||||
int shift = kAll[i].shift;
|
||||
bar->setValueChangedListener([this, shift](u8 value) {
|
||||
this->packed = (this->packed & ~(0xFFu << shift)) | ((u32)value << shift);
|
||||
Result rc = sysclkIpcSetOverride(HorizonOCModule_Governor, this->packed);
|
||||
if (R_FAILED(rc)) FatalGui::openWithResultCode("sysclkIpcSetOverride", rc);
|
||||
this->lastContextUpdate = armGetSystemTick();
|
||||
});
|
||||
this->listElement->addItem(bar);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void GlobalOverrideGui::addGovernorSection() {
|
||||
auto* item = new tsl::elm::ListItem("Governor");
|
||||
item->setValue("\u2192"); // right arrow
|
||||
item->setClickListener([this](u64 keys) {
|
||||
if (keys & HidNpadButton_A) {
|
||||
u32 packed = this->context ? this->context->overrideFreqs[HorizonOCModule_Governor] : 0;
|
||||
tsl::changeTo<GovernorOverrideSubMenuGui>(packed);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(item);
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::listUI()
|
||||
{
|
||||
BaseMenuGui::refresh(); // get latest context
|
||||
if(!this->context)
|
||||
return;
|
||||
|
||||
Result rc = sysclkIpcGetConfigValues(&configList); // idk why this is needed, probably some refreshing issue
|
||||
if (R_FAILED(rc)) [[unlikely]] {
|
||||
FatalGui::openWithResultCode("sysclkIpcGetConfigValues", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(
|
||||
"Temporary Overrides " + ult::DIVIDER_SYMBOL + " \ue0e3 Reset"));
|
||||
this->addModuleListItem(SysClkModule_CPU);
|
||||
this->addModuleListItem(SysClkModule_GPU);
|
||||
this->addModuleListItem(SysClkModule_MEM);
|
||||
#if IS_MINIMAL == 0
|
||||
ValueThresholds lcdThresholds(60, 65);
|
||||
if(configList.values[HorizonOCConfigValue_OverwriteRefreshRate])
|
||||
this->addModuleListItemValue(HorizonOCModule_Display, "Display", IsAula() ? 45 : 40, configList.values[HorizonOCConfigValue_MaxDisplayClockH], this->context->isUsingRetroSuper ? 5 : 1, " Hz", 1, 0, lcdThresholds);
|
||||
#endif
|
||||
|
||||
this->addGovernorSection();
|
||||
}
|
||||
|
||||
void GlobalOverrideGui::refresh()
|
||||
{
|
||||
BaseMenuGui::refresh();
|
||||
|
||||
if (!this->context)
|
||||
return;
|
||||
|
||||
for (std::uint16_t m = 0; m < SysClkModule_EnumMax; m++) {
|
||||
if (m == HorizonOCModule_Governor) {
|
||||
this->listHz[m] = this->context->overrideFreqs[m];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->listItems[m] != nullptr &&
|
||||
this->listHz[m] != this->context->overrideFreqs[m]) {
|
||||
|
||||
auto it = this->customFormatModules.find((SysClkModule)m);
|
||||
if (it != this->customFormatModules.end()) {
|
||||
std::string suffix = std::get<0>(it->second);
|
||||
std::uint32_t divisor = std::get<1>(it->second);
|
||||
int decimalPlaces = std::get<2>(it->second);
|
||||
|
||||
if (this->context->overrideFreqs[m] == 0) {
|
||||
this->listItems[m]->setValue(FREQ_DEFAULT_TEXT);
|
||||
} else {
|
||||
char buf[32];
|
||||
if (decimalPlaces > 0) {
|
||||
double displayValue = (double)this->context->overrideFreqs[m] / divisor;
|
||||
snprintf(buf, sizeof(buf), "%.*f%s",
|
||||
decimalPlaces, displayValue, suffix.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u%s",
|
||||
this->context->overrideFreqs[m] / divisor, suffix.c_str());
|
||||
}
|
||||
this->listItems[m]->setValue(buf);
|
||||
}
|
||||
} else {
|
||||
this->listItems[m]->setValue(
|
||||
formatListFreqHz(this->context->overrideFreqs[m]));
|
||||
}
|
||||
|
||||
this->listHz[m] = this->context->overrideFreqs[m];
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Source/hoc-clk/overlay/src/ui/gui/global_override_gui.h
Normal file
74
Source/hoc-clk/overlay/src/ui/gui/global_override_gui.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include "freq_choice_gui.h"
|
||||
#include <string>
|
||||
#include "value_choice_gui.h"
|
||||
class GlobalOverrideGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::map<SysClkModule, std::tuple<std::string, std::uint32_t, int>> customFormatModules;
|
||||
tsl::elm::ListItem* listItems[SysClkModule_EnumMax];
|
||||
std::uint32_t listHz[SysClkModule_EnumMax];
|
||||
void openFreqChoiceGui(SysClkModule module);
|
||||
void addGovernorSection();
|
||||
void addModuleListItem(SysClkModule module);
|
||||
void addModuleToggleItem(SysClkModule module);
|
||||
void openValueChoiceGui(
|
||||
tsl::elm::ListItem* listItem,
|
||||
std::uint32_t currentValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
const std::map<std::uint32_t, std::string>& labels,
|
||||
const std::vector<NamedValue>& namedValues,
|
||||
bool showDefaultValue
|
||||
);
|
||||
void addModuleListItemValue(
|
||||
SysClkModule module,
|
||||
const std::string& categoryName,
|
||||
std::uint32_t min,
|
||||
std::uint32_t max,
|
||||
std::uint32_t step,
|
||||
const std::string& suffix,
|
||||
std::uint32_t divisor,
|
||||
int decimalPlaces,
|
||||
ValueThresholds thresholds = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true
|
||||
);
|
||||
public:
|
||||
GlobalOverrideGui();
|
||||
~GlobalOverrideGui() {}
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
void setModuleCustomFormat(SysClkModule module, const std::string& suffix, std::uint32_t divisor, int decimalPlaces);
|
||||
};
|
||||
134
Source/hoc-clk/overlay/src/ui/gui/labels.cpp
Normal file
134
Source/hoc-clk/overlay/src/ui/gui/labels.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
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"},
|
||||
{2703000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_m_uv = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{2397000000, "Safe Max"},
|
||||
{2499000000, "Unsafe Max"},
|
||||
{2703000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_e = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Safe Max"},
|
||||
{2091000000, "Unsafe Max"},
|
||||
{2397000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> cpu_freq_label_e_uv = {
|
||||
{612000000, "Sleep Mode"},
|
||||
{1020000000, "Stock"},
|
||||
{1224000000, "Dev OC"},
|
||||
{1785000000, "Boost Mode"},
|
||||
{2091000000, "Safe Max"},
|
||||
{2193000000, "Unsafe Max"},
|
||||
{2397000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_e = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{921600000, "Safe Max"},
|
||||
{960000000, "Unsafe Max"},
|
||||
{1075200000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_e_uv = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{345600000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{422400000, "Handheld"},
|
||||
{460800000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{960000000, "Safe Max"},
|
||||
{1075200000, "Absolute 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"},
|
||||
{1075200000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m_slt = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1152200000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string> gpu_freq_label_m_hiopt = {
|
||||
{76800000, "Boost Mode"},
|
||||
{307200000, "Handheld"},
|
||||
{384000000, "Handheld"},
|
||||
{460800000, "Handheld"},
|
||||
{614400000, "Handheld Safe Max"},
|
||||
{768000000, "Docked"},
|
||||
{1228800000, "Safe Max"},
|
||||
{1305600000, "Unsafe Max"},
|
||||
{1536000000, "Absolute Max"},
|
||||
};
|
||||
|
||||
std::map<uint32_t, std::string>* marikoUV[3] {
|
||||
&gpu_freq_label_m,
|
||||
&gpu_freq_label_m_slt,
|
||||
&gpu_freq_label_m_hiopt,
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32_t, std::string>* eristaUV[3] {
|
||||
&gpu_freq_label_e,
|
||||
&gpu_freq_label_e_uv,
|
||||
&gpu_freq_label_e_uv,
|
||||
};
|
||||
34
Source/hoc-clk/overlay/src/ui/gui/labels.h
Normal file
34
Source/hoc-clk/overlay/src/ui/gui/labels.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
extern std::map<uint32_t, std::string> cpu_freq_label_m;
|
||||
extern std::map<uint32_t, std::string> cpu_freq_label_m_uv;
|
||||
extern std::map<uint32_t, std::string> cpu_freq_label_e;
|
||||
extern std::map<uint32_t, std::string> cpu_freq_label_e_uv;
|
||||
extern std::map<uint32_t, std::string> gpu_freq_label_m;
|
||||
extern std::map<uint32_t, std::string> gpu_freq_label_m_slt;
|
||||
extern std::map<uint32_t, std::string> gpu_freq_label_m_hiopt;
|
||||
extern std::map<uint32_t, std::string> gpu_freq_label_e;
|
||||
extern std::map<uint32_t, std::string> gpu_freq_label_e_uv;
|
||||
|
||||
extern std::map<uint32_t, std::string>* marikoUV[3];
|
||||
extern std::map<uint32_t, std::string>* eristaUV[3];
|
||||
123
Source/hoc-clk/overlay/src/ui/gui/main_gui.cpp
Normal file
123
Source/hoc-clk/overlay/src/ui/gui/main_gui.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "main_gui.h"
|
||||
|
||||
#include "fatal_gui.h"
|
||||
#include "app_profile_gui.h"
|
||||
#include "global_override_gui.h"
|
||||
#include "misc_gui.h"
|
||||
#include "about_gui.h"
|
||||
|
||||
void MainGui::listUI()
|
||||
{
|
||||
// this->enabledToggle = new tsl::elm::ToggleListItem("Enable", false);
|
||||
// enabledToggle->setStateChangedListener([this](bool state) {
|
||||
// Result rc = sysclkIpcSetEnabled(state);
|
||||
// if(R_FAILED(rc))
|
||||
// {
|
||||
// FatalGui::openWithResultCode("sysclkIpcSetEnabled", rc);
|
||||
// }
|
||||
|
||||
// this->lastContextUpdate = armGetSystemTick();
|
||||
// this->context->enabled = state;
|
||||
// });
|
||||
// this->listElement->addItem(this->enabledToggle);
|
||||
|
||||
tsl::elm::ListItem* appProfileItem = new tsl::elm::ListItem("Edit App Profile");
|
||||
appProfileItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
AppProfileGui::changeTo(this->context->applicationId);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(appProfileItem);
|
||||
|
||||
|
||||
tsl::elm::ListItem* globalProfileItem = new tsl::elm::ListItem("Edit Global Profile");
|
||||
globalProfileItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
AppProfileGui::changeTo(SYSCLK_GLOBAL_PROFILE_TID);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(globalProfileItem);
|
||||
|
||||
tsl::elm::ListItem* globalOverrideItem = new tsl::elm::ListItem("Temporary Overrides");
|
||||
globalOverrideItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
tsl::changeTo<GlobalOverrideGui>();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(globalOverrideItem);
|
||||
|
||||
//this->listElement->addItem(new tsl::elm::CategoryHeader("Misc"));
|
||||
|
||||
tsl::elm::ListItem* miscItem = new tsl::elm::ListItem("Settings");
|
||||
miscItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
tsl::changeTo<MiscGui>();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(miscItem);
|
||||
|
||||
tsl::elm::ListItem* aboutItem = new tsl::elm::ListItem("About");
|
||||
aboutItem->setClickListener([this](u64 keys) {
|
||||
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
|
||||
{
|
||||
tsl::changeTo<AboutGui>();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
this->listElement->addItem(aboutItem);
|
||||
|
||||
}
|
||||
|
||||
void MainGui::refresh()
|
||||
{
|
||||
BaseMenuGui::refresh();
|
||||
//if(this->context)
|
||||
//{
|
||||
// this->enabledToggle->setState(this->context->enabled);
|
||||
//}
|
||||
}
|
||||
39
Source/hoc-clk/overlay/src/ui/gui/main_gui.h
Normal file
39
Source/hoc-clk/overlay/src/ui/gui/main_gui.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base_menu_gui.h"
|
||||
|
||||
class MainGui : public BaseMenuGui
|
||||
{
|
||||
public:
|
||||
MainGui() {}
|
||||
~MainGui() {}
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
};
|
||||
1748
Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp
Normal file
1748
Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp
Normal file
File diff suppressed because it is too large
Load Diff
72
Source/hoc-clk/overlay/src/ui/gui/misc_gui.h
Normal file
72
Source/hoc-clk/overlay/src/ui/gui/misc_gui.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "../../ipc.h"
|
||||
#include "base_menu_gui.h"
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "freq_choice_gui.h"
|
||||
#include "value_choice_gui.h"
|
||||
class MiscGui : public BaseMenuGui
|
||||
{
|
||||
public:
|
||||
MiscGui();
|
||||
~MiscGui();
|
||||
void listUI() override;
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
SysClkConfigValueList* configList;
|
||||
std::map<SysClkConfigValue, tsl::elm::ListItem*> configButtons;
|
||||
std::map<SysClkConfigValue, ValueRange> configRanges;
|
||||
std::map<SysClkConfigValue, std::vector<NamedValue>> configNamedValues;
|
||||
std::map<SysClkConfigValue, tsl::elm::ToggleListItem*> configToggles;
|
||||
std::map<SysClkConfigValue, std::tuple<tsl::elm::TrackBar*, tsl::elm::ListItem*, std::vector<uint64_t>>> configTrackbars;
|
||||
std::set<SysClkConfigValue> configButtonSKeys;
|
||||
std::map<SysClkConfigValue, std::string> configButtonSSubtext;
|
||||
|
||||
void addConfigToggle(SysClkConfigValue configVal, const char* altName);
|
||||
void addConfigButton(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true);
|
||||
|
||||
void addConfigButtonS(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
const ValueThresholds* thresholds,
|
||||
const std::map<uint32_t, std::string>& labels = {},
|
||||
const std::vector<NamedValue>& namedValues = {},
|
||||
bool showDefaultValue = true,
|
||||
const char* subText = nullptr);
|
||||
void addFreqButton(SysClkConfigValue configVal,
|
||||
const char* altName,
|
||||
SysClkModule module,
|
||||
const std::map<uint32_t, std::string>& labels = {});
|
||||
void updateConfigToggles();
|
||||
|
||||
tsl::elm::ToggleListItem* enabledToggle;
|
||||
u8 frameCounter = 60;
|
||||
};
|
||||
126
Source/hoc-clk/overlay/src/ui/gui/ult_ext.h
Normal file
126
Source/hoc-clk/overlay/src/ui/gui/ult_ext.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <tesla.hpp>
|
||||
|
||||
class ImageElement : public tsl::elm::ListItem {
|
||||
private:
|
||||
const uint8_t* imgData;
|
||||
uint32_t imgWidth, imgHeight;
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
ImageElement(const uint8_t* data, uint32_t w, uint32_t h)
|
||||
: tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
|
||||
// Draw image centered horizontally
|
||||
u16 centerX = this->getX() + (this->getWidth() - imgWidth) / 2;
|
||||
renderer->drawBitmap(
|
||||
centerX,
|
||||
this->getY() + 10,
|
||||
imgWidth,
|
||||
imgHeight,
|
||||
imgData
|
||||
);
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
// Take up no space when hidden
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
// Normal layout when visible
|
||||
tsl::elm::ListItem::layout(parentX, parentY, parentWidth, parentHeight);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawHighlight(tsl::gfx::Renderer *renderer) override {
|
||||
// Do nothing - no highlight
|
||||
}
|
||||
|
||||
virtual bool onClick(u64 keys) override {
|
||||
return false; // Non-clickable
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr; // Make it non-focusable
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCategoryHeader : public tsl::elm::CategoryHeader {
|
||||
private:
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
HideableCategoryHeader(const std::string& title)
|
||||
: tsl::elm::CategoryHeader(title), visible(true) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
tsl::elm::CategoryHeader::draw(renderer);
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
tsl::elm::CategoryHeader::layout(parentX, parentY, parentWidth, parentHeight);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCustomDrawer : public tsl::elm::Element {
|
||||
private:
|
||||
bool visible;
|
||||
u32 height;
|
||||
|
||||
public:
|
||||
HideableCustomDrawer(u32 h)
|
||||
: Element(), visible(true), height(h) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
// Empty drawer - just for spacing
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
this->setBoundaries(parentX, parentY, parentWidth, height);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
200
Source/hoc-clk/overlay/src/ui/gui/value_choice_gui.cpp
Normal file
200
Source/hoc-clk/overlay/src/ui/gui/value_choice_gui.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "value_choice_gui.h"
|
||||
#include "../format.h"
|
||||
#include "fatal_gui.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
ValueChoiceGui::ValueChoiceGui(std::uint32_t selectedValue,
|
||||
const ValueRange& range,
|
||||
const std::string& categoryName,
|
||||
ValueChoiceListener listener,
|
||||
const ValueThresholds& thresholds,
|
||||
bool enableThresholds,
|
||||
std::map<std::uint32_t, std::string> labels,
|
||||
std::vector<NamedValue> namedValues,
|
||||
bool showDefaultValue,
|
||||
bool showDNO)
|
||||
: selectedValue(selectedValue),
|
||||
range(range),
|
||||
categoryName(categoryName),
|
||||
listener(listener),
|
||||
thresholds(thresholds),
|
||||
enableThresholds(enableThresholds),
|
||||
labels(labels),
|
||||
namedValues(namedValues),
|
||||
showDefaultValue(showDefaultValue),
|
||||
showDNO(showDNO)
|
||||
{
|
||||
}
|
||||
|
||||
ValueChoiceGui::~ValueChoiceGui()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ValueChoiceGui::formatValue(std::uint32_t value)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if(showDefaultValue) {
|
||||
if (value == 0) {
|
||||
return this->showDNO ? FREQ_DEFAULT_TEXT : VALUE_DEFAULT_TEXT;
|
||||
}
|
||||
}
|
||||
double displayValue = static_cast<double>(value) / static_cast<double>(range.divisor);
|
||||
oss << std::fixed << std::setprecision(range.decimalPlaces) << displayValue;
|
||||
if (!range.suffix.empty()) {
|
||||
oss << " " << range.suffix;
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
int ValueChoiceGui::getSafetyLevel(std::uint32_t value)
|
||||
{
|
||||
if(thresholds.warning == 0 && thresholds.danger == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (value > thresholds.danger) {
|
||||
return 2;
|
||||
}
|
||||
if (value > thresholds.warning) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* ValueChoiceGui::createValueListItem(std::uint32_t value, bool selected, int safety)
|
||||
{
|
||||
std::string text = formatValue(value);
|
||||
std::string rightText = "";
|
||||
|
||||
auto it = labels.find(value);
|
||||
if (it != labels.end()) {
|
||||
rightText = it->second;
|
||||
}
|
||||
|
||||
if (selected) {
|
||||
const_cast<std::string&>(rightText) = "\uE14B";
|
||||
}
|
||||
|
||||
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() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, value](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(value)) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return listItem;
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* ValueChoiceGui::createNamedValueListItem(const NamedValue& namedValue, bool selected, int safety)
|
||||
{
|
||||
std::string text = namedValue.name;
|
||||
if (selected) {
|
||||
const_cast<std::string&>(namedValue.rightText) = "\uE14B";
|
||||
}
|
||||
|
||||
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(text, namedValue.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;
|
||||
}
|
||||
|
||||
if (!namedValue.rightText.empty() && !selected)
|
||||
listItem->setValueColor(tsl::Color(180, 180, 180, 255));
|
||||
else if(selected)
|
||||
listItem->setValueColor(tsl::infoTextColor);
|
||||
|
||||
listItem->setClickListener([this, value = namedValue.value](u64 keys)
|
||||
{
|
||||
if ((keys & HidNpadButton_A) == HidNpadButton_A && this->listener) {
|
||||
if (this->listener(value)) {
|
||||
tsl::goBack();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return listItem;
|
||||
}
|
||||
|
||||
void ValueChoiceGui::listUI()
|
||||
{
|
||||
if (!categoryName.empty()) {
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader(categoryName));
|
||||
}
|
||||
|
||||
if (showDefaultValue) {
|
||||
this->listElement->addItem(this->createValueListItem(0, this->selectedValue == 0, 0));
|
||||
}
|
||||
for (const auto& namedValue : namedValues) {
|
||||
int safety = enableThresholds ? getSafetyLevel(namedValue.value) : 0;
|
||||
bool selected = (namedValue.value == this->selectedValue);
|
||||
this->listElement->addItem(this->createNamedValueListItem(namedValue, selected, safety));
|
||||
}
|
||||
|
||||
if (namedValues.empty()) {
|
||||
for (std::uint32_t value = range.min; value <= range.max; value += range.step)
|
||||
{
|
||||
int safety = getSafetyLevel(value);
|
||||
bool selected = (value == this->selectedValue);
|
||||
this->listElement->addItem(this->createValueListItem(value, selected, safety));
|
||||
}
|
||||
}
|
||||
|
||||
this->listElement->jumpToItem("", "\uE14B");
|
||||
}
|
||||
114
Source/hoc-clk/overlay/src/ui/gui/value_choice_gui.h
Normal file
114
Source/hoc-clk/overlay/src/ui/gui/value_choice_gui.h
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#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;
|
||||
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) {}
|
||||
};
|
||||
|
||||
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) {}
|
||||
};
|
||||
|
||||
struct NamedValue {
|
||||
std::string name;
|
||||
std::uint32_t value;
|
||||
std::string rightText;
|
||||
|
||||
NamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
||||
: name(name), value(value), rightText(rightText) {}
|
||||
};
|
||||
|
||||
class ValueChoiceGui : public BaseMenuGui
|
||||
{
|
||||
protected:
|
||||
std::uint32_t selectedValue;
|
||||
ValueRange range;
|
||||
std::string categoryName;
|
||||
ValueChoiceListener listener;
|
||||
ValueThresholds thresholds;
|
||||
bool enableThresholds;
|
||||
std::map<std::uint32_t, std::string> labels;
|
||||
|
||||
std::vector<NamedValue> namedValues;
|
||||
bool showDefaultValue = true;
|
||||
bool showDNO = false;
|
||||
tsl::elm::ListItem* createValueListItem(std::uint32_t value, bool selected, int safety);
|
||||
tsl::elm::ListItem* createNamedValueListItem(const NamedValue& namedValue, 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 = {},
|
||||
std::vector<NamedValue> namedValues = {},
|
||||
bool showDefaultValue = true,
|
||||
bool showDNO = false);
|
||||
~ValueChoiceGui();
|
||||
|
||||
void addNamedValue(const std::string& name, std::uint32_t value, const std::string& rightText = "")
|
||||
{
|
||||
namedValues.emplace_back(name, value, rightText);
|
||||
}
|
||||
|
||||
void addNamedValues(const std::vector<NamedValue>& values)
|
||||
{
|
||||
namedValues.insert(namedValues.end(), values.begin(), values.end());
|
||||
}
|
||||
|
||||
void clearNamedValues()
|
||||
{
|
||||
namedValues.clear();
|
||||
}
|
||||
|
||||
void setShowDefaultValue(bool show)
|
||||
{
|
||||
showDefaultValue = show;
|
||||
}
|
||||
|
||||
void listUI() override;
|
||||
};
|
||||
37
Source/hoc-clk/overlay/src/ui/style.h
Normal file
37
Source/hoc-clk/overlay/src/ui/style.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tesla.hpp>
|
||||
|
||||
#define TEXT_COLOR tsl::gfx::Renderer::a(0xFFFF)
|
||||
#define DESC_COLOR tsl::gfx::Renderer::a({ 0xC, 0xC, 0xC, 0xF })
|
||||
#define VALUE_COLOR tsl::gfx::Renderer::a({ 0x5, 0xC, 0xA, 0xF })
|
||||
#define SMALL_TEXT_SIZE 15
|
||||
#define LABEL_SPACING 7
|
||||
#define LABEL_FONT_SIZE 15
|
||||
Reference in New Issue
Block a user