使用 AccessibilityService 模拟操纵杆运动 [英] Simulating joystick movement using AccessibilityService

查看:57
本文介绍了使用 AccessibilityService 模拟操纵杆运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 AccessibilityService 在屏幕上模拟点击和操纵杆移动.

I am trying to simulate tap and joystick movement on screen using AccessibilityService.

此外,我正在从游戏手柄控制器设备获取我的输入.做水龙头就可以了.我的问题是模拟屏幕上的操纵杆移动.

In addition i'm getting my input from gamepad controller device. doing tap is ok and done. my problem is simulating joystick movement on screen.

我不知道如何使用 GestureDescription 进行连续触摸,因为此功能需要持续时间.

I don't know how can i do continuous touch with GestureDescription, because of time duration that this function requires.

我已使用此代码进行点击:

i have used this code for tap:

  public void virtual_touch(int posX, int posY)
{
    Path path = new Path();

    path.moveTo(posX, posY);
    GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
    gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 10, 10));
    //gestureBuilder.build();

    boolean isDispatched = dispatchGesture(gestureBuilder.build(), new AccessibilityService.GestureResultCallback()
    {
        @Override
        public void onCompleted(GestureDescription gestureDescription)
        {
            super.onCompleted(gestureDescription);
            MyUtils.Log("onCompleted");
        }

        @Override
        public void onCancelled(GestureDescription gestureDescription)
        {
            super.onCancelled(gestureDescription);
            MyUtils.Log("onCancelled");
        }
    }, null);

    MyUtils.Log("virtual_touch isDispatched : " + isDispatched);
}

推荐答案

For Continue Stroke 使用此方法可能会对您有所帮助.

For Continue Stroke Use this method may be this will help to you.

willContinue --继续描边

willContinue -- continueStroke

public GestureDescription.StrokeDescription continueStroke(路径路径,启动时间长,持续时间长,boolean willContinue)

public GestureDescription.StrokeDescription continueStroke (Path path, long startTime, long duration, boolean willContinue)

boolean:如果此笔划将在下一个手势中继续,则为 true 否则为 false.当手势完成时,连续的笔画会保持其指针向下.

boolean: true if this stroke will be continued by one in the next gesture false otherwise. Continued strokes keep their pointers down when the gesture completes.

这篇关于使用 AccessibilityService 模拟操纵杆运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆