Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmanLP committed Jan 2, 2025
1 parent 1966d12 commit c21bc00
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ void WheelHandler::UpdateAxisBuffer(float* buf, float input) {
static const float LIMIT = 2.0f;
static const float REDUCE_STEP = 1.0f;

// reduce buffered value
if (*buf != 0.0f) {
if (input != 0.0f) {
// add current input to buffer
*buf += input;
// limit buffer
if (fabs(*buf) > LIMIT) {
*buf = copysignf(LIMIT, *buf);
}
} else if (*buf != 0.0f) {
// reduce buffered value
if (fabs(*buf) <= REDUCE_STEP) {
*buf = 0.0f;
} else {
*buf -= copysignf(REDUCE_STEP, *buf);
}
}

// add current input to buffer
*buf += input;

// limit buffer
if (fabs(*buf) >= LIMIT) {
*buf = copysignf(LIMIT, *buf);
}
}

void WheelHandler::Update() {
Expand Down

0 comments on commit c21bc00

Please sign in to comment.