sysclk: fix up saltynx integration
This commit is contained in:
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @file ipc.h
|
* @file ipc.h
|
||||||
* @brief Inter-process communication handling
|
* @brief Inter-process communication handling
|
||||||
* @author plutoo
|
* @author plutoo
|
||||||
* @copyright libnx Authors
|
* @copyright libnx Authors (ISC License)
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
|
|||||||
|
|
||||||
// All constants pre-calculated and cached
|
// All constants pre-calculated and cached
|
||||||
static constexpr const char* const labels[] = {
|
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};
|
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[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[23], false, positions[2] - 2, y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Bat Age
|
||||||
|
|
||||||
|
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); // disp volt
|
renderer->drawString(displayStrings[26], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // FPS
|
||||||
|
|
||||||
y+=20;
|
y+=20;
|
||||||
}
|
}
|
||||||
@@ -286,8 +286,12 @@ void BaseMenuGui::refresh()
|
|||||||
|
|
||||||
sprintf(displayStrings[25], "%u Hz", context->realFreqs[HorizonOCModule_Display]);
|
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()
|
tsl::elm::Element* BaseMenuGui::baseUI()
|
||||||
|
|||||||
@@ -632,7 +632,6 @@ void ClockManager::HandleFreqReset(SysClkModule module, bool isBoost) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClockManager::SetClocks(bool isBoost) {
|
void ClockManager::SetClocks(bool isBoost) {
|
||||||
FileUtils::LogLine("FPS: %d", this->saltyNXIntegration->GetFPS());
|
|
||||||
std::uint32_t targetHz = 0;
|
std::uint32_t targetHz = 0;
|
||||||
std::uint32_t maxHz = 0;
|
std::uint32_t maxHz = 0;
|
||||||
std::uint32_t nearestHz = 0;
|
std::uint32_t nearestHz = 0;
|
||||||
@@ -892,6 +891,8 @@ bool ClockManager::RefreshContext()
|
|||||||
if(Board::GetConsoleType() != HorizonOCConsoleType_Hoag)
|
if(Board::GetConsoleType() != HorizonOCConsoleType_Hoag)
|
||||||
Board::SetDisplayRefreshDockedState(this->context->profile == SysClkProfile_Docked);
|
Board::SetDisplayRefreshDockedState(this->context->profile == SysClkProfile_Docked);
|
||||||
|
|
||||||
|
this->context->fps = saltyNXIntegration->GetFPS();
|
||||||
|
|
||||||
return hasChanged;
|
return hasChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,12 @@ bool SysDockIntegration::getCurrentSysDockState() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool wasSaltyNxLoaded = false;
|
||||||
SaltyNXIntegration::SaltyNXIntegration() {
|
SaltyNXIntegration::SaltyNXIntegration() {
|
||||||
if(!CheckPort()) return;
|
if(!CheckPort()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wasSaltyNxLoaded = true;
|
||||||
LoadSharedMemory();
|
LoadSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,22 +45,15 @@ SaltyNXIntegration::SaltyNXIntegration() {
|
|||||||
//Check if SaltyNX is working
|
//Check if SaltyNX is working
|
||||||
bool SaltyNXIntegration::CheckPort () {
|
bool SaltyNXIntegration::CheckPort () {
|
||||||
Handle saltysd;
|
Handle saltysd;
|
||||||
for (int i = 0; i < 67; i++) {
|
for (int i = 0; i < 500; 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++) {
|
|
||||||
if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
|
if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
|
||||||
svcCloseHandle(saltysd);
|
svcCloseHandle(saltysd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else svcSleepThread(1'000'000);
|
else {
|
||||||
|
if (i == 499) return false;
|
||||||
|
svcSleepThread(100'000'000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -90,15 +86,15 @@ void SaltyNXIntegration::searchSharedMemoryBlock(uintptr_t base) {
|
|||||||
u64 prevTid = 0;
|
u64 prevTid = 0;
|
||||||
|
|
||||||
u8 SaltyNXIntegration::GetFPS() {
|
u8 SaltyNXIntegration::GetFPS() {
|
||||||
if(ProcessManagement::GetCurrentApplicationId() <= 0x010000000000FFFFULL) return 254; // only try to read fps for games, not system apps
|
u64 tid = ProcessManagement::GetCurrentApplicationId();
|
||||||
if(prevTid != ProcessManagement::GetCurrentApplicationId()) {
|
if(tid == 0 || wasSaltyNxLoaded == false)
|
||||||
uintptr_t base = (uintptr_t)shmemGetAddr(&_sharedmemory);
|
return 254; // only try to read fps for games, not system apps
|
||||||
searchSharedMemoryBlock(base);
|
|
||||||
prevTid = ProcessManagement::GetCurrentApplicationId();
|
if(prevTid != tid) {
|
||||||
}
|
uintptr_t base = (uintptr_t)shmemGetAddr(&_sharedmemory);
|
||||||
if (NxFps) {
|
searchSharedMemoryBlock(base);
|
||||||
return NxFps->FPS;
|
prevTid = tid;
|
||||||
} else {
|
|
||||||
return 254;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NxFps ? NxFps->FPS : 254;
|
||||||
}
|
}
|
||||||
@@ -65,6 +65,8 @@ extern "C"
|
|||||||
|
|
||||||
fake_heap_start = (char*)addr;
|
fake_heap_start = (char*)addr;
|
||||||
fake_heap_end = (char*)addr + size;
|
fake_heap_end = (char*)addr + size;
|
||||||
|
|
||||||
|
virtmemSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __appInit(void)
|
void __appInit(void)
|
||||||
@@ -91,8 +93,6 @@ extern "C"
|
|||||||
rc = i2cInitialize();
|
rc = i2cInitialize();
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||||
|
|
||||||
virtmemSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __appExit(void)
|
void __appExit(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user