diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-02-12 17:44:55 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-02-12 17:44:55 +1100 |
| commit | 0426d245c8d863f18babdfbaf21c8673b0746feb (patch) | |
| tree | 32c78617d954ca6546b0225de68e0acc299e7bca /src/drivers/relative_wheel.cpp | |
| parent | 527374c72e1ec52e1d5814dbee3587ae100631dd (diff) | |
| download | tangara-fw-0426d245c8d863f18babdfbaf21c8673b0746feb.tar.gz | |
Scroll sensitivity configurable, but inverted
Diffstat (limited to 'src/drivers/relative_wheel.cpp')
| -rw-r--r-- | src/drivers/relative_wheel.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/drivers/relative_wheel.cpp b/src/drivers/relative_wheel.cpp index 2b8c9b20..056c80c9 100644 --- a/src/drivers/relative_wheel.cpp +++ b/src/drivers/relative_wheel.cpp @@ -16,6 +16,7 @@ namespace drivers { RelativeWheel::RelativeWheel(TouchWheel& touch) : touch_(touch), is_enabled_(true), + threshold_(10), is_clicking_(false), was_clicking_(false), is_first_read_(true), @@ -47,12 +48,11 @@ auto RelativeWheel::Update() -> void { int delta = 128 - last_angle_; uint8_t rotated_angle = new_angle + delta; - int threshold = 10; - if (rotated_angle < 128 - threshold) { + if (rotated_angle < 128 - threshold_) { ticks_ = 1; last_angle_ = new_angle; - } else if (rotated_angle > 128 + threshold) { + } else if (rotated_angle > 128 + threshold_) { ticks_ = -1; last_angle_ = new_angle; } else { @@ -64,6 +64,14 @@ auto RelativeWheel::SetEnabled(bool en) -> void { is_enabled_ = en; } +auto RelativeWheel::SetThreshold(int val) -> void { + threshold_ = val; +} + +auto RelativeWheel::GetThreshold() -> int { + return threshold_; +} + auto RelativeWheel::is_clicking() const -> bool { if (!is_enabled_) { return false; |
