Teensyduino/Arduino - what do the predefined menu entries do? (i.e. "keyboard mode")

Status
Not open for further replies.

Rejutka

New member
Teensyduino/Arduino - what do the predefined menu entries do? (i.e. "keyboard mode")

I know I can create a program that'll tell the Teensy (I'm using a 3.2) to act as a USB keyboard by selecting the corresponding menu entries.

But what exactly do they do? How can I replicate that without the menu entries?

I want Teensy to act as a keyboard, but I want to be able to specify the layout myself, ideally outside of the predefined ones.

I'm assuming that several libraries (among other things) are loaded - but I don't see where.
It's probably something obvious once I know where to look...
 
But what exactly do they do?

They change the -D parameters when Arduino runs the gcc compiler. Those define symbols. If you read the code in hardware/teensy/avr/cores/teensy3 (especially usb_desc.h and usb_desc.c) you'll see they reconfigure which code gets built based on those symbols.

In Arduino, click File > Preferences to turn on verbose info while compiling. That will show you the full compiler commands. Look for "-DUSB_KEYBOARD" or similar ones.

I want Teensy to act as a keyboard, but I want to be able to specify the layout myself, ideally outside of the predefined ones.

You'll probably need to edit the files within hardware/teensy/avr/cores/teensy3.

It's probably something obvious once I know where to look...

Yup, and now you know where. It's just a folder on your computer with the files.

In using a Mac, the trick is to control-click on Arduino and choose "Show Package Contents" to see inside Arduino, then look in Contents/Java to find the hardware folder. On Windows and Linux it's just ordinary folders, so you'll see "hardware" right inside Arduino's folder.

On Windows, the installer defaults to putting it all in C:\Programs Files (x86)\Arduino. If you're using Linux, you probably are well aware of where you put the files.
 
Yup, and now you know where.
And knowing is half the battle...


I've found the files, thanks!

I've also pieced together how parts of it work - no doubt it's all very ingenious, but it's not very user-friendly if you're not used to that kind of thing. (More than a decade of using very user-friendly IDEs that don't even show files and link everything behind the scenes tend to spoil one :( )

It took me a time to realize that boards.txt indeed controls the menu - since for some reason the keyboard layout "german" was constantly shown as "Deutsch" in the menu. It may be correct, but it's creeping me out that there is no mention of "deutsch" in the files, where does the translation come from?...


I'll try to figure it out myself, but I'll not turn away an explanation - how do the entries in boards.txt fit to the actual files?
For example:
Code:
teensy31.menu.keys.de-de=German
teensy31.menu.keys.de-de.build.keylayout=GERMAN
[/quote]
The first line I get - board is "teensy31", which translates to "Teensy 3.2 / 3.1" in the menu.
"menu" is probably a Arduino-specific keyword, to create a menu entry.
"keys" is defined in the file to translate to "Keyboard Layout", which is another menu entry that appears once "Teensy 3.2 / 3.1" is selected.

I found that the second line basically tells the compiler to include "keylayouts.h" and define "LAYOUT_GERMAN", so that the corresponding key codes are defined.

Which all makes sense - except that it doesn't.
I'm obviously missing something, but where is the connection? How does the system get from "keylayout=GERMAN" to "#define LAYOUT_GERMAN; include keylayouts.h;" or something like that?
The same goes for the other menu entries, of course. Like where the actual keyboard is defined and such.
 
Last edited:
"german" was constantly shown as "Deutsch" in the menu. It may be correct, but it's creeping me out that there is no mention of "deutsch" in the files, where does the translation come from?...

The Arduino IDE has its own translation system built in. It automatically translates English words and phrases from a long list.

I personally do not know all the details about how it works. But I can point you to the files on github, if you wish to investigate and learn more.

https://github.com/arduino/Arduino/tree/master/arduino-core/src/processing/app/i18n

Here is a recently comment from one of the Arduino developers with more info.

https://github.com/arduino/Arduino/issues/6815#issuecomment-336396510
 
Status
Not open for further replies.
Back
Top