43 doubleClickTimeout_(0),
44 retriggerTimeoutMs_(0),
75 buttonStates_[
i] = -timeout_;
76 lastClickTimes_[
i] = 0;
77 lastRetriggerTimes_[
i] = 0;
78 numSuccessiveClicks_[
i] = 0;
91 lastCallSysTime_ =
now;
94 ProcessButton(
i, backend_->IsButtonPressed(
i),
timeDiff,
now);
105 return buttonStates_[
buttonId] >= timeout_;
121 if(buttonStates_[
id] < 0)
126 if(buttonStates_[
id] + 1 > -timeout_)
129 if(buttonStates_[
id] + 1 <= -timeout_)
136 buttonStates_[id] = 1;
138 if(buttonStates_[
id] - 1 >= timeout_)
139 PostPhysicalButtonDownEvent(
id, currentSystemTime);
147 if(buttonStates_[
id] - 1 < timeout_)
149 buttonStates_[id] += timeInMsSinceLastCall;
150 if(buttonStates_[
id] - 1 >= timeout_)
151 PostPhysicalButtonDownEvent(
id, currentSystemTime);
154 else if(retriggerTimeoutMs_ > 0)
156 const auto timeSincePress
157 = currentSystemTime - lastClickTimes_[id];
158 if(timeSincePress >= retriggerTimeoutMs_)
160 const auto timeSinceLastRetrigger
161 = currentSystemTime - lastRetriggerTimes_[id];
162 if(timeSinceLastRetrigger > retriggerPeriodMs_)
164 lastRetriggerTimes_[id] = currentSystemTime;
166 id, numSuccessiveClicks_[
id],
true);
174 buttonStates_[id] = -1;
176 if(buttonStates_[
id] + 1 <= -timeout_)
182 void PostPhysicalButtonDownEvent(uint16_t
id, uint32_t currentSystemTime)
184 const auto timeDiff = currentSystemTime - lastClickTimes_[id];
185 if(timeDiff <= doubleClickTimeout_)
186 numSuccessiveClicks_[id]++;
188 numSuccessiveClicks_[id] = 1;
190 lastClickTimes_[id] = currentSystemTime;
197 UiEventQueue* queue_;
198 BackendType* backend_;
200 uint32_t doubleClickTimeout_;
201 uint32_t retriggerTimeoutMs_;
202 uint32_t retriggerPeriodMs_;
203 int16_t buttonStates_[numButtons];
205 uint32_t lastClickTimes_[numButtons];
206 uint32_t lastRetriggerTimes_[numButtons];
207 uint8_t numSuccessiveClicks_[numButtons];
208 uint32_t lastCallSysTime_;