Keyboard layout problem


I’m struggling with a weird issue porting some code from my dev computer(ubuntu 16.04) to a raspberry pi 3.

I’m creating an app where the user will type a password that will unlock some motors.

Everything is working on my computer, but running on the rpi the app is turning to run with the wrong keyboard layout. I’m French, so I need an azerty layout, which is ok on my dev computer but the app is running with a qwerty layout on the rpi.

The weird thing is that all my rpi system is indeed running an azerty layout, just the OF app is running with a qwerty layout.

I already checked my /etc/defaults/locale and /etc/defaults/keyboard are the same on both computers.

I can’t figure out what’s wrong.

Any idea?


FIY, here is my code

This issue drives me crazy :frowning:

From what I see here:

It seems that when creating a ofAppELGWindow the keyboard event directly rely on /dev/input/eventX which is not good since /dev/input/eventX seems to not take locale in account.

I tried on my dev computer AND on the RPi the following: ⁠⁠⁠⁠evtest /dev/input/eventX an I do receive the “q” keycode when I press “a”.

So for me, using /dev/input/eventX directly to detect key press is unreliable because it doesn’t take in account my locale.

What could be a workaround? Because for me right now, it seems we cannot create an OF app running on the RPi with a different keyboard layout than the one “used” while listening to /dev/input/eventX, and that would be a major issue.

yes this is something that is not implemented yet. the problem with the pi is that there’s no xwindow or any other window manager there so everything has to be done manually including translating the keys according to the locale which is not trivial if you want to take into account every possible locale.

i would suggest to build a table with the correspondance for every key you are going to use and the correct key in your keyboard. something like:

std::map<int, int> localeTable;
localeTable['q'] = 'a';

then in keyPressed:

if(localeTable.find(key) != localeTable.end()){
    key = localeTable[key];

Thanks @arturo , it confirms my fear.

But installing a desktop environment (e.g. Raspbian Jessie with pixel) on the rpi would provide a xwindow right?

For now I guess I will replace the letter maps defined in the ofAppEGLWindow.cpp by mine.


yes but even with that opengl applications won’t run under x window so the translation methods won’t work

1 Like

Thanks! Makes sense.

Oh, and last thing, why the key code enter is not catched from KEY_ENTER to OF_KEY_ENTER ? As other special keys?

that might be a bug, can you open an issue on github?

Sure, i’ll make a PR

Since all key codes are here:

Wouldn’t it make sense to use this mapping instead of the crappy one inside ofAppGLESWindow ?

And provide a way to override it within ofGLESWindowSettings, e.g. something like:

std::map<int, int> myLocaleTable;
myLocaleTable['q'] = 'a';
// and so on
settings.localeTable = myLocaleTable;

Because providing every keyboard layouts would be impossible. So providing a way to override the key codes with a locale table would be enough.


Hi there @xseignard, I just stumbled upon this thread because I am dealing with the same problem — I’m working on a project which requires use of the Canadian French layout to input accents. It works perfectly fine on the mac, but not on the Raspberry Pi.

Did you ever end up implementing your map? Would you mind sharing it as a reference? I will probably have to end up doing the same thing, but for the Canadian French layout.

Hello @cjniven
Back in the days I did some crappy stuff to handle it, and now I stumble accross the same issue again.
I still have no good solution to this problem.
Do you ?