diff --git a/Source/sys-clk/common/include/SaltyNX.h b/Source/sys-clk/common/include/SaltyNX.h
index bc590373..06ebc50b 100644
--- a/Source/sys-clk/common/include/SaltyNX.h
+++ b/Source/sys-clk/common/include/SaltyNX.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) MasaGratoR
+ *
+ * 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 .
+ *
+ */
+
#pragma once
#include "ipc.h"
diff --git a/Source/sys-clk/common/include/ipc.h b/Source/sys-clk/common/include/ipc.h
index 905b30b4..3015af32 100644
--- a/Source/sys-clk/common/include/ipc.h
+++ b/Source/sys-clk/common/include/ipc.h
@@ -2,7 +2,7 @@
* @file ipc.h
* @brief Inter-process communication handling
* @author plutoo
- * @copyright libnx Authors
+ * @copyright libnx Authors (ISC License)
*/
#pragma once
#include
diff --git a/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.cpp b/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.cpp
index 568ba7ea..8225970a 100644
--- a/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.cpp
+++ b/Source/sys-clk/overlay/src/ui/gui/base_menu_gui.cpp
@@ -58,7 +58,7 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
// 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"
+ "App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "BAT", "PMIC", "FAN", "DISP", "FPS"
};
static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1};
@@ -168,8 +168,8 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
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
-
- renderer->drawString(displayStrings[26], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // disp volt
+ 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;
}
@@ -286,8 +286,12 @@ void BaseMenuGui::refresh()
sprintf(displayStrings[25], "%u Hz", context->realFreqs[HorizonOCModule_Display]);
- //sprintf(displayStrings[26], "%u", context->speedos[HorizonOCSpeedo_CPU]);
-
+ if(context->fps == 254) {
+ strcpy(displayStrings[26], "N/A");
+ } else {
+ memset(displayStrings[26], 0, sizeof(displayStrings[26]));
+ sprintf(displayStrings[26], "%u", context->fps);
+ }
}
tsl::elm::Element* BaseMenuGui::baseUI()
diff --git a/Source/sys-clk/sysmodule/src/clock_manager.cpp b/Source/sys-clk/sysmodule/src/clock_manager.cpp
index 886b133d..b7441d42 100644
--- a/Source/sys-clk/sysmodule/src/clock_manager.cpp
+++ b/Source/sys-clk/sysmodule/src/clock_manager.cpp
@@ -632,7 +632,6 @@ void ClockManager::HandleFreqReset(SysClkModule module, bool isBoost) {
}
void ClockManager::SetClocks(bool isBoost) {
- FileUtils::LogLine("FPS: %d", this->saltyNXIntegration->GetFPS());
std::uint32_t targetHz = 0;
std::uint32_t maxHz = 0;
std::uint32_t nearestHz = 0;
@@ -892,6 +891,8 @@ bool ClockManager::RefreshContext()
if(Board::GetConsoleType() != HorizonOCConsoleType_Hoag)
Board::SetDisplayRefreshDockedState(this->context->profile == SysClkProfile_Docked);
+ this->context->fps = saltyNXIntegration->GetFPS();
+
return hasChanged;
}
diff --git a/Source/sys-clk/sysmodule/src/integrations.cpp b/Source/sys-clk/sysmodule/src/integrations.cpp
index 9560c102..357c8bcd 100644
--- a/Source/sys-clk/sysmodule/src/integrations.cpp
+++ b/Source/sys-clk/sysmodule/src/integrations.cpp
@@ -32,9 +32,12 @@ bool SysDockIntegration::getCurrentSysDockState() {
return false;
}
}
-
+bool wasSaltyNxLoaded = false;
SaltyNXIntegration::SaltyNXIntegration() {
- if(!CheckPort()) return;
+ if(!CheckPort()) {
+ return;
+ }
+ wasSaltyNxLoaded = true;
LoadSharedMemory();
}
@@ -42,22 +45,15 @@ SaltyNXIntegration::SaltyNXIntegration() {
//Check if SaltyNX is working
bool SaltyNXIntegration::CheckPort () {
Handle saltysd;
- for (int i = 0; i < 67; i++) {
- if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
- svcCloseHandle(saltysd);
- break;
- }
- else {
- if (i == 66) return false;
- svcSleepThread(1'000'000);
- }
- }
- for (int i = 0; i < 67; i++) {
+ for (int i = 0; i < 500; i++) {
if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
svcCloseHandle(saltysd);
return true;
}
- else svcSleepThread(1'000'000);
+ else {
+ if (i == 499) return false;
+ svcSleepThread(100'000'000);
+ }
}
return false;
}
@@ -90,15 +86,15 @@ void SaltyNXIntegration::searchSharedMemoryBlock(uintptr_t base) {
u64 prevTid = 0;
u8 SaltyNXIntegration::GetFPS() {
- if(ProcessManagement::GetCurrentApplicationId() <= 0x010000000000FFFFULL) return 254; // only try to read fps for games, not system apps
- if(prevTid != ProcessManagement::GetCurrentApplicationId()) {
- uintptr_t base = (uintptr_t)shmemGetAddr(&_sharedmemory);
- searchSharedMemoryBlock(base);
- prevTid = ProcessManagement::GetCurrentApplicationId();
- }
- if (NxFps) {
- return NxFps->FPS;
- } else {
- return 254;
+ u64 tid = ProcessManagement::GetCurrentApplicationId();
+ if(tid == 0 || wasSaltyNxLoaded == false)
+ return 254; // only try to read fps for games, not system apps
+
+ if(prevTid != tid) {
+ uintptr_t base = (uintptr_t)shmemGetAddr(&_sharedmemory);
+ searchSharedMemoryBlock(base);
+ prevTid = tid;
}
+
+ return NxFps ? NxFps->FPS : 254;
}
\ No newline at end of file
diff --git a/Source/sys-clk/sysmodule/src/main.cpp b/Source/sys-clk/sysmodule/src/main.cpp
index 3821a564..3cf92c9c 100644
--- a/Source/sys-clk/sysmodule/src/main.cpp
+++ b/Source/sys-clk/sysmodule/src/main.cpp
@@ -65,6 +65,8 @@ extern "C"
fake_heap_start = (char*)addr;
fake_heap_end = (char*)addr + size;
+
+ virtmemSetup();
}
void __appInit(void)
@@ -91,8 +93,6 @@ extern "C"
rc = i2cInitialize();
if (R_FAILED(rc))
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
-
- virtmemSetup();
}
void __appExit(void)