libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GameCubePlatform.cpp
1/****************************************************************************
2 * Platform Abstraction Layer (OGC driver)
3 * Daryl Borth 2026
4 * GameCubePlatform.cpp
5 ***************************************************************************/
6#include "GameCubePlatform.h"
7
9{
10 this->config = config;
11
12 this->threadDriver = new OgcThreadDriver();
13 this->threadDriver->init();
14
15 this->videoDriver = new OgcVideoDriver();
16 this->videoDriver->init(config.canvasWidth, config.canvasHeight);
17
18 this->audioDriver = new OgcAudioDriver();
19 this->audioDriver->init();
20
21 this->inputDriver = new OgcInputDriver();
22 this->inputDriver->init();
23
24 this->fileSystemDriver = new GameCubeFileSystemDriver();
25 this->fileSystemDriver->init();
26
27#if LOGGING_ENABLED
28 this->logger = new Logger();
29 this->logger->registerBackend(LOGGER_OSREPORT, new OgcLoggerSysReport());
30 this->logger->registerBackend(LOGGER_SERIAL, new OgcLoggerUsbGecko());
31 this->logger->registerBackend(LOGGER_FILE, new LoggerFile());
32
33 LogConfig logConfig;
34 static const int deviceCandidates[] = { DEVICE_SD_PORT2 };
35 const char * mountPath = FindFirstMountedPath(this->fileSystemDriver, deviceCandidates, 1);
36
37 if(mountPath[0] != '\0') {
38 // mountPath already ends in "/" (eg. "port2:/") - no separator needed.
39 snprintf(logConfig.filePath, sizeof(logConfig.filePath), "%sdebug.log", mountPath);
40 }
41
42 this->logger->init(logConfig);
43#endif
44}
45
47{
48 if (logger) {
49 logger->shutdown();
50 delete logger;
51 logger = nullptr;
52 }
53
54 if (fileSystemDriver) {
55 fileSystemDriver->shutdown();
56 delete fileSystemDriver;
57 fileSystemDriver = nullptr;
58 }
59
60 if (inputDriver) {
61 inputDriver->shutdown();
62 delete inputDriver;
63 inputDriver = nullptr;
64 }
65
66 if (audioDriver) {
67 audioDriver->shutdown();
68 delete audioDriver;
69 audioDriver = nullptr;
70 }
71
72 if (videoDriver) {
73 videoDriver->shutdown();
74 delete videoDriver;
75 videoDriver = nullptr;
76 }
77
78 if (threadDriver) {
79 threadDriver->shutdown();
80 delete threadDriver;
81 threadDriver = nullptr;
82 }
83}
84
85// GameCube has no power-button/shutdown concept to honor (getSystemEvent()
86// always reports None - see Platform.h) and no menu/loader distinction
87// worth making here, so this is unconditional.
89{
90 this->shutdown();
91 exit(0);
92}
GameCube FileSystemDriver: memory card slots, GC Loader, and DVD, plus DEVICE_SMB (broadband adapter)...
void requestExit() override
Tears down the platform (via shutdown()) and then performs whatever platform-appropriate action actua...
void init(const PlatformConfig &config) override
Constructs and initializes all five drivers for this platform.
void shutdown() override
Shuts down and releases all five drivers.
Log backend that appends to a file through the platform's devoptab path.
Definition LoggerFile.h:26
Central fan-out dispatcher.
Definition Logger.h:191
GC/Wii AudioDriver: AESND-based fixed voices for one-shots, wraps a GuiSoundOggPlayer for the backgro...
GC/Wii InputDriver: PAD (GameCube) / WPAD (Wiimote, Nunchuk, Classic, Wii U Pro Controller) plus a Wi...
Log backend writing to the console debug output via SYS_Report.
Log backend for a USB Gecko adapter over EXI, via usbgecko.c.
GC/Wii ThreadDriver, built on libogc's LWP threading primitives.
GC/Wii VideoDriver: raw GX, double-buffered XFB.
PlatformConfig config
Set by init() in every concrete Platform - store the passed-in config as the very first line of the o...
Definition Platform.h:117
@ DEVICE_SD_PORT2
GameCube SD Gecko in memory card slot B.
Full runtime configuration for the Logger.
Definition Logger.h:101
char filePath[1024]
Path of the log file for the file backend. Each platform's init() points this at debug....
Definition Logger.h:134
Settings passed to Platform::init().
Definition Platform.h:50