libctru  v1.6.0
Data Structures | Macros | Typedefs | Enumerations | Functions
console.h File Reference

3ds stdio support. More...

#include <3ds/types.h>
#include <3ds/gfx.h>

Go to the source code of this file.

Data Structures

struct  ConsoleFont
 A font struct for the console. More...
struct  PrintConsole
 Console structure used to store the state of a console render context. More...


#define CONSOLE_ESC(x)   "\x1b[" #x
#define CONSOLE_RED   CONSOLE_ESC(31;1m)
#define CONSOLE_COLOR_BOLD   (1<<0)
 Bold text.
#define CONSOLE_COLOR_FAINT   (1<<1)
 Faint text.
#define CONSOLE_ITALIC   (1<<2)
 Italic text.
#define CONSOLE_UNDERLINE   (1<<3)
 Underlined text.
#define CONSOLE_BLINK_SLOW   (1<<4)
 Slow blinking text.
#define CONSOLE_BLINK_FAST   (1<<5)
 Fast blinking text.
#define CONSOLE_COLOR_REVERSE   (1<<6)
 Reversed color text.
#define CONSOLE_CONCEAL   (1<<7)
 Concealed text.
#define CONSOLE_CROSSED_OUT   (1<<8)
 Crossed out text.


typedef bool(* ConsolePrint) (void *con, int c)
 A callback for printing a character.


enum  debugDevice {
  debugDevice_3DMOO = debugDevice_SVC
 Console debug devices supported by libnds. More...


void consoleSetFont (PrintConsole *console, ConsoleFont *font)
 Loads the font into the console. More...
void consoleSetWindow (PrintConsole *console, int x, int y, int width, int height)
 Sets the print window. More...
PrintConsoleconsoleGetDefault (void)
 Gets a pointer to the console with the default values. More...
PrintConsoleconsoleSelect (PrintConsole *console)
 Make the specified console the render target. More...
PrintConsoleconsoleInit (gfxScreen_t screen, PrintConsole *console)
 Initialise the console. More...
void consoleDebugInit (debugDevice device)
 Initializes debug console output on stderr to the specified device. More...
void consoleClear (void)
 Clears the screan by using iprintf("\x1b[2J");.

Detailed Description

3ds stdio support.

Provides stdio integration for printing to the 3DS screen as well as debug print functionality provided by stderr.

General usage is to initialize the console by:


or to customize the console usage by:

Enumeration Type Documentation

◆ debugDevice

Console debug devices supported by libnds.


Swallows prints to stderr.


Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers.


Directs stderr debug statements to 3DS console window.

Function Documentation

◆ consoleDebugInit()

void consoleDebugInit ( debugDevice  device)

Initializes debug console output on stderr to the specified device.

deviceThe debug device (or devices) to output debug print statements to.

◆ consoleGetDefault()

PrintConsole* consoleGetDefault ( void  )

Gets a pointer to the console with the default values.

This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit().

A pointer to the console with the default values.

◆ consoleInit()

PrintConsole* consoleInit ( gfxScreen_t  screen,
PrintConsole console 

◆ consoleSelect()

PrintConsole* consoleSelect ( PrintConsole console)

Make the specified console the render target.

consoleA pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)).
A pointer to the previous console.
audio/filters/source/main.c, audio/streaming/source/main.c, graphics/printing/both-screen-text/source/main.c, and graphics/printing/multiple-windows-text/source/main.c.

◆ consoleSetFont()

void consoleSetFont ( PrintConsole console,
ConsoleFont font 

Loads the font into the console.

consolePointer to the console to update, if NULL it will update the current console.
fontThe font to load.

◆ consoleSetWindow()

void consoleSetWindow ( PrintConsole console,
int  x,
int  y,
int  width,
int  height 

Sets the print window.

consoleConsole to set, if NULL it will set the current console window.
xX location of the window.
yY location of the window.
widthWidth of the window.
heightHeight of the window.