在 Android 通过 get_event 获得 input 设备 上报event

本文介绍了Android系统中用于获取input设备上报event的工具get_event,包括如何使用该工具以及如何通过静态编译和adb推送进行调试。内容涵盖红外gp2ap、touchscreen、物理按键key和headset的上报event,以及get_event.c源码的调试方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Android 本身有一个genevnet 和 sendevent 工具用来从内核获取event事件和向内核发送event事件,具体可以参考  Android 下收发input事件的工具 getevent 和 sendevent

o get_evnet 是一个可以获得注册成input设备上报event的调试工具。

o usage: get_event /dev/input/eventX, X is 0, 1, 2,3,  4, 5,6

o 附件为其源代码, 可以采用静态编译,然后通过adb push进 手机, 进行调试。

arm-linux-gcc -static get_event.c -o get_evnet

-> 获得 红外gp2ap 的上报 event
    shell@android:/ # get_event /dev/input/event0
    Input driver version is 1.0.1
    Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
    Input device name: gp2ap
    Supported events:
      Event type 0 (Sync)
      Event type 3 (Absolute)
        Event code 25 (Distance)
          Value     -1
          Min        0
          Max        1
        Event code 40 (Misc)
          Value      0
          Min        0
          Max    65535

    Testing ... (interrupt to exit)

-> 获得touchscreen 的上报 event
130|shell@android:/ # get_event /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x1 version 0x1005
Input device name: mx_ts
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 102 (Home)
    Event code 103 (Up)
    Event code 105 (Left)
    Event code 106 (Right)
    Event code 107 (End)
    Event code 108 (Down)
    Event code 129 (Again)
    Event code 158 (Back)
    Event code 325 (ToolFinger)
    Event code 330 (Touch)
  Event type 3 (Absolute)
    Event code 0 (X)
      Value      0
      Min        0
      Max     1334
    Event code 1 (Y)
      Value      0
      Min        0
      Max     2214
    Event code 24 (Pressure)
      Value      0
      Min        0
      Max      255
    Event code 47 (?)
      Value      0
      Min        0
      Max        9
    Event code 48 (ABS_MT_TOUCH_MAJOR)
      Value      0
      Min        0
      Max       15
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     1334
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max     2214
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max      255
Testing ... (interrupt to exit)
Event: time 1325376099.794968, type 3 (Absolute), code 57 (ABS_MT_TRACKING_ID), value 0
Event: time 1325376099.794990, type 1 (Key), code 330 (Touch), value 1
Event: time 1325376099.794999, type 1 (Key), code 325 (ToolFinger), value 1
Event: time 1325376099.795009, type 3 (Absolute), code 53 (ABS_MT_POSITION_X), value 738
Event: time 1325376099.795018, type 3 (Absolute), code 54 (ABS_MT_POSITION_Y), value 1487
Event: time 1325376099.795027, type 3 (Absolute), code 58 (ABS_MT_PRESSURE), value 84
Event: time 1325376099.795036, type 3 (Absolute), code 48 (A
### NET_DVR_GET_ACS_EVENT Function Usage The `NET_DVR_GET_ACS_EVENT` function is used to retrieve access control system (ACS) event information from a device through the Hikvision SDK. This function allows developers to obtain detailed records of events such as card swipes, door openings, and alarms generated by ACS devices. Below are key points regarding its usage: #### Parameter Description - **uid**: The user ID returned after logging into the device using the `NET_DVR_Login_V30` function. - **dwCommand**: Specifies the type of configuration being retrieved; here it should be set to `NET_DVR_GET_ACS_EVENT`. - **lpInBuffer**: A pointer to input data required for retrieving specific configurations. For this command, it typically contains parameters like channel numbers or time ranges. - **nInBufferSize**: Size of the input buffer provided above. - **lpOutBuffer**: Pointer where output results will be stored upon successful execution. - **nOutBufferSize**: Maximum size allocated for storing outputs. - **pnStatus**: Optional parameter indicating status during retrieval process. An example implementation might look similar to what follows when implemented within C++ code context: ```cpp #include "HCNetSDK.h" // Define necessary structures based on API documentation... typedef struct tagNET_DVR_ACS_EVENT { DWORD dwSize; BYTE byChannelNo; // ... other fields ... } NET_DVR_ACS_EVENT; void GetACSEvent(long userId){ NET_DVR_ACS_EVENT acsEvent {}; BOOL bRet = NET_DVR_GetDVRConfig( userId, NET_DVR_GET_ACS_EVENT, nullptr, /* No special inputs needed */ &acsEvent, sizeof(NET_DVR_ACS_EVENT), NULL /* Not interested in bytes written back */ ); if (!bRet){ printf("Failed to get ACS Event with error %d\n", NET_DVR_GetLastError()); } } ``` This snippet demonstrates how one could call `NET_DVR_GetDVRConfig`, passing appropriate arguments including setting `dwCommand=NET_DVR_GET_ACS_EVENT`. It also includes basic error handling via checking return value against success condition alongside printing out any encountered errors utilizing `NET_DVR_GetLastError`. For more comprehensive understanding about configuring remote settings related specifically towards Access Control Systems refer previously mentioned reference material concerning starting remote configurations [^2]. Additionally, remember that once you have successfully fetched these events they may trigger certain actions depending upon your application logic which can further involve processing them inside callback functions much alike those explained under alarm notifications setup section involving face detection at entry points etc., thus making sure all relevant pieces fit together seamlessly according business requirements defined beforehand.[^3]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值