AndroidでInputイベントを取得するためのgeteventの使用法



Usage Getevent Get Input Event Android



geteventコマンドは、主要なレポート情報の取得やタッチスクリーンレポート情報の取得など、Androidシステムの入力イベントを取得するために使用されます。特定のコードディレクトリ:/system/core/toolbox/getevent.c。

最初に効果を見てください:



getevent -hをチェックして、関連情報を取得します。



msm8909w:/ $ getevent -h getevent -h Usage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device] -t: show time stamps -n: don't print newlines -s: print switch states for given bits -S: print all switch states -v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64) -d: show HID descriptor, if available -p: show possible events (errs, dev, name, pos. events) -i: show all device info and possible events -l: label event types and names in plain text -q: quiet (clear verbosity mask) -c: print given number of events then exit -r: print rate events are received The corresponding Chinese explanation: -t display time -n print without wrapping -s display the switch status of the specified bit -S displays the switch status of all bits -v Display related information according to the mask value, and will always display the reported data after execution -d If the device is available, display the hidden description information of the device -p Display event types and encoding methods supported by the device -i displays all information and supported events of the device -l output event type and name in text form -q silent (clear and long mask) -c print a fixed number of events and exit -r display event reporting rate

デバイスにgeteventと入力して、以下を確認します。

デフォルトでアップロードされるデータがあります。私たちのデバイスの入力/イベント2は、対応するタッチスクリーンのデータです。



上記のデータの形式は次のとおりです。/dev/input/event0: 'イベントタイプ' 'パラメータビット定義' '値'

イベントタイプ:入力イベントのタイプ:

#define EV_SYN 0x00

#define EV_KEY 0x01

#define EV_REL 0x02

#define EV_ABS 0x03

#define EV_MSC 0x04

#define EV_SW 0x05

#define EV_LED 0x11

#define EV_SND 0x12

#define EV_REP 0x14

#define EV_FF 0x15

#define EV_PWR 0x16

入力関連の操作について:

/ proc / bus / input /と入力すると、次のように、デバイスとハンドラーの2つのノードがあることがわかります。

上記からわかるように、TP関連の情報なので、すばやく問い合わせることができます。