aem*_*mus 20
好吧,没有X11这个问题就更难了.
对于击键部分,你可以使用类似于这个的代码,但你必须作为参数传递你正在阅读的设备(键盘,通常是/ dev/input/event0)
#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int fd;
if(argc < 2) {
printf("usage: %s <device>\n", argv[0]);
return 1;
}
fd = open(argv[1], O_RDONLY);
struct input_event ev;
while (1)
{
read(fd, &ev, sizeof(struct input_event));
if(ev.type == 1)
printf("key %i state %i\n", ev.code, ev.value);
}
}
Run Code Online (Sandbox Code Playgroud)
积分不给我,这段代码取自Ventriloctrl黑客来获取击键. http://public.callutheran.edu/~abarker/ventriloctrl-0.4.tar.gz
希望我有所帮助.