Event capture on specific keys from X11 on Linux

I am writing a C ++ program to implement the keyboard backlight function from OS X on a MacBook Pro that works with a Linux distribution. Until now, he turned on the backlight when loading, and if no keyboard and mouse events are logged for 20 seconds, it turns off and, of course, turns on again when the event is logged. The next thing I need to run this program is grabbing the keys on the keyboard backlight keys / keys, but I'm not sure how to do it.

I am currently using XScreenSaverQueryInfo to get keyboard and mouse downtime, so a method using the X11 API will be fine. I did a lot of searches, but did not find a way that I was sure of it. The problem that I see with a lot of methods that I found is that they use keycode to identify the key, but I do not think that would be a viable solution, since the program should work for any keyboard available.

Any idea of ​​a method and API I should work with? What will work best?

Hi,

+3
source share
2 answers

XGrabKey(). , , XKeysymToKeycode(). , , MappingNotify (XMappingEvent). ( , MappingNotify, MapNotify.) , , , X, , , X.org - . , , , Linux .

, , , XGrabKey(), - , X - , . XGrabKey() , . , NumLock, , . . X11/Xlib

Linux ( ​​ ), , . , , , . , , , , , , .

, , - Xkb API, . , Xkb, .

+2

, xev. , , , .

+2

Source: https://habr.com/ru/post/1782347/


All Articles