Homebrew HBKBLib - A 3DS Keyboard Library

  • Thread starter Thread starter jbr373
  • Start date Start date
  • Views Views 28,435
  • Replies Replies 62
  • Likes Likes 37
Thanks! :D
E.g. change the x-function to an enter-function, place the "Enter"-Button on the right and the left button exit the homebrew.
[__exit__] & [__enter__] button? :)
That shouldn't be too hard to add,
I'll have to implement a keyboard 3ds.js anyways so I might as well modify this and release it on Github :)
 
  • Like
Reactions: Shadowtrance
Much wow...
The code is really ugly would likely be much faster to just start from scratch; what's up with
Code:
...
else if (Key == HBKB_KEY_SPECIAL_G)
            UserInput += "/";
        else if (Key == HBKB_KEY_SPECIAL_H)
            UserInput += "(";
        else if (Key == HBKB_KEY_SPECIAL_I)
            UserInput += ")";
        else if (Key == HBKB_KEY_SPECIAL_J)
            UserInput += "?";
        else if (Key == HBKB_KEY_SPECIAL_K)
            UserInput += "*";
        else if (Key == HBKB_KEY_SPECIAL_L)
            UserInput += "'";
        else if (Key == HBKB_KEY_SPECIAL_M)
            UserInput += "<";
        else if (Key == HBKB_KEY_SPECIAL_N)
            UserInput += ">";
        else if (Key == HBKB_KEY_SPECIAL_O)
            UserInput += "+";
        else if (Key == HBKB_KEY_SPECIAL_P)
            UserInput += "[";
        else if (Key == HBKB_KEY_SPECIAL_Q)
            UserInput += "]";
        else if (Key == HBKB_KEY_SPECIAL_R)
            UserInput += "{";
        else if (Key == HBKB_KEY_SPECIAL_S)
            UserInput += "}";
        else if (Key == HBKB_KEY_SPECIAL_T)
            UserInput += ",";
        else if (Key == HBKB_KEY_SPECIAL_U)
            UserInput += ";";
        else if (Key == HBKB_KEY_SPECIAL_V)
            UserInput += ".";
        else if (Key == HBKB_KEY_SPECIAL_W)
            UserInput += ":";
        else if (Key == HBKB_KEY_SPECIAL_X)
            UserInput += "-";
        else if (Key == HBKB_KEY_SPECIAL_Y)
            UserInput += "_";
        else if (Key == HBKB_KEY_SPECIAL_Z)
            UserInput += "=";
        else if (Key == HBKB_KEY_SPACE)
            UserInput += " ";
...
ever heard of switch statements?
 
Btw, I have a keyboard class whose layout is define with an XML file. Will be ready soon for a new game, but will need to be modified if you want to use outside of cpp3ds (my lib)

YEFmn95.jpg


https://github.com/Cruel/DrawAttack/blob/master/res/romfs/kb/keyboard.xml

https://github.com/Cruel/DrawAttack/blob/master/src/Keyboard/Keyboard.cpp

You can add as many <layout> elements you want to span any number of additional character sets. I will probably add a japanese keyboard layout as a more verbose example. It uses a single image/font file and each key can use a different <style> which defines font characteristics and texture coordinate for "skinning".

Even more importantly, it has a cursor in the input box which you can tap to change position.
 
Last edited by TheCruel,
Much wow...
The code is really ugly would likely be much faster to just start from scratch; what's up with
Code:
...
else if (Key == HBKB_KEY_SPECIAL_G)
            UserInput += "/";
        else if (Key == HBKB_KEY_SPECIAL_H)
            UserInput += "(";
        else if (Key == HBKB_KEY_SPECIAL_I)
            UserInput += ")";
        else if (Key == HBKB_KEY_SPECIAL_J)
            UserInput += "?";
        else if (Key == HBKB_KEY_SPECIAL_K)
            UserInput += "*";
        else if (Key == HBKB_KEY_SPECIAL_L)
            UserInput += "'";
        else if (Key == HBKB_KEY_SPECIAL_M)
            UserInput += "<";
        else if (Key == HBKB_KEY_SPECIAL_N)
            UserInput += ">";
        else if (Key == HBKB_KEY_SPECIAL_O)
            UserInput += "+";
        else if (Key == HBKB_KEY_SPECIAL_P)
            UserInput += "[";
        else if (Key == HBKB_KEY_SPECIAL_Q)
            UserInput += "]";
        else if (Key == HBKB_KEY_SPECIAL_R)
            UserInput += "{";
        else if (Key == HBKB_KEY_SPECIAL_S)
            UserInput += "}";
        else if (Key == HBKB_KEY_SPECIAL_T)
            UserInput += ",";
        else if (Key == HBKB_KEY_SPECIAL_U)
            UserInput += ";";
        else if (Key == HBKB_KEY_SPECIAL_V)
            UserInput += ".";
        else if (Key == HBKB_KEY_SPECIAL_W)
            UserInput += ":";
        else if (Key == HBKB_KEY_SPECIAL_X)
            UserInput += "-";
        else if (Key == HBKB_KEY_SPECIAL_Y)
            UserInput += "_";
        else if (Key == HBKB_KEY_SPECIAL_Z)
            UserInput += "=";
        else if (Key == HBKB_KEY_SPACE)
            UserInput += " ";
...
ever heard of switch statements?

Yes, and it'd be even better to use uppercase characters only and convert them to lowercase with str.to_lower();
However, I haven't touched this in a while but I'll try to improve it

I might actually take this weekend to improve it, add the QWERTZ Layout and more special characters.
Also, the Android/iOS skin looks fantastic!
 
  • Like
Reactions: filfat
Yes, and it'd be even better to use uppercase characters only and convert them to lowercase with str.to_lower();
However, I haven't touched this in a while but I'll try to improve it

I might actually take this weekend to improve it, add the QWERTZ Layout and more special characters.
Also, the Android/iOS skin looks fantastic!
Or maybe even use the ASCII code and skip the switch statement altogether. :)
 
  • Like
Reactions: norips
Yes, and it'd be even better to use uppercase characters only and convert them to lowercase with str.to_lower();
However, I haven't touched this in a while but I'll try to improve it

I might actually take this weekend to improve it, add the QWERTZ Layout and more special characters.
Also, the Android/iOS skin looks fantastic!
Put your project on github. So we can help ;)
 
Much wow...
The code is really ugly would likely be much faster to just start from scratch; what's up with
Code:
...
else if (Key == HBKB_KEY_SPECIAL_G)
            UserInput += "/";
        else if (Key == HBKB_KEY_SPECIAL_H)
            UserInput += "(";
        else if (Key == HBKB_KEY_SPECIAL_I)
            UserInput += ")";
        else if (Key == HBKB_KEY_SPECIAL_J)
            UserInput += "?";
        else if (Key == HBKB_KEY_SPECIAL_K)
            UserInput += "*";
        else if (Key == HBKB_KEY_SPECIAL_L)
            UserInput += "'";
        else if (Key == HBKB_KEY_SPECIAL_M)
            UserInput += "<";
        else if (Key == HBKB_KEY_SPECIAL_N)
            UserInput += ">";
        else if (Key == HBKB_KEY_SPECIAL_O)
            UserInput += "+";
        else if (Key == HBKB_KEY_SPECIAL_P)
            UserInput += "[";
        else if (Key == HBKB_KEY_SPECIAL_Q)
            UserInput += "]";
        else if (Key == HBKB_KEY_SPECIAL_R)
            UserInput += "{";
        else if (Key == HBKB_KEY_SPECIAL_S)
            UserInput += "}";
        else if (Key == HBKB_KEY_SPECIAL_T)
            UserInput += ",";
        else if (Key == HBKB_KEY_SPECIAL_U)
            UserInput += ";";
        else if (Key == HBKB_KEY_SPECIAL_V)
            UserInput += ".";
        else if (Key == HBKB_KEY_SPECIAL_W)
            UserInput += ":";
        else if (Key == HBKB_KEY_SPECIAL_X)
            UserInput += "-";
        else if (Key == HBKB_KEY_SPECIAL_Y)
            UserInput += "_";
        else if (Key == HBKB_KEY_SPECIAL_Z)
            UserInput += "=";
        else if (Key == HBKB_KEY_SPACE)
            UserInput += " ";
...
ever heard of switch statements?

I do agree that this code is strange but I recently hear (sorry I don't have the source anymore nor the time to search, I think it's from a Google development seminar) that switch statements should always be avoided and is crap, its not better than an if/else. So.. You didn't made a point there ;)
 
Last edited by cpasjuste,
I did work on it already for a bit today and made it more readable and simpler, so that it's more easy to edit if someone wants to do that (or one could in fact use ASCII code instead, didn't really think of that!)
The first release of this was a quick way to get a Keyboard library out ;)
And putting this Code on Github needs to be done as well, and I will create a GitHub Account and push this source as soon as I've finished my 2D Sideview Game Code (so I can upload both in one big push)
 
  • Like
Reactions: filfat
Has anyone used this with a sf2dlib screen?
i.e: i draw a sf2d screen then, if needed, i call the keyboard.

The problem is that no matter what i do the keyboard doesn't appear on screen (i'm drawing the bottom screen and then, if needed, i call the keyboard with CallKeyboard)

[EDIT]For future references: it doesn't run well inside a sf2d_frame
 
Last edited by Slashcash,
  • Like
Reactions: clank
This looks great, I may use this on a project I'm working on! It definitely would make my life a bit easier in terms of UI design...
 
Another reference for future users: the provided pre-compiled library doesn't work well with the latest ctrulib. Just recompile it entirely, you will save some head-ache
 
How do I install and use this? When I try to run make on the demo I get undefined references and I make install doesn't work after I run make on the library source. I tried putting libhbkb.a into /usr/local/ manually as well but to no avail.
 
Last edited by Monado_III,
Is there any reason not to use the apt swkbd applet?

Sure, nobody's reversed it yet, not to mention launching library applets in ctrulib is broken (at least according to the comment, it leaves a zombie process/thread running or something).
 

Site & Scene News

Popular threads in this forum