Created
June 25, 2018 10:09
-
-
Save easierbycode/d9b6bb1b17cd0af24d015c45b280c636 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <switch.h> | |
#include <stdio.h> | |
int main(int argc, char** argv) { | |
u32 kdown = 0x00000000; | |
u32 kdownOld = 0x00000000; | |
gfxInitDefault(); | |
consoleInit(nullptr); //Init the console | |
while(appletMainLoop()) { | |
hidScanInput(); //Scan for input | |
kdown = hidKeysDown(CONTROLLER_P1_AUTO); //Read the currently pressed buttons and store that value into kdown | |
//Edge detection. We don't want to print "Hello World" while A is pressed. We only want to print it once and then again on the next press | |
if(kdown > kdownOld) { | |
if(kdown & KEY_A) | |
printf("Hello World\n"); //Prints to the console on screen | |
} | |
kdownOld = kdown; | |
gfxFlushBuffers(); //Finish this frame | |
gfxSwapBuffers(); //Display it on the screen | |
gfxWaitForVsync(); //Wait till the last frame finished displaying before updating to avoid flickering | |
} | |
gfxExit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment