-
-
Notifications
You must be signed in to change notification settings - Fork 304
various fixes for scroll wheel #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glempi
wants to merge
1
commit into
PixlOne:main
Choose a base branch
from
glempi:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,19 +44,29 @@ AxisGesture::AxisGesture(Device* device, config::AxisGesture& config, | |
| const auto& axis = std::get<std::string>(_config.axis.value()); | ||
| try { | ||
| _input_axis = _device->virtualInput()->toAxisCode(axis); | ||
| logPrintf(INFO, "axis %d %s", _input_axis, axis.c_str()); | ||
| } catch (InputDevice::InvalidEventCode& e) { | ||
| logPrintf(WARN, "Invalid axis %s."); | ||
| logPrintf(WARN, "Invalid axis %s.", axis.c_str()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| if (_input_axis.has_value()) | ||
| _device->virtualInput()->registerAxis(_input_axis.value()); | ||
| registerAxis(_input_axis.value()); | ||
| } | ||
|
|
||
| void AxisGesture::registerAxis(uint axis) { | ||
| _device->virtualInput()->registerAxis(axis); | ||
| int low_res_axis = InputDevice::getLowResAxis(axis); | ||
| if (low_res_axis != -1) { | ||
| _device->virtualInput()->registerAxis(low_res_axis); | ||
| } | ||
| } | ||
|
|
||
| void AxisGesture::press(bool init_threshold) { | ||
| std::shared_lock lock(_config_mutex); | ||
| logPrintf(RAWREPORT, "press %d %d\n", _axis, init_threshold); | ||
| if (init_threshold) { | ||
| _axis = (int32_t) (_config.threshold.value_or(defaults::gesture_threshold)); | ||
| } else { | ||
|
|
@@ -76,12 +86,14 @@ void AxisGesture::move(int16_t axis) { | |
| if (!_input_axis.has_value()) | ||
| return; | ||
|
|
||
|
|
||
| const auto threshold = _config.threshold.value_or( | ||
| defaults::gesture_threshold); | ||
| int32_t new_axis = _axis + axis; | ||
| int low_res_axis = InputDevice::getLowResAxis(axis); | ||
| int low_res_axis = InputDevice::getLowResAxis(_input_axis.value()); | ||
| int hires_remainder = _hires_remainder; | ||
|
|
||
|
|
||
| if (new_axis > threshold) { | ||
| double move = axis; | ||
| if (_axis < threshold) | ||
|
|
@@ -102,21 +114,34 @@ void AxisGesture::move(int16_t axis) { | |
| _axis_remainder -= int_remainder; | ||
| } | ||
|
|
||
| if (negative_multiplier) | ||
| move_floor = -move_floor; | ||
|
|
||
| if (low_res_axis != -1) { | ||
| int lowres_movement, hires_movement = (int) move_floor; | ||
| int lowres_movement = 0; | ||
| int hires_movement = (int) move_floor; | ||
| _device->virtualInput()->moveAxis(_input_axis.value(), hires_movement); | ||
| hires_remainder += hires_movement; | ||
| if (abs(hires_remainder) >= 60) { | ||
| if (abs(hires_remainder) >= 1) { | ||
| lowres_movement = hires_remainder / 120; | ||
| if (lowres_movement == 0) | ||
| if (lowres_movement == 0) { | ||
| lowres_movement = hires_remainder > 0 ? 1 : -1; | ||
| } | ||
|
Comment on lines
+124
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code style changes like these introduce unnecessary noise in the diff. I'd recommend removing them and keeping the diff focused on the actual behavior changes. |
||
|
|
||
| if ((lowres_movement > 0 && negative_multiplier) || | ||
| (lowres_movement < 0 && !negative_multiplier)) | ||
| { | ||
| lowres_movement = 0; | ||
| } | ||
|
|
||
| hires_remainder -= lowres_movement * 120; | ||
|
|
||
| _device->virtualInput()->moveAxis(low_res_axis, lowres_movement); | ||
| } | ||
|
|
||
| logPrintf(RAWREPORT, "move %ld [%.2f], l_mv:%d h_mv:%d code:%d/%d;" | ||
| " axis %d/%d; new_axis %d; hires_rem %d th %d neg %d mv %.1f\n", | ||
| time(NULL), _config.axis_multiplier.value_or(1), lowres_movement, hires_movement, | ||
| _input_axis.value(), low_res_axis, axis, _axis, new_axis, hires_remainder, | ||
| threshold, negative_multiplier, move); | ||
|
|
||
| _hires_remainder = hires_remainder; | ||
| } else { | ||
| _device->virtualInput()->moveAxis(_input_axis.value(), (int) move_floor); | ||
|
|
@@ -164,7 +189,7 @@ void AxisGesture::setAxis(const std::string& axis) { | |
| } else { | ||
| _input_axis = _device->virtualInput()->toAxisCode(axis); | ||
| _config.axis = axis; | ||
| _device->virtualInput()->registerAxis(_input_axis.value()); | ||
| registerAxis(_input_axis.value()); | ||
| } | ||
| setHiresMultiplier(_hires_multiplier); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these blank new lines for? 🤔
Here, and in lines 96, 135, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The God told me put this line here 🤣. Actually i don't have a plan to make stylish fixes after 3 years
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway without this PR wheel scrolling logic of logiops still is broken and do not work correct