forked from drath/libratbag
hidpp10: fix finding the closest dpi (#463)
value and dpi are unsigned so the delta calculations was wrong when dpi is larger than than value. Casting to int should be fine for the expected range of values in those variables.
This commit is contained in:
committed by
Peter Hutterer
parent
b474e76ac2
commit
770dd62b1d
@@ -643,7 +643,7 @@ hidpp10_get_dpi_mapping(struct hidpp10_device *dev, unsigned int value)
|
||||
min_delta = INT_MAX;
|
||||
|
||||
for (i = 0; i < dev->dpi_count; i++) {
|
||||
delta = abs(value - m[i].dpi);
|
||||
delta = abs((int)value - (int)m[i].dpi);
|
||||
if (delta < min_delta) {
|
||||
result = m[i].raw_value;
|
||||
min_delta = delta;
|
||||
|
||||
Reference in New Issue
Block a user