Unicode & SDL_GetKeyState

Hi!

I have the unfortunate task of reinventing the wheel to make an edit box
in my GUI system.
I’ve been using SDL_GetKeyState to update my keyboard state info.
I am reluctant to switch to using the event system.
Is there some way that I can obtain the unicode character of a key (if
any) when I have the SDLK_ value returned by SDL_GetKeyState?

Thanks,–
Dan “Aggrav8d” Royer
CEO / Lead Programmer
Marginally Clever Games

Hi!

I have the unfortunate task of reinventing the wheel to make an edit
box in my GUI system.
I’ve been using SDL_GetKeyState to update my keyboard state info.
I am reluctant to switch to using the event system.

Why? It’s the only sensible way of doing it, IMHO. :slight_smile:

Is there some way that I can obtain the unicode character of a key
(if any) when I have the SDLK_ value returned by SDL_GetKeyState?

Not without bypassing SDL, AFAIK.

However, if you really don’t want to refactor your code to use events
for some reason, how about replacing SDL_PumpEvents() with your own
implementation that captures Unicode as well?

That said, you can count on lost keys and other weird stuff if you do
it this way, especially if your frame rate ever drops significantly.
Processing the events yourself is the only reliable method, unless
the only thing you want to know is whether or not a certain key is
down at the moment.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Sunday 13 February 2005 22.10, Dan Royer wrote:

I have the unfortunate task of reinventing the wheel to make an edit box
in my GUI system.
I’ve been using SDL_GetKeyState to update my keyboard state info.
I am reluctant to switch to using the event system.
Is there some way that I can obtain the unicode character of a key (if
any) when I have the SDLK_ value returned by SDL_GetKeyState?

Some time ago I’ve encountered almost identical problem (SDL_GetKeyState, how to get uppercase keycodes for GUI edit etc.), I’ve also asked for help on this list and response I got, was simple: switch to events. I’ve started arguing, there was good discussion about pros and cons of events, SDL_GetKeyState() etc., and eventually, at the end, I said “thx guys, it looks like events are really the only way to go”, opened IDE and started changing code.
Since then, my new input code has been working almost flawlessly; if you want, I can send you code or give some tips how to write it from scratch. But now, I have only one, probably sad, advice for you: your only hope is switching to events…

Koshmaar

P.S. ok, ok, but if you have much free time, you can alwyas try hacking things with SDL_GetKeyState, and if you succeed - remember to write about it on this list, I’m sure everyone would be happy to see that there’s other solution.