News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

detecting keyboard layout under linux

Started by arnoldemu, 09:16, 15 October 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arnoldemu

Does anyone know how to detect the keyboard layout under linux???

C or C++ code please.

I know how to do this under windows. wxwidgets doesn't seem to have a function to help me.

I believe I need to use kbdd???



My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Sykobee (Briggsy)

#1
Well, on the command line:

setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}'

so I'd look at the source for setxkbmap to see what it does?

Actually, the -query option might be better.

setxkbmap -query | grep layout


If you are detecting keyboard layout so in English you use (e.g.,) WASD and in French you use ZQSD, for example, you could have the startup script for the tool configure a settings file for the application with the correct key-codes?

redbox

Quote from: Sykobee (Briggsy) on 09:42, 15 October 13
setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}'

setxkbmap works with X but does it work under the command line as well?

Sykobee (Briggsy)

localectl might work? It doesn't on X though, but it might in a plain text-mode console.

arnoldemu

Quote from: Sykobee (Briggsy) on 12:43, 15 October 13
localectl might work? It doesn't on X though, but it might in a plain text-mode console.

so many possibilities :(

On windows it is soo easy.

So I want to detect the keyboard language so I can configure my emulator automatically.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Sykobee (Briggsy)

And then there's Wayland and Mir ... hopefully they use a compatible keyboard system to X so you don't need completely new tools there.


Really there should be an API to get this information. File a bug against wxWindows :p

Powered by SMFPacks Menu Editor Mod