Skip to content

Commit 2fc89b9

Browse files
committed
Move range min/max checks above identical
Since the input types can be larger than the default ranges, it was possible to keep the ranges at default and still pass a value larger than could fit within that range. This constrains all values, even with identical ranges.
1 parent e311c2f commit 2fc89b9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/XInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ XInputGamepad::Range * XInputGamepad::getRangeFromEnum(XInputControl ctrl) {
378378
}
379379

380380
int32_t XInputGamepad::rescaleInput(int32_t val, Range in, Range out) {
381-
if (in.min == out.min && in.max == out.max) return val; // Ranges identical
382381
if (val <= in.min) return out.min; // Out of range -
383382
if (val >= in.max) return out.max; // Out of range +
383+
if (in.min == out.min && in.max == out.max) return val; // Ranges identical
384384
return map(val, in.min, in.max, out.min, out.max);
385385
}
386386

0 commit comments

Comments
 (0)