libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Platform.h
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * Platform.h
5 *
6 * Primary entry point
7 ***************************************************************************/
8#pragma once
9
10#include "AudioDriver.h"
11#include "VideoDriver.h"
12#include "InputDriver.h"
13#include "FileSystemDriver.h"
14#include "ThreadDriver.h"
15#include "Logger.h"
16
17class AudioDriver;
18class VideoDriver;
19class InputDriver;
21class ThreadDriver;
22class Logger;
23
26enum class Status
27{
28 Running,
29 Paused,
30 Exiting
31};
32
36enum class SystemEvent
37{
38 None,
45};
46
50{
56 float assetScaleX = 1.0f;
58 float assetScaleY = 1.0f;
59};
60
66{
67 public:
68 virtual ~Platform() = default;
69
72 virtual void init(const PlatformConfig& config) = 0;
74 const PlatformConfig& getConfig() const { return config; }
80 virtual void requestExit() = 0;
81
83 virtual AudioDriver* getAudio() = 0;
85 virtual VideoDriver* getVideo() = 0;
87 virtual InputDriver* getInput() = 0;
91 virtual ThreadDriver* getThread() = 0;
95 virtual Logger* getLogger() = 0;
96
100
102 virtual Status getStatus() const = 0;
104 virtual void triggerExit() = 0;
112 bool shouldExit() { return getStatus() == Status::Exiting || getSystemEvent() == SystemEvent::ShutdownRequested; }
113
114 protected:
118
123 virtual void shutdown() = 0;
124};
125
127extern Platform* platform;
Platform audio backend GuiSound delegates to: fixed one-shot PCM voices plus one background OGG strea...
Definition AudioDriver.h:18
Storage device enumeration/mount/poll backend for the SD/USB/DVD file browser.
Platform input backend GuiElements delegate to, via the per-channel InputController objects update() ...
Definition InputDriver.h:22
Central fan-out dispatcher.
Definition Logger.h:191
Composition root for a platform.
Definition Platform.h:66
virtual InputDriver * getInput()=0
virtual ThreadDriver * getThread()=0
virtual AudioDriver * getAudio()=0
virtual void requestExit()=0
Tears down the platform (via shutdown()) and then performs whatever platform-appropriate action actua...
virtual void triggerExit()=0
Transitions platform state to move to Exiting.
virtual VideoDriver * getVideo()=0
virtual Status getStatus() const =0
Current platform lifecycle state (Running, Paused, Exiting).
virtual FileSystemDriver * getFileSystem()=0
bool shouldExit()
True once triggerExit() has been called, or the platform's own getSystemEvent() independently reports...
Definition Platform.h:112
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
const PlatformConfig & getConfig() const
The PlatformConfig this platform was init()'d with.
Definition Platform.h:74
virtual Logger * getLogger()=0
May return nullptr on a Platform that hasn't finished init() yet - LogPrintf()/LOG_*() already guard ...
virtual void init(const PlatformConfig &config)=0
Constructs and initializes all five drivers for this platform.
virtual SystemEvent getSystemEvent()=0
Current hardware/OS-level system event, if any.
virtual void shutdown()=0
Shuts down and releases all five drivers.
Raw platform threading primitives.
Platform video backend owning the frame lifecycle (init/render/clear, screen size,...
Definition VideoDriver.h:28
SystemEvent
A hardware/OS-level system event a Platform can report.
Definition Platform.h:37
Status
Platform execution state.
Definition Platform.h:27
@ ResetRequested
Reset button pressed (Wii only).
Definition Platform.h:44
@ ShutdownRequested
Power button pressed (console or, on Wii, a Wiimote) - or, on Wii U, the OS asking the app to exit.
Definition Platform.h:41
Settings passed to Platform::init().
Definition Platform.h:50
int canvasHeight
Design canvas height in pixels (eg.
Definition Platform.h:52
float assetScaleX
Horizontal ratio of source art pixels to design-canvas pixels.
Definition Platform.h:56
int canvasWidth
Design canvas width in pixels (eg.
Definition Platform.h:51
float assetScaleY
Vertical counterpart of assetScaleX.
Definition Platform.h:58