Homebrew HBKBLib - A 3DS Keyboard Library

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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?
 

TheCruel

Developer
Banned
Joined
Dec 6, 2013
Messages
1,350
Trophies
2
XP
3,131
Country
United States
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,

jbr373

Member
OP
Newcomer
Joined
Aug 17, 2015
Messages
18
Trophies
0
Age
30
XP
227
Country
Gambia, The
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

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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

norips

Active Member
Newcomer
Joined
Aug 13, 2012
Messages
32
Trophies
0
XP
162
Country
France
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 ;)
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,483
Country
France
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,

jbr373

Member
OP
Newcomer
Joined
Aug 17, 2015
Messages
18
Trophies
0
Age
30
XP
227
Country
Gambia, The
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

Slashcash

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
338
Trophies
0
XP
611
Country
Italy
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
D

Deleted User

Guest
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...
 

Slashcash

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
338
Trophies
0
XP
611
Country
Italy
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
 

Monado_III

Well-Known Member
Member
Joined
Feb 8, 2015
Messages
722
Trophies
0
Location
/dev/null
XP
1,443
Country
Canada
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,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    BakerMan @ BakerMan: decade dance, roller mobster, in the face of evil, sexualizer