68 lines
1.5 KiB
C
68 lines
1.5 KiB
C
![]() |
/*
|
||
|
Circle Pad example made by Aurelio Mannara for ctrulib
|
||
|
Please refer to https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/services/hid.h for more information
|
||
|
This code was modified for the last time on: 12/13/2014 2:20 UTC+1
|
||
|
|
||
|
This wouldn't be possible without the amazing work done by:
|
||
|
-Smealum
|
||
|
-fincs
|
||
|
-WinterMute
|
||
|
-yellows8
|
||
|
-plutoo
|
||
|
-mtheall
|
||
|
-Many others who worked on 3DS and I'm surely forgetting about
|
||
|
*/
|
||
|
|
||
|
#include <3ds.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
// Initialize services
|
||
|
srvInit();
|
||
|
aptInit();
|
||
|
gfxInit();
|
||
|
hidInit(NULL);
|
||
|
|
||
|
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
|
||
|
consoleInit(GFX_TOP, NULL);
|
||
|
|
||
|
printf("\x1b[0;0HPress Start to exit.");
|
||
|
printf("\x1b[1;0HCirclePad position:");
|
||
|
|
||
|
// Main loop
|
||
|
while (aptMainLoop())
|
||
|
{
|
||
|
//Scan all the inputs. This should be done once for each frame
|
||
|
hidScanInput();
|
||
|
|
||
|
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||
|
u32 kDown = hidKeysDown();
|
||
|
|
||
|
if (kDown & KEY_START) break; // break in order to return to hbmenu
|
||
|
|
||
|
circlePosition pos;
|
||
|
|
||
|
//Read the CirclePad position
|
||
|
hidCircleRead(&pos);
|
||
|
|
||
|
//Print the CirclePad position
|
||
|
printf("\x1b[2;0H%04d; %04d", pos.dx, pos.dy);
|
||
|
|
||
|
|
||
|
// Flush and swap framebuffers
|
||
|
gfxFlushBuffers();
|
||
|
gfxSwapBuffers();
|
||
|
|
||
|
//Wait for VBlank
|
||
|
gspWaitForVBlank();
|
||
|
}
|
||
|
|
||
|
// Exit services
|
||
|
gfxExit();
|
||
|
hidExit();
|
||
|
aptExit();
|
||
|
srvExit();
|
||
|
return 0;
|
||
|
}
|