daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "main.h"
  2.  
  3. volatile int frame = 0;
  4.  
  5. void vblank() {
  6.     frame++;
  7. }
  8.  
  9. int main() {
  10.     touchPosition touchXY;
  11.     char* lastPressed = "None";
  12.  
  13.     irqSet(IRQ_VBLANK, vblank);
  14.  
  15.     consoleDemoInit();
  16.  
  17.     printf("      Hello World!\n");
  18.     printf("     \x1b[32mwww.devkitpro.org\n");
  19.     printf("   \x1b[32;1mwww.daporkchop.net\x1b[39m");
  20.  
  21.     while (true) {
  22.         swiWaitForVBlank();
  23.         scanKeys();
  24.         int keys = keysDown();
  25.         if (keys & KEY_START) {
  26.             return 0;
  27.         } else if (keys & KEY_A)    {
  28.             lastPressed = "A";
  29.         } else if (keys & KEY_B)    {
  30.             lastPressed = "B";
  31.         } else if (keys & KEY_X)    {
  32.             lastPressed = "X";
  33.         } else if (keys & KEY_Y)    {
  34.             lastPressed = "Y";
  35.         } else if (keys & KEY_L)    {
  36.             lastPressed = "L";
  37.         } else if (keys & KEY_R)    {
  38.             lastPressed = "R";
  39.         } else if (keys & KEY_UP)    {
  40.             lastPressed = "Up";
  41.         } else if (keys & KEY_DOWN)    {
  42.             lastPressed = "Down";
  43.         } else if (keys & KEY_LEFT)    {
  44.             lastPressed = "Left";
  45.         } else if (keys & KEY_RIGHT)    {
  46.             lastPressed = "Right";
  47.         } else if (keys & KEY_SELECT)    {
  48.             lastPressed = "Select";
  49.         }
  50.  
  51.         touchRead(&touchXY);
  52.  
  53.         // print at using ansi escape sequence \x1b[line;columnH
  54.         printf("\x1b[10;0HFrame = %d", frame);
  55.         printf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px);
  56.         printf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py);
  57.        
  58.         printf("\x1b[19;0HLast pressed: %s\n", lastPressed);
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top