Hi everyone, I'm trying to program a game in C++ using SDL and i want to get peoples names. its not working though, and I'm really confused as to why. :?:
i'm using code like the following:
StringInput.h
class StringInput {
private:
std::string str;
SDL_Surface *text;
int x,y,r,g,b;
SDL_Color textColor;
Uint32 uc;
public:
StringInput(int x, int y);
...
handleInput();
...
};
StringInput.cpp
StringInput::StringInput(int x, int y) {
...
SDL_EnableUNICODE(1);
}
...
void StringInput::handleInput() {
...
if(event.key.keysym.sym!=SDLK_BACKSPACE){
str+=(char)(event.key.keysym.unicode);
} else if(str.length()!=0){
str.erase(str.length()-1);
} else { }
...
}
...
At this point I have done a lot of debugging output to a file called stdout.txt
I have figured out that the value event.key.keysym.unicode is 0 all the time when I type something (normally something like jaksl ... )
What could cause this and how to fix it?
This is in a game of mine that I really want to make. I need help badly. :(