diff --git a/3DS/data/keyboard.bin b/3DS/data/keyboard.bin new file mode 100644 index 0000000..a496063 Binary files /dev/null and b/3DS/data/keyboard.bin differ diff --git a/3DS/include/brewboard.h b/3DS/include/brewboard.h new file mode 100644 index 0000000..bb57601 --- /dev/null +++ b/3DS/include/brewboard.h @@ -0,0 +1,8 @@ +#pragma once + +char* bbHandleKeyboard(); + +#ifdef TEXTSTUFF_H +void bbDisplayText(char* text); +char* bbHandleKeyboardBlocking(char* text); +#endif diff --git a/3DS/source/brewboard.c b/3DS/source/brewboard.c new file mode 100644 index 0000000..6da96bc --- /dev/null +++ b/3DS/source/brewboard.c @@ -0,0 +1,85 @@ +#include <3ds.h> +#include +#include +//#include "textstuff.h" +#include "keyboard_bin.h" + +void gfxDrawSprite(gfxScreen_t screen, gfx3dSide_t side, u8* spriteData, u16 width, u16 height, s16 x, s16 y) { + if(!spriteData)return; + + u16 fbWidth, fbHeight; + u8* fbAdr=gfxGetFramebuffer(screen, side, &fbWidth, &fbHeight); + + if(x+width<0 || x>=fbWidth)return; + if(y+height<0 || y>=fbHeight)return; + + u16 xOffset=0, yOffset=0; + u16 widthDrawn=width, heightDrawn=height; + + if(x<0)xOffset=-x; + if(y<0)yOffset=-y; + if(x+width>=fbWidth)widthDrawn=fbWidth-x; + if(y+height>=fbHeight)heightDrawn=fbHeight-y; + widthDrawn-=xOffset; + heightDrawn-=yOffset; + + int j; + for(j=yOffset; j= 1 && tpos.px <= 312 && tpos.py >= 78 && tpos.py <= 208 && kDown & KEY_TOUCH) + chr = chars[(u16)(floor(tpos.px/26)+12*floor((tpos.py-78)/26))]; + + return chr; +} + +#ifdef TEXTSTUFF_H +void bbDisplayText(char* text) { + tsDrawWord(GFX_BOTTOM, GFX_LEFT, (char*)text, 10, 220, 0, 0, 0); +} + +char* bbHandleKeyboardBlocking(char* text) { + static char out[37]; + char chr; + u8 i; + + strncpy(out, text, 37); + i = strlen(out); + + while (aptMainLoop()) { + gspWaitForVBlank(); + hidScanInput(); + + chr = bbHandleKeyboard(out); + if (chr == '\13') + break; + else if (i > 0 && chr == '\x08') { + i--; + out[i] = '\0'; + } else if (i < 36 && chr != '\0') { + out[i] = chr; + i++; + out[i] = '\0'; + } + + tsDrawWord(GFX_BOTTOM, GFX_LEFT, (char*)out, 10, 220, 0, 0, 0); + + gfxFlushBuffers(); + gfxSwapBuffers(); + } + return (char*)out; +} +#endif \ No newline at end of file