So I'm making a little console thingy that toggles with the F1 key. I enabled unicode, and decided I might use some unicode to write stuff. But, no characters are read!
Look:
Init unicode:
void input::enable_unicode() {
//if (!is_unicode_on()) // don't need right now
SDL_EnableUNICODE(1);
}
input::input() {
::benefit::input::enable_unicode(); // HERE
_fill_keys(m_ascii_keys);
m_keys = NULL;
m_quit_requested = NULL;
}
Convert from unicode to ascii:
char input::to_ascii(Uint16 unicode) {
char c = '\0';
if ((unicode & 0xFF80) == 0)
c = unicode & 0x7F;
return c;
}
Take the char and add it:
void on_keydown(SDL_keysym key) {
switch (key.sym) {
case SDLK_F1:
m_console.set_focus((m_console.has_focus()) ? false : true);
break;
case SDLK_ESCAPE:
this->benefit::input::request_quit();
break;
default:
break;
}
if (m_console.has_focus()) {
switch (key.sym) {
case SDLK_BACKSPACE:
m_console.pop_char();
break;
case SDLK_RETURN:
m_console.push_line();
break;
default: {
char c = benefit::input::to_ascii(key.unicode);
if (c != '\0')
m_console.push_char(c); // THIS NEVER GET'S CALLED!
} break;
}
}
}
And the funky thing is, that if I comment out the 'c' stuff and just push_char() an 'a' or something, it works (I get 'a's for every key, but I actually want the actual unicode [ascii]).
Any ideas?
And yes, I have enabled my console ;P. I get my message:
app() {
m_quit = false;
m_console.font.load_font("Font.bmp", 0, 0, 0);
m_console.set_wh(VIDEO_W, int(float(VIDEO_H) * 0.5f));
m_console.push_line("Console initialized!"); // I RECIEVE THIS!!!
m_console.push_line();
m_console.set_focus(true);
m_video.initialize_window(VIDEO_W, VIDEO_H, "App!");
m_renderer.resize_viewport(0, 0, VIDEO_W, VIDEO_H);
}
And the other funky thing is that enter does what it is supposed to, and backspace too. Just the unicode seems to not work.