From d9d3867ce19fbfba92647187ef2820eb234020de Mon Sep 17 00:00:00 2001 From: SUMUKH <130692934+sumukhj1219@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:03:51 +0530 Subject: [PATCH] Fixes Mouse Clicker Should have a "0" value setting for "as fast as possible" #3876 (#3894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixes mouse clicking rate * Hid: limit max clicks to 100/s, rewrite code to make it more robust Co-authored-by: あく --- .../system/hid_app/views/hid_mouse_clicker.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/applications/system/hid_app/views/hid_mouse_clicker.c b/applications/system/hid_app/views/hid_mouse_clicker.c index 0bb815249..e289b7179 100644 --- a/applications/system/hid_app/views/hid_mouse_clicker.c +++ b/applications/system/hid_app/views/hid_mouse_clicker.c @@ -7,7 +7,7 @@ #define TAG "HidMouseClicker" #define DEFAULT_CLICK_RATE 1 -#define MAXIMUM_CLICK_RATE 60 +#define MAXIMUM_CLICK_RATE 100 struct HidMouseClicker { View* view; @@ -34,7 +34,9 @@ static void hid_mouse_clicker_start_or_restart_timer(void* context) { HidMouseClickerModel * model, { 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); } @@ -75,7 +77,11 @@ static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) { // Clicks/s 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); 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; break; case InputKeyDown: - if(model->rate > 1) { + if(model->rate > 0) { model->rate--; } rate_changed = true;