Jump to content

[Version 1] Weird Characters After Sending


Recommended Posts

Hi. I got my teensy today and tried to send the better cmd command:

cmd /Q /D /T:7F /F:OFF /V:OFF /K "@echo off && mode con:RATE=31 DELAY=0 && mode con:COLS=15 LINES=1 && title . && cls"

But after sending by teensy it is:

cmd -Q -D -TÖ7F -FÖOFF -VÖOFF -K Ä"echo off // mode conÖRATE´31 DELAZ´0 // mode conÖCOLS´15 LINES´1 // title . // clsÄ

I think it might be caused by german keyboard layout?! Any idea how to fix it easily?

Thank you!

Link to post
Share on other sites
  • 2 weeks later...

I'd like to add a "Keyboard Layout" option in the next version of Teensyduino. It would appear in the Tools menu immediately below the "USB Type" and be enabled if you selected a USB type which includes Keyboard.

I've found several pictures that show the various layouts, but nowhere have I been able to find solid specs on the actual key codes (in terms of HID usage tables, not legacy PC stuff) which different keyboard layouts actually send.

Does anyone know where I might find these?

Or is there somewhere (hopefully cheap) where I can buy various non-US keyboards from within the USA?

Or does anyone have an extra USB keyboard they could send to me? Maybe I need to start a wish list for all the various layouts?

Link to post
Share on other sites

A "Keyboard Layout"-Option would be great. Or maybe you could let the user specify which keycodes to send. That way we could map the key codes to the actual output ourselves. Instead of keyboard.set_key1(KEY_A) we could do keyboard.set_key1(HIDCODE).

Being a total programming newbie I don't even know if that's possible or if I'm making sense at all, but hey...

Anyways, I tried to the map the keystrokes send by the Teensy to the keystrokes defined in the Arduino-Code myself and this is what I came up with:

void setup() { 
  delay(5000);
  Keyboard.set_modifier(128); 
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  Keyboard.set_modifier(0); 
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  Keyboard.print("notepad.exe");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);

  Keyboard.print("abcdefghijklmnopqrstuvwxyz");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("1234567890ß");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("<,.-öä#ü+");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);

  Keyboard.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);

  Keyboard.print("!\"§$%&/\()=?");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print(">;:_ÖÄ'Ü*");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("²³\{\[]}\\");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("|~");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  }
void loop() {
}

Output is the following:

abcdefghijklmnopqrstuvwxzy
1234567890
;,.ߧ`
ABCDEFGHIJKLMNOPQRSTUVWXZY
!Ä$%/-)=´_
:öÖ?ä(
Üü+*#
'°

German keyboard layout and german locale in Windows.

Since there are german characters in the output ('ä', 'Ü') there is obviously some strange mapping going on. And it doesn't work backwards, "<" comes out as ";", but ";" doesn't come out as "<" but as "ö".

Link to post
Share on other sites
A "Keyboard Layout"-Option would be great. Or maybe you could let the user specify which keycodes to send. That way we could map the key codes to the actual output ourselves. Instead of keyboard.set_key1(KEY_A) we could do keyboard.set_key1(HIDCODE).

KEY_A is the HID code, IIRC it's a #define

Link to post
Share on other sites
German keyboard layout and german locale in Windows.

I am working on a keyboard layout layer, which will eventually be selected from a Tools > Keyboard Layout menu. I hope to make an alpha test release in about 1 week, which will not have the menu but you can change the layout by editing a file.

So far, I've done US-English, US-International and German. None are tested yet.

I could REALLY use your help now with one a little question. I need to know which codes are '<' and '#' when the German layout/locale is selected. For example, if you were to do:

for (int i=4; i&lt;64; i++) {
  Keyboard.print(i);
  Keyboard.set_modifier(0);
  Keyboard.set_key1(i);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(2500);
}

My best guess is they might be 49 for '#' and 50 for '<', but I can't find any really solid documentation about these 2 keys. If you could run this test and report back for sure which 2 codes are those 2 keys, it would really help me now.

In about a week I should have something new that might fix all this, and later it'll even be nicely selectable from a menu.

I'm also working on some other new stuff... right now, adding USB MIDI type. :)

Link to post
Share on other sites

Here's an alpha test version with international keyboard support. It also has a MIDI USB type. Linux only so far. I'll port to Mac and Windows in a couple weeks. Of course, devices you create in Linux should work when plugged into PCs with Windows or Macs, but right now this alpha code only supports building them on Linux.

http://www.pjrc.com/teensy/beta/teensyduino

To change the keyboard type, look for the file hardware/teensy/cores/teensy/keylayouts.h. Just uncomment the one you want. So far, I've done US-English, US-Intl, German and Canadian French. More will be added soon. Eventually keyboard layout will be selected from a menu.

edit: international keyboard only works on Keyboard+Mouse type. The Disk+Keyboard types still use the old code.

This turned out to be not-so-simple, requiring a UTF8 parser and deadkey sequence layer, and so far I'm building the layout definitions manually which takes forever and probably has a few random errors. If you're in Germany or Quebec, please give this a try and let me know if it works or not.

Edited by Paul Stoffregen
Link to post
Share on other sites

Sorry for the late reply, hope it's still of use.

Output of your code is the following:

5b6c7d8e9f10g11h12i13j14k15l16m17n18o19p20q21r22s23t24u25v26w27x28z29y3013123233
3434535636737838939040
41443    44 45ß46´47ü48+49#50#51ö52ä53^54,55.56-57%(

After that the Windows Help opened (I suppose the Teensy send an F1-keystroke). In it's input line the following was entered:

%)&amp;=&amp;!&amp;"&amp;§

Somewhere inbetween the Caps Lock key was switched on, I suspected after 57, so I changed the code and tested that and yes

Keyboard.set_key1(57);
Keyboard.send_now();

fires Caps Lock.

So I changed the code again and made it count from 58 to 64 and then Notepad (which I use to see the output) opened the "Search"-Window (usually opened by F3). That's why I suppose after 57 come the F-keys.

After that I got curious (looking for the forward and backward slashes) and let it run with SHIFT Modifier enabled.

5B6C7D8E9F10G11H12I13J14K15L16M17N18O19P20Q21R22S23T24U25V26W27X28Z29Y30!31"32§33$34%35&amp;36/37(38)39=40
41443    44 45?46`47Ü48*49'50'51Ö52Ä53°54;55:56_

Forward slash after 36, yay!

Then, looking for the Backslash, which is usually AltGr+ß on german keyboards, I tried with Keyboard.set_modifier(MODIFIERKEY_SHIFT | MODIFIERKEY_ALT) but notepad didn't like that and produced nothing but the index numbers. I couldn't find a modifier setting for the AltGr-Key in teensyduino's documentation. Do you even have this key on english keyboards?

Anyways, I hope my uneducated poking around is of any use. Now I'm off to play around with the Linux-Alpha-Version.

btw: Thanks a lot for that fun toy!

Edited by Tian Dan
Link to post
Share on other sites

Thanks. I actually did quite a bit of experimentation and found code 100. Well, I hope anyway.

If not, well, those characters normally from that key between the left shift and the Y key will be wrong. On keyboards made in the USA, they don't put a key there at all. The left shift is wider and the Z key is right next to it. Z and Y are swapped from US to German layouts, so imagine no key between your Y key and shift. That's how they are here, so that 1 extra key has been a real mystery.

Well, also, every layout diagram shows a key directly above Enter on US layouts, but it's to the left of Enter on non-US keyboards. Hopefully it's the same code? If some characters from that key next to Enter are wrong, well, that's the one other place I had to do some guesswork.

I configured a Windows XP test machine for German keyboard and got most characters correct typing into Notepad, so I think this code is pretty close. I created the entire layout mapping manually, so there's probably a key or two I might have done incorrectly....

Edited by Paul Stoffregen
Link to post
Share on other sites

Works great. Tried the alpha version and get the characters I want in Linux (Ubuntu 10.04 german) as well as in Windows (7). Did this

void setup () {
  delay(2500);
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("notepad.exe");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(2000);

  Keyboard.print("testing german keyboard layout");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  Keyboard.print("this should be Zeppelin: z");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  Keyboard.print("this should be Ypsilon: y");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  Keyboard.print("this should be forward slash: /");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  Keyboard.print("and now, hopefully backward slash: \\");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  Keyboard.print("oh,oh, one more. those bracket thingies: &lt; and &gt;");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
}

void loop () {
}

and got exactly the expected behaviour and output, even those bracket thingies between the y and left shift keys.

Thanks a lot for your effort. If you want me to do some more testing, let me know.

Link to post
Share on other sites
Works great. Tried the alpha version and get the characters I want in Linux (Ubuntu 10.04 german) as well as in Windows (7).

Good to hear it's working. Thanks.

It's really a huge help.

Thanks a lot for your effort. If you want me to do some more testing, let me know.

It should also be able to type all those non-US characters which require AltGr or first pressing the deadkeys.

Well, at least all of them on the German keyboard. Some keyboards like Finnish Multilingual have massive numbers of very special glyphs. So far, I've only coded unicode-to-keystroke for ASCII, Latin-1 and the Euro symbol.

Link to post
Share on other sites

Couldn't stop myself and ran the test in cat-on-keyboard-mode. Did this

void setup () {
  delay(2500);
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1500);
  
  Keyboard.print("notepad.exe");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(2000);

  Keyboard.print("testing german keyboard layout");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //this should look like so: abcdefghijklmnopqrstuvwxyzäöü&lt;,.-#+
  Keyboard.print("abcdefghijklmnopqrstuvwxyzäöü&lt;,.-#+");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //SHIFT: this should look like so: ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ&gt;;:_'*
  Keyboard.print("ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ&gt;;:_'*");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //this should look like so: 1234567890ß
  Keyboard.print("1234567890ß");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //SHIFT: this should look like so: !"§$%&amp;/()=?
  Keyboard.print("!\"§$%&amp;/()=?");
  Keyboard.send_now();
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //ALTGR: this should look like so: ¹²³¼½¬{[]}\@€|
  Keyboard.print("¹²³¼½¬\{\[]}\\@€|");
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(1000);
  //ALT+TAB
  Keyboard.set_modifier(MODIFIERKEY_ALT);
  Keyboard.set_key1(KEY_TAB);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(2000);
  Keyboard.set_modifier(MODIFIERKEY_ALT);
  Keyboard.set_key1(KEY_TAB);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
}

void loop () {
}

Came out almost perfectly, even ALT+TAB works perfectly. The only thing missing is "ß", which is the unmodified version of the question mark and the backslash, the key to the right of the zero key (on german keyboards). It''s a german specialty and afaik never used in computer/programming context.

Link to post
Share on other sites

Thanks for that, Paul. But already I'm running into the next road block. For some reason the "println"-functionality doesn't work in my arduino environment. It does print out the letters and numbers but it doesn't do the line break at the end. Several "println"-commands one after the other just produce continuous textflow without line breaks.

My first guess is that the println-function contains some kind of appended Enter-Keypress-thingy that also doesn't work with german keyboards. Could that be?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...