1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-11-05 08:26:32 +00:00

Put xbox one max trigger value in a define

This commit is contained in:
cathery 2019-11-09 23:37:26 +03:00
parent 8739069e6b
commit de3667aad8

View File

@ -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<float>(value - deadzone) / (1023 - deadzone);
: static_cast<float>(value - deadzone) / (TRIGGER_MAXVALUE - deadzone);
}
void XboxOneController::NormalizeAxis(int16_t x,