Skip to content

Commit

Permalink
fix: apply swipe delay when re-entering bounds
Browse files Browse the repository at this point in the history
Workaround for mouse aim lag issue #82
Swipe delay should be set to a non-zero value to be effective.
  • Loading branch information
Xtr126 committed Mar 7, 2024
1 parent 5bee2d1 commit 44d1e21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/xtr/keymapper/keymap/KeymapConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void loadSharedPrefs() {
keyGraveMouseAim = sharedPref.getBoolean("key_grave_mouse_aim", true);
rightClickMouseAim = sharedPref.getBoolean("right_click_mouse_aim", true);

swipeDelayMs = sharedPref.getInt("swipe_delay_ms", 0);
swipeDelayMs = sharedPref.getInt("swipe_delay_ms", 10);
dpadRadiusMultiplier = sharedPref.getFloat("dpad_radius", 1f);

touchpadInputMode = sharedPref.getString("touchpad_input_mode", TOUCHPAD_DISABLED);
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/xtr/keymapper/mouse/MouseAimHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import static xtr.keymapper.server.InputService.UP;

import android.graphics.RectF;
import android.os.Handler;
import android.os.Looper;

import xtr.keymapper.server.IInputInterface;
import xtr.keymapper.touchpointer.PointerId;
Expand All @@ -21,11 +23,14 @@ public class MouseAimHandler {
private IInputInterface service;
private final int pointerIdMouse = PointerId.pid1.id;
private final int pointerIdAim = PointerId.pid2.id;
private final Handler mHandler;


public MouseAimHandler(MouseAimConfig config){
currentX = config.xCenter;
currentY = config.yCenter;
this.config = config;
mHandler = new Handler(Looper.getMainLooper());
}

public void setInterface(IInputInterface input) {
Expand All @@ -47,10 +52,13 @@ public void setDimensions(int width, int height){
}

public void resetPointer() {
currentY = config.yCenter;
currentX = config.xCenter;
service.injectEvent(currentX, currentY, UP, pointerIdAim);
service.injectEvent(currentX, currentY, DOWN, pointerIdAim);
mHandler.postDelayed(() -> {
currentY = config.yCenter;
currentX = config.xCenter;
service.injectEvent(currentX, currentY, DOWN, pointerIdAim);
},
service.getKeymapConfig().swipeDelayMs);
}

public void handleEvent(int code, int value, OnRightClick r) {
Expand Down

0 comments on commit 44d1e21

Please sign in to comment.