• Linux C监听鼠标键盘操作


    代码:

    //monitor.c
    #include <stdio.h> #include <linux/input.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char** argv) { int keys_fd; char ret[2]; struct input_event t; keys_fd = open(argv[1], O_RDONLY); if(keys_fd<=0) { printf("error "); return -1; } while(1) { read(keys_fd, &t, sizeof(struct input_event)); printf("key %i state %i type %i ", t.code, t.value, t.type); } close(keys_fd); return 0; }

    编译:gcc -o monitor monitor.c

    查看外设:ls -l /dev/input/    # 外设有多个event0到event5,不确定哪个是鼠标哪个是键盘,可以都试试

    执行:monitor /dev/input/event2

    文章出处:http://www.cnblogs.com/aaron-agu/ 只有毅力和决心才能使人真正具有价值!
  • 相关阅读:
    面试题 04.03. 特定深度节点链表
    WordStack
    libevent源码解析2
    libevent源码解析1
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    最短路径(dijkstra 与 Floyd)
    LR怎么并行的
  • 原文地址:https://www.cnblogs.com/aaron-agu/p/14335167.html
Copyright © 2020-2023  润新知