Whenever I try to make a homebrew app that uses a while loop or for loop I can't get the buttons to work. Can you help me? Here's an example of something where + is supposed to close out but doesn't.
// Include the most common headers from the C standard library
#include <iostream>
// Include the main libnx system header, for Switch development
#include <switch.h>
using namespace std;
// Main program entrypoint
int main(int argc, char* argv[])
{
// 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.
// Other initialization goes here. As a demonstration, we print hello world.
// Main loop
while (appletMainLoop())
{
// Scan all the inputs. This should be done once for each frame
consoleInit(NULL);
hidScanInput();
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
// hidKeysDown returns information about which buttons have been
// just pressed in this frame compared to the previous one
if (kDown & KEY_PLUS)
break; // break in order to return to hbmenu
// Your code goes here
int number = 1;
while (number >= 0) {
cout << number << endl;
number++;
// 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;
}
// Include the most common headers from the C standard library
#include <iostream>
// Include the main libnx system header, for Switch development
#include <switch.h>
using namespace std;
// Main program entrypoint
int main(int argc, char* argv[])
{
// 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.
// Other initialization goes here. As a demonstration, we print hello world.
// Main loop
while (appletMainLoop())
{
// Scan all the inputs. This should be done once for each frame
consoleInit(NULL);
hidScanInput();
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
// hidKeysDown returns information about which buttons have been
// just pressed in this frame compared to the previous one
if (kDown & KEY_PLUS)
break; // break in order to return to hbmenu
// Your code goes here
int number = 1;
while (number >= 0) {
cout << number << endl;
number++;
// 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;
}