获取输入设备的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 ...
随机推荐
- 布局常见问题之css实现多行文本溢出显示省略号(…)全攻略
省略号在ie中可以使用text-overflow:ellipsis了,但有很多的浏览器都需要固定宽度了,同时ff这些浏览器并不支持text-overflow:ellipsis设置了,下文来给各位整理一 ...
- form里面的action和method(post和get的方法)使用
一.form里面的action和method的post使用方法 <%@ Page Language="C#" AutoEventWireup="true" ...
- qml 中 使用 shader
使用绘制工具如Photoshop .Flash已经可以创建许多效果非常绚丽的图像.动画等. Qt/QML 的努力其实是在这些工具发展的后面, 因此很多效果在Qt中无法实现. 不得不佩服Qt小组的才智, ...
- ggplot2 scale相关设置2—时间设置
在scale设置中,常用的日期方面的设置函数包括: scale_x_date(),scale_y_date(),scale_x_datetime(),scale_y_datetime() 接下来, ...
- 向openwrt 源码添加ap143支持
借鉴地址:http://www.pppei.net/blog/post/536 1.向文件 \target\linux\ar71xx\generic\profiles\atheros.mk 中添加ap ...
- Linux中如何设置java环境变量
这里介绍Linux下如何设置java环境变量. 工具/原料 Linux java环境变量 方法/步骤 1 查看java的安装路径 查看java执行路径 配置java环境变量 java的安装 ...
- 驱动力—— 通信引擎(上)—— ESFramework 4.0 进阶(03)
在ESFramework 4.0 进阶(02)-- 核心:消息处理的骨架流程一文中我们详细介绍了ESFramework中消息处理的骨架流程,并且我们已经知道,ESFramework中的所有通信引擎使用 ...
- 实现类似QQ自拍头像的功能(demo源码)
在很多软件系统中,都允许用户设置自己的头像,甚至可以直接使用摄像头照相作为自己的头像,就像QQ的自拍头像功能一样. 这种功能是如何实现的了?最直接的,我们可以使用Windows提供的VFW技术或Dir ...
- $each $position $sort $slice
$push 向数组中添加元素 $each 循环数据(循环添加数据到数组) $sort 对数组进行排序(1:升序:-1:降序.) $slice 对整个collection表进行数据裁减,用的时候一定要当 ...
- C - 小Y上学记——认识新同学
C - 小Y上学记——认识新同学 Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) ...