Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -428,11 +428,12 @@ return OFMaxRetainCount; } - (bool)hasTerminal { -#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) +#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \ + defined(OF_NINTENDO_SWITCH) return true; #elif defined(HAVE_ISATTY) && !defined(OF_WII_U) return isatty(_fd); #else return false; Index: src/test/OTAppDelegate.m ================================================================== --- src/test/OTAppDelegate.m +++ src/test/OTAppDelegate.m @@ -45,10 +45,28 @@ /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id #endif + +#ifdef OF_NINTENDO_SWITCH +# define id nx_id +# include +# undef id + +static OFDate *lastConsoleUpdate; + +static void +updateConsole(bool force) +{ + if (force || lastConsoleUpdate.timeIntervalSinceNow <= -1.0 / 60) { + consoleUpdate(NULL); + [lastConsoleUpdate release]; + lastConsoleUpdate = [[OFDate alloc] init]; + } +} +#endif @interface OTAppDelegate: OFObject @end enum Status { @@ -101,10 +119,14 @@ #elif defined(OF_NINTENDO_3DS) gfxInitDefault(); atexit(gfxExit); consoleInit(GFX_TOP, NULL); +#elif defined(OF_NINTENDO_SWITCH) + consoleInit(NULL); + padConfigureInput(1, HidNpadStyleSet_NpadStandard); + updateConsole(true); #endif } - (OFSet OF_GENERIC(Class) *)testClasses { @@ -267,10 +289,23 @@ if (hidKeysDown() & KEY_A) break; gspWaitForVBlank(); } +#elif defined(OF_NINTENDO_SWITCH) + [OFStdOut setForegroundColor: [OFColor silver]]; + [OFStdOut writeLine: @"Press A to continue"]; + + while (appletMainLoop()) { + PadState pad; + + padUpdate(&pad); + updateConsole(true); + + if (padGetButtonsDown(&pad) & HidNpadButton_A) + break; + } #endif } } - (OFString *)descriptionForException: (id)exception @@ -329,11 +364,12 @@ size_t numSucceeded = 0, numFailed = 0, numSkipped = 0; OFMutableDictionary *summaries = [OFMutableDictionary dictionary]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeString: @"Found "]; -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ + !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", testClasses.count]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test case%s\n", @@ -457,27 +493,30 @@ [OFStdOut setForegroundColor: [OFColor blue]]; [OFStdOut writeFormat: @"%@\n", line.secondObject]; } } -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ + !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #else [OFStdOut setForegroundColor: [OFColor purple]]; #endif [OFStdOut writeFormat: @"%zu", numSucceeded]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s succeeded, ", (numSucceeded != 1 ? "s" : "")]; -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ + !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numFailed]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s failed, ", (numFailed != 1 ? "s" : "")]; -#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) +#if !defined(OF_WII) && !defined(OF_NINTENDO_DS) && \ + !defined(OF_NINTENDO_3DS) && !defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numSkipped]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s skipped\n", @@ -517,10 +556,15 @@ if (hidKeysDown() & KEY_START) break; gspWaitForVBlank(); } +#elif defined(OF_NINTENDO_SWITCH) + while (appletMainLoop()) + updateConsole(true); + + consoleExit(NULL); #endif [OFApplication terminateWithStatus: (int)numFailed]; } @end