libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
WutLoggerUsbSerial.h
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * WutLoggerUsbSerial.h
5 *
6 * USB-to-TTL / USB-serial output for Wii U. Stock wut has no first-party
7 * USB-serial API - this backend targets the community "usbserial" homebrew
8 * module (loaded as a .rpl at runtime, eg. via Aroma's module system),
9 * which exposes Init()/Deinit()/Write() over a small C header.
10 *
11 * That header is treated as an OPTIONAL dependency, not a hard build
12 * requirement: if <usbserial/usbserial.h> isn't present in the toolchain,
13 * this file still compiles - init() simply reports failure and write() is
14 * a no-op, exactly like a Gecko backend with nothing plugged in. This
15 * keeps "no hardcoded options" honest at the build-dependency level too:
16 * a project that doesn't ship the module doesn't need an #ifdef at every
17 * call site, and one that does gets the real backend for free.
18 *
19 * To enable: add the usbserial-wiiu package to your (wut) toolchain and
20 * rebuild - no source changes needed here.
21 ***************************************************************************/
22#pragma once
23
24#include "../Logger.h"
25
26#if __has_include(<usbserial/usbserial.h>)
27 #define WUT_USBSERIAL_AVAILABLE 1
28#else
29 #define WUT_USBSERIAL_AVAILABLE 0
30#endif
31
35{
36 public:
37 bool init(const LogConfig & config) override;
38 void shutdown() override;
39 void write(LogLevel level, const char * line, size_t len) override;
40 const char * name() const override { return "USBSerial"; }
41
42 private:
43 bool ready = false;
44};
Abstract backend a Logger fans a formatted line out to.
Definition Logger.h:153
Log backend writing to a USB serial adapter (requires the optional usbserial module).
const char * name() const override
Short identifier for diagnostics (eg. "UDP", "File").
bool init(const LogConfig &config) override
Opens whatever handle/socket/file this backend needs, using only fields from config (nothing hardcode...
void shutdown() override
Releases whatever init() acquired.
void write(LogLevel level, const char *line, size_t len) override
Writes one already-formatted, newline-terminated line.
LogLevel
Severity of a single log call.
Definition Logger.h:45
Full runtime configuration for the Logger.
Definition Logger.h:101