[SDL] Reading text from keyboard

ToyToy toytoy at gmx.ch
Fri Jan 17 14:07:02 PST 2003


I now added unicode support with SDL_EnableUNICODE(1) and try to process the
events like this:

			case SDL_KEYDOWN:
				if((Event.key.keysym.unicode & 0xFF80) == 0)
					char ch = Event.key.keysym.unicode &
						m_strText += ch;

The problem is that the variable ch is always zero whatever key I press. Do
you have any idea what I'm doing wrong? (I've got WinXP)

Milo Spirig

-----Ursprüngliche Nachricht-----
Von: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] Im Auftrag von David
Gesendet: Freitag, 17. Januar 2003 18:46
An: sdl at libsdl.org
Betreff: Re: [SDL] Reading text from keyboard

On Friday 17 January 2003 15.20, toytoy at gmx.ch wrote:
> Hi
> I'm looking for a comfortable possibility to read text from the 
> keyboard. At the Moment I'm checking for a lot key combinations for 
> special characters, but that's really bad, specially because I got a 
> swiss keyboard... Is there a better way to do this job, I already 
> tried the SDL input events but it seems they also don't give you key 
> combinations (like shift+1, ...).

They sure do, but *all* physical keys are treated as such, regardless 
of keymaps and stuff. Think of the keyboard as a gigantic gamepad. :-)

As to your problem, you're *not* supposed to do this yourself in an 
application, ever. That won't work with different layouts (like 
Dvorak... *heh*), and it hardcodes your application to a specific 
language for no good reason.

Doesn't UNICODE provide the information you need?

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

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. | RT and 
| off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -'
   --- http://olofson.net --- http://www.reologica.se ---

SDL mailing list
SDL at libsdl.org

More information about the SDL mailing list