MCPcopy Create free account
hub / github.com/cathery/sys-con / NormalizeTrigger

Method NormalizeTrigger

source/ControllerLib/Controllers/XboxController.cpp:112–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112float XboxController::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
113{
114 uint8_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
115 //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
116 return value < deadzone
117 ? 0
118 : static_cast<float>(value - deadzone) / (UINT8_MAX - deadzone);
119}
120
121void XboxController::NormalizeAxis(int16_t x,
122 int16_t y,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected