What commands are required to write events in / dev / input / EventX?

I am developing an Android application that needs to send touch events to / dev / input / EventX. I know the C code structure for performing the following operations is as follows:

struct input_event {
    struct timeval time;
    unsigned short type;
    unsigned short code;
    unsigned int value;
};

To use such code, I need to set NDK. On the contrary, I want to use runtime. Getruntime. Exec() to run equivalent linux commands in Android without using NDK. Is there any way?

If not, do you need other C codes to send events? For example, how do I send x = 200 and y = 300 touch events to event0? I searched, but I couldn't find a clear solution

thank you.

resolvent:

I don't know why you need to send events directly to / dev / input / EventX. However, if it can be sent through ADB, many types of events can be injected into the device

Try the following on your computer:

ADB shell input faucet 200300

Or on your Android device shell:

Input tap 200300

However, it has high latency due to external injection

For more information about entering commands, see here

Usage: input [<source>] <command> [<arg>...]

The sources are: 
      mouse
      keyboard
      joystick
      touchnavigation
      touchpad
      trackball
      stylus
      dpad
      touchscreen
      gamepad

The commands and default sources are:
      text <string> (Default: touchscreen)
      keyevent [--longpress] <key code number or name> ... (Default: keyboard)
      tap <x> <y> (Default: touchscreen)
      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
      press (Default: trackball)
      roll <dx> <dy> (Default: trackball)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>