一、获取/dev/input/event16设备的vid和pid

testhid.c

  1. #include <linux/types.h>
  2. #include <linux/input.h>
  3. #include <linux/hidraw.h>
  4. #include <sys/ioctl.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <poll.h>
  10. #include <time.h>
  11. #include <math.h>
  12. #include <stdio.h>
  13. #include <stdint.h>
  14. #include <string.h>
  15. #include <stdlib.h>
  16. #include <errno.h>
  17. int main(){
  18. char filename[64];
  19. strcpy(filename,"/dev/input/event16");
  20. char name[80];
  21. int fd = open(filename, O_RDWR /*| O_NONBLOCK*/);
  22. if(fd <= 0) {
  23. printf("TK----------->>>>open error\n");
  24. return -1;
  25. }
  26. /////////
  27. struct input_id inputId;
  28. int rc = ioctl(fd, EVIOCGID, &inputId);
  29. printf("TK-------->>>>info.vendor is 0x%x\n",inputId.vendor);
  30. printf("TK-------->>>>info.product is 0x%x\n",inputId.product);
  31. printf("TK-------->>>>info.bustype is 0x%x\n",inputId.bustype);
  32. /*
  33. struct hidraw_devinfo info;
  34. int rc = ioctl(fd, HIDIOCGRAWINFO, &info);
  35. printf("TK-------->>>>info.vendor is 0x%x\n",info.vendor);
  36. printf("TK-------->>>>info.product is 0x%x\n",info.product);
  37. printf("TK-------->>>>info.bustype is 0x%x\n",info.bustype);
  38. */
  39. ///////////
  40. struct hidraw_report_descriptor descriptor;
  41. rc = ioctl(fd, HIDIOCGRDESC, &descriptor);
  42. printf("TK-------->>>>descriptor.size is 0x%04x\n",descriptor.size);
  43. //////
  44. int descriptorSize=0;
  45. rc = ioctl(fd, HIDIOCGRDESCSIZE, &descriptorSize);
  46. printf("TK-------->>>>descriptorSize is 0x%04x\n",descriptorSize);
  47. //////
  48. name[sizeof(name) - 1] = '\0';
  49. if(ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
  50. name[0] = '\0';
  51. }
  52. printf("TK------->>>name is %s\n",name);
  53. //////
  54. close(fd);
  55. return 0;
  56. }

二、编译

Android.mk

  1. LOCAL_PATH:= $(call my-dir)
  2. include $(CLEAR_VARS)
  3. LOCAL_SRC_FILES:= \
  4. testhid.c
  5. LOCAL_SHARED_LIBRARIES := \
  6. libutils
  7. LOCAL_MODULE:= testinput
  8. LOCAL_MODULE_TAGS := optional
  9. include $(BUILD_EXECUTABLE)

三、运行

    1. TK-------->>>>info.vendor is 0x0
    2. TK-------->>>>info.product is 0x1
    3. TK-------->>>>info.bustype is 0x19
    4. TK-------->>>>descriptor.size is 0x0000
    5. TK-------->>>>descriptorSize is 0x0000
    6. TK------->>>name is Power Button

获取输入设备的vid和pid的更多相关文章

  1. 通过串口设备vid,pid自动获得该设备所对应的串口号

    用C#做串口通讯很方便,因为dotfx2.0已经集成了Serial Port控件,此控件使用上比MSComm控件更简单,当然它也有一个小bug (RecievedBytesThreshold设置有时候 ...

  2. 重新想象 Windows 8 Store Apps (49) - 输入: 获取输入设备信息, 虚拟键盘, Tab 导航, Pointer, Tap, Drag, Drop

    [源码下载] 重新想象 Windows 8 Store Apps (49) - 输入: 获取输入设备信息, 虚拟键盘, Tab 导航, Pointer, Tap, Drag, Drop 作者:weba ...

  3. USB的VID和PID,以及分类(Class,SubClass,Protocol)

    USB(Universal Serial BUS,通用串行总线)协议规定,所有的USB设备都有VID(Vendor ID,供应商识别码)和PID(Product ID,产品识别码).VID由供应商向U ...

  4. 去确认CP210x UART Bridge的USB的VID和PID

    [背景] 之前买的USB口的HART猫: [记录]为USB接口的HART猫ExSaf ESH232U安装对应的USB转RS232驱动 其中内部是USB转RS232. 然后打算去看看之前的自己此处的某个 ...

  5. 浅谈USB设备的VID和PID

    根据USB规范的规定,所有的USB设备都有供应商ID(VID)和产品识别码(PID),主机通过不同的VID和PID来区别不同的设备,VID和PID都是两个字节长,其中,供应商ID(VID)由供应商向U ...

  6. (转)USB的VID和PID,以及分类(Class,SubClass,Protocol)

    USB的VID和PID,以及分类(Class,SubClass,Protocol) 原文地址:http://blog.csdn.net/gaojinshan/article/details/78783 ...

  7. VID和PID

    今天很在一份datasheet上突然看到 VID 和 PID 很奇怪!!还不是很懂!!! 参考:https://blog.csdn.net/gaojinshan/article/details/787 ...

  8. Linux下查看USB设备的VID、PID命令

    Linux下查看PID命令 cat /proc/bus/usb/devices 或 lsusb 方法一:在/etc/init.d/rcS中添加mount -t usbfs none /proc/bus ...

  9. 获取服务进程server.exe的pid(0号崩溃)

    #include "stdafx.h" #include <windows.h> #include <iostream> #include <COMD ...

随机推荐

  1. Major and minor numbers

    The major nuber is the driver associated with the device, while the minor number is used by the kern ...

  2. NYIST OJ 题目38 布线问题

    最小生成树水题,先按最小生成树做,答案最后加上最小的从第i号楼接线到外界供电设施所需要的费用即可. #include<cstdio> #include<cstring> #in ...

  3. Journey

    Journey 题目链接:http://codeforces.com/problemset/problem/721/C dp/记忆化搜索/拓扑排序 刚开始想到用bfs+dp,fst(然而中间有一步逻辑 ...

  4. Counting Stars

    Counting Stars 题目链接:http://acm.xidian.edu.cn/problem.php?id=1177 离线+一维树状数组 一眼扫过去:平面区间求和,1e6的数据范围,这要h ...

  5. B/S和C/S的区别。

    现在软件开发的整体架构主要分为B/S架构与C/S架构 一,C/S——Client/Service:客户机/服务器模式: C/S (Client/Server)结构,即大家熟知的客户机和服务器结构.它是 ...

  6. input、button、a标签 等定义的按钮尺寸的兼容性问题

    在项目中有遇到这类问题,搜索了一下解决方式,采用链接:https://segmentfault.com/q/1010000000190931 里各位楼主的答案,摘抄如下: 例子如下: HTML: &l ...

  7. ggplot2 geom相关设置——添加线条

    在作图过程中,有时我们可能需要通过添加一些线条,使得图形的可视化变得更好,比如一些趋势线等等. 下面我们来看下,一些线条的添加方式. geom_abline(mapping = NULL, data  ...

  8. ebtables使用

    Targets: (1)ACCEPT : 让帧通过 (2)DROP: 丢弃帧. (3)CONTINUE:让帧继续走下面的规则(rule) (4)RETURN: 停止当前链的过滤规则,进而去走前面链的下 ...

  9. php使用iconv进行从utf-8转为gb2312字符编码出错或截断的解决方案

    iconv("GB2312","UTF-8",$text);修改为以下其中一种:1.iconv("UTF-8","GBK" ...

  10. wuzhi 五指 数据库仿 thinkphp

    在/coreframe/app/模块/libs/class/mydb.class.php 中编辑 调用 : $mydb = load_class("mydb","模块&q ...