feat: 优化不跟手的问题
This commit is contained in:
@@ -111,12 +111,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
touchOverlay.setTouchEventListener(new RemoteTouchView.TouchEventListener() {
|
||||
@Override
|
||||
public void onTouch(float relX, float relY) {
|
||||
sendTouchCommand(relX, relY);
|
||||
// 已通过 onMotionEvent 处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwipe(float relX1, float relY1, float relX2, float relY2, long duration) {
|
||||
sendSwipeCommand(relX1, relY1, relX2, relY2, duration);
|
||||
// 已通过 onMotionEvent 处理
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,7 +126,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onLongPress(float relX, float relY) {
|
||||
sendLongPressCommand(relX, relY);
|
||||
// 如果需要高层级的长按,可以保留,但 raw 模式下远程系统会自动识别
|
||||
// sendLongPressCommand(relX, relY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(int action, float relX, float relY) {
|
||||
sendMotionEventCommand(action, relX, relY);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -361,6 +367,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMotionEventCommand(int action, float relX, float relY) {
|
||||
if (webRtcClient != null) {
|
||||
JsonObject cmd = new JsonObject();
|
||||
cmd.addProperty("action", "MOTION_EVENT");
|
||||
cmd.addProperty("motionAction", action);
|
||||
cmd.addProperty("x", relX);
|
||||
cmd.addProperty("y", relY);
|
||||
webRtcClient.sendControlCommand(cmd.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void disconnect() {
|
||||
if (webRtcClient != null) {
|
||||
webRtcClient.close();
|
||||
|
||||
Reference in New Issue
Block a user