Bug in Keyhandling on MacOS & Windows

There is a long standing bug in SDL keyhandling on MacOS & Windows.

Example: on a german keyboard, y and z are swapped. However, if I
press ‘Z’, keysymbol SDLK_Y (!) is returned by SDL.

Reason (on mac at least, I will only speak about MacOS from now since
I have no windows to test on): the pure scancode is used to generate
the keysym. However, obviously this is wrong: scancodes are keyboard
dependant, while keysym shouldn’t be.

I am not certain about how to fix this (it would involve accessing
the data in the active ‘KMAP’ resource I guess), but maybe someone
here has an idea?

Max–

Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890

Hi!On Sun, Jan 07, 2001 at 09:50:21PM +0100, Max Horn wrote:

Example: on a german keyboard, y and z are swapped. However, if I
press ‘Z’, keysymbol SDLK_Y (!) is returned by SDL.

I think this is exactly what is intended. The SDLK_* symbols refer to the
position of a key on the keyboard which is what you want when you’re
using the keyboard for movement/navigation, as is common in games (you also
want the symbols to be independent of any modifier keys). If you want to get
the character value of the keys, turn on the Unicode translation and it
will convert the SDLK’s to their ASCII/Unicode representation, according to
the keymap selected by the user.

Bye,
Christian


/ Coding on PowerPC and proud of it
/ http://www.uni-mainz.de/~bauec002/

I think this is exactly what is intended. The SDLK_* symbols refer to the
position of a key on the keyboard […]

No. SDLK_* should refer to what is printed on the keys, just like X11 keysyms.
Max is correct, this is definitely a bug

Hi!On Mon, Jan 08, 2001 at 12:31:09PM +0100, Mattias Engdeg?rd wrote:

No. SDLK_* should refer to what is printed on the keys, just like X11 keysyms.
Max is correct, this is definitely a bug

I like the current behaviour better. Especially, when the user presses
Shift-1, I want SDL to send me an SDLK_1 with a SHIFT modifier bit, not
an SDLK_EXCLAM (when I’m interested in the ‘!’, I use the Unicode translation).

Bye,
Christian


/ Coding on PowerPC and proud of it
/ http://www.uni-mainz.de/~bauec002/

At 12:31 Uhr +0100 08.01.2001, Mattias Engdeg?rd wrote:

I think this is exactly what is intended. The SDLK_* symbols refer to the
position of a key on the keyboard […]

No. SDLK_* should refer to what is printed on the keys, just like X11 keysyms.
Max is correct, this is definitely a bug

Yes excatly :wink: I had a long discussion on this on IRC yesterday.

Unicode is useless for key input, except maybe for writing. Reason:
if you want to catch for example Ctrl-Alt-m, then the unicode for
this on Mac and Windows (dunno about other OS) will be ‘?’ (greek
small letter mu) so it is not possible to catch it easily.

Max–

Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890

At 13:24 Uhr +0100 08.01.2001, Christian Bauer wrote:

Hi!

No. SDLK_* should refer to what is printed on the keys, just like
X11 keysyms.
Max is correct, this is definitely a bug

I like the current behaviour better. Especially, when the user presses
Shift-1, I want SDL to send me an SDLK_1 with a SHIFT modifier bit, not
an SDLK_EXCLAM (when I’m interested in the ‘!’, I use the Unicode
translation).

You got this wrong. SDL of course will send SDLK_1 and SHIFT, even
with modifiers. The key you pressed is the “1” key primary (it
secondaryil is also the “!” key), so the keysym for it should always
be SDLK_1.

However, the keysym for the key labeled “Z” should always be SDLK_Z.
Note that there also is no keysym SDLK_z (lowercase z) - we always
return the “primary” meaning.

Without this, it is impossible to get key combos cleanly on
international keyboards.

Again: unicode (as you say it correctly) is good for reading text
from the user. SDLK_* (the “keysyms”) are thought for key commands.
Finally, on the lowest level, we have “scancodes”, which are OS
dependant, and usually follow the key layout (however, this is not
always true either!!! in fact, I have three different keyboards here
that all vary slightly, and the keys there do not always have the
same positon, e.g. ‘^’ is differently placed (as a “primary” key).

Max>On Mon, Jan 08, 2001 at 12:31:09PM +0100, Mattias Engdeg?rd wrote:


Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890

I like the current behaviour better. Especially, when the user presses
Shift-1, I want SDL to send me an SDLK_1 with a SHIFT modifier bit, not
an SDLK_EXCLAM (when I’m interested in the ‘!’, I use the Unicode translation).

This is exactly what you should get, and this does not contradict that
the keysym refers to the key, not the position it holds on american
keyboards

I like the current behaviour better. Especially, when the user presses
Shift-1, I want SDL to send me an SDLK_1 with a SHIFT modifier bit, not
an SDLK_EXCLAM (when I’m interested in the ‘!’, I use the Unicode transla=
tion).

Bye,
Christian

I think you misunderstand… Shift-1 would send an SDLK_1
(and and SDLK_LSHIFT or SDLK_RSHIFT)… SDLK_EXCLAM is
reserved for keys that are ‘!’ WITHOUT modifier keys…
like on french keyboards…

Regards,

-Loren


Great news! Get free KNXmail here!
http://www.knx1070.com

Hi!On Mon, Jan 08, 2001 at 01:55:01PM +0100, Max Horn wrote:

However, the keysym for the key labeled “Z” should always be SDLK_Z.
Note that there also is no keysym SDLK_z (lowercase z) - we always
return the “primary” meaning.

What does it return on a Russian keyboard?

Bye,
Christian


/ Coding on PowerPC and proud of it
/ http://www.uni-mainz.de/~bauec002/

At 14:49 Uhr +0100 08.01.2001, Christian Bauer wrote:

Hi!

However, the keysym for the key labeled “Z” should always be SDLK_Z.
Note that there also is no keysym SDLK_z (lowercase z) - we always
return the “primary” meaning.

What does it return on a Russian keyboard?

What does it return on a chinese keyboard?

There is no easy way to support non-latin keyboards at all. Actually,
I am not sure how to write a game for a chinese keyboard at all?!? I
never had to cope with it. If anyone could enlighten us here, please
speak up.

Max>On Mon, Jan 08, 2001 at 01:55:01PM +0100, Max Horn wrote:


Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890