Danish ae, o and a on the keyboard :)

Hello!

I’m wondering how to test for the danish letters
?, ? and ? on the keyboard with SDL. If I test
for SDLK_SEMICOLON, SDLK_QUOTE and SDLK_LEFTBRACKET
respectively it works as it should on an american
keyboard map (which is of course not supposed to work
at all…) :slight_smile:
But when changing to danish keyboard map the
? and ? does not work anymore - but ?
(that would be SDLK_QUOTE) still works…
very odd - eh?

Anybody knows how this keyboard stuff is supposed
to work? Sam?

Cheers–
http://www.HardcoreProcessing.com

I’m wondering how to test for the danish letters
?, ? and ? on the keyboard with SDL. If I test
for SDLK_SEMICOLON, SDLK_QUOTE and SDLK_LEFTBRACKET
respectively it works as it should on an american
keyboard map (which is of course not supposed to work
at all…) :slight_smile:
But when changing to danish keyboard map the
? and ? does not work anymore - but ?
(that would be SDLK_QUOTE) still works…
very odd - eh?

Anybody knows how this keyboard stuff is supposed
to work? Sam?

Yep, here’s the process (using the latest CVS snapshot):
Add “-DDEBUG_KEYS” to the obj/x11 Makefile and compile SDL.
Run the keyboard example program from the SDL example archive. You’ll need the FreeType library and a TrueType font with all the international glyphs in it.
Change your keyboard map to the one for your keyboard (danish), and start typing each key on your keyboard. SDL will print out the X keysym of each key that is pressed, and the keyboard program will print out what SDL thinks it is. :slight_smile:
Now, for each key that isn’t right, look it up in /usr/X11R6/include/X11/keysymdef.h and add it to the keymap initialization in SDL_InitOSKeymap() in SDL_sysevents.c. You’ll probably also need to add the key to SDL_keysym.h - you’ll need to add it with the actual ASCII value of the key. A sample program at the end of this message will show you how to get that value. If the ASCII value conflicts with existing keysyms, let me know, and I’ll pick a new value for the existing sym. You’ll also need to add that key to the key name initialization in SDL_keyboard.c. Repeat this process for each un-shifted/un-control’d key on the keyboard.
Now, add a section to SDL_keyboard.c for your keyboard layout, including all shifted and control’d and alt-gr’d keys on your keyboard. This should just be a matter of typing the appropriate key into the file.
Now go over the entire keyboard and make sure all the keys work as expected, in both US keyboard layout and your keyboard layout. Then, send me a patch! :slight_smile:

I’ll be happy to do this process for you, all you have to do is send me a keyboard and which X keyboard layout to use:
Sam Lantinga
23149 Los Alisos Blvd #202
Mission Viejo, CA 92691
USA
I’ll even send the keyboard back, if you want. :slight_smile:

Here’s a test program to get the ASCII value of a keystroke:

– printkey.c –

#include <stdio.h>

main()
{
int c;

    while ((c=getchar()) != EOF) {
            if ( c != '\n' )
                    printf("%d\n", c);
    }
    exit(0);

}----------------

Hey, anybody know how to do this process for Win32?

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Just a question:
What is the reason why you decided not to use standard X-Keysym-Function…
Is there a problem with Windoze?
Because I alway thought that it is alot of work to add all keyboard layouts

cheers
ManuelOn Wed, 05 May 1999, you wrote:

I’m wondering how to test for the danish letters
?, ? and ? on the keyboard with SDL. If I test
for SDLK_SEMICOLON, SDLK_QUOTE and SDLK_LEFTBRACKET
respectively it works as it should on an american
keyboard map (which is of course not supposed to work
at all…) :slight_smile:
But when changing to danish keyboard map the
? and ? does not work anymore - but ?
(that would be SDLK_QUOTE) still works…
very odd - eh?

Anybody knows how this keyboard stuff is supposed
to work? Sam?

Yep, here’s the process (using the latest CVS snapshot):
Add “-DDEBUG_KEYS” to the obj/x11 Makefile and compile SDL.
Run the keyboard example program from the SDL example archive. You’ll need the FreeType library and a TrueType font with all the international glyphs in it.
Change your keyboard map to the one for your keyboard (danish), and start typing each key on your keyboard. SDL will print out the X keysym of each key that is pressed, and the keyboard program will print out what SDL thinks it is. :slight_smile:
Now, for each key that isn’t right, look it up in /usr/X11R6/include/X11/keysymdef.h and add it to the keymap initialization in SDL_InitOSKeymap() in SDL_sysevents.c. You’ll probably also need to add the key to SDL_keysym.h - you’ll need to add it with the actual ASCII value of the key. A sample program at the end of this message will show you how to get that value. If the ASCII value conflicts with existing keysyms, let me know, and I’ll pick a new value for the existing sym. You’ll also need to add that key to the key name initialization in SDL_keyboard.c. Repeat this process for each un-shifted/un-control’d key on the keyboard.
Now, add a section to SDL_keyboard.c for your keyboard layout, including all shifted and control’d and alt-gr’d keys on your keyboard. This should just be a matter of typing the appropriate key into the file.
Now go over the entire keyboard and make sure all the keys work as expected, in both US keyboard layout and your keyboard layout. Then, send me a patch! :slight_smile:

I’ll be happy to do this process for you, all you have to do is send me a keyboard and which X keyboard layout to use:
Sam Lantinga
23149 Los Alisos Blvd #202
Mission Viejo, CA 92691
USA
I’ll even send the keyboard back, if you want. :slight_smile:

Here’s a test program to get the ASCII value of a keystroke:

– printkey.c –

#include <stdio.h>

main()
{
int c;

    while ((c=getchar()) != EOF) {
            if ( c != '\n' )
                    printf("%d\n", c);
    }
    exit(0);

}

Hey, anybody know how to do this process for Win32?

-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Just a question:
What is the reason why you decided not to use standard X-Keysym-Function…
Is there a problem with Windoze?

The keysyms don’t translate across platforms, unfortunately.

Because I alway thought that it is alot of work to add all keyboard layouts

Yep, I’m open to suggestions that will work on all platforms. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/