mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-20 21:12:38 +02:00
69 lines
2.2 KiB
C
69 lines
2.2 KiB
C
// Include the most common headers from the C standard library
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <malloc.h>
|
|
#include <time.h>
|
|
|
|
// Include the main libnx system header, for Switch development
|
|
#include <switch.h>
|
|
|
|
// See also libnx error.h.
|
|
|
|
// This example shows how to use the error LibraryApplet, see also libnx error.h.
|
|
|
|
// Main program entrypoint
|
|
int main(int argc, char* argv[])
|
|
{
|
|
Result rc=0;
|
|
|
|
// This example uses a text console, as a simple way to output text to the screen.
|
|
// If you want to write a software-rendered graphics application,
|
|
// take a look at the graphics/simplegfx example, which uses the libnx Framebuffer API instead.
|
|
// If on the other hand you want to write an OpenGL based application,
|
|
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
|
consoleInit(NULL);
|
|
|
|
// Configure our supported input layout: a single player with standard controller styles
|
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
|
|
|
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
|
PadState pad;
|
|
padInitializeDefault(&pad);
|
|
|
|
printf("error example\n");
|
|
|
|
consoleUpdate(NULL);
|
|
|
|
printf("Press A to launch error applet.\n");
|
|
printf("Press + to exit.\n");
|
|
|
|
// Main loop
|
|
while (appletMainLoop())
|
|
{
|
|
// Scan the gamepad. This should be done once for each frame
|
|
padUpdate(&pad);
|
|
|
|
// padGetButtonsDown returns the set of buttons that have been
|
|
// newly pressed in this frame compared to the previous one
|
|
u64 kDown = padGetButtonsDown(&pad);
|
|
|
|
if (kDown & HidNpadButton_Plus)
|
|
break; // break in order to return to hbmenu
|
|
|
|
if (kDown & HidNpadButton_A) {
|
|
printf("Running errorResultRecordShow()...\n");
|
|
consoleUpdate(NULL);
|
|
rc = errorResultRecordShow(MAKERESULT(16, 250), time(NULL));
|
|
printf("errorResultRecordShow(): 0x%x\n", rc);
|
|
}
|
|
|
|
// Update the console, sending a new frame to the display
|
|
consoleUpdate(NULL);
|
|
}
|
|
|
|
// Deinitialize and clean up resources used by the console (important!)
|
|
consoleExit(NULL);
|
|
return 0;
|
|
}
|