Merge sys-clk-oc and add upto 2903 clocks (please don't use)

I do have to come up with a better name too...
This commit is contained in:
souldbminersmwc
2025-08-22 18:31:38 -04:00
parent 822556e6e4
commit 4738eea080
289 changed files with 50229 additions and 4772 deletions

View File

@@ -0,0 +1,23 @@
/*
* --------------------------------------------------------------------------
* "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
#if defined(__cplusplus)
extern "C"
{
#endif
#include <sysclk.h>
#include <sysclk/client/ipc.h>
#if defined(__cplusplus)
}
#endif

View File

@@ -0,0 +1,75 @@
/*
* --------------------------------------------------------------------------
* "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
* --------------------------------------------------------------------------
*/
#define TESLA_INIT_IMPL
#include <tesla.hpp>
#include "ui/gui/fatal_gui.h"
#include "ui/gui/main_gui.h"
class AppOverlay : public tsl::Overlay
{
public:
AppOverlay() {}
~AppOverlay() {}
virtual void exitServices() override {
sysclkIpcExit();
}
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override
{
uint32_t apiVersion;
smInitialize();
tsl::hlp::ScopeGuard smGuard([] { smExit(); });
if(!sysclkIpcRunning())
{
return initially<FatalGui>(
"sys-clk is not running.\n\n"
"\n"
"Please make sure it is correctly\n\n"
"installed and enabled.",
""
);
}
if(R_FAILED(sysclkIpcInitialize()) || R_FAILED(sysclkIpcGetAPIVersion(&apiVersion)))
{
return initially<FatalGui>(
"Could not connect to sys-clk.\n\n"
"\n"
"Please make sure it is correctly\n\n"
"installed and enabled.",
""
);
}
if(SYSCLK_IPC_API_VERSION != apiVersion)
{
return initially<FatalGui>(
"Overlay not compatible with\n\n"
"the running sys-clk version.\n\n"
"\n"
"Please make sure everything is\n\n"
"installed and up to date.",
""
);
}
return initially<MainGui>();
}
};
int main(int argc, char **argv)
{
return tsl::loop<AppOverlay>(argc, argv);
}

View File

@@ -0,0 +1,31 @@
/*
* --------------------------------------------------------------------------
* "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(225) {
this->gui = gui;
}
void draw(tsl::gfx::Renderer* renderer) override
{
tsl::elm::HeaderOverlayFrame::draw(renderer);
this->gui->preDraw(renderer);
}
protected:
BaseGui* gui;
};

View File

@@ -0,0 +1,28 @@
/*
* --------------------------------------------------------------------------
* "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>
#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); }

View File

@@ -0,0 +1,114 @@
/*
* --------------------------------------------------------------------------
* "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"
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;
}
tsl::changeTo<FreqChoiceGui>(this->profileList->mhzMap[profile][module] * 1000000, hzList, hzCount, [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;
});
}
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;
}
return false;
});
this->listElement->addItem(listItem);
}
void AppProfileGui::addProfileUI(SysClkProfile profile)
{
this->listElement->addItem(new tsl::elm::CategoryHeader(sysclkFormatProfile(profile, true)));
this->addModuleListItem(profile, SysClkModule_CPU);
this->addModuleListItem(profile, SysClkModule_GPU);
this->addModuleListItem(profile, SysClkModule_MEM);
}
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)
{
tsl::changeTo<FatalGui>(
"Application changed\n\n"
"\n"
"The running application changed\n\n"
"while editing was going on.",
""
);
}
}

View File

@@ -0,0 +1,33 @@
/*
* --------------------------------------------------------------------------
* "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"
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 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;
};

View File

@@ -0,0 +1,46 @@
/*
* --------------------------------------------------------------------------
* "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 "logo_rgba_bin.h"
#define LOGO_WIDTH 110
#define LOGO_HEIGHT 39
#define LOGO_X 18
#define LOGO_Y 21
#define LOGO_LABEL_X (LOGO_X + LOGO_WIDTH + 6)
#define LOGO_LABEL_Y 50
#define LOGO_LABEL_FONT_SIZE 28
#define VERSION_X (LOGO_LABEL_X + 110)
#define VERSION_Y LOGO_LABEL_Y
#define VERSION_FONT_SIZE 15
void BaseGui::preDraw(tsl::gfx::Renderer* renderer)
{
renderer->drawBitmap(LOGO_X, LOGO_Y, LOGO_WIDTH, LOGO_HEIGHT, logo_rgba_bin);
renderer->drawString("overlay", false, LOGO_LABEL_X, LOGO_LABEL_Y, LOGO_LABEL_FONT_SIZE, TEXT_COLOR);
renderer->drawString(TARGET_VERSION, false, VERSION_X, VERSION_Y, VERSION_FONT_SIZE, DESC_COLOR);
}
tsl::elm::Element* BaseGui::createUI()
{
BaseFrame* rootFrame = new BaseFrame(this);
rootFrame->setContent(this->baseUI());
return rootFrame;
}
void BaseGui::update()
{
this->refresh();
}

View File

@@ -0,0 +1,27 @@
/*
* --------------------------------------------------------------------------
* "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 "../style.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() {}
};

View File

@@ -0,0 +1,150 @@
/*
* --------------------------------------------------------------------------
* "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"
BaseMenuGui::BaseMenuGui()
{
this->context = nullptr;
this->lastContextUpdate = 0;
this->listElement = nullptr;
}
BaseMenuGui::~BaseMenuGui()
{
if(this->context)
{
delete this->context;
}
}
void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer)
{
BaseGui::preDraw(renderer);
if(this->context)
{
char buf[32];
std::uint32_t y = 85;
renderer->drawString("App ID: ", false, 20, y, SMALL_TEXT_SIZE, DESC_COLOR);
snprintf(buf, sizeof(buf), "%016lX", context->applicationId);
renderer->drawString(buf, false, 81, y, SMALL_TEXT_SIZE, VALUE_COLOR);
renderer->drawString("Profile: ", false, 246, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString(sysclkFormatProfile(context->profile, true), false, 302, y, SMALL_TEXT_SIZE, VALUE_COLOR);
y += 30;
static struct
{
SysClkModule m;
std::uint32_t x;
} freqOffsets[SysClkModule_EnumMax] = {
{ SysClkModule_CPU, 61 },
{ SysClkModule_GPU, 204 },
{ SysClkModule_MEM, 342 },
};
for(unsigned int i = 0; i < SysClkModule_EnumMax; i++)
{
std::uint32_t hz = this->context->freqs[freqOffsets[i].m];
snprintf(buf, sizeof(buf), "%u.%u MHz", hz / 1000000, hz / 100000 - hz / 1000000 * 10);
renderer->drawString(buf, false, freqOffsets[i].x, y, SMALL_TEXT_SIZE, VALUE_COLOR);
}
renderer->drawString("CPU:", false, 20, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("GPU:", false, 162, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("MEM:", false, 295, y, SMALL_TEXT_SIZE, DESC_COLOR);
y += 25;
for(unsigned int i = 0; i < SysClkModule_EnumMax; i++)
{
std::uint32_t hz = this->context->realFreqs[freqOffsets[i].m];
snprintf(buf, sizeof(buf), "%u.%u MHz", hz / 1000000, hz / 100000 - hz / 1000000 * 10);
renderer->drawString(buf, false, freqOffsets[i].x, y, SMALL_TEXT_SIZE, VALUE_COLOR);
}
y += 25;
static struct
{
SysClkThermalSensor s;
std::uint32_t x;
} tempOffsets[SysClkModule_EnumMax] = {
{ SysClkThermalSensor_SOC, 61 },
{ SysClkThermalSensor_PCB, 204 },
{ SysClkThermalSensor_Skin, 342 },
};
renderer->drawString("SOC:", false, 20, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("PCB:", false, 166, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("Skin:", false, 303, y, SMALL_TEXT_SIZE, DESC_COLOR);
for(unsigned int i = 0; i < SysClkModule_EnumMax; i++)
{
std::uint32_t millis = this->context->temps[tempOffsets[i].s];
snprintf(buf, sizeof(buf), "%u.%u °C", millis / 1000, (millis - millis / 1000 * 1000) / 100);
renderer->drawString(buf, false, tempOffsets[i].x, y, SMALL_TEXT_SIZE, VALUE_COLOR);
}
y += 30;
static struct
{
SysClkPowerSensor s;
std::uint32_t x;
} powerOffsets[SysClkPowerSensor_EnumMax] = {
{ SysClkPowerSensor_Now, 204 },
{ SysClkPowerSensor_Avg, 342 },
};
renderer->drawString("Battery Power", false, 20, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("Now:", false, 160, y, SMALL_TEXT_SIZE, DESC_COLOR);
renderer->drawString("Avg:", false, 304, y, SMALL_TEXT_SIZE, DESC_COLOR);
for(unsigned int i = 0; i < SysClkPowerSensor_EnumMax; i++)
{
std::uint32_t mw = this->context->power[powerOffsets[i].s];
snprintf(buf, sizeof(buf), "%d mW", mw);
renderer->drawString(buf, false, powerOffsets[i].x, y, SMALL_TEXT_SIZE, VALUE_COLOR);
}
}
}
void BaseMenuGui::refresh()
{
std::uint64_t ticks = armGetSystemTick();
if(armTicksToNs(ticks - this->lastContextUpdate) > 500000000UL)
{
this->lastContextUpdate = ticks;
if(!this->context)
{
this->context = new SysClkContext;
}
Result rc = sysclkIpcGetCurrentContext(this->context);
if(R_FAILED(rc))
{
FatalGui::openWithResultCode("sysclkIpcGetCurrentContext", rc);
return;
}
}
}
tsl::elm::Element* BaseMenuGui::baseUI()
{
tsl::elm::List* list = new tsl::elm::List();
this->listElement = list;
this->listUI();
return list;
}

View File

@@ -0,0 +1,30 @@
/*
* --------------------------------------------------------------------------
* "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:
SysClkContext* context;
std::uint64_t lastContextUpdate;
tsl::elm::List* listElement;
public:
BaseMenuGui();
~BaseMenuGui();
void preDraw(tsl::gfx::Renderer* renderer) override;
tsl::elm::Element* baseUI() override;
void refresh() override;
virtual void listUI() = 0;
};

View File

@@ -0,0 +1,67 @@
/*
* --------------------------------------------------------------------------
* "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 sys-clk.\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;
}

View File

@@ -0,0 +1,29 @@
/*
* --------------------------------------------------------------------------
* "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);
};

View File

@@ -0,0 +1,52 @@
/*
* --------------------------------------------------------------------------
* "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, FreqChoiceListener listener)
{
this->selectedHz = selectedHz;
this->hzList = hzList;
this->hzCount = hzCount;
this->listener = listener;
}
tsl::elm::ListItem* FreqChoiceGui::createFreqListItem(std::uint32_t hz, bool selected)
{
tsl::elm::ListItem* listItem = new tsl::elm::ListItem(formatListFreqHz(hz));
listItem->setValue(selected ? "\uE14B" : "");
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()
{
this->listElement->addItem(this->createFreqListItem(0, this->selectedHz == 0));
for(std::uint32_t i = 0; i < this->hzCount; i++) {
std::uint32_t hz = this->hzList[i];
this->listElement->addItem(this->createFreqListItem(hz, (hz / 1000000) == (this->selectedHz / 1000000)));
}
}

View File

@@ -0,0 +1,34 @@
/*
* --------------------------------------------------------------------------
* "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_menu_gui.h"
using FreqChoiceListener = std::function<bool(std::uint32_t hz)>;
#define FREQ_DEFAULT_TEXT "Do not override"
class FreqChoiceGui : public BaseMenuGui
{
protected:
std::uint32_t selectedHz;
std::uint32_t* hzList;
std::uint32_t hzCount;
FreqChoiceListener listener;
tsl::elm::ListItem* createFreqListItem(std::uint32_t hz, bool selected);
public:
FreqChoiceGui(std::uint32_t selectedHz, std::uint32_t* hzList, std::uint32_t hzCount, FreqChoiceListener listener);
~FreqChoiceGui() {}
void listUI() override;
};

View File

@@ -0,0 +1,92 @@
/*
* --------------------------------------------------------------------------
* "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 "global_override_gui.h"
#include "fatal_gui.h"
#include "../format.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;
}
tsl::changeTo<FreqChoiceGui>(this->context->overrideFreqs[module], hzList, hzCount, [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;
});
}
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;
}
return false;
});
this->listElement->addItem(listItem);
this->listItems[module] = listItem;
}
void GlobalOverrideGui::listUI()
{
this->addModuleListItem(SysClkModule_CPU);
this->addModuleListItem(SysClkModule_GPU);
this->addModuleListItem(SysClkModule_MEM);
}
void GlobalOverrideGui::refresh()
{
BaseMenuGui::refresh();
if(this->context)
{
for(std::uint16_t m = 0; m < SysClkModule_EnumMax; m++)
{
if(this->listItems[m] != nullptr && this->listHz[m] != this->context->overrideFreqs[m])
{
this->listItems[m]->setValue(formatListFreqHz(this->context->overrideFreqs[m]));
this->listHz[m] = this->context->overrideFreqs[m];
}
}
}
}

View File

@@ -0,0 +1,31 @@
/*
* --------------------------------------------------------------------------
* "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"
class GlobalOverrideGui : public BaseMenuGui
{
protected:
tsl::elm::ListItem* listItems[SysClkModule_EnumMax];
std::uint32_t listHz[SysClkModule_EnumMax];
void openFreqChoiceGui(SysClkModule module);
void addModuleListItem(SysClkModule module);
public:
GlobalOverrideGui();
~GlobalOverrideGui() {}
void listUI() override;
void refresh() override;
};

View File

@@ -0,0 +1,67 @@
/*
* --------------------------------------------------------------------------
* "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"
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);
this->listElement->addItem(new tsl::elm::CategoryHeader("Advanced"));
tsl::elm::ListItem* globalOverrideItem = new tsl::elm::ListItem("Temporary overrides");
globalOverrideItem->setClickListener([this](u64 keys) {
if((keys & HidNpadButton_A) == HidNpadButton_A)
{
tsl::changeTo<GlobalOverrideGui>();
return true;
}
return false;
});
this->listElement->addItem(globalOverrideItem);
}
void MainGui::refresh()
{
BaseMenuGui::refresh();
if(this->context)
{
this->enabledToggle->setState(this->context->enabled);
}
}

View File

@@ -0,0 +1,25 @@
/*
* --------------------------------------------------------------------------
* "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
{
protected:
tsl::elm::ToggleListItem* enabledToggle;
public:
MainGui() {}
~MainGui() {}
void listUI() override;
void refresh() override;
};

View File

@@ -0,0 +1,20 @@
/*
* --------------------------------------------------------------------------
* "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