Make accessors in RelativeWheel const

custom
jacqueline 2 years ago
parent 95618239e6
commit 3df4cc9e3d
  1. 4
      src/drivers/include/relative_wheel.hpp
  2. 12
      src/drivers/relative_wheel.cpp

@ -25,8 +25,8 @@ class RelativeWheel {
auto Update() -> void;
auto SetEnabled(bool) -> void;
auto is_clicking() -> bool;
auto ticks() -> std::int_fast16_t;
auto is_clicking() const -> bool;
auto ticks() const -> std::int_fast16_t;
// Not copyable or movable.
RelativeWheel(const RelativeWheel&) = delete;

@ -65,22 +65,18 @@ auto RelativeWheel::SetEnabled(bool en) -> void {
is_enabled_ = en;
}
auto RelativeWheel::is_clicking() -> bool {
auto RelativeWheel::is_clicking() const -> bool {
if (!is_enabled_) {
return false;
}
bool ret = is_clicking_;
is_clicking_ = 0;
return ret;
return is_clicking_;
}
auto RelativeWheel::ticks() -> std::int_fast16_t {
auto RelativeWheel::ticks() const -> std::int_fast16_t {
if (!is_enabled_) {
return 0;
}
int_fast16_t t = ticks_;
ticks_ = 0;
return t;
return ticks_;
}
} // namespace drivers

Loading…
Cancel
Save