Jump to content


Photo

Support For Localized Keyboard Layouts


  • Please log in to reply
7 replies to this topic

#1 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 03 January 2006 - 02:13 PM

I wrote a simple class which allows ppl to use their own local keyboard layouts (like finnish, german or french keyboard layouts) with CEGUI based on http://www.ogre3d.or...boardTranslator

It's working now, but all the keycodes are hardcoded into the source. As obivious, a XML based configuration would be better, but I'd like some advice how to store the data into xml.

Ogre gives us they keyboard character, like 'c' or '!' if it knows it (unsigned char). If it doesn't, the other option is to use the ((Ogre::KeyEvent *)e)->getKey(), which returns an int.

So, the question is, how to store an unsigned char character, like 'c', or an unsigned char integer, like 99 (which stands for 'c') into XML avoiding any problems with XML character set? I would also appreciate an example =)

- Garo

#2 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 03 January 2006 - 08:56 PM

Like that? :huh:

<Key Name="F5" Code="0x3F"/>


Ah, the key name has to be in native language.. Then like that (in ASCII xml):

<Key NameIndex="15" Code="0x3F"/>


And in separate unicode file on line 15th store key name. At startup load the file in a vector of unicode strings or something...

Or in whatever way, but I think it better be in separate file.

(You need to store key name, right?)
Darkness is under the candle.

#3 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 03 January 2006 - 11:06 PM

(You need to store key name, right?)

<{POST_SNAPBACK}>


I'm not so sure. Currently, the system works as a simple translation engine. If the character which comes from Ogre is specified, then it's just translated into another character.

Some pseudocode:

Ogre::KeyEvent *e;
unsigned char before = e.getKeyChar();
unsigned char after;
if (before is inside native_character array at index i) {
  after = finnish_keymap_array[i];
} else {
  after = before;
}

I haven't checked it out yet, but does Ogre and CEGUI support unicodes? The KeyboardTranslator which I've copied and added a finnish keyboard map is a really simple thing, it just translates the characters before they are injected into CEGUI.
It does work, but if we really want to have full support for UNICODE, I think this isn't enough :(

- Garo

#4 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 04 January 2006 - 09:31 AM

Guyver thinks that we should not develop this further by now, and I agree him. Maybe later, when we have time, we can move the hardcoded translation tables into (for example) XML files, so that others can easily create new layout maps. I'll commit this soon into dagonsquirrel branch, where it will be soon merged into HEAD.

It currently supports Finnish, French and Germany layout maps =)

If we have foreign coders, they can create their own local layout maps into this if they wish.

- Garo

#5 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 05 January 2006 - 08:45 PM

Ah.. I don't get it. What do you mean by keyboard layout? That english 'A' will be tied up to a different key and have a different code coming from keyboard?
Darkness is under the candle.

#6 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 05 January 2006 - 10:16 PM

Ah.. I don't get it. What do you mean by keyboard layout? That english 'A' will be tied up to a different key and have a different code coming from keyboard?

<{POST_SNAPBACK}>


Here's an image of our keyboard layout (used by the finns and the swedish ppl) http://content.answe...out_Swedish.png

In english layout, you get * (star) by pressing shift-8 (if I member correctly) but in our layout that combination gives '('.

So with this, I can type the special characters (like *, (, ), /, +, ? etc) as I have used to. The normal letters and numbers are at the same place, they aren't changed.

- Garo

#7 UnFleshed One

UnFleshed One

    Programming Department

  • Xenocide Inactive
  • 304 posts

Posted 06 January 2006 - 01:02 AM

Heh, and what about russian and all languages that have nothing in common with english?

I have two completely different layouts on my keyboard. One english and one russian. And when I want to type in russian, а question mark is shift-7 (and all other keys are messed up basically). Typing in both layouts at the same time is real pain in the lower back (although there is some nice software).

Hm, what I mean is that I don't expect programs (and games too) to support both layouts. (where is the dot now, is it in english layout, is it in russian layout, is it in english transcoded as russhian or russian as english?). I know that when I'm in russian, shift-7 will type '?', when in english -- shift-/. If something starts to type comma when I'm in english and expect a question mark, it will give me an epileptic strike :).

Anyway, isn't it a king of thing that supposed to be specified by OS? That is a '(' will always have the same int even if you are pressing three fingered combinations to get it?
Darkness is under the candle.

#8 Garo

Garo

    Programming Department

  • Xenocide Programming Department
  • 119 posts

Posted 06 January 2006 - 01:08 AM

Anyway, isn't it a king of thing that supposed to be specified by OS? That is a '(' will always have the same int even if you are pressing three fingered combinations to get it?

<{POST_SNAPBACK}>


Yes. OS does this. But I don't think that Ogre can do it. It seems to hook they keyboard at much lower level than the OS is.

- Garo