获取输入设备的vid和pid
一、获取/dev/input/event16设备的vid和pid
testhid.c
- #include <linux/types.h>
- #include <linux/input.h>
- #include <linux/hidraw.h>
- #include <sys/ioctl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <poll.h>
- #include <time.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <stdlib.h>
- #include <errno.h>
- int main(){
- char filename[64];
- strcpy(filename,"/dev/input/event16");
- char name[80];
- int fd = open(filename, O_RDWR /*| O_NONBLOCK*/);
- if(fd <= 0) {
- printf("TK----------->>>>open error\n");
- return -1;
- }
- /////////
- struct input_id inputId;
- int rc = ioctl(fd, EVIOCGID, &inputId);
- printf("TK-------->>>>info.vendor is 0x%x\n",inputId.vendor);
- printf("TK-------->>>>info.product is 0x%x\n",inputId.product);
- printf("TK-------->>>>info.bustype is 0x%x\n",inputId.bustype);
- /*
- struct hidraw_devinfo info;
- int rc = ioctl(fd, HIDIOCGRAWINFO, &info);
- printf("TK-------->>>>info.vendor is 0x%x\n",info.vendor);
- printf("TK-------->>>>info.product is 0x%x\n",info.product);
- printf("TK-------->>>>info.bustype is 0x%x\n",info.bustype);
- */
- ///////////
- struct hidraw_report_descriptor descriptor;
- rc = ioctl(fd, HIDIOCGRDESC, &descriptor);
- printf("TK-------->>>>descriptor.size is 0x%04x\n",descriptor.size);
- //////
- int descriptorSize=0;
- rc = ioctl(fd, HIDIOCGRDESCSIZE, &descriptorSize);
- printf("TK-------->>>>descriptorSize is 0x%04x\n",descriptorSize);
- //////
- name[sizeof(name) - 1] = '\0';
- if(ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
- name[0] = '\0';
- }
- printf("TK------->>>name is %s\n",name);
- //////
- close(fd);
- return 0;
- }
二、编译
Android.mk
- LOCAL_PATH:= $(call my-dir)
- include $(CLEAR_VARS)
- LOCAL_SRC_FILES:= \
- testhid.c
- LOCAL_SHARED_LIBRARIES := \
- libutils
- LOCAL_MODULE:= testinput
- LOCAL_MODULE_TAGS := optional
- include $(BUILD_EXECUTABLE)
三、运行
- TK-------->>>>info.vendor is 0x0
- TK-------->>>>info.product is 0x1
- TK-------->>>>info.bustype is 0x19
- TK-------->>>>descriptor.size is 0x0000
- TK-------->>>>descriptorSize is 0x0000
- TK------->>>name is Power Button
获取输入设备的vid和pid的更多相关文章
- 通过串口设备vid,pid自动获得该设备所对应的串口号
用C#做串口通讯很方便,因为dotfx2.0已经集成了Serial Port控件,此控件使用上比MSComm控件更简单,当然它也有一个小bug (RecievedBytesThreshold设置有时候 ...
- 重新想象 Windows 8 Store Apps (49) - 输入: 获取输入设备信息, 虚拟键盘, Tab 导航, Pointer, Tap, Drag, Drop
[源码下载] 重新想象 Windows 8 Store Apps (49) - 输入: 获取输入设备信息, 虚拟键盘, Tab 导航, Pointer, Tap, Drag, Drop 作者:weba ...
- USB的VID和PID,以及分类(Class,SubClass,Protocol)
USB(Universal Serial BUS,通用串行总线)协议规定,所有的USB设备都有VID(Vendor ID,供应商识别码)和PID(Product ID,产品识别码).VID由供应商向U ...
- 去确认CP210x UART Bridge的USB的VID和PID
[背景] 之前买的USB口的HART猫: [记录]为USB接口的HART猫ExSaf ESH232U安装对应的USB转RS232驱动 其中内部是USB转RS232. 然后打算去看看之前的自己此处的某个 ...
- 浅谈USB设备的VID和PID
根据USB规范的规定,所有的USB设备都有供应商ID(VID)和产品识别码(PID),主机通过不同的VID和PID来区别不同的设备,VID和PID都是两个字节长,其中,供应商ID(VID)由供应商向U ...
- (转)USB的VID和PID,以及分类(Class,SubClass,Protocol)
USB的VID和PID,以及分类(Class,SubClass,Protocol) 原文地址:http://blog.csdn.net/gaojinshan/article/details/78783 ...
- VID和PID
今天很在一份datasheet上突然看到 VID 和 PID 很奇怪!!还不是很懂!!! 参考:https://blog.csdn.net/gaojinshan/article/details/787 ...
- Linux下查看USB设备的VID、PID命令
Linux下查看PID命令 cat /proc/bus/usb/devices 或 lsusb 方法一:在/etc/init.d/rcS中添加mount -t usbfs none /proc/bus ...
- 获取服务进程server.exe的pid(0号崩溃)
#include "stdafx.h" #include <windows.h> #include <iostream> #include <COMD ...
随机推荐
- java泛型操作复习,以及讲解在android中使用的场景
android使用泛型的地方很多,比如集成自BaseAdapter实现封装的Adapter,对常用操作进行封装,但是需要对传进来的数据进行处理,此时就使用到泛型,示例如下: public abstra ...
- Android设置对话框去除黑边
在res/values/styles.xml文件中添加如下内容 <style name="dialog" parent="@android:style/Theme. ...
- Linux系统编程初探系列之一:文件编程
系统函数 int creat(const char* filename,mode_t mode) filename:需要创建的文件名(包含路径,缺省为当前路径) mode:创建模式 常见的创建模式有: ...
- magento数据查询
一.查询出所有的数据: 1.以mysql查询语句在magento里执行,以此来查询你所需要的语句! $read = Mage::getSingleton('core/resource')->ge ...
- jquery无法为动态生成的元素添加点击事件的解决方法
遇到 jquery无法为动态生成的元素添加点击事件,谷歌一下,整理一下解决方法如下: (<li>中间的元素是动态生成的), 现在想为<i>添加点击事件, 例子如下: <d ...
- 【Python@Thread】thread模块
一.关于Python多线程 Python解释器中可以同时运行多个线程,但是再任意时刻只能有一个线程在解释器运行. Python虚拟机的访问是由全局解锁器(GIL)控制的,由GIL保证同时只有一个线程的 ...
- 【Sort】插入排序
今晚更新几个排序算法 插入排序,时间复杂度O(n^2),从前往后遍历,每遍历到一个值的时候,其前面的所有值已经完成排序,把这个值插入适当位置 void intersort(int *nums,int ...
- Docker 安装完启动服务报错
[root@lh- ~]# docker images Cannot connect to the Docker daemon. Is the docker daemon running on thi ...
- JAVASCRIPT 框架>>
jQuery jQueryjQuery 是目前最受欢迎的 JavaScript 框架 jQuery 是为处理 HTML 事件而特别设计的<script type="text/javas ...
- 不创建类将json数据转换
一般,取到json数据之后,都会将json数据转换为对象,通过属性取得里面的属性值,这样做可以很好地利用vs的智能提示,让开发更轻松,但是代价就是,你需要手动的创建json数据相对应的类. 也有其他方 ...