开发者

Linux daemon to change user input stream?

开发者 https://www.devze.com 2023-02-28 17:50 出处:网络
I\'d like to write a program to remap user input for stuff like changing keyboard layouts, but also more complex things like making a shorthand program (i.e. \"t qk fx jmps ovr t lzy dg\" outputs as \

I'd like to write a program to remap user input for stuff like changing keyboard layouts, but also more complex things like making a shorthand program (i.e. "t qk fx jmps ovr t lzy dg" outputs as "the quick fox jumps over the lazy dog"). I'd prefer to do this at the X level or below.

Can I make some kind of virtual keyboard based on actual user output? Ideally I'd like some kind of simple interface (i.e. standard input to the program is a series of real user input events, output is the user input events for the virtual keyboard), but if that's not possible I'd still be interested in pointers 开发者_Python百科to how this can be done. I don't know anything about Linux hardware devices, low-level X stuff, or the kernel right now; in fact I'm fairly new to Linux. Links to "Basics" tutorials would not be unappreciated.


You can use the Linux event subsystem to do this:

  • Use the Linux input event interface (evdev) to receive events from any input device. See also the input.h header file for more information on the actual API.

  • Use the EVIOCGRAB ioctl to grab the keyboard device, so that no other userspace applications but your daemon will receive any input events.

  • Use the uinput interface to create a new virtual keyboard with any features that you need. See also the uinput.h header file for more information on the uinput API and this for a readable walkthrough.

There are a few applications that could serve as an example, such as EvRouter, ESE Key Daemon and my own evmapd.

0

精彩评论

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