Nintendo 3DS >> C/C++
Input (Pad)
參考資訊:
1. libctru doc
2. 3ds-examples
說明:
API |
---|
bool aptMainLoop(void) |
void hidScanInput(void) |
u32 hidKeysDown(void) |
main.c
#include <3ds.h> #include <stdio.h> int main(void) { u32 pre_k = 0, cur_k = 0; char *name[] = { "A", "B", "SELECT", "START", "RIGHT", "LEFT", "UP", "DOWN", "R", "L", "X", "Y", "", "", "ZL", "ZR", "", "", "", "", "TOUCH", "", "", "", "CSTICK_RIGHT", "CSTICK_LEFT", "CSTICK_UP", "CSTICK_DOWN", "CPAD_RIGHT", "CPAD_LEFT", "CPAD_UP", "CPAD_DOWN" }; gfxInitDefault(); consoleInit(GFX_TOP, NULL); while (aptMainLoop()) { hidScanInput(); cur_k = hidKeysDown(); if (cur_k != pre_k) { pre_k = cur_k; for (int c=0; c<32; c++) { if (cur_k & (1 << c)) { printf("%s pressed\n", name[c]); } } gfxFlushBuffers(); gfxSwapBuffers(); } gspWaitForVBlank(); } gfxExit(); return 0; }
完成