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 Update() -> void;
auto SetEnabled(bool) -> void; auto SetEnabled(bool) -> void;
auto is_clicking() -> bool; auto is_clicking() const -> bool;
auto ticks() -> std::int_fast16_t; auto ticks() const -> std::int_fast16_t;
// Not copyable or movable. // Not copyable or movable.
RelativeWheel(const RelativeWheel&) = delete; RelativeWheel(const RelativeWheel&) = delete;

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

Loading…
Cancel
Save