【发布时间】:2019-12-03 08:50:59
【问题描述】:
我正在尝试使用 AccessibilityService 在屏幕上模拟点击和操纵杆移动。
此外,我还从游戏手柄控制器设备获取输入。做水龙头就可以了。我的问题是模拟屏幕上的操纵杆移动。
由于此功能需要持续时间,我不知道如何使用 GestureDescription 进行连续触摸。
我已使用此代码进行点击:
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);
}
【问题讨论】:
标签: java android touch joystick