开发者

Python - detect keyboard layout

Playing around with RFID reader in serial, using python to output to console through ui开发者_如何学JAVAnput/

The thing is, doing the conversion from fake-rfid-keyboard-codes to code sent to uinput/, I would better know if I am using a QWERTY or an AZERTY ('a' becoming 'q', etc...)

Back here in Belgium, especially during the event I am working on we are highly susceptible to have both keyboard layouts, I have to support both 'on-the-fly'

Any os.*() function to do the job?

Thanx !


You could start by looking at setxkbmap -print, but generally this is nontrivial.

Why not instead set the keyboard layout to QWERTY for the virtual keyboard device you're creating with uinput? X supports separate layouts for each device.

xinput list                   # find the device ID, say, 12
setxkbmap -device 12 us       # use it

In my experience, whenever I plug in an external USB keyboard it always starts out as US English, so I'm not sure that's even necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜