Page 1 of 1

Q: Overlaying keyboard on background

Posted: Thu Apr 16, 2009 11:14 am
by chukmunnlee
HI I've been trying to display the keyboard over a bitmap background. I got the background but the graphics for the keyboard is garbled. Any pointers appreciated. Thanks

Here is the code

videoSetMode(MODE_5_2D);
vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG, VRAM_D_LCD);

consoleDemoInit();

bg = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
buffer = (u16*)bgGetGfxPtr(bg);

//Create the keyboard
keyboard = keyboardInit(NULL, 2, BgType_Bmp16, BgSize_B8_512x256, 20, 0, true, true);

//Load the background on buffer
...
lcdMainOnBottom();

while (1) {
key = keysDown();
if ((key & KEY_A) {
if (keyboardDisplay->visible)
keyboardHide();
else
keyboardShow();
}
}

Re: Q: Overlaying keyboard on background

Posted: Thu Apr 16, 2009 4:17 pm
by Sylus101
Well, a couple of observations...

You've declared the keyboard as 16 bit, but have a mapbase of 20. That would be 20 * 16K as the mapbase offset and likely too much. I suppose you want an 8 there.

You've got a 16 bit type, but you're showing BgSize_B8_512x256, do you mean BgSize_B16_256x256 perhaps?

I ran a handful of tests and couldn't actually get a keyboard to work at all with 8bit or 16 bit backgrounds... I was able to get it to work with a 4bit text bg like in the docs example for what keyboardDemoInit() does "Same as calling keyboardInit(NULL, 3, BgType_Text4bpp, BgSize_T_256x512, 20, 0, false, true)"