#define CONSOLE_CONCEAL (1<<7)\r
#define CONSOLE_CROSSED_OUT (1<<8)\r
\r
+//! Console debug devices supported by libnds.\r
+typedef enum {\r
+ debugDevice_NULL, //!< swallows prints to stderr\r
+ debugDevice_3DMOO, //!< Directs stderr debug statements to 3dmoo\r
+ debugDevice_CONSOLE, //!< Directs stderr debug statements to 3DS console window\r
+} debugDevice;\r
+\r
/*! \brief Loads the font into the console\r
\param console pointer to the console to update, if NULL it will update the current console\r
\param font the font to load\r
*/\r
PrintConsole* consoleInit(gfxScreen_t screen, PrintConsole* console);\r
\r
+/*! \brief Initializes debug console output on stderr to the specified device\r
+ \param device The debug device (or devices) to output debug print statements to\r
+*/\r
+void consoleDebugInit(debugDevice device);\r
+\r
+\r
//! Clears the screan by using iprintf("\x1b[2J");\r
void consoleClear(void);\r
\r
#include <sys/iosupport.h>\r
#include <3ds/gfx.h>\r
#include <3ds/console.h>\r
+#include <3ds/svc.h>\r
\r
#include "default_font_bin.h"\r
\r
NULL\r
};\r
\r
+//---------------------------------------------------------------------------------\r
+ssize_t debug_write(struct _reent *r, int fd, const char *ptr, size_t len) {\r
+//---------------------------------------------------------------------------------\r
+ svcOutputDebugString(ptr,len);\r
+ return len;\r
+}\r
+\r
+static const devoptab_t dotab_3dmoo = {\r
+ "3dmoo",\r
+ 0,\r
+ NULL,\r
+ NULL,\r
+ debug_write,\r
+ NULL,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+\r
static const devoptab_t dotab_null = {\r
"null",\r
0,\r
return currentConsole;\r
\r
}\r
+\r
+//---------------------------------------------------------------------------------\r
+void consoleDebugInit(debugDevice device){\r
+//---------------------------------------------------------------------------------\r
+\r
+ int buffertype = _IONBF;\r
+\r
+ switch(device) {\r
+\r
+ case debugDevice_3DMOO:\r
+ devoptab_list[STD_ERR] = &dotab_3dmoo;\r
+ buffertype = _IOLBF;\r
+ break;\r
+ case debugDevice_CONSOLE:\r
+ devoptab_list[STD_ERR] = &dotab_stdout;\r
+ break;\r
+ case debugDevice_NULL:\r
+ devoptab_list[STD_ERR] = &dotab_null;\r
+ break;\r
+ }\r
+ setvbuf(stderr, NULL , buffertype, 0);\r
+\r
+}\r
+\r
//---------------------------------------------------------------------------------\r
PrintConsole *consoleSelect(PrintConsole* console){\r
//---------------------------------------------------------------------------------\r