sysclk: fix up saltynx integration
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user