PDA

View Full Version : Turkish Language Support



m339
02-22-2013, 10:18 AM
Hello,

As there is no Turkish language support in current version of teensyduino/arduino, I am not able to work with my teensy 3.0 with Turkish Keyboard.
How can I add my own Turkish language keyboard support to my teensy 3.0 ?

Regards,

Nantonos
02-22-2013, 07:12 PM
Look in hardware/teensy/cores/teensy3 at the file keylayouts.h. Make a backup of it first, then open in a text editor to see how the various existing keyboards are defined. Make a new section (probably best to copy another keyboard that is similar) then edit. The thing to bear in mind is that the keys are named after the American keyboard layout (http://en.wikipedia.org/wiki/Keyboard_layout#United_States) so for example the top left key is called KEY_TILDE because there is a ~ there on the US layout. In the Turkish keyboard section you define that, for example, KEY_TILDE plus shift gives you .

You will of course know how a Turkish keyboard is laid out but for other folks reading this thread this is the layout (http://en.wikipedia.org/wiki/Keyboard_layout#Turkish_.28Q-keyboard.29).

If you get it working then post it here as an attachment and if you get stuck, let us know.

Nantonos
02-22-2013, 07:41 PM
It just occurred to me that your question could be interpreted two ways. One way (the way I answered) is about making a device using Teensy that acts like a Turkish USB keyboard.

But maybe you meant that your computer keyboard is not supported when you are progrmming? If that is the case then the answer probably involves modifying Java files and Paul would need to ansewr that (its also possible that the support would be better added to the Arduino environment so people not using Teensy would also benefit).

PaulStoffregen
02-22-2013, 08:15 PM
Would anyone be willing to put together a list of the Unicode numbers for those special keys (anything that has a Unicode number higher than 255)?

PaulStoffregen
02-22-2013, 09:48 PM
But maybe you meant that your computer keyboard is not supported when you are progrmming? ...... its also possible that the support would be better added to the Arduino environment so people not using Teensy would also benefit.

The Arduino IDE already has many translations.

http://playground.arduino.cc/Main/LanguagesIDE

Turkish is "in progress", so not yet in the File > Preferences list. That page has info about contributing to the translations.

Teensyduino does not have any non-English support, but it has relatively few messages that appear.

Nantonos
02-22-2013, 10:04 PM
Would anyone be willing to put together a list of the Unicode numbers for those special keys (anything that has a Unicode number higher than 255)?

011E Ğ Latin capital letter G with breve
011F ğ Latin small letter g with breve
0130 İ Latin captial letter I with dot above
0131 ı Latin small letter dotless i
015E Ş Latin capital letter S with cedilla
0151 ş Latin small letter s with cedilla

There are five dead keys for accents shown in red here (http://en.wikipedia.org/wiki/File:KB_Turkey.svg)

Notice that in Turkish (rather logically in fact) the capital form of dotted i is capital dotted i and the lowercase form of I is lowercase dotless i.

Edit: can you believe that the Unicode code charts are in protected PDF so you can't copy paste from them? Hence two edits to this post to correct spelling mistakes, sigh.

Nantonos
02-22-2013, 10:06 PM
That page has info about contributing to the translations.

Teensyduino does not have any non-English support, but it has relatively few messages that appear.

Ah yes, that is yet a third meaning of supported (the menus, messages etc are translated). I don't think that was the comment here though, due to the specific mention of the keyboard.

Nantonos
02-22-2013, 10:10 PM
OK I just added a Turkish keyboard layout to my Win7, starte up Arduino 1.0.3+Teensyduino 112 and set the keyboard to Turkish. As expected, pressing the [ and ] keys produced "ğ". So a Turkish keyboard is supported in the Arduino environment, at least on Windows. I think "making a Teensy be a Turkish keyboard" was meant.

PaulStoffregen
02-23-2013, 01:12 PM
011E Ğ Latin capital letter G with breve
011F ğ Latin small letter g with breve
0130 İ Latin captial letter I with dot above
0131 ı Latin small letter dotless i
015E Ş Latin capital letter S with cedilla
0151 ş Latin small letter s with cedilla


Currently keylayouts.c has 2 arrays, one for code points 0 to 127, and another for 128 to 255. Unicode 20AC (the Euro sign) is handled as a special case. As things exist at the moment, there's no code to map other Unicode numbers to the keycodes.

It seems like most of the non-European keyboards will need only a handful of Unicode mappings, sparsely populating the 16 bit range above 00FF, so a huge array probably is not a good idea. Maybe an array of unicode numbers and keycode pairs would be better? It'll require a search, rather than a quick direct lookup, but maybe that's a reasonable trade-off? I guess the question is whether other layouts people request in the future will need only small numbers of Unicode mappings above 00FF, and how far they'll be distributed over the Unicode 16 bit range?

m339
02-23-2013, 03:55 PM
Hello Nantonos, could you share your Turkish keyboard layout please? When i use keyboard println, when i type cmd.exe for example it presses as cmdexe

Regards,

Nantonos
02-24-2013, 01:12 AM
Currently keylayouts.c has 2 arrays, one for code points 0 to 127, and another for 128 to 255. Unicode 20AC (the Euro sign) is handled as a special case. As things exist at the moment, there's no code to map other Unicode numbers to the keycodes.

Aha okay, I saw the ascii and 8859-1 (basic latin) arrays in keylayouts.c and I wasn't sure how was being handled.


It seems like most of the non-European keyboards will need only a handful of Unicode mappings, sparsely populating the 16 bit range above 00FF, so a huge array probably is not a good idea.

Yes, a huge array is not a good idea, especially as it extends to 10FFFF.


Maybe an array of unicode numbers and keycode pairs would be better? It'll require a search, rather than a quick direct lookup, but maybe that's a reasonable trade-off? I guess the question is whether other layouts people request in the future will need only small numbers of Unicode mappings above 00FF, and how far they'll be distributed over the Unicode 16 bit range?

(Unicode does not have a 16-bit range).

Agreed, since most keyboards have relatively few keys (even with modifier keys included). The keyboards that produce a lot of characters (Japanese, Chinese, Korean) do so in combination with an input method editor (IME) running on the OS, so the actual keyboard part is relatively simple still; the complexity (and large dictionaries) are in the OS.

Nantonos
02-24-2013, 01:19 AM
Hello Nantonos, could you share your Turkish keyboard layout please? When i use keyboard println, when i type cmd.exe for example it presses as cmdexe

What OS are you using and do you have a Turkish keyboard layout installed there (i.e. when you type in a plain text editor, do the right letters come out as printed on the keyboard)?

When I say that I tried a Turkish keylayout, I mean that I switched to that in the OS (Windows 7) while running Arduino, and verified that the correct characters came out according to the Turkish keyboard layout on wikipedia.

271

m339
03-06-2013, 11:42 AM
Yes, I am using Turkish Keyboard on Windows 7 64 Bit and all Turkish characters works fine except in Arduino.

PaulStoffregen
03-06-2013, 01:58 PM
Ok, here's my first attempt at a Turkish layout. This is untested, so expect some problems. I'll try to fix them as they're discovered.

Also, this will NOT support the 6 special characters mentioned above. Those require part of the Keyboard code to be rewritten. First, let's try to get just the other keys working...

To use this, add these lines to hardware/teensy/boards.txt



teensy3.menu.keys.tr-tr.name=Turkish
teensy3.menu.keys.tr-tr.build.define1=-DLAYOUT_TURKISH


Then add the contents of the attached file to hardware/teensy/cores/teensy3/keylayouts.h

Again, this is untested, and I did it after staying up all night, so it's almost certain to have some errors. Please try to be specific when reporting the problems, and I'll get them fixed.

Nantonos
03-07-2013, 03:15 AM
This seems to be largely correct. I found two errors (and six omissions, which it is cleaner to add for checking even if the values are not yet supported, and also helped me to find the errors). I guess Paul that you either didn't see, or didn't understand, when I said earlier:


Notice that in Turkish (rather logically in fact) the capital form of dotted i is capital dotted i and the lowercase form of I is lowercase dotless i.
On a Turkish keyboard the I key produces the dotless forms and the @/' key (which has an İ on it) produced the dotted forms.

These two lines are incorrect:


#define ASCII_69 KEY_I // 105 i
#define ISO_8859_1_E9 ACUTE_ACCENT_BITS + KEY_E // 233 e ACUTE

and should be replaced by these two:


#define ASCII_69 KEY_QUOTE // 105 i
#define ISO_8859_1_E9 KEY_TILDE + SHIFT_BITS // 233 e ACUTE

while these should be added:


// not yet implemented
#define UNICODE_011E KEY_LEFT_BRACE + SHIFT_MASK // 011E Ğ Latin capital letter G with breve
#define UNICODE_011F KEY_LEFT_BRACE // 011F ğ Latin small letter g with breve
#define UNICODE_0130 KEY_QUOTE + SHIFT_MASK // 0130 İ Latin captial letter I with dot above
#define UNICODE_0131 KEY_I // 0131 ı Latin small letter dotless i
#define UNICODE_015E KEY_SEMICOLON + SHIFT_MASK // 015E Ş Latin capital letter S with cedilla
#define UNICODE_0151 KEY_SEMICOLON // 0151 ş Latin small letter s with cedilla

Nantonos
03-07-2013, 03:27 AM
This keyboard layout is handy as a cheat sheet for the key names. It is derived from the wikipedia US ANSI keyboard layout, with the engraved letters faded out and the key names and modifier names added. This is a PNG since the forum does not allow SVG uploads.

306

PaulStoffregen
03-07-2013, 08:44 PM
and should be replaced by these two:


#define ASCII_69 KEY_QUOTE // 105 i
#define ISO_8859_1_E9 KEY_TILDE + SHIFT_BITS // 233 e ACUTE


Thanks!

I've updated my copy. This will be included in Teensyduino 1.13.



while these should be added:


// not yet implemented
#define UNICODE_011E KEY_LEFT_BRACE + SHIFT_MASK // 011E Ğ Latin capital letter G with breve
#define UNICODE_011F KEY_LEFT_BRACE // 011F ğ Latin small letter g with breve
#define UNICODE_0130 KEY_QUOTE + SHIFT_MASK // 0130 İ Latin captial letter I with dot above
#define UNICODE_0131 KEY_I // 0131 ı Latin small letter dotless i
#define UNICODE_015E KEY_SEMICOLON + SHIFT_MASK // 015E Ş Latin capital letter S with cedilla
#define UNICODE_0151 KEY_SEMICOLON // 0151 ş Latin small letter s with cedilla

I'll add these too. However, I'm not planning to implement them this way. It may be a while until I rewrite the keyboard code to support these, and eventually other layouts using more of the unicode space beyond 0x00FF.

Nantonos
03-08-2013, 01:17 AM
Thanks!
I've updated my copy. This will be included in Teensyduino 1.13.

Cool.



I'll add these too. However, I'm not planning to implement them this way.

Sounds as if you have some early thoughts on a different method (or are aware of issues with the way is handled currently) - care to share?



It may be a while until I rewrite the keyboard code to support these, and eventually other layouts using more of the unicode space beyond 0x00FF.

Of course, there is only one of you (I think). It will open up some large markets once completed however (Japan, India, China ... and basically everywhere except for US/Canada/Mexico/Australia/NZ and parts of Europe, which are already covered).

PaulStoffregen
03-08-2013, 02:25 AM
Sounds as if you have some early thoughts on a different method (or are aware of issues with the way € is handled currently) - care to share?


I'm planning on a 3rd array of 2-field structs, with each unicode and keycode pair. Initially it'll probably be a linear search for any unicode value >= 0x0100, but if any layouts with a large number of non-latin keys are implemented, it could be changed to a binary search.




It will open up some large markets once completed however (Japan, India, China ... and basically everywhere except for US/Canada/Mexico/Australia/NZ and parts of Europe, which are already covered).


Those may be very large markets in terms of the number of people, but so far very few people from those countries have ever purchased any Teensy board. Still, I'm willing to do them (like I did just do this one)... but with so many other things so many people want (audio, usb host, etc), my general plan is to wait until people ask.

m339
03-08-2013, 07:54 PM
When will you release Teensyduino 1.13 ?


Thanks!

I've updated my copy. This will be included in Teensyduino 1.13.



I'll add these too. However, I'm not planning to implement them this way. It may be a while until I rewrite the keyboard code to support these, and eventually other layouts using more of the unicode space beyond 0x00FF.