MCPcopy Create free account
hub / github.com/dmadison/ArduinoXInput / rescaleInput

Method rescaleInput

src/XInput.cpp:528–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528int32_t XInputController::rescaleInput(int32_t val, const Range& in, const Range& out) {
529 if (val <= in.min) return out.min; // Out of range -
530 if (val >= in.max) return out.max; // Out of range +
531 if (in.min == out.min && in.max == out.max) return val; // Ranges identical
532 return map(val, in.min, in.max, out.min, out.max);
533}
534
535int16_t XInputController::invertInput(int16_t val, const Range& range) {
536 return range.max - val + range.min;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected