feat: Add humanize:minTime

Set the minimum time of the cursor movement.
This commit is contained in:
daijro 2024-10-12 00:21:38 -05:00
parent c448ec81ab
commit 3b996534d8

View file

@ -182,6 +182,13 @@ class HumanizeMouseTrajectory {
return 150; return 150;
} }
int32_t getMinTime() const {
if (auto minTime = MaskConfig::GetDouble("humanize:minTime")) {
return static_cast<int32_t>(minTime.value() * 100);
}
return 0;
}
std::vector<std::vector<double>> tweenPoints( std::vector<std::vector<double>> tweenPoints(
const std::vector<std::vector<double>>& points) const { const std::vector<std::vector<double>>& points) const {
assert(isListOfPoints(points) && "List of points not valid"); assert(isListOfPoints(points) && "List of points not valid");
@ -196,7 +203,7 @@ class HumanizeMouseTrajectory {
// Uses a power scale to keep the speed consistent // Uses a power scale to keep the speed consistent
int targetPoints = std::min( int targetPoints = std::min(
getMaxTime(), getMaxTime(),
std::max(2, static_cast<int>(std::pow(totalLength, 0.25) * 20))); std::max(getMinTime() + 2, static_cast<int>(std::pow(totalLength, 0.25) * 20)));
std::vector<std::vector<double>> res; std::vector<std::vector<double>> res;
for (int i = 0; i < targetPoints; i++) { for (int i = 0; i < targetPoints; i++) {