Fix ThumbWheel feature direction bug

Should fix #145 for the MX Master 3
This commit is contained in:
pixl 2021-03-13 17:55:53 -05:00
parent ffcfb3da82
commit 48399a1dd4
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E

View File

@ -142,23 +142,15 @@ void ThumbWheel::_handleEvent(hidpp20::ThumbWheel::ThumbwheelEvent event)
if(event.rotation) { if(event.rotation) {
int8_t direction = event.rotation > 0 ? 1 : -1; int8_t direction = event.rotation > 0 ? 1 : -1;
std::shared_ptr<actions::Gesture> scroll_action; std::shared_ptr<actions::Gesture> scroll_action;
std::shared_ptr<actions::Gesture> opposite_scroll;
if(event.rotation > 0) { if(direction > 0)
scroll_action = _config.rightAction(); scroll_action = _config.rightAction();
opposite_scroll = _config.leftAction(); else
} else {
scroll_action = _config.leftAction(); scroll_action = _config.leftAction();
opposite_scroll = _config.rightAction();
}
if(direction != _last_direction) { if(scroll_action) {
if(opposite_scroll) scroll_action->press(true);
opposite_scroll->release(); scroll_action->move(direction * event.rotation);
if(scroll_action) {
scroll_action->press(true);
scroll_action->move(direction * event.rotation);
}
} }
_last_direction = direction; _last_direction = direction;