![]() |
|
Allegro 5 User Input |
ma3stro
Member #15,329
October 2013
|
I have these lines in my project: ALLEGRO_USTR *input= al_ustr_new(""); . if(events.keyboard.unichar >= 32) . and here, I want to test the input with an if statement but I am not allowed to compare ALLEGRO_USTR format with char* or int. How can I make something like this work : if(input == '3') ? |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
How did you declare input? Int? They all watch too much MSNBC... they get ideas. |
ma3stro
Member #15,329
October 2013
|
ALLEGRO_USTR* format. |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
I'd think this would work int inchar = events.keyboard.unichar; if(inchar >= 32) { pos += al_ustr_append_chr(input, inchar); blah blah if(inchar == '3') { blah . . .
They all watch too much MSNBC... they get ideas. |
ma3stro
Member #15,329
October 2013
|
Thanks, it works! One more question, What if I use the backspace key? |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
I also get the keycode into an int, i.e. int inkey = events.keyboard.keycode; if(inkey == ALLEGRO_KEY_BACKSPACE) { blah
They all watch too much MSNBC... they get ideas. |
ma3stro
Member #15,329
October 2013
|
Of course, the last question was stupid |
Aikei_c
Member #14,871
January 2013
![]() |
By the way, don't forget that you have to eventually free ALLEGRO_USTR* with a call to al_ustr_free() |
|