栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

需要拦截HID键盘事件(然后阻止它们)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

需要拦截HID键盘事件(然后阻止它们)

因此,根据我在此处找到的帖子,我整理了一个概念验证应用

它确实满足了我的要求-即使我仍然会分享我的解决方案。

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <errno.h>#include <fcntl.h>#include <dirent.h>#include <linux/input.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/select.h>#include <sys/time.h>#include <termios.h>#include <signal.h>int main(int argc, char* argv[]){    struct input_event ev[64];    int fevdev = -1;    int result = 0;    int size = sizeof(struct input_event);    int rd;    int value;    char name[256] = "Unknown";    char *device = "/dev/input/event3";    fevdev = open(device, O_RDONLY);    if (fevdev == -1) {        printf("Failed to open event device.n");        exit(1);    }    result = ioctl(fevdev, EVIOCGNAME(sizeof(name)), name);    printf ("Reading From : %s (%s)n", device, name);    printf("Getting exclusive access: ");    result = ioctl(fevdev, EVIOCGRAB, 1);    printf("%sn", (result == 0) ? "SUCCESS" : "FAILURE");    while (1)    {        if ((rd = read(fevdev, ev, size * 64)) < size) { break;        }        value = ev[0].value;        if (value != ' ' && ev[1].value == 1 && ev[1].type == 1) { printf ("Code[%d]n", (ev[1].pre));        }    }    printf("Exiting.n");    result = ioctl(fevdev, EVIOCGRAB, 1);    close(fevdev);    return 0;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/401026.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号