Simulating joystick movement using AccessibilityService

删除回忆录丶 提交于 2020-01-25 10:24:05

问题


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.

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);
}

回答1:


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

willContinue -- continueStroke

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

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.



来源:https://stackoverflow.com/questions/57195814/simulating-joystick-movement-using-accessibilityservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!