summaryrefslogtreecommitdiff
path: root/src/tangara/input/input_touch_wheel.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-09 17:05:54 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-09 17:05:54 +1000
commit2afeb2989b2f845664e12f93e850aab983be12cc (patch)
tree1f10c9e8e2e1ff47d5d189e59976d06920612c09 /src/tangara/input/input_touch_wheel.cpp
parentb720ba42a0f7645e1f6c3925e92971778c309e94 (diff)
downloadtangara-fw-2afeb2989b2f845664e12f93e850aab983be12cc.tar.gz
use long-press shortcuts again, but make them a bit harder to trigger accidentally
Diffstat (limited to 'src/tangara/input/input_touch_wheel.cpp')
-rw-r--r--src/tangara/input/input_touch_wheel.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/tangara/input/input_touch_wheel.cpp b/src/tangara/input/input_touch_wheel.cpp
index 2c4a8b03..75159320 100644
--- a/src/tangara/input/input_touch_wheel.cpp
+++ b/src/tangara/input/input_touch_wheel.cpp
@@ -40,10 +40,10 @@ TouchWheel::TouchWheel(drivers::NvsStorage& nvs, drivers::TouchWheel& wheel)
return true;
}),
centre_("centre", actions::select(), {}, {}, {}),
- up_("up", {}, actions::scrollToTop(), {}, {}),
+ up_("up", {}, {}, actions::scrollToTop(), {}),
right_("right", {}),
- down_("down", {}, actions::scrollToBottom(), {}, {}),
- left_("left", {}, actions::goBack(), {}, {}),
+ down_("down", {}, {}, actions::scrollToBottom(), {}),
+ left_("left", {}, {}, actions::goBack(), {}),
is_scrolling_(false),
threshold_(calculateThreshold(nvs.ScrollSensitivity())),
is_first_read_(true),
@@ -73,20 +73,26 @@ auto TouchWheel::read(lv_indev_data_t* data) -> void {
// If the user is touching the wheel but not scrolling, then they may be
// clicking on one of the wheel's cardinal directions.
- bool pressing = wheel_data.is_wheel_touched && !is_scrolling_;
-
- up_.update(pressing && drivers::TouchWheel::isAngleWithin(
- wheel_data.wheel_position, 0, 32),
- data);
- right_.update(pressing && drivers::TouchWheel::isAngleWithin(
- wheel_data.wheel_position, 192, 32),
- data);
- down_.update(pressing && drivers::TouchWheel::isAngleWithin(
- wheel_data.wheel_position, 128, 32),
- data);
- left_.update(pressing && drivers::TouchWheel::isAngleWithin(
- wheel_data.wheel_position, 64, 32),
+ if (is_scrolling_) {
+ up_.cancel();
+ right_.cancel();
+ down_.cancel();
+ left_.cancel();
+ } else {
+ bool pressing = wheel_data.is_wheel_touched;
+ up_.update(pressing && drivers::TouchWheel::isAngleWithin(
+ wheel_data.wheel_position, 0, 32),
data);
+ right_.update(pressing && drivers::TouchWheel::isAngleWithin(
+ wheel_data.wheel_position, 192, 32),
+ data);
+ down_.update(pressing && drivers::TouchWheel::isAngleWithin(
+ wheel_data.wheel_position, 128, 32),
+ data);
+ left_.update(pressing && drivers::TouchWheel::isAngleWithin(
+ wheel_data.wheel_position, 64, 32),
+ data);
+ }
}
auto TouchWheel::name() -> std::string {