• Advertisement
Sign in to follow this  

hello problem with SDL_Event please help ...

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a little problem with SDL_Event please have a look at next code void get_number(board b, Textures *T,int i,int j) { SDL_Event event; SDL_Color color = {0x8b,0x8b,0x8b}; char c; char str[2] = "\0"; int got_number = 0; while(got_number == 0) { SDL_WaitEvent(&event); if(event.type == SDL_KEYDOWN) { if(( event.key.keysym.unicode >= (Uint16)'0' ) && ( event.key.keysym.unicode <= (Uint16)'9' )) { c = (char)event.key.keysym.unicode; if(c - 48 == 0) { b[j].number = 0; b[j].type = 0; (*T).Board[j] = NULL; } else { str[0] = c; b[j].number = c - 48; b[j].type = 2; (*T).Board[j] = TTF_RenderText_Solid((*T).font,str,color); } got_number = 1; } } } } The problem is that it gets that i pressed any key but it doesnt gets which key was pressed and of course it isnt gets out of while. i dont know where the problem is ... maybe there is another way to work with keys ? Sorry for my english. Hope for your respond and thank you!

Share this post


Link to post
Share on other sites
Advertisement
Have you enabled UNICODE processing (i.e. called SDL_EnableUNICODE) before that? As far as I know you habe to enable that for event.key.keysym.unicode to contain meaningfull values.

Share this post


Link to post
Share on other sites
Quote:
Original post by sebbit
Have you enabled UNICODE processing (i.e. called SDL_EnableUNICODE) before that? As far as I know you habe to enable that for event.key.keysym.unicode to contain meaningfull values.



No ... i think i didnt ...
Any way i hear first time about that ...

Can you please tell me how to do it?

Share this post


Link to post
Share on other sites
Here's the relevant part of the SDL Documentation SDL_EnableUNICODE.
In short: just call SDL_EnableUNICODE( SDL_ENABLE ) before you use event.key.keysyum.unicode.

Share this post


Link to post
Share on other sites
Quote:
Original post by sebbit
Here's the relevant part of the SDL Documentation SDL_EnableUNICODE.
In short: just call SDL_EnableUNICODE( SDL_ENABLE ) before you use event.key.keysyum.unicode.



Thank you it worked!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement