I've been working on this problem recently and my solution was to use the dbEntry command to create a char* array that I would output to the screen. After capturing this string you have to remove any escape characters from it, such as the backspace or tab characters. The way I am doing this now is brutish and ugly and doesn't seem to work properly with the tab character yet, I am going to likely reprogram it before putting it into my main game.
Here is the code, put this in your main loop:
I really suggest changing my example as it is really programmed badly.
while (LoopGDK()) {
dbCLS ();
tempIn = dbEntry ();
tLen = dbLen(tempIn);
if (tLen > 0) {
for (int i = 0;; i ++) {
if (tempIn[i] == '\0') { break; }
if (tempIn[i] == '\b') {
tLen--;
for (int j = i; j < dbLen(tempIn); j++) {
tempIn[j - 1] = tempIn[j + 1];
}
tempIn[tLen] = '\0';
i = 0;
}
}
tLen = dbLen(tempIn);
if (tempIn[0] == '\b') {
for (int i = 0;; i ++) {
if (tempIn[i] == '\0') { break; }
if (tempIn[i] == '\b') {
for (int j = i; j < dbLen(tempIn); j++) {
tempIn[j] = tempIn[j + 1];
}
}
}
}
for (int i = 0;;i++) {
if (tempIn[i] == '\0') { break; }
if (tempIn[i] == '\t' || tempIn[i] == '\n' || tempIn[i] == '\f' || tempIn[i] == '\r' || tempIn[i] == '\a' || tempIn[i] == '\b') {
for (int j = i; j < dbLen(tempIn); j++) {
tempIn[j] = tempIn[j + 1];
}
i = 0;
}
}
}
arial->AAPrint (0, 0, ALIGN_LEFT, "Welcome to BorealisClient, please enter an IP address:");
arial->AAPrint (0, 15, ALIGN_LEFT, "IP Address>");
arial->AAPrint (90, 15, ALIGN_LEFT, tempIn);
if (dbReturnKey () == 1 && dbLen(tempIn) > 1) {
dbClearEntryBuffer ();
ipAddress = tempIn;
tempIn = NULL;
break;
}
dbSync();
} // End of loop
I attached to this post the server and chat client I am working on for my game (I will eventually integrate the above code into my game for a chat box), it should show you the code in action.
------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.