mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-07 10:58:13 +01:00
Improve the helloworld sample.
This commit is contained in:
parent
4a32445ed5
commit
cdc540938a
@ -4,6 +4,8 @@ include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
|
|||||||
|
|
||||||
add_executable(helloworld main.cpp)
|
add_executable(helloworld main.cpp)
|
||||||
target_link_libraries(helloworld
|
target_link_libraries(helloworld
|
||||||
|
whb
|
||||||
|
defaultheap
|
||||||
coreinit
|
coreinit
|
||||||
proc_ui
|
proc_ui
|
||||||
sysapp)
|
sysapp)
|
||||||
|
@ -1,89 +1,35 @@
|
|||||||
#include <coreinit/core.h>
|
|
||||||
#include <coreinit/debug.h>
|
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <coreinit/foreground.h>
|
#include <coreinit/time.h>
|
||||||
#include <proc_ui/procui.h>
|
#include <coreinit/systeminfo.h>
|
||||||
#include <sysapp/launch.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
bool isAppRunning = true;
|
#include <whb/proc.h>
|
||||||
std::string testStr = "Initial Value";
|
#include <whb/log.h>
|
||||||
|
#include <whb/log_console.h>
|
||||||
static void
|
|
||||||
SaveCallback()
|
|
||||||
{
|
|
||||||
OSSavesDone_ReadyToRelease(); // Required
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
AppRunning()
|
|
||||||
{
|
|
||||||
if (!OSIsMainCore()) {
|
|
||||||
ProcUISubProcessMessages(true);
|
|
||||||
} else {
|
|
||||||
ProcUIStatus status = ProcUIProcessMessages(true);
|
|
||||||
|
|
||||||
if (status == PROCUI_STATUS_EXITING) {
|
|
||||||
// Being closed, deinit, free, and prepare to exit
|
|
||||||
testStr = "PROCUI_STATUS_EXITING";
|
|
||||||
isAppRunning = false;
|
|
||||||
ProcUIShutdown();
|
|
||||||
} else if (status == PROCUI_STATUS_RELEASE_FOREGROUND) {
|
|
||||||
// Free up MEM1 to next foreground app, deinit screen, etc.
|
|
||||||
testStr = "PROCUI_STATUS_RELEASE_FOREGROUND";
|
|
||||||
ProcUIDrawDoneRelease();
|
|
||||||
} else if(status == PROCUI_STATUS_IN_FOREGROUND) {
|
|
||||||
// Executed while app is in foreground
|
|
||||||
testStr = "PROCUI_STATUS_IN_FOREGROUND";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isAppRunning;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
CoreEntryPoint(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
OSReport("Hello world from %s %s", argv[0], testStr.c_str());
|
|
||||||
return argc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ProcUIInit(&SaveCallback);
|
OSCalendarTime tm;
|
||||||
OSReport("Main thread running on core %d", OSGetCoreId());
|
|
||||||
|
|
||||||
// Run thread on core 0
|
WHBProcInit();
|
||||||
OSThread *threadCore0 = OSGetDefaultThread(0);
|
WHBLogConsoleInit();
|
||||||
|
WHBLogPrintf("Hello World!");
|
||||||
|
|
||||||
const char *core0Args[] = {
|
while(WHBProcIsRunning()) {
|
||||||
"Core 0"
|
OSTicksToCalendarTime(OSGetTime(), &tm);
|
||||||
};
|
WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.",
|
||||||
|
tm.tm_mday, tm.tm_mon, tm.tm_year,
|
||||||
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
|
|
||||||
OSRunThread(threadCore0, CoreEntryPoint, 0, core0Args);
|
WHBLogConsoleDraw();
|
||||||
|
OSSleepTicks(OSMilliseconds(1000));
|
||||||
|
}
|
||||||
|
|
||||||
// Run thread on core 2
|
WHBLogPrintf("Exiting... good bye.");
|
||||||
OSThread *threadCore2 = OSGetDefaultThread(2);
|
WHBLogConsoleDraw();
|
||||||
|
OSSleepTicks(OSMilliseconds(1000));
|
||||||
|
|
||||||
const char *core2Args[] = {
|
WHBLogConsoleFree();
|
||||||
"Core 2"
|
WHBProcShutdown();
|
||||||
};
|
|
||||||
|
|
||||||
OSRunThread(threadCore2, CoreEntryPoint, 2, core2Args);
|
|
||||||
|
|
||||||
// Wait for threads to return
|
|
||||||
int resultCore0 = -1, resultCore2 = -1;
|
|
||||||
OSJoinThread(threadCore0, &resultCore0);
|
|
||||||
OSJoinThread(threadCore2, &resultCore2);
|
|
||||||
|
|
||||||
OSReport("Core 0 thread returned %d", resultCore0);
|
|
||||||
OSReport("Core 2 thread returned %d", resultCore2);
|
|
||||||
|
|
||||||
// Sends messages for ProcUI to release foreground, exit
|
|
||||||
// and launch into the system menu immediately.
|
|
||||||
SYSLaunchMenu();
|
|
||||||
|
|
||||||
while(AppRunning());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user