Skip to content

Commit

Permalink
Import patches from akari 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRouletteBoi committed Apr 16, 2022
1 parent 4554455 commit db0ec7d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 34 deletions.
17 changes: 8 additions & 9 deletions src/Core/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@ Helpers::Helpers()

void Helpers::OnUpdate()
{
// Update plugins and widgets pointers
system_plugin = vsh::paf::View::Find("system_plugin");
game_plugin = vsh::paf::View::Find("game_plugin");
game_ext_plugin = vsh::paf::View::Find("game_ext_plugin");
game_plugin = vsh::paf::View::Find("game_plugin");
system_plugin = vsh::paf::View::Find("system_plugin");
xmb_plugin = vsh::paf::View::Find("xmb_plugin");

page_autooff_guide = system_plugin ? system_plugin->FindWidget("page_autooff_guide") : nullptr;


MonitorGameState();

#ifdef LAUNCHER_DEBUG
if (g_Input.IsButtonBinds(CInput::BUTTON_L1, CInput::BUTTON_PAD_UP))
TakeScreenshot();
#endif // LAUNCHER_DEBUG
}

void Helpers::MonitorGameState()
{
// Detect game launch
//uint64_t timeNow = GetTimeNow();
if (vsh::GetCooperationMode() != vsh::eCooperationMode::XMB && !m_StateGameRunning)
{
m_StateGameRunning = true;
m_StateGameJustLaunched = true;
//m_GameLaunchTime = timeNow;
}
else if (vsh::GetCooperationMode() == vsh::eCooperationMode::XMB)
m_StateGameRunning = false;

//if (timeNow - m_GameLaunchTime > 15 * 1000)
// m_StateGameJustLaunched = false;
}
8 changes: 6 additions & 2 deletions src/Core/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ class Helpers
void MonitorGameState();

public:
vsh::paf::View* system_plugin{};
vsh::paf::View* game_plugin{};
vsh::paf::View* game_ext_plugin{};
vsh::paf::View* game_plugin{};
vsh::paf::View* system_plugin{};
vsh::paf::View* xmb_plugin{};
vsh::paf::PhWidget* page_autooff_guide{};

bool m_IsHen{};
bool m_StateGameRunning{};
bool m_StateGameJustLaunched{};

private:
uint64_t m_GameLaunchTime{};
};

extern Helpers g_Helpers;
19 changes: 12 additions & 7 deletions src/Core/Menu/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void Overlay::OnShutdown()
m_StateRunning = false;

sys_ppu_thread_yield();
Sleep(refreshDelay + 500);
Sleep(refreshDelay * 1000 + 500);

uint64_t exitCode;
sys_ppu_thread_join(UpdateInfoThreadId, &exitCode);
Expand All @@ -65,7 +65,7 @@ void Overlay::DrawOverlay()
uint64_t timeNow = GetTimeNow();
if (timeNow - m_TemperatureCycleTime > 5000)
{
cycleTempType ^= 1;
m_CycleTemperatureType ^= 1;
m_TemperatureCycleTime = timeNow;
}

Expand All @@ -83,7 +83,7 @@ void Overlay::DrawOverlay()

if (showRAM)
{
vsh::swprintf(buffer, 50, L"RAM: %.0f%% / %i KB Used\n", m_MemoryUsage.percent, m_MemoryUsage.used);
vsh::swprintf(buffer, 50, L"RAM: %.1f%% %.1f / %.1f MB\n", m_MemoryUsage.percent, m_MemoryUsage.used, m_MemoryUsage.total);
overlayText += buffer;
}

Expand Down Expand Up @@ -286,20 +286,25 @@ void Overlay::UpdateInfoThread(uint64_t arg)

while (g_Overlay.m_StateRunning)
{
Sleep(refreshDelay);
Sleep(refreshDelay * 1000);

// Using syscalls in a loop on hen will cause a black screen when launching a game
// so in order to fix this we need to sleep 10/15 seconds when a game is launched
if (g_Helpers.m_StateGameJustLaunched)
{
Sleep(15 * 1000);
g_Helpers.m_StateGameJustLaunched = false;
Sleep(15 * 1000);
g_Helpers.m_StateGameJustLaunched = false;
}

g_Overlay.m_MemoryUsage = GetMemoryUsage();
// Convert to MB
g_Overlay.m_MemoryUsage.total /= 1024;
g_Overlay.m_MemoryUsage.free /= 1024;
g_Overlay.m_MemoryUsage.used /= 1024;

g_Overlay.m_FanSpeed = GetFanSpeed();

if (g_Overlay.cycleTempType)
if (g_Overlay.m_CycleTemperatureType)
{
g_Overlay.m_CPUTemp = GetTemperatureFahrenheit(0);
g_Overlay.m_GPUTemp = GetTemperatureFahrenheit(1);
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Menu/Overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Overlay
float m_FirmwareVersion{};
uint16_t m_PayloadVersion{};
uint64_t m_TemperatureCycleTime{};
bool cycleTempType{};
bool m_CycleTemperatureType{};
TempType tempType{};

uint8_t displayMode{}; // XMB + IN-GAME or XMB or IN-GAME
Expand All @@ -71,7 +71,7 @@ class Overlay
vsh::vec2 m_SafeArea{ 31, 18 };
float m_SizeText = 20;
vsh::vec4 m_ColorText{ 1, 1, 1, 1 };
static const int refreshDelay = 500;
static const int refreshDelay = 1;

float m_FPS = 100.0f;
float m_FpsLastTime = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/Core/Rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void Render::OnUpdate()

if (!g_Helpers.page_autooff_guide)
{
DestroyPlanesAndTexts();
DestroyWidgets();
return;
}

Expand All @@ -18,13 +18,13 @@ void Render::OnUpdate()
{
if (!phText->IsAttached())
{
DestroyPlanesAndTexts();
DestroyWidgets();
return;
}
}
else
{
CreatePlanesAndTexts();
CreateWidgets();
return;
}

Expand Down Expand Up @@ -83,7 +83,7 @@ vsh::paf::PhText* Render::GetText(int index)
return m_TextList[index];
}

void Render::CreatePlanesAndTexts()
void Render::CreateWidgets()
{
if (!g_Helpers.page_autooff_guide)
return;
Expand All @@ -107,7 +107,7 @@ void Render::CreatePlanesAndTexts()
}
}

void Render::DestroyPlanesAndTexts()
void Render::DestroyWidgets()
{
if (!g_Helpers.page_autooff_guide)
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Rendering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class Render

public:
void OnUpdate();
void DestroyPlanesAndTexts();
void DestroyWidgets();
void Text(const std::wstring& text, vsh::vec2 position, float height, Align horizontalAlign, Align verticalAlign, vsh::vec4 color, float angle = 0);
void Text(const std::string& text, vsh::vec2 position, float height, Align horizontalAlign, Align verticalAlign, vsh::vec4 color, float angle = 0);

private:
vsh::paf::PhText* CreateText(const std::string& widgetName);
vsh::paf::PhText* GetText(int index);

void CreatePlanesAndTexts();
void CreateWidgets();
void ClearTexts();

private:
Expand Down
8 changes: 4 additions & 4 deletions src/Utils/ConsoleInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ memUsage_s GetMemoryUsage()
{ system_call_1(352, (uint64_t)&mem_info); } // sys_memory_get_user_memory_size

memUsage_s mem_usage;
mem_usage.total = (mem_info.total >> 10);
mem_usage.used = ((mem_info.total - mem_info.available) >> 10);
//mem_usage.percent = ((static_cast<float>(mem_usage.used) / static_cast<float>(mem_usage.total)) * 100.0f);
mem_usage.percent = (static_cast<float>(mem_usage.used) * 100) / static_cast<float>(mem_usage.total);
mem_usage.total = static_cast<float>(mem_info.total) / 1024.0;
mem_usage.free = static_cast<float>(mem_info.available) / 1024.0;
mem_usage.used = mem_usage.total - mem_usage.free;
mem_usage.percent = (mem_usage.used * 100.0) / mem_usage.total;

return mem_usage;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Utils/ConsoleInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ struct memInfo_s

struct memUsage_s
{ // in kilobytes
uint32_t total;
uint32_t used;
float percent;
float total;
float free;
float used;
float percent;
};

struct idps_s
Expand Down

0 comments on commit db0ec7d

Please sign in to comment.