Skip to content

Commit d7cab17

Browse files
committed
DFT: make sure iptsd_dft_interpolate_position never returns {true,NAN} (e.g. when both arguments to pow are negative)
1 parent 0f08b6f commit d7cab17

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/daemon/dft.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ iptsd_dft_interpolate_position(const Context &ctx, const struct ipts_pen_dft_win
6363
// find critical point of fitted parabola
6464
f64 d = (x[0] - x[2]) / (2 * (x[0] - 2 * x[1] + x[2]));
6565

66+
if (std::isnan(d))
67+
return std::tuple {false, 0};
68+
6669
return std::tuple {true, row.first + maxi + std::clamp(d, mind, maxd)};
6770
}
6871

0 commit comments

Comments
 (0)