Skip to content

Commit

Permalink
Added no sleep thread, Blocked PS button while in installer, Blocked …
Browse files Browse the repository at this point in the history
…USB Connection popup while in app
  • Loading branch information
Electric1447 committed Jul 11, 2021
1 parent db4d7ab commit dab63e7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include("${VITASDK}/share/vita.cmake" REQUIRED)
set(VITA_APP_NAME "EasyVPK")
set(VITA_TITLEID "ESVPK0009")
set(UPDATER_TITLEID "ESUPD0009")
set(VITA_VERSION "02.00")
set(VITA_VERSION "02.01")


set(PACKAGE_TEMP_FOLDER "ux0:/temp/pkg/")
Expand Down
2 changes: 1 addition & 1 deletion sce_sys/livearea/contents/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<frame id="frame4">
<liveitem>
<text align="left" text-align="left" word-wrap="off" ellipsis="on">
<str size="18" color="#ffffff" shadow="on">v2.0.0</str>
<str size="18" color="#ffffff" shadow="on">v2.0.1</str>
</text>
</liveitem>
</frame>
Expand Down
11 changes: 8 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include <psp2/ime_dialog.h>
#include <psp2/appmgr.h>
#include <psp2/promoterutil.h>
#include <psp2/shellutil.h>

#include "net/download.hpp"
#include "utils/filesystem.hpp"
#include "utils/nosleep_thread.h"
#include "utils/search.hpp"
#include "utils/vitaPackage.h"

Expand All @@ -18,9 +20,6 @@
#include "screens/installer.hpp"


SceCtrlData pad;


void initSceAppUtil() {

// Init SceAppUtil
Expand All @@ -40,6 +39,8 @@ void initSceAppUtil() {

int main() {
initSceAppUtil();
sceShellUtilInitEvents(0); // Init SceShellUtil events
StartNoSleepThread(); // Sleep invalidates file descriptors

// remove updater app if installed
{ // extra scope needed to cause VitaPackage cleanup procedure
Expand Down Expand Up @@ -71,6 +72,8 @@ int main() {
Installer installerView;
Details detailsView;

SceCtrlData pad;

while(1) {
sceCtrlPeekBufferPositive(0, &pad, 1);
vita2d_start_drawing();
Expand All @@ -94,6 +97,8 @@ int main() {

if (pad.buttons == SCE_CTRL_SELECT || sharedData.scene == -1)
break;

sceShellUtilLock(SCE_SHELL_UTIL_LOCK_TYPE_USB_CONNECTION); // Prevent automatic CMA connection
}

httpTerm();
Expand Down
2 changes: 1 addition & 1 deletion src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@


using namespace std;

using json = nlohmann::json;


extern unsigned int basicfont_size;
extern unsigned char basicfont[];

Expand Down
6 changes: 5 additions & 1 deletion src/screens/installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,17 @@ void Installer::draw(SharedData &sharedData) {
sharedData.scene = 1;
return;
}


sceShellUtilLock(SCE_SHELL_UTIL_LOCK_TYPE_PS_BTN); // Lock PS button

SceUID main_thread = sceKernelCreateThread("main_downloader", downloader_main, 0x40, 0x1000000, 0, 0, NULL);
if (main_thread >= 0){
sceKernelStartThread(main_thread, 0, NULL);
sceKernelWaitThreadEnd(main_thread, NULL, NULL);
}

sceShellUtilUnlock(SCE_SHELL_UTIL_LOCK_TYPE_PS_BTN); // Unlock PS button

if (launchUpdater)
openApp(UPDATER_TITLEID);

Expand Down
20 changes: 20 additions & 0 deletions src/utils/nosleep_thread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "nosleep_thread.h"

#include <psp2/kernel/threadmgr.h>
#include <psp2/kernel/processmgr.h>


void StartNoSleepThread() {
SceUID thid_sleep = sceKernelCreateThread("nosleep_thread", (SceKernelThreadEntry)nosleep_thread, 0x40, 0x1000, 0, 0, nullptr);
sceKernelStartThread(thid_sleep, 0, nullptr);
}

int nosleep_thread(SceSize args, void *argp) {
while (true) {
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND);
sceKernelDelayThread(10 * 1000 * 1000);
}

sceKernelExitDeleteThread(0);
return 0;
}
7 changes: 7 additions & 0 deletions src/utils/nosleep_thread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <psp2/types.h>


void StartNoSleepThread();
int nosleep_thread(SceSize args, void *argp);

0 comments on commit dab63e7

Please sign in to comment.