From de3667aad89afc2e73c7c0f39d5616097cc72b5c Mon Sep 17 00:00:00 2001 From: cathery Date: Sat, 9 Nov 2019 23:37:26 +0300 Subject: [PATCH] Put xbox one max trigger value in a define --- ControllerUSB/source/Controllers/XboxOneController.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ControllerUSB/source/Controllers/XboxOneController.cpp b/ControllerUSB/source/Controllers/XboxOneController.cpp index 0da4258..e4757a8 100644 --- a/ControllerUSB/source/Controllers/XboxOneController.cpp +++ b/ControllerUSB/source/Controllers/XboxOneController.cpp @@ -4,6 +4,8 @@ static ControllerConfig _xboxoneControllerConfig{}; +#define TRIGGER_MAXVALUE 1023 + //Following input packets were referenced from https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c static const uint8_t xboxone_fw2015_init[] = { @@ -202,11 +204,11 @@ Status XboxOneController::SendInitBytes() float XboxOneController::NormalizeTrigger(uint16_t value) { - uint16_t deadzone = (1023 * _xboxoneControllerConfig.triggerDeadzonePercent) / 100; + uint16_t deadzone = (TRIGGER_MAXVALUE * _xboxoneControllerConfig.triggerDeadzonePercent) / 100; //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone return value < deadzone ? 0 - : static_cast(value - deadzone) / (1023 - deadzone); + : static_cast(value - deadzone) / (TRIGGER_MAXVALUE - deadzone); } void XboxOneController::NormalizeAxis(int16_t x,