Preserve signedness from opt_encoder_handler for scroll data on Ploopy devices #12223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bugfix for Ploopy devices (trackball and mouse).
Ploopy devices use an optical encoder to produce scroll information. The
opt_encoder_handler
returns a value of1
,-1
or0
depending on direction of scroll. This was being coerced into auint8_t
, discarding the sign. The problem was masked by the coercion happening when the value is put into the mouse descriptor'sint8_t
.It's not clear to me why
process_wheel_user
usesint16_t
for itsh
andv
parameters, when themouse_report
values are onlyint8_t
, anddir
only takes values of1
,-1
and0
. Perhapsint8_t
is more appropriate for thedir
variable? Maybe evenopt_encoder_handler
? I matched thedir
type to the function which produces it, and changed nothing that didn't strictly need to change.