0

I'm writing a driver for a pda with a goal of converting UART received key numbers to keystrokes.

The way i currently have this system set up is that when a key number is received, i can exec a program. In a config it is defined what command is executed if a certain number is received by my driver. It does this by fork()ing and exec()ing. It runs at boot and immediately parses these key numbers, so i intend to use this instead of a real keyboard.

Is there any program then, with which i could simply do something like

programname KEY_SPACE 1 to press KEY_SPACE

and

programname KEY_SPACE 0 to release KEY_SPACE?

Such a program must work without, as well as with X. I'd also prefer this to be able to do mouse events as well, however if there is a different program to do that, that's fine by me. It can be run as root as well, if need be.

1

1 Answer 1

0

What you need is to use uinput, it allows to emulate input device from userspace. You have documentation here: https://www.kernel.org/doc/html/v5.11/input/uinput.html It has an example showing how to send a KEY_SPACE press event and then a KEY_SPACE release event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.