Skip to content

Commit

Permalink
refactor: multiply float only if sensitivity is adjusted
Browse files Browse the repository at this point in the history
Apply scaling only when necessary as it has a performance cost
  • Loading branch information
Xtr126 committed Aug 24, 2024
1 parent 53b58c0 commit ae3904d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/xtr/keymapper/mouse/MouseAimConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getData() {
+ width + " " + height + " "
+ xleftClick + " " + yleftClick + " "
+ xSensitivity + " " + ySensitivity + " "
+ (limitedBounds ? 1 : 0);
+ (applyNonLinearScaling ? 1 : 0);
}

public void setCenterXY(MovableFrameLayout crosshair){
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/xtr/keymapper/mouse/MouseAimHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ public float calculateScaledX(int value) {
} else {
return value * config.xSensitivity;
}
} else {
} else if (config.xSensitivity != 1.0) {
return value * config.xSensitivity;
} else {
return value;
}
}

private float calculateScaledY(int value) {
return value * config.ySensitivity;
if (config.ySensitivity != 1.0) {
return value * config.ySensitivity;
} else {
return value;
}
}

public void stop() {
Expand Down

0 comments on commit ae3904d

Please sign in to comment.