Opened 18 years ago

Closed 17 years ago

Last modified 17 months ago

#431 closed defect (fixed)

ALL: key translation

Reported by: SF/madshi Owned by: fingolfin
Priority: low Component: GUI
Keywords: Cc:
Game:

Description

ScummVM doesn't translate keys correctly. When pressing e.g. a german umlaut key, I get whatever is on the english keyboard instead.

First I thought this would be a bug in SDL, so I wrote to SDL about it. I got a little demo source back from Sam Lantinga showing how to do things right. Here is the patch for ScummVM, could someone please check it in? Thank you!

In the initialization somewhere call:

/* Enable UNICODE translation for keyboard input */ SDL_EnableUNICODE(1);

Then in SDL.cpp in "OSystem_SDL::poll_event" please check whether "ev.key.keysym.unicode" is filled. If it is, please use that instead of "ev.key.keysym.sym". That was it. Here's a part of the sources I got from Sam:

if ( sym->unicode ) { /* Is it a control-character? */ if ( sym->unicode < ' ' ) { printf(" (^%c)", sym- >unicode+'@'); } else { #ifdef UNICODE printf(" (%c)", sym->unicode); #else /* This is a Latin-1 program, so only show 8-bits */ if ( !(sym->unicode & 0xFF00) ) printf(" (%c)", sym- >unicode); #endif } }

This code correctly gives me all german special characters.

Ticket imported from: #600258. Ticket imported from: bugs/431.

Change History (7)

comment:1 by fingolfin, 18 years ago

Ah if it was so easy, but it isn't.

See: We are using key combos like e.g. Alt-0. On my keyboard, this will generates the character != (not equal sign). If we would use the unicode character, we could not anymore detect these key combos properly. Same for any combo that involves Shift.

We could still fix this by using the keysym for keycombos, and the unicode value for text intput... only that some key combos are done by the Scumm code itself, it seems. So it's very very tricky, I am not even sure it's posssible at all do get this completly right.

FYI, we had the same problem in Exult.

comment:2 by SF/madshi, 18 years ago

Wow, fast reply!

Hmmm... You're right. Sigh. And it gets even *more* complicated: Strg-Z is Strg-Y on my keyboard, so this combo would only work *with* unicode... :-)

>> We could still fix this by using the keysym for >> keycombos, and the unicode value for text intput.

Sounds like a good idea. I could easily live with "wrong" special key combos like Strg+Y, if only the text input would be correctly translated...

Or alternatively (maybe even better) double check both the sym and the unicode values for key combos. This way Alt-O would work for you. And for me both Alt-Z and Alt-Y would have the same effect.

>> only that some key combos are done by >> the Scumm code itself, it seems

I'm sorry, I don't understand that part of your comment. What do you mean with that?

comment:3 by fingolfin, 17 years ago

See also https://sourceforge.net/tracker/index.php?func=detail&aid= 551447&group_id=37116&atid=418820

comment:4 by fingolfin, 17 years ago

Priority: normallow
Summary: key translationALL: key translation

comment:5 by fingolfin, 17 years ago

Implemented in CVS. It wasn't that bad to do at all, it turned out :-)

comment:6 by fingolfin, 17 years ago

Owner: set to fingolfin
Resolution: fixed
Status: newclosed

comment:7 by digitall, 17 months ago

Component: --Unset--GUI
Note: See TracTickets for help on using tickets.