blocksds / sdk

Main BlocksDS SDK repository
https://blocksds.github.io/docs/
130 stars 5 forks source link

Initializing a keyboard more than once shows uninitialized data on-screen #144

Closed NovaSquirrel closed 2 months ago

NovaSquirrel commented 3 months ago

If you call keyboardInit more than once, you'll see the keyboard appear all the way up at the top of the screen briefly before disappearing. I was able to prevent this by clearing the tilemap the keyboard is told to use, so I assume this means that keyboardInit is displaying whatever was in that tilemap before it was called.

AntonioND commented 2 months ago

As asie has mentioned:

I think nobody anticipated keyboardInit being called twice. We might need a keyboardExit that calls bgHide and wipes curKeyboard

AntonioND commented 2 months ago

Also, have you tried using keyboardHide() when you stop using the keyboard?

NovaSquirrel commented 2 months ago

Yes, keyboardHide() doesn't fix this. According to the source it just scrolls the keyboard offscreen and hides the background layer, but I think keyboardInit() resets that stuff by re-initializing the background.

AntonioND commented 2 months ago

The problem is that the background layer is enabled when it is set up (so, if there are graphics in VRAM, it will display them right away), then the keyboard graphics are loaded, then the background layer is hidden.

This patch should fix that: https://github.com/blocksds/libnds/commit/62a019b0838e591a206486064ff46978d2834446

Now I hide the layer right after it's set up. I've also added keyboardEnd() to hide the keyboard right away in case it's needed to hide it without an animation in some case.

AntonioND commented 2 months ago

@asiekierka has also provided this additional patch to fix a couple of things I missed in mine: https://github.com/blocksds/libnds/pull/91

AntonioND commented 2 months ago

I'm closing this due to inactivity. If the bug is still there, feel free to re-open the issue.