Skip to content

Commit

Permalink
Add home button denied icon support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fangal-Airbag committed Jun 18, 2023
1 parent 44b442b commit aecb01d
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.vscode
/build
*.elf
*.rpx
Expand Down
12 changes: 11 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
****************************************************************************/
#include <coreinit/foreground.h>
#include <proc_ui/procui.h>
#include <coreinit/memdefaultheap.h>
#include <nn/erreula.h>
#include "Application.h"
#include "gui/FreeTypeGX.h"
#include "gui/GuiImageAsync.h"
Expand All @@ -32,6 +34,14 @@ Application *Application::applicationInstance = NULL;
bool Application::exitApplication = false;
bool Application::quitRequest = false;

u32 Application::hbmDeniedCallback(void *context)
{
nn::erreula::HomeNixSignArg homeNixSignArg;
nn::erreula::AppearHomeNixSign(homeNixSignArg);

return 0;
}

Application::Application()
: CThread(CThread::eAttributeAffCore0 | CThread::eAttributePinnedAff, 0, 0x20000)
, bgMusic(NULL)
Expand All @@ -57,6 +67,7 @@ Application::Application()
exitApplication = false;

ProcUIInit(OSSavesDone_ReadyToRelease);
ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED, hbmDeniedCallback, NULL, 1);
}

Application::~Application()
Expand All @@ -73,7 +84,6 @@ Application::~Application()
SoundHandler::DestroyInstance();

CursorDrawer::destroyInstance();

ProcUIShutdown();
}

Expand Down
2 changes: 2 additions & 0 deletions src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Application : public CThread
private:
Application();
virtual ~Application();

static u32 hbmDeniedCallback(void *context);

bool procUI(void);

Expand Down
2 changes: 1 addition & 1 deletion src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern "C" {
#endif

#define WUP_GX2_VERSION "v1.3"
#define WUP_GX2_VERSION "v1.3.1"
#ifdef __cplusplus
}
#endif
Expand Down
52 changes: 52 additions & 0 deletions src/menu/ErrorViewer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <stdio.h>
#include <malloc.h>
#include <vpad/input.h>
#include "utils/logger.h"
#include "ErrorViewer.h"

ErrorViewer::ErrorViewer()
{
client = (FSClient *)malloc(sizeof(FSClient));
FSAddClient(client, FS_ERROR_FLAG_ALL);

createArg.workMemory = malloc(nn::erreula::GetWorkMemorySize());
createArg.fsClient = client;
if (!nn::erreula::Create(createArg)) {
log_printf("Failed to create error viewer");
return;
}
}

ErrorViewer::~ErrorViewer()
{
nn::erreula::Destroy();
free(createArg.workMemory);
FSDelClient(client, FS_ERROR_FLAG_ALL);
free(client);
}

void ErrorViewer::calc()
{
VPADStatus vpadStatus;
VPADRead(VPAD_CHAN_0, &vpadStatus, 1, nullptr);
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &vpadStatus.tpNormal, &vpadStatus.tpNormal);

nn::erreula::ControllerInfo controllerInfo;
controllerInfo.vpad = &vpadStatus;
controllerInfo.kpad[0] = nullptr;
controllerInfo.kpad[1] = nullptr;
controllerInfo.kpad[2] = nullptr;
controllerInfo.kpad[3] = nullptr;

nn::erreula::Calc(controllerInfo);
}

void ErrorViewer::drawTV()
{
nn::erreula::DrawTV();
}

void ErrorViewer::drawDRC()
{
nn::erreula::DrawDRC();
}
22 changes: 22 additions & 0 deletions src/menu/ErrorViewer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <nn/erreula.h>
#include <coreinit/filesystem.h>

class ErrorViewer
{
public:
ErrorViewer();

~ErrorViewer();

void calc();

static void drawTV();

static void drawDRC();

private:
FSClient *client;
nn::erreula::CreateArg createArg;
};
4 changes: 2 additions & 2 deletions src/menu/InstallWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void InstallWindow::OnDestinationChoice(GuiElement * element, int choice)
void InstallWindow::executeThread()
{
Application::instance()->exitDisable();
OSEnableHomeButtonMenu(false);
OSEnableHomeButtonMenu(FALSE);

canceled = false;

Expand Down Expand Up @@ -149,7 +149,7 @@ void InstallWindow::executeThread()
if(APD_enabled)
enableAutoPowerDown();

OSEnableHomeButtonMenu(true);
OSEnableHomeButtonMenu(TRUE);
Application::instance()->exitEnable();
}

Expand Down
10 changes: 10 additions & 0 deletions src/menu/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ MainWindow::MainWindow(int w, int h)
pointerImg[i]->setScale(1.5f);
pointerValid[i] = false;
}

errorViewer = new ErrorViewer();

SetupMainView();
}
Expand Down Expand Up @@ -72,6 +74,8 @@ MainWindow::~MainWindow()

if(folderList != NULL)
delete folderList;

delete errorViewer;
}

void MainWindow::updateEffects()
Expand Down Expand Up @@ -133,6 +137,8 @@ void MainWindow::update(GuiController *controller)
pointerImg[wpadIdx]->setAngle(controller->data.pointerAngle);
pointerValid[wpadIdx] = true;
}

errorViewer->calc();
}

void MainWindow::drawDrc(CVideo *video)
Expand All @@ -151,6 +157,8 @@ void MainWindow::drawDrc(CVideo *video)
pointerImg[i]->setAlpha(1.0f);
}
}

errorViewer->drawDRC();
}

void MainWindow::drawTv(CVideo *video)
Expand All @@ -168,6 +176,8 @@ void MainWindow::drawTv(CVideo *video)
pointerValid[i] = false;
}
}

errorViewer->drawTV();
}

void MainWindow::SetupMainView()
Expand Down
2 changes: 2 additions & 0 deletions src/menu/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "fs/CFolderList.hpp"
#include "BrowserWindow.h"
#include "InstallWindow.h"
#include "ErrorViewer.h"
#include "gui/GuiParticleImage.h"
#include "system/CMutex.h"

Expand Down Expand Up @@ -164,6 +165,7 @@ class MainWindow : public sigslot::has_slots<>
CFolderList * folderList;
BrowserWindow * browserWindow;
InstallWindow * installWindow;
ErrorViewer * errorViewer;

CMutex guiMutex;
};
Expand Down

0 comments on commit aecb01d

Please sign in to comment.