Fixed KeyPreset throttling logic

so ONLY HOLD presses are affected
This commit is contained in:
bigguy345 committed 2025-12-20 13:55:42 +02:00
1 parent 4b7effe2d7
commit af0553ba0d
1 file changed
+11 -5
@@ -74,10 +74,13 @@ public class KeyPreset {
return this;
}
public boolean shouldThrottle() {
/**
* Determine whether the given press type should be throttled. Only HOLD events are throttled.
*/
public boolean shouldThrottle(PressType pressType) {
if (throttleInterval <= 0) return false;
long currentTime = System.currentTimeMillis();
long intervalToUse = isFirstAction && firstThrottleInterval > 0 ?
long intervalToUse = pressType == PressType.HOLD && isFirstAction && firstThrottleInterval > 0 ?
firstThrottleInterval : throttleInterval;
if (currentTime - lastActionTime < intervalToUse) return true;
lastActionTime = currentTime;
@@ -122,10 +125,13 @@ public class KeyPreset {
}
public KeyPreset onAction(PressType... pressTypes) {
if (task != null && !shouldThrottle()) {
for (PressType pressType : pressTypes)
if (task == null)
return this;
for (PressType pressType : pressTypes)
if (!shouldThrottle(pressType))
this.task.accept(new KeyEvent(pressType, this));
}
return this;
}