Skip to content

Commit

Permalink
Fixes Mouse Clicker Should have a "0" value setting for "as fast as p…
Browse files Browse the repository at this point in the history
…ossible" flipperdevices#3876 (flipperdevices#3894)

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

Co-authored-by: あく <[email protected]>
  • Loading branch information
2 people authored and RogueMaster committed Oct 15, 2024
1 parent af29eda commit f45e3b1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions applications/external/hid_app/views/hid_mouse_clicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f45e3b1

Please sign in to comment.