Nintendo 3DS >> C/C++
Software Keyboard
參考資訊:
1. libctru doc
2. 3ds-examples
說明:
API |
---|
void swkbdInit(SwkbdState *swkbd, SwkbdType type, int numButtons, int maxTextLength) |
void swkbdSetInitialText(SwkbdState *swkbd, const char *text) |
void swkbdSetHintText(SwkbdState *swkbd, const char *text) |
void swkbdSetButton(SwkbdState *swkbd, SwkbdButton button, const char *text, bool submit) |
void swkbdSetFeatures(SwkbdState *swkbd, u32 features) |
SwkbdButton swkbdInputText(SwkbdState *swkbd, char *buf, size_t bufsize) |
main.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <3ds.h> #include <stdio.h> #include <string.h> int main ( void ) { char mybuf[255] = {0}; SwkbdState swkbd = {0}; SwkbdButton button = SWKBD_BUTTON_NONE ; gfxInitDefault (); consoleInit ( GFX_TOP , NULL ); swkbdInit (&swkbd, SWKBD_TYPE_NORMAL , 3, -1); swkbdSetInitialText (&swkbd, mybuf); swkbdSetHintText (&swkbd, "Please input your text" ); swkbdSetButton (&swkbd, SWKBD_BUTTON_LEFT , "No" , false ); swkbdSetButton (&swkbd, SWKBD_BUTTON_MIDDLE , " " , true ); swkbdSetButton (&swkbd, SWKBD_BUTTON_RIGHT , "Yes" , true ); swkbdSetFeatures (&swkbd, SWKBD_PREDICTIVE_INPUT ); button = swkbdInputText (&swkbd, mybuf, sizeof (mybuf)); if (button != SWKBD_BUTTON_NONE ) { printf ( "Text: %s\n" , mybuf); } gfxFlushBuffers (); gfxSwapBuffers (); gspWaitForVBlank (); svcSleepThread (3000000000LL); gfxExit (); return 0; } |
完成