Fixes Mouse Clicker Should have a "0" value setting for "as fast as possible" #3876 (#3894)

* fixes mouse clicking rate
* Hid: limit max clicks to 100/s, rewrite code to make it more robust

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
SUMUKH 2024-10-14 20:03:51 +05:30 committed by GitHub
parent 421bd3e1f9
commit d9d3867ce1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,7 @@
#define TAG "HidMouseClicker" #define TAG "HidMouseClicker"
#define DEFAULT_CLICK_RATE 1 #define DEFAULT_CLICK_RATE 1
#define MAXIMUM_CLICK_RATE 60 #define MAXIMUM_CLICK_RATE 100
struct HidMouseClicker { struct HidMouseClicker {
View* view; View* view;
@ -34,7 +34,9 @@ static void hid_mouse_clicker_start_or_restart_timer(void* context) {
HidMouseClickerModel * model, HidMouseClickerModel * model,
{ {
furi_timer_start( furi_timer_start(
hid_mouse_clicker->timer, furi_kernel_get_tick_frequency() / model->rate); hid_mouse_clicker->timer,
furi_kernel_get_tick_frequency() /
((model->rate) ? model->rate : MAXIMUM_CLICK_RATE));
}, },
true); true);
} }
@ -75,7 +77,11 @@ static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) {
// Clicks/s // Clicks/s
char label[20]; char label[20];
snprintf(label, sizeof(label), "%d clicks/s", model->rate); if(model->rate) {
snprintf(label, sizeof(label), "%d clicks/s", model->rate);
} else {
snprintf(label, sizeof(label), "max clicks/s");
}
elements_multiline_text_aligned(canvas, 28, 37, AlignCenter, AlignBottom, label); elements_multiline_text_aligned(canvas, 28, 37, AlignCenter, AlignBottom, label);
canvas_draw_icon(canvas, 25, 20, &I_ButtonUp_7x4); canvas_draw_icon(canvas, 25, 20, &I_ButtonUp_7x4);
@ -139,7 +145,7 @@ static bool hid_mouse_clicker_input_callback(InputEvent* event, void* context) {
consumed = true; consumed = true;
break; break;
case InputKeyDown: case InputKeyDown:
if(model->rate > 1) { if(model->rate > 0) {
model->rate--; model->rate--;
} }
rate_changed = true; rate_changed = true;